summaryrefslogtreecommitdiff
path: root/test.hs
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2017-12-18 20:05:28 +0100
committerJasper Van der Jeugt <m@jaspervdj.be>2017-12-18 20:05:28 +0100
commit030864a921d38405778ddeb1286e8922955c8ab4 (patch)
tree81b65317f3b48dd39f192739dcc39b5adac35c5f /test.hs
parent7634b44e4ad9f6a0ba77c377eb1ee43085687789 (diff)
downloadhakyll-030864a921d38405778ddeb1286e8922955c8ab4.tar.gz
Fix warnings and errors
Diffstat (limited to 'test.hs')
-rw-r--r--test.hs30
1 files changed, 30 insertions, 0 deletions
diff --git a/test.hs b/test.hs
new file mode 100644
index 0000000..8b3a2de
--- /dev/null
+++ b/test.hs
@@ -0,0 +1,30 @@
+{-# LANGUAGE BangPatterns #-}
+import Control.Monad (forM)
+import qualified Crypto.Hash.SHA256 as SHA256
+import qualified Data.ByteString.Base16 as Base16
+import qualified Data.ByteString.Char8 as BS8
+import qualified Data.ByteString.Lazy as BSL
+import Data.Map (Map)
+import qualified Data.Map as Map
+import Hakyll
+import System.FilePath ((</>))
+
+type FileHashes = Map Identifier String
+
+mkFileHashes :: FilePath -> IO FileHashes
+mkFileHashes dir = do
+ allFiles <- getRecursiveContents (\_ -> return False) dir
+ fmap Map.fromList $ forM allFiles $ \path0 -> do
+ let path1 = dir </> path0
+ !h <- hash path1
+ return (fromFilePath path1, h)
+ where
+ hash :: FilePath -> IO String
+ hash fp = do
+ !h <- SHA256.hashlazy <$> BSL.readFile fp
+ return $! BS8.unpack $! Base16.encode h
+
+main :: IO ()
+main = hakyll $ do
+ fileHashes <- preprocess (mkFileHashes "images")
+ undefined