summaryrefslogtreecommitdiff
path: root/src/Hakyll/Core/CopyFile.hs
blob: dbbaaa1ad7e20266e1ee50e43454268cd72c6599 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
-- | Exports simple compilers to just copy files
--
{-# LANGUAGE GeneralizedNewtypeDeriving, DeriveDataTypeable #-}
module Hakyll.Core.CopyFile
    ( CopyFile (..)
    , copyFileCompiler
    ) where

import Control.Arrow ((>>^))
import System.Directory (copyFile)

import Data.Typeable (Typeable)
import Data.Binary (Binary)

import Hakyll.Core.ResourceProvider
import Hakyll.Core.Writable
import Hakyll.Core.Compiler
import Hakyll.Core.Identifier

-- | Newtype construct around 'FilePath' which will copy the file directly
--
newtype CopyFile = CopyFile {unCopyFile :: FilePath}
                 deriving (Show, Eq, Ord, Binary, Typeable)

instance Writable CopyFile where
    write dst (CopyFile src) = copyFile src dst

copyFileCompiler :: Compiler Resource CopyFile
copyFileCompiler = getIdentifier >>^ CopyFile . toFilePath