on master help sign in
Add mapA
commit986a74b3af664b824a5c67524d2433d7e990f502 authorJasper Van der Jeugt <jaspervdj@gmail.com> dateMon 7 Feb 2011, 11:41 (16 years ago) parent781138a
1 file changed+9−4
src/Hakyll/Core/Util/Arrow.hs+9−4
src/Hakyll/Core/Util/Arrow.hs+9−4
@@ -7,7 +7,9 @@ module Hakyll.Core.Util.Arrow
77 , mapA
88 ) where
99
10−import Control.Arrow (Arrow, (&&&), arr, (>>^))
10+import Control.Arrow ( Arrow, ArrowChoice, (&&&), arr, (>>^), (|||)
11+ , (>>>), (***)
12+ )
1113
1214constA :: Arrow a
1315 => c
@@ -25,7 +27,10 @@ unitA :: Arrow a
2527 => a b ()
2628unitA = constA ()
2729
28−mapA :: Arrow a
29− => (b -> c)
30+mapA :: ArrowChoice a
31+ => a b c
3032 -> a [b] [c]
31−mapA = arr . map
33+mapA f = arr listEither >>> arr id ||| (f *** mapA f >>> arr (uncurry (:)))
34+ where
35+ listEither [] = Left []
36+ listEither (x : xs) = Right (x, xs)