Permalink
Browse files

Fix warnings and errors

  • Loading branch information...
jaspervdj committed Dec 18, 2017
1 parent 7634b44 commit 030864a921d38405778ddeb1286e8922955c8ab4
Showing with 46 additions and 16 deletions.
  1. +3 −0 hakyll.cabal
  2. +0 −1 lib/Hakyll/Check.hs
  3. +3 −1 lib/Hakyll/Commands.hs
  4. +5 −9 lib/Hakyll/Web/Pandoc.hs
  5. +30 −0 test.hs
  6. +1 −2 tests/Hakyll/Web/CompressCss/Tests.hs
  7. +4 −3 tests/TestSuite/Util.hs
View
@@ -311,6 +311,9 @@ Executable hakyll-init
Hs-source-dirs: src
Main-is: Init.hs
Other-modules:
Paths_hakyll
Build-depends:
hakyll,
base >= 4 && < 5,
View
@@ -17,7 +17,6 @@ import Control.Monad.Reader (ReaderT, ask, runReaderT)
import Control.Monad.State (StateT, get, modify, runStateT)
import Control.Monad.Trans (liftIO)
import Control.Monad.Trans.Resource (runResourceT)
import Data.ByteString.Char8 (unpack)
import Data.List (isPrefixOf)
import qualified Data.Map.Lazy as Map
import Network.URI (unEscapeString)
View
@@ -16,7 +16,8 @@ module Hakyll.Commands
--------------------------------------------------------------------------------
import Control.Concurrent
import System.Exit (ExitCode, exitWith)
import System.Exit (ExitCode)
--------------------------------------------------------------------------------
import Hakyll.Check (Check(..))
@@ -29,6 +30,7 @@ import Hakyll.Core.Rules.Internal
import Hakyll.Core.Runtime
import Hakyll.Core.Util.File
--------------------------------------------------------------------------------
#ifdef WATCH_SERVER
import Hakyll.Preview.Poll (watchUpdates)
View
@@ -22,11 +22,9 @@ module Hakyll.Web.Pandoc
--------------------------------------------------------------------------------
import qualified Data.Set as S
import qualified Data.Text as T
import Text.Pandoc
import Text.Pandoc.Error (PandocError (..))
import Text.Pandoc.Highlighting (pygments)
import qualified Data.Text as T
--------------------------------------------------------------------------------
@@ -51,11 +49,9 @@ readPandocWith
-> Compiler (Item Pandoc) -- ^ Resulting document
readPandocWith ropt item =
case runPure $ traverse (reader ropt (itemFileType item)) (fmap T.pack item) of
Left (PandocParseError err) -> fail $
"Hakyll.Web.Pandoc.readPandocWith: parse failed: " ++ err
Left (PandocParsecError _ err) -> fail $
Left err -> fail $
"Hakyll.Web.Pandoc.readPandocWith: parse failed: " ++ show err
Right item' -> return item'
Right item' -> return item'
where
reader ro t = case t of
DocBook -> readDocBook ro
@@ -88,8 +84,8 @@ writePandocWith :: WriterOptions -- ^ Writer options for pandoc
-> Item String -- ^ Resulting HTML
writePandocWith wopt (Item itemi doc) =
case runPure $ writeHtml5String wopt doc of
Left (PandocSomeError err) -> error $ "Hakyll.Web.Pandoc.writePandocWith: unknown error: " ++ err
Right item' -> Item itemi $ T.unpack item'
Left err -> error $ "Hakyll.Web.Pandoc.writePandocWith: " ++ show err
Right item' -> Item itemi $ T.unpack item'
--------------------------------------------------------------------------------
View
30 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
@@ -5,9 +5,8 @@ module Hakyll.Web.CompressCss.Tests
--------------------------------------------------------------------------------
import Data.Char (toUpper)
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.HUnit (assert, (@=?))
import Test.Tasty.HUnit ((@=?))
--------------------------------------------------------------------------------
View
@@ -76,13 +76,14 @@ testCompilerDone store provider underlying compiler = do
result <- testCompiler store provider underlying compiler
case result of
CompilerDone x _ -> return x
CompilerError e -> error $
CompilerError e -> fail $
"TestSuite.Util.testCompilerDone: compiler " ++ show underlying ++
" threw: " ++ intercalate "; " e
CompilerRequire i _ -> error $
CompilerRequire i _ -> fail $
"TestSuite.Util.testCompilerDone: compiler " ++ show underlying ++
" requires: " ++ show i
CompilerSnapshot _ _ -> fail
"TestSuite.Util.testCompilerDone: unexpected CompilerSnapshot"
--------------------------------------------------------------------------------

0 comments on commit 030864a

Please sign in to comment.