on master help sign in
Micro-cleanup
6e7dc0eJasper Van der Jeugt
src/Hakyll/Core/CompiledItem.hs+4−3
@@ -11,6 +11,7 @@ module Hakyll.Core.CompiledItem
11
11
12import Data.Binary (Binary)
12import Data.Binary (Binary)
13import Data.Typeable (Typeable, cast)
13import Data.Typeable (Typeable, cast)
14+import Data.Maybe (fromMaybe)
14
15
15import Hakyll.Core.Writable
16import Hakyll.Core.Writable
16
17
@@ -34,6 +35,6 @@ compiledItem = CompiledItem
34unCompiledItem :: (Binary a, Typeable a, Writable a)
35unCompiledItem :: (Binary a, Typeable a, Writable a)
35 => CompiledItem
36 => CompiledItem
36 -> a
37 -> a
37−unCompiledItem (CompiledItem x) = case cast x of
38+unCompiledItem (CompiledItem x) = fromMaybe error' $ cast x
38− Just x' -> x'
39+ where
39− Nothing -> error "Hakyll.Core.CompiledItem.unCompiledItem: Unsupported type"
40+ error' = error "Hakyll.Core.CompiledItem.unCompiledItem: Unsupported type"
src/Hakyll/Core/Compiler/Internal.hs+1−2
@@ -92,8 +92,7 @@ runCompilerJob compiler identifier provider route store modified =
92runCompilerDependencies :: Compiler () a
92runCompilerDependencies :: Compiler () a
93 -> ResourceProvider
93 -> ResourceProvider
94 -> Dependencies
94 -> Dependencies
95−runCompilerDependencies compiler provider =
96− runReader (compilerDependencies compiler) provider
95+runCompilerDependencies compiler = runReader (compilerDependencies compiler)
97
96
98fromJob :: (a -> CompilerM b)
97fromJob :: (a -> CompilerM b)
99 -> Compiler a b
98 -> Compiler a b
src/Hakyll/Core/DirectedGraph.hs+2−2
@@ -65,12 +65,12 @@ reachableNodes set graph = reachable (setNeighbours set) set
65 sanitize' = S.filter (`S.notMember` visited)
65 sanitize' = S.filter (`S.notMember` visited)
66 neighbours' = setNeighbours (sanitize' next)
66 neighbours' = setNeighbours (sanitize' next)
67
67
68− setNeighbours = S.unions . map (flip neighbours graph) . S.toList
68+ setNeighbours = S.unions . map (`neighbours` graph) . S.toList
69
69
70-- | Remove all dangling pointers, i.e. references to notes that do
70-- | Remove all dangling pointers, i.e. references to notes that do
71-- not actually exist in the graph.
71-- not actually exist in the graph.
72--
72--
73sanitize :: Ord a => DirectedGraph a -> DirectedGraph a
73sanitize :: Ord a => DirectedGraph a -> DirectedGraph a
74−sanitize (DirectedGraph graph) = DirectedGraph $ M.map sanitize' $ graph
74+sanitize (DirectedGraph graph) = DirectedGraph $ M.map sanitize' graph
75 where
75 where
76 sanitize' (Node t n) = Node t $ S.filter (`M.member` graph) n
76 sanitize' (Node t n) = Node t $ S.filter (`M.member` graph) n
src/Hakyll/Core/DirectedGraph/DependencySolver.hs+3−3
@@ -10,7 +10,7 @@ module Hakyll.Core.DirectedGraph.DependencySolver
10import Prelude
10import Prelude
11import qualified Prelude as P
11import qualified Prelude as P
12import Data.Set (Set)
12import Data.Set (Set)
13−import Data.Maybe (catMaybes)
13+import Data.Maybe (mapMaybe)
14import qualified Data.Map as M
14import qualified Data.Map as M
15import qualified Data.Set as S
15import qualified Data.Set as S
16
16
@@ -48,7 +48,7 @@ order temp stack set graph@(DirectedGraph graph')
48 -- Check which dependencies are still in the graph
48 -- Check which dependencies are still in the graph
49 let tag = nodeTag node
49 let tag = nodeTag node
50 deps = S.toList $ nodeNeighbours node
50 deps = S.toList $ nodeNeighbours node
51− unsatisfied = catMaybes $ map (flip M.lookup graph') deps
51+ unsatisfied = mapMaybe (`M.lookup` graph') deps
52 in case unsatisfied of
52 in case unsatisfied of
53
53
54 -- All dependencies for node are satisfied, we can return it and
54 -- All dependencies for node are satisfied, we can return it and
@@ -58,7 +58,7 @@ order temp stack set graph@(DirectedGraph graph')
58
58
59 -- There is at least one dependency left. We need to solve that
59 -- There is at least one dependency left. We need to solve that
60 -- one first...
60 -- one first...
61− (dep : _) -> if (nodeTag dep) `S.member` set
61+ (dep : _) -> if nodeTag dep `S.member` set
62 -- The dependency is already in our stack - cycle detected!
62 -- The dependency is already in our stack - cycle detected!
63 then cycleError
63 then cycleError
64 -- Continue with the dependency
64 -- Continue with the dependency
src/Hakyll/Core/DirectedGraph/Internal.hs+2−2
@@ -16,8 +16,8 @@ import qualified Data.Set as S
16-- | A node in the directed graph
16-- | A node in the directed graph
17--
17--
18data Node a = Node
18data Node a = Node
19− { nodeTag :: a -- ^ Tag identifying the node
19+ { nodeTag :: a -- ^ Tag identifying the node
20− , nodeNeighbours :: (Set a) -- ^ Edges starting at this node
20+ , nodeNeighbours :: Set a -- ^ Edges starting at this node
21 } deriving (Show)
21 } deriving (Show)
22
22
23-- | Append two nodes. Useful for joining graphs.
23-- | Append two nodes. Useful for joining graphs.
src/Hakyll/Core/ResourceProvider/FileResourceProvider.hs+1−1
@@ -17,7 +17,7 @@ import Hakyll.Core.Util.File
17fileResourceProvider :: IO ResourceProvider
17fileResourceProvider :: IO ResourceProvider
18fileResourceProvider = do
18fileResourceProvider = do
19 list <- map parseIdentifier <$> getRecursiveContents "."
19 list <- map parseIdentifier <$> getRecursiveContents "."
20− return $ ResourceProvider
20+ return ResourceProvider
21 { resourceList = list
21 { resourceList = list
22 , resourceString = readFile . toFilePath
22 , resourceString = readFile . toFilePath
23 , resourceLazyByteString = LB.readFile . toFilePath
23 , resourceLazyByteString = LB.readFile . toFilePath
src/Hakyll/Core/Route.hs+2−2
@@ -59,8 +59,8 @@ idRoute = Route $ Just . toFilePath
59-- > Just "posts/the-art-of-trolling.html"
59-- > Just "posts/the-art-of-trolling.html"
60--
60--
61setExtension :: String -> Route
61setExtension :: String -> Route
62−setExtension exension = Route $ fmap (flip replaceExtension exension)
62+setExtension extension = Route $ fmap (`replaceExtension` extension)
63− . unRoute idRoute
63+ . unRoute idRoute
64
64
65-- | Modify a route: apply the route if the identifier matches the given
65-- | Modify a route: apply the route if the identifier matches the given
66-- pattern, fail otherwise.
66-- pattern, fail otherwise.
src/Hakyll/Core/Rules.hs+1−1
@@ -116,7 +116,7 @@ addCompilers :: (Binary a, Typeable a, Writable a)
116 -- ^ Compiler generating the other compilers
116 -- ^ Compiler generating the other compilers
117 -> Rules
117 -> Rules
118 -- ^ Resulting rules
118 -- ^ Resulting rules
119−addCompilers identifier compiler = RulesM $ tell $ RuleSet mempty $
119+addCompilers identifier compiler = RulesM $ tell $ RuleSet mempty
120 [(identifier, compiler >>> arr makeRule )]
120 [(identifier, compiler >>> arr makeRule )]
121 where
121 where
122 makeRule = MetaCompileRule . map (second box)
122 makeRule = MetaCompileRule . map (second box)
src/Hakyll/Core/Run.hs+2−3
@@ -16,7 +16,6 @@ import Data.Monoid (mempty, mappend)
16import Data.Typeable (Typeable)
16import Data.Typeable (Typeable)
17import Data.Binary (Binary)
17import Data.Binary (Binary)
18import System.FilePath ((</>))
18import System.FilePath ((</>))
19−import Control.Applicative ((<$>))
20import Data.Set (Set)
19import Data.Set (Set)
21import qualified Data.Set as S
20import qualified Data.Set as S
22
21
@@ -115,7 +114,7 @@ addNewCompilers oldCompilers newCompilers = Hakyll $ do
115
114
116 -- Find the old graph and append the new graph to it. This forms the
115 -- Find the old graph and append the new graph to it. This forms the
117 -- complete graph
116 -- complete graph
118− completeGraph <- (mappend currentGraph) . hakyllGraph <$> get
117+ completeGraph <- mappend currentGraph . hakyllGraph <$> get
119
118
120 liftIO $ writeDot "dependencies.dot" show completeGraph
119 liftIO $ writeDot "dependencies.dot" show completeGraph
121
120
@@ -190,6 +189,6 @@ runCompilers ((id', compiler) : compilers) = Hakyll $ do
190 unHakyll $ runCompilers compilers
189 unHakyll $ runCompilers compilers
191
190
192 -- Metacompiler, slightly more complicated
191 -- Metacompiler, slightly more complicated
193− MetaCompileRule newCompilers -> do
192+ MetaCompileRule newCompilers ->
194 -- Actually I was just kidding, it's not hard at all
193 -- Actually I was just kidding, it's not hard at all
195 unHakyll $ addNewCompilers compilers newCompilers
194 unHakyll $ addNewCompilers compilers newCompilers
src/Hakyll/Web/Pandoc.hs+1−1
@@ -89,7 +89,7 @@ pageRenderPandocWith :: P.ParserState
89 -> P.WriterOptions
89 -> P.WriterOptions
90 -> Compiler (Page String) (Page String)
90 -> Compiler (Page String) (Page String)
91pageRenderPandocWith state options =
91pageRenderPandocWith state options =
92− pageReadPandocWith state >>^ (fmap $ writePandocWith options)
92+ pageReadPandocWith state >>^ fmap (writePandocWith options)
93
93
94-- | The default reader options for pandoc parsing in hakyll
94-- | The default reader options for pandoc parsing in hakyll
95--
95--