on master help sign in
Micro-cleanup
commit6e7dc0e58fd2d7814934e0c041a4e18232102087 authorJasper Van der Jeugt <jaspervdj@gmail.com> dateFri 14 Jan 2011, 08:50 (16 years ago) parent3ea3c52
10 files changed+19−20
src/Hakyll/Core/CompiledItem.hs+4−3 src/Hakyll/Core/Compiler/Internal.hs+1−2 src/Hakyll/Core/DirectedGraph.hs+2−2 src/Hakyll/Core/DirectedGraph/DependencySolver.hs+3−3 src/Hakyll/Core/DirectedGraph/Internal.hs+2−2 src/Hakyll/Core/ResourceProvider/FileResourceProvider.hs+1−1 src/Hakyll/Core/Route.hs+2−2 src/Hakyll/Core/Rules.hs+1−1 src/Hakyll/Core/Run.hs+2−3 src/Hakyll/Web/Pandoc.hs+1−1
src/Hakyll/Core/CompiledItem.hs+4−3
@@ -11,6 +11,7 @@ module Hakyll.Core.CompiledItem
1111
1212import Data.Binary (Binary)
1313import Data.Typeable (Typeable, cast)
14+import Data.Maybe (fromMaybe)
1415
1516import Hakyll.Core.Writable
1617
@@ -34,6 +35,6 @@ compiledItem = CompiledItem
3435unCompiledItem :: (Binary a, Typeable a, Writable a)
3536 => CompiledItem
3637 -> a
37−unCompiledItem (CompiledItem x) = case cast x of
38− Just x' -> x'
39− Nothing -> error "Hakyll.Core.CompiledItem.unCompiledItem: Unsupported type"
38+unCompiledItem (CompiledItem x) = fromMaybe error' $ cast x
39+ where
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 =
9292runCompilerDependencies :: Compiler () a
9393 -> ResourceProvider
9494 -> Dependencies
95−runCompilerDependencies compiler provider =
96− runReader (compilerDependencies compiler) provider
95+runCompilerDependencies compiler = runReader (compilerDependencies compiler)
9796
9897fromJob :: (a -> CompilerM b)
9998 -> Compiler a b
src/Hakyll/Core/DirectedGraph.hs+2−2
@@ -65,12 +65,12 @@ reachableNodes set graph = reachable (setNeighbours set) set
6565 sanitize' = S.filter (`S.notMember` visited)
6666 neighbours' = setNeighbours (sanitize' next)
6767
68− setNeighbours = S.unions . map (flip neighbours graph) . S.toList
68+ setNeighbours = S.unions . map (`neighbours` graph) . S.toList
6969
7070-- | Remove all dangling pointers, i.e. references to notes that do
7171-- not actually exist in the graph.
7272--
7373sanitize :: Ord a => DirectedGraph a -> DirectedGraph a
74−sanitize (DirectedGraph graph) = DirectedGraph $ M.map sanitize' $ graph
74+sanitize (DirectedGraph graph) = DirectedGraph $ M.map sanitize' graph
7575 where
7676 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
1010import Prelude
1111import qualified Prelude as P
1212import Data.Set (Set)
13−import Data.Maybe (catMaybes)
13+import Data.Maybe (mapMaybe)
1414import qualified Data.Map as M
1515import qualified Data.Set as S
1616
@@ -48,7 +48,7 @@ order temp stack set graph@(DirectedGraph graph')
4848 -- Check which dependencies are still in the graph
4949 let tag = nodeTag node
5050 deps = S.toList $ nodeNeighbours node
51− unsatisfied = catMaybes $ map (flip M.lookup graph') deps
51+ unsatisfied = mapMaybe (`M.lookup` graph') deps
5252 in case unsatisfied of
5353
5454 -- All dependencies for node are satisfied, we can return it and
@@ -58,7 +58,7 @@ order temp stack set graph@(DirectedGraph graph')
5858
5959 -- There is at least one dependency left. We need to solve that
6060 -- one first...
61− (dep : _) -> if (nodeTag dep) `S.member` set
61+ (dep : _) -> if nodeTag dep `S.member` set
6262 -- The dependency is already in our stack - cycle detected!
6363 then cycleError
6464 -- Continue with the dependency
src/Hakyll/Core/DirectedGraph/Internal.hs+2−2
@@ -16,8 +16,8 @@ import qualified Data.Set as S
1616-- | A node in the directed graph
1717--
1818data Node a = Node
19− { nodeTag :: a -- ^ Tag identifying the node
20− , nodeNeighbours :: (Set a) -- ^ Edges starting at this node
19+ { nodeTag :: a -- ^ Tag identifying the node
20+ , nodeNeighbours :: Set a -- ^ Edges starting at this node
2121 } deriving (Show)
2222
2323-- | Append two nodes. Useful for joining graphs.
src/Hakyll/Core/ResourceProvider/FileResourceProvider.hs+1−1
@@ -17,7 +17,7 @@ import Hakyll.Core.Util.File
1717fileResourceProvider :: IO ResourceProvider
1818fileResourceProvider = do
1919 list <- map parseIdentifier <$> getRecursiveContents "."
20− return $ ResourceProvider
20+ return ResourceProvider
2121 { resourceList = list
2222 , resourceString = readFile . toFilePath
2323 , resourceLazyByteString = LB.readFile . toFilePath
src/Hakyll/Core/Route.hs+2−2
@@ -59,8 +59,8 @@ idRoute = Route $ Just . toFilePath
5959-- > Just "posts/the-art-of-trolling.html"
6060--
6161setExtension :: String -> Route
62−setExtension exension = Route $ fmap (flip replaceExtension exension)
63− . unRoute idRoute
62+setExtension extension = Route $ fmap (`replaceExtension` extension)
63+ . unRoute idRoute
6464
6565-- | Modify a route: apply the route if the identifier matches the given
6666-- pattern, fail otherwise.
src/Hakyll/Core/Rules.hs+1−1
@@ -116,7 +116,7 @@ addCompilers :: (Binary a, Typeable a, Writable a)
116116 -- ^ Compiler generating the other compilers
117117 -> Rules
118118 -- ^ Resulting rules
119−addCompilers identifier compiler = RulesM $ tell $ RuleSet mempty $
119+addCompilers identifier compiler = RulesM $ tell $ RuleSet mempty
120120 [(identifier, compiler >>> arr makeRule )]
121121 where
122122 makeRule = MetaCompileRule . map (second box)
src/Hakyll/Core/Run.hs+2−3
@@ -16,7 +16,6 @@ import Data.Monoid (mempty, mappend)
1616import Data.Typeable (Typeable)
1717import Data.Binary (Binary)
1818import System.FilePath ((</>))
19−import Control.Applicative ((<$>))
2019import Data.Set (Set)
2120import qualified Data.Set as S
2221
@@ -115,7 +114,7 @@ addNewCompilers oldCompilers newCompilers = Hakyll $ do
115114
116115 -- Find the old graph and append the new graph to it. This forms the
117116 -- complete graph
118− completeGraph <- (mappend currentGraph) . hakyllGraph <$> get
117+ completeGraph <- mappend currentGraph . hakyllGraph <$> get
119118
120119 liftIO $ writeDot "dependencies.dot" show completeGraph
121120
@@ -190,6 +189,6 @@ runCompilers ((id', compiler) : compilers) = Hakyll $ do
190189 unHakyll $ runCompilers compilers
191190
192191 -- Metacompiler, slightly more complicated
193− MetaCompileRule newCompilers -> do
192+ MetaCompileRule newCompilers ->
194193 -- Actually I was just kidding, it's not hard at all
195194 unHakyll $ addNewCompilers compilers newCompilers
src/Hakyll/Web/Pandoc.hs+1−1
@@ -89,7 +89,7 @@ pageRenderPandocWith :: P.ParserState
8989 -> P.WriterOptions
9090 -> Compiler (Page String) (Page String)
9191pageRenderPandocWith state options =
92− pageReadPandocWith state >>^ (fmap $ writePandocWith options)
92+ pageReadPandocWith state >>^ fmap (writePandocWith options)
9393
9494-- | The default reader options for pandoc parsing in hakyll
9595--