on master help sign in
Merge pull request #4263 from clayrat/monad-helpers

Add helper functions for Monad

commit6f08595fd924d6b570c746c3b677a5bf11ef374f authorAhmad Salim Al-Sibahi <asal@itu.dk> dateTue 2 Jan 2018, 15:13 (9 years ago) parent4431c5a6aea36c
2 files changed+19
libs/contrib/Control/Monad/Syntax.idr+18 libs/contrib/contrib.ipkg+1
libs/contrib/Control/Monad/Syntax.idrnew file+18
@@ -0,0 +1,18 @@
1+module Control.Monad.Syntax
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/contrib/contrib.ipkg+1
@@ -13,6 +13,7 @@ modules = CFFI
1313
1414 , Control.Delayed
1515 , Control.Isomorphism.Primitives
16+ , Control.Monad.Syntax
1617 , Control.Partial
1718 , Control.Pipeline
1819