@@ -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)