summaryrefslogtreecommitdiff
path: root/src/Hakyll/Core/Util/Arrow.hs
blob: d97ba229fe5e7f9a42be7691641c36cf9f98f3d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
-- | Various arrow utility functions
--
module Hakyll.Core.Util.Arrow
    ( constA
    , sequenceA
    , unitA
    , mapA
    ) where

import Control.Arrow (Arrow, (&&&), arr, (>>^))

constA :: Arrow a
       => c
       -> a b c
constA = arr . const

sequenceA :: Arrow a
          => [a b c]
          -> a b [c]
sequenceA = foldl reduce $ constA []
  where
    reduce la xa = xa &&& la >>^ arr (uncurry (:))

unitA :: Arrow a
      => a b ()
unitA = constA ()

mapA :: Arrow a
     => (b -> c)
     -> a [b] [c]
mapA = arr . map