diff options
Diffstat (limited to 'src/Hakyll/Core')
-rw-r--r-- | src/Hakyll/Core/Compiler.hs | 7 | ||||
-rw-r--r-- | src/Hakyll/Core/Compiler/Internal.hs | 6 | ||||
-rw-r--r-- | src/Hakyll/Core/Util/Arrow.hs | 37 |
3 files changed, 32 insertions, 18 deletions
diff --git a/src/Hakyll/Core/Compiler.hs b/src/Hakyll/Core/Compiler.hs index e1eab79..840f3bd 100644 --- a/src/Hakyll/Core/Compiler.hs +++ b/src/Hakyll/Core/Compiler.hs @@ -108,7 +108,6 @@ module Hakyll.Core.Compiler , cached , unsafeCompiler , traceShowCompiler - , mapCompiler , timedCompiler , byPattern , byExtension @@ -328,12 +327,6 @@ traceShowCompiler = fromJob $ \x -> CompilerM $ do report logger $ show x return x --- | Map over a compiler --- -mapCompiler :: Compiler a b - -> Compiler [a] [b] -mapCompiler (Compiler d j) = Compiler d $ mapM j - -- | Log and time a compiler -- timedCompiler :: String -- ^ Message diff --git a/src/Hakyll/Core/Compiler/Internal.hs b/src/Hakyll/Core/Compiler/Internal.hs index acdfe80..2a3342f 100644 --- a/src/Hakyll/Core/Compiler/Internal.hs +++ b/src/Hakyll/Core/Compiler/Internal.hs @@ -38,6 +38,7 @@ import Hakyll.Core.Logger import Hakyll.Core.ResourceProvider import Hakyll.Core.Routes import Hakyll.Core.Store +import Hakyll.Core.Util.Arrow -------------------------------------------------------------------------------- @@ -139,6 +140,11 @@ instance ArrowChoice Compiler where -------------------------------------------------------------------------------- +instance ArrowMap Compiler where + mapA (Compiler d j) = Compiler d $ mapM j + + +-------------------------------------------------------------------------------- -- | Run a compiler, yielding the resulting target runCompilerJob :: Compiler () a -- ^ Compiler to run -> Identifier () -- ^ Target identifier diff --git a/src/Hakyll/Core/Util/Arrow.hs b/src/Hakyll/Core/Util/Arrow.hs index f46d083..96a5e09 100644 --- a/src/Hakyll/Core/Util/Arrow.hs +++ b/src/Hakyll/Core/Util/Arrow.hs @@ -1,25 +1,40 @@ +-------------------------------------------------------------------------------- -- | Various arrow utility functions --- module Hakyll.Core.Util.Arrow - ( constA + ( ArrowMap (..) + , constA , sequenceA , unitA ) where -import Control.Arrow (Arrow, (&&&), arr, (>>^)) -constA :: Arrow a - => c - -> a b c +-------------------------------------------------------------------------------- +import Control.Arrow (Arrow, ArrowChoice, arr, (&&&), (>>^)) + + +-------------------------------------------------------------------------------- +-- | Additional arrow typeclass for performance reasons. +class ArrowChoice a => ArrowMap a where + mapA :: a b c -> a [b] [c] + + +-------------------------------------------------------------------------------- +instance ArrowMap (->) where + mapA = map + + +-------------------------------------------------------------------------------- +constA :: Arrow a => c -> a b c constA = arr . const -sequenceA :: Arrow a - => [a b c] - -> a b [c] + +-------------------------------------------------------------------------------- +sequenceA :: Arrow a => [a b c] -> a b [c] sequenceA = foldr reduce $ constA [] where reduce xa la = xa &&& la >>^ arr (uncurry (:)) -unitA :: Arrow a - => a b () + +-------------------------------------------------------------------------------- +unitA :: Arrow a => a b () unitA = constA () |