summaryrefslogtreecommitdiff
path: root/src/Hakyll
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2011-02-07 11:41:09 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2011-02-07 11:41:09 +0100
commit986a74b3af664b824a5c67524d2433d7e990f502 (patch)
treebf0f9d723e885db06818668ef280b4d64a3f27d2 /src/Hakyll
parent781138a0e79a942b9835b159293f2b4088e98ac1 (diff)
downloadhakyll-986a74b3af664b824a5c67524d2433d7e990f502.tar.gz
Add mapA
Diffstat (limited to 'src/Hakyll')
-rw-r--r--src/Hakyll/Core/Util/Arrow.hs13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/Hakyll/Core/Util/Arrow.hs b/src/Hakyll/Core/Util/Arrow.hs
index d97ba22..49cbf2b 100644
--- a/src/Hakyll/Core/Util/Arrow.hs
+++ b/src/Hakyll/Core/Util/Arrow.hs
@@ -7,7 +7,9 @@ module Hakyll.Core.Util.Arrow
, mapA
) where
-import Control.Arrow (Arrow, (&&&), arr, (>>^))
+import Control.Arrow ( Arrow, ArrowChoice, (&&&), arr, (>>^), (|||)
+ , (>>>), (***)
+ )
constA :: Arrow a
=> c
@@ -25,7 +27,10 @@ unitA :: Arrow a
=> a b ()
unitA = constA ()
-mapA :: Arrow a
- => (b -> c)
+mapA :: ArrowChoice a
+ => a b c
-> a [b] [c]
-mapA = arr . map
+mapA f = arr listEither >>> arr id ||| (f *** mapA f >>> arr (uncurry (:)))
+ where
+ listEither [] = Left []
+ listEither (x : xs) = Right (x, xs)