blob: d25bc2831c9afa76e02d3702cdda2bfb80e3182f (
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
|
-- | Various arrow utility functions
--
module Hakyll.Core.Util.Arrow
( sequenceArr
, unitArr
, withUnitArr
) where
import Prelude hiding (id)
import Control.Arrow (Arrow, (&&&), (>>>), arr, (***))
import Control.Category (id)
sequenceArr :: Arrow a
=> [a b c]
-> a b [c]
sequenceArr = foldl reduce $ arr $ const []
where
reduce la xa = xa &&& la >>> arr (uncurry (:))
unitArr :: Arrow a
=> a b ()
unitArr = arr (const ())
withUnitArr :: Arrow a
=> a b c
-> a () d
-> a b (c, d)
withUnitArr a1 a2 = a1 &&& unitArr >>> id *** a2
|