summaryrefslogtreecommitdiff
path: root/src/Hakyll/Core/Util
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2012-11-09 18:13:51 +0100
committerJasper Van der Jeugt <m@jaspervdj.be>2012-11-09 18:13:51 +0100
commit4cb6f9241435fae7a23a7f9fbbdab99e65285eff (patch)
tree462f951e02579518958e15accb95be5d6d11abba /src/Hakyll/Core/Util
parent2834fd94945ad20bf19c39957cddfdf858c0ba22 (diff)
downloadhakyll-4cb6f9241435fae7a23a7f9fbbdab99e65285eff.tar.gz
Rewrite template application
Diffstat (limited to 'src/Hakyll/Core/Util')
-rw-r--r--src/Hakyll/Core/Util/Arrow.hs37
1 files changed, 26 insertions, 11 deletions
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 ()