Add helper functions for Monad
commit28c3928bbe0ae8f42df3a857f65fd01742020082
authorAlex Gryzlov <alexander.gryzlov@adform.com>
dateWed 20 Dec 2017, 18:21 (9 years ago)
parent76e45a3
libs/base/Control/Monad.idrnew file+18
@@ -0,0 +1,18 @@
1+module Control.Monad
2+
3+%default total
4+%access public export
5+
6+infixr 1 =<<, <=<, >=>
7+
8+||| Left-to-right Kleisli composition of monads.
9+(>=>) : Monad m => (a -> m b) -> (b -> m c) -> (a -> m c)
10+(>=>) f g = \x => f x >>= g
11+
12+||| Right-to-left Kleisli composition of monads, flipped version of `>=>`.
13+(<=<) : Monad m => (b -> m c) -> (a -> m b) -> (a -> m c)
14+(<=<) = flip (>=>)
15+
16+||| Right-to-left monadic bind, flipped version of `>>=`.
17+(=<<) : Monad m => (a -> m b) -> m a -> m b
18+(=<<) = flip (>>=)
libs/base/base.ipkg+1
@@ -8,6 +8,7 @@ modules = Control.Arrow
88 , Control.IOExcept
99 , Control.Isomorphism
1010
11+ , Control.Monad
1112 , Control.Monad.Identity
1213 , Control.Monad.Reader
1314 , Control.Monad.RWS