on master help sign in
Add CopyFile newtype
86fafe6Jasper Van der Jeugt
src/Hakyll/Core/Writable.hs+16−1
@@ -1,10 +1,17 @@
1-- | Describes writable items; items that can be saved to the disk
1-- | Describes writable items; items that can be saved to the disk
2--
2--
3−{-# LANGUAGE FlexibleInstances #-}
3+{-# LANGUAGE FlexibleInstances, GeneralizedNewtypeDeriving,
4+ DeriveDataTypeable #-}
4module Hakyll.Core.Writable
5module Hakyll.Core.Writable
5 ( Writable (..)
6 ( Writable (..)
7+ , CopyFile (..)
6 ) where
8 ) where
7
9
10+import System.Directory (copyFile)
11+
12+import Data.Binary (Binary)
13+import Data.Typeable (Typeable)
14+
8-- | Describes an item that can be saved to the disk
15-- | Describes an item that can be saved to the disk
9--
16--
10class Writable a where
17class Writable a where
@@ -13,3 +20,11 @@ class Writable a where
13
20
14instance Writable [Char] where
21instance Writable [Char] where
15 write = writeFile
22 write = writeFile
23+
24+-- | Newtype construct around 'FilePath' which will copy the file directly
25+--
26+newtype CopyFile = CopyFile {unCopyFile :: FilePath}
27+ deriving (Show, Eq, Ord, Binary, Typeable)
28+
29+instance Writable CopyFile where
30+ write dst (CopyFile src) = copyFile src dst