on master help sign in
Strictness cleanup.
d7f04a2Jasper Van der Jeugt
hakyll.cabal+1−1
@@ -34,7 +34,7 @@ library
34 mtl >= 1.1,
34 mtl >= 1.1,
35 old-locale >= 1,
35 old-locale >= 1,
36 time >= 1,
36 time >= 1,
37− parallel >= 2,
37+ deepseq >= 1,
38 binary >= 0.5
38 binary >= 0.5
39 exposed-modules: Text.Hakyll
39 exposed-modules: Text.Hakyll
40 Text.Hakyll.Hakyll
40 Text.Hakyll.Hakyll
src/Text/Hakyll/Page.hs+3−7
@@ -13,7 +13,6 @@ import Data.Char (isSpace)
13import Data.Maybe (fromMaybe)
13import Data.Maybe (fromMaybe)
14import Control.Monad (liftM)
14import Control.Monad (liftM)
15import Control.Monad.Reader (liftIO)
15import Control.Monad.Reader (liftIO)
16−import Control.Parallel.Strategies (rdeepseq, ($|))
17import System.FilePath (takeExtension)
16import System.FilePath (takeExtension)
18import System.IO
17import System.IO
19
18
@@ -121,17 +120,14 @@ readPageFromFile path = do
121 (True : repeat False)
120 (True : repeat False)
122
121
123 -- Read file.
122 -- Read file.
124− handle <- liftIO $ openFile path ReadMode
123+ contents <- liftIO $ readFile path
125− sections <- fmap (splitAtDelimiters . lines )
124+ let sections = splitAtDelimiters $ lines $ contents
126− (liftIO $ hGetContents handle)
127−
128− let context = concat $ zipWith ($) sectionFunctions sections
125+ context = concat $ zipWith ($) sectionFunctions sections
129 page = fromContext $ M.fromList $
126 page = fromContext $ M.fromList $
130 [ ("url", url)
127 [ ("url", url)
131 , ("path", path)
128 , ("path", path)
132 ] ++ context
129 ] ++ context
133
130
134− seq (($|) id rdeepseq context) $ liftIO $ hClose handle
135 return page
131 return page
136 where
132 where
137 url = toURL path
133 url = toURL path
src/Text/Hakyll/Render/Internal.hs+2−2
@@ -11,11 +11,11 @@ module Text.Hakyll.Render.Internal
11
11
12import qualified Data.Map as M
12import qualified Data.Map as M
13import Text.Hakyll.Context (Context, ContextManipulation)
13import Text.Hakyll.Context (Context, ContextManipulation)
14+import Control.DeepSeq (deepseq)
14import Control.Monad.Reader (liftIO)
15import Control.Monad.Reader (liftIO)
15import Data.List (isPrefixOf, foldl')
16import Data.List (isPrefixOf, foldl')
16import Data.Char (isAlphaNum)
17import Data.Char (isAlphaNum)
17import Data.Maybe (fromMaybe)
18import Data.Maybe (fromMaybe)
18−import Control.Parallel.Strategies (rdeepseq, ($|))
19
19
20import Text.Hakyll.Renderable
20import Text.Hakyll.Renderable
21import Text.Hakyll.Page
21import Text.Hakyll.Page
@@ -57,7 +57,7 @@ pureRenderWith manipulation template context =
57 let contextIgnoringRoot = M.insert "root" "$root" (manipulation context)
57 let contextIgnoringRoot = M.insert "root" "$root" (manipulation context)
58 body = regularSubstitute template contextIgnoringRoot
58 body = regularSubstitute template contextIgnoringRoot
59 -- Force the body to be rendered.
59 -- Force the body to be rendered.
60− in ($|) id rdeepseq (M.insert "body" body context)
60+ in body `deepseq` M.insert "body" body context
61
61
62-- | A pure renderAndConcat function.
62-- | A pure renderAndConcat function.
63pureRenderAndConcatWith :: ContextManipulation
63pureRenderAndConcatWith :: ContextManipulation
tests/Tests.hs+1−1
@@ -45,7 +45,7 @@ tests = [ testGroup "Util group"
45 ]
45 ]
46
46
47 , testGroup "File group"
47 , testGroup "File group"
48− , testCase "toRoot 1" test_to_root1
48+ [ testCase "toRoot 1" test_to_root1
49 , testCase "toRoot 2" test_to_root2
49 , testCase "toRoot 2" test_to_root2
50 , testCase "toRoot 3" test_to_root3
50 , testCase "toRoot 3" test_to_root3
51 , testCase "removeSpaces 1" test_remove_spaces1
51 , testCase "removeSpaces 1" test_remove_spaces1