summaryrefslogtreecommitdiff
path: root/src/Hakyll/Core/Util
diff options
context:
space:
mode:
Diffstat (limited to 'src/Hakyll/Core/Util')
-rw-r--r--src/Hakyll/Core/Util/Arrow.hs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/Hakyll/Core/Util/Arrow.hs b/src/Hakyll/Core/Util/Arrow.hs
new file mode 100644
index 0000000..d25bc28
--- /dev/null
+++ b/src/Hakyll/Core/Util/Arrow.hs
@@ -0,0 +1,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