on master help sign in
Add CopyFile newtype
commit86fafe6e61f71428f933f62a3c68cb3819c189c9 authorJasper Van der Jeugt <jaspervdj@gmail.com> dateThu 30 Dec 2010, 13:49 (16 years ago) parent687c17c
1 file changed+16−1
src/Hakyll/Core/Writable.hs+16−1
src/Hakyll/Core/Writable.hs+16−1
@@ -1,10 +1,17 @@
11-- | Describes writable items; items that can be saved to the disk
22--
3−{-# LANGUAGE FlexibleInstances #-}
3+{-# LANGUAGE FlexibleInstances, GeneralizedNewtypeDeriving,
4+ DeriveDataTypeable #-}
45module Hakyll.Core.Writable
56 ( Writable (..)
7+ , CopyFile (..)
68 ) where
79
10+import System.Directory (copyFile)
11+
12+import Data.Binary (Binary)
13+import Data.Typeable (Typeable)
14+
815-- | Describes an item that can be saved to the disk
916--
1017class Writable a where
@@ -13,3 +20,11 @@ class Writable a where
1320
1421instance Writable [Char] where
1522 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