on master help sign in
Fix warnings and errors
commit030864a921d38405778ddeb1286e8922955c8ab4 authorJasper Van der Jeugt <m@jaspervdj.be> dateMon 18 Dec 2017, 20:05 (9 years ago) parent7634b44
7 files changed+46−16
hakyll.cabal+3 lib/Hakyll/Check.hs−1 lib/Hakyll/Commands.hs+3−1 lib/Hakyll/Web/Pandoc.hs+5−9 test.hs+30 tests/Hakyll/Web/CompressCss/Tests.hs+1−2 tests/TestSuite/Util.hs+4−3
hakyll.cabal+3
@@ -311,6 +311,9 @@ Executable hakyll-init
311311 Hs-source-dirs: src
312312 Main-is: Init.hs
313313
314+ Other-modules:
315+ Paths_hakyll
316+
314317 Build-depends:
315318 hakyll,
316319 base >= 4 && < 5,
lib/Hakyll/Check.hs−1
@@ -17,7 +17,6 @@ import Control.Monad.Reader (ReaderT, ask, runReaderT)
1717import Control.Monad.State (StateT, get, modify, runStateT)
1818import Control.Monad.Trans (liftIO)
1919import Control.Monad.Trans.Resource (runResourceT)
20−import Data.ByteString.Char8 (unpack)
2120import Data.List (isPrefixOf)
2221import qualified Data.Map.Lazy as Map
2322import Network.URI (unEscapeString)
lib/Hakyll/Commands.hs+3−1
@@ -16,7 +16,8 @@ module Hakyll.Commands
1616
1717--------------------------------------------------------------------------------
1818import Control.Concurrent
19−import System.Exit (ExitCode, exitWith)
19+import System.Exit (ExitCode)
20+
2021
2122--------------------------------------------------------------------------------
2223import Hakyll.Check (Check(..))
@@ -29,6 +30,7 @@ import Hakyll.Core.Rules.Internal
2930import Hakyll.Core.Runtime
3031import Hakyll.Core.Util.File
3132
33+
3234--------------------------------------------------------------------------------
3335#ifdef WATCH_SERVER
3436import Hakyll.Preview.Poll (watchUpdates)
lib/Hakyll/Web/Pandoc.hs+5−9
@@ -22,11 +22,9 @@ module Hakyll.Web.Pandoc
2222
2323
2424--------------------------------------------------------------------------------
25−import qualified Data.Set as S
25+import qualified Data.Text as T
2626import Text.Pandoc
27−import Text.Pandoc.Error (PandocError (..))
2827import Text.Pandoc.Highlighting (pygments)
29−import qualified Data.Text as T
3028
3129
3230--------------------------------------------------------------------------------
@@ -51,11 +49,9 @@ readPandocWith
5149 -> Compiler (Item Pandoc) -- ^ Resulting document
5250readPandocWith ropt item =
5351 case runPure $ traverse (reader ropt (itemFileType item)) (fmap T.pack item) of
54− Left (PandocParseError err) -> fail $
55− "Hakyll.Web.Pandoc.readPandocWith: parse failed: " ++ err
56− Left (PandocParsecError _ err) -> fail $
52+ Left err -> fail $
5753 "Hakyll.Web.Pandoc.readPandocWith: parse failed: " ++ show err
58− Right item' -> return item'
54+ Right item' -> return item'
5955 where
6056 reader ro t = case t of
6157 DocBook -> readDocBook ro
@@ -88,8 +84,8 @@ writePandocWith :: WriterOptions -- ^ Writer options for pandoc
8884 -> Item String -- ^ Resulting HTML
8985writePandocWith wopt (Item itemi doc) =
9086 case runPure $ writeHtml5String wopt doc of
91− Left (PandocSomeError err) -> error $ "Hakyll.Web.Pandoc.writePandocWith: unknown error: " ++ err
92− Right item' -> Item itemi $ T.unpack item'
87+ Left err -> error $ "Hakyll.Web.Pandoc.writePandocWith: " ++ show err
88+ Right item' -> Item itemi $ T.unpack item'
9389
9490
9591--------------------------------------------------------------------------------
test.hsnew file+30
@@ -0,0 +1,30 @@
1+{-# LANGUAGE BangPatterns #-}
2+import Control.Monad (forM)
3+import qualified Crypto.Hash.SHA256 as SHA256
4+import qualified Data.ByteString.Base16 as Base16
5+import qualified Data.ByteString.Char8 as BS8
6+import qualified Data.ByteString.Lazy as BSL
7+import Data.Map (Map)
8+import qualified Data.Map as Map
9+import Hakyll
10+import System.FilePath ((</>))
11+
12+type FileHashes = Map Identifier String
13+
14+mkFileHashes :: FilePath -> IO FileHashes
15+mkFileHashes dir = do
16+ allFiles <- getRecursiveContents (\_ -> return False) dir
17+ fmap Map.fromList $ forM allFiles $ \path0 -> do
18+ let path1 = dir </> path0
19+ !h <- hash path1
20+ return (fromFilePath path1, h)
21+ where
22+ hash :: FilePath -> IO String
23+ hash fp = do
24+ !h <- SHA256.hashlazy <$> BSL.readFile fp
25+ return $! BS8.unpack $! Base16.encode h
26+
27+main :: IO ()
28+main = hakyll $ do
29+ fileHashes <- preprocess (mkFileHashes "images")
30+ undefined
tests/Hakyll/Web/CompressCss/Tests.hs+1−2
@@ -5,9 +5,8 @@ module Hakyll.Web.CompressCss.Tests
55
66
77--------------------------------------------------------------------------------
8−import Data.Char (toUpper)
98import Test.Tasty (TestTree, testGroup)
10−import Test.Tasty.HUnit (assert, (@=?))
9+import Test.Tasty.HUnit ((@=?))
1110
1211
1312--------------------------------------------------------------------------------
tests/TestSuite/Util.hs+4−3
@@ -76,13 +76,14 @@ testCompilerDone store provider underlying compiler = do
7676 result <- testCompiler store provider underlying compiler
7777 case result of
7878 CompilerDone x _ -> return x
79− CompilerError e -> error $
79+ CompilerError e -> fail $
8080 "TestSuite.Util.testCompilerDone: compiler " ++ show underlying ++
8181 " threw: " ++ intercalate "; " e
82− CompilerRequire i _ -> error $
82+ CompilerRequire i _ -> fail $
8383 "TestSuite.Util.testCompilerDone: compiler " ++ show underlying ++
8484 " requires: " ++ show i
85−
85+ CompilerSnapshot _ _ -> fail
86+ "TestSuite.Util.testCompilerDone: unexpected CompilerSnapshot"
8687
8788
8889--------------------------------------------------------------------------------