on master help sign in
Cleanup arrow code
687c17cJasper Van der Jeugt
src/Hakyll/Core/Compiler.hs+2−2
@@ -105,11 +105,11 @@ fromCompilerM :: (a -> CompilerM b)
105 -> Compiler a b
105 -> Compiler a b
106fromCompilerM = Compiler (return S.empty)
106fromCompilerM = Compiler (return S.empty)
107
107
108−getIdentifier :: Compiler () Identifier
108+getIdentifier :: Compiler a Identifier
109getIdentifier = fromCompilerM $ const $ CompilerM $
109getIdentifier = fromCompilerM $ const $ CompilerM $
110 compilerIdentifier <$> ask
110 compilerIdentifier <$> ask
111
111
112−getResourceString :: Compiler () String
112+getResourceString :: Compiler a String
113getResourceString = getIdentifier >>> getResourceString'
113getResourceString = getIdentifier >>> getResourceString'
114 where
114 where
115 getResourceString' = fromCompilerM $ \id' -> CompilerM $ do
115 getResourceString' = fromCompilerM $ \id' -> CompilerM $ do
src/Hakyll/Core/Util/Arrow.hs+17−20
@@ -1,28 +1,25 @@
1-- | Various arrow utility functions
1-- | Various arrow utility functions
2--
2--
3module Hakyll.Core.Util.Arrow
3module Hakyll.Core.Util.Arrow
4− ( sequenceArr
4+ ( constA
5− , unitArr
5+ , sequenceA
6− , withUnitArr
6+ , unitA
7 ) where
7 ) where
8
8
9−import Prelude hiding (id)
10−import Control.Arrow (Arrow, (&&&), (>>>), arr, (***))
9+import Control.Arrow (Arrow, (&&&), arr, (>>^))
11−import Control.Category (id)
12
10
13−sequenceArr :: Arrow a
11+constA :: Arrow a
14− => [a b c]
12+ => c
15− -> a b [c]
13+ -> a b c
16−sequenceArr = foldl reduce $ arr $ const []
14+constA = arr . const
17− where
18− reduce la xa = xa &&& la >>> arr (uncurry (:))
19
15
20−unitArr :: Arrow a
16+sequenceA :: Arrow a
21− => a b ()
17+ => [a b c]
22−unitArr = arr (const ())
18+ -> a b [c]
19+sequenceA = foldl reduce $ constA []
20+ where
21+ reduce la xa = xa &&& la >>^ arr (uncurry (:))
23
22
24−withUnitArr :: Arrow a
23+unitA :: Arrow a
25− => a b c
24+ => a b ()
26− -> a () d
25+unitA = constA ()
27− -> a b (c, d)
28−withUnitArr a1 a2 = a1 &&& unitArr >>> id *** a2
src/Hakyll/Web/FileType.hs+3−3
@@ -7,7 +7,7 @@ module Hakyll.Web.FileType
7 ) where
7 ) where
8
8
9import System.FilePath (takeExtension)
9import System.FilePath (takeExtension)
10−import Control.Arrow ((>>>), arr)
10+import Control.Arrow ((>>^))
11
11
12import Hakyll.Core.Identifier
12import Hakyll.Core.Identifier
13import Hakyll.Core.Compiler
13import Hakyll.Core.Compiler
@@ -51,5 +51,5 @@ fileType = fileType' . takeExtension
51
51
52-- | Get the file type for the current file
52-- | Get the file type for the current file
53--
53--
54−getFileType :: Compiler () FileType
54+getFileType :: Compiler a FileType
55−getFileType = getIdentifier >>> arr (fileType . toFilePath)
55+getFileType = getIdentifier >>^ fileType . toFilePath
src/Hakyll/Web/Pandoc.hs+3−4
@@ -20,14 +20,13 @@ module Hakyll.Web.Pandoc
20
20
21import Prelude hiding (id)
21import Prelude hiding (id)
22import Control.Applicative ((<$>))
22import Control.Applicative ((<$>))
23−import Control.Arrow ((>>>), arr)
23+import Control.Arrow ((>>^), (&&&))
24import Control.Category (id)
24import Control.Category (id)
25
25
26import Text.Pandoc (Pandoc)
26import Text.Pandoc (Pandoc)
27import qualified Text.Pandoc as P
27import qualified Text.Pandoc as P
28
28
29import Hakyll.Core.Compiler
29import Hakyll.Core.Compiler
30−import Hakyll.Core.Util.Arrow
31import Hakyll.Web.FileType
30import Hakyll.Web.FileType
32import Hakyll.Web.Page
31import Hakyll.Web.Page
33
32
@@ -75,7 +74,7 @@ pageReadPandoc = pageReadPandocWith defaultParserState
75--
74--
76pageReadPandocWith :: P.ParserState -> Compiler (Page String) (Page Pandoc)
75pageReadPandocWith :: P.ParserState -> Compiler (Page String) (Page Pandoc)
77pageReadPandocWith state =
76pageReadPandocWith state =
78− withUnitArr id getFileType >>> arr pageReadPandocWith'
77+ id &&& getFileType >>^ pageReadPandocWith'
79 where
78 where
80 pageReadPandocWith' (p, t) = readPandocWith state t <$> p
79 pageReadPandocWith' (p, t) = readPandocWith state t <$> p
81
80
@@ -90,7 +89,7 @@ pageRenderPandocWith :: P.ParserState
90 -> P.WriterOptions
89 -> P.WriterOptions
91 -> Compiler (Page String) (Page String)
90 -> Compiler (Page String) (Page String)
92pageRenderPandocWith state options =
91pageRenderPandocWith state options =
93− pageReadPandocWith state >>> arr (fmap $ writePandocWith options)
92+ pageReadPandocWith state >>^ (fmap $ writePandocWith options)
94
93
95-- | The default reader options for pandoc parsing in hakyll
94-- | The default reader options for pandoc parsing in hakyll
96--
95--