mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-01 09:49:24 +03:00
Merge pull request #376 from andrevidela/kleisli-arrow
Add Kleisli arrow operators to contrib
This commit is contained in:
commit
cd777a00ce
21
libs/contrib/Control/Monad/Syntax.idr
Normal file
21
libs/contrib/Control/Monad/Syntax.idr
Normal file
@ -0,0 +1,21 @@
|
||||
module Control.Monad.Syntax
|
||||
|
||||
%default total
|
||||
|
||||
infixr 1 =<<, <=<, >=>
|
||||
|
||||
||| Left-to-right Kleisli composition of monads.
|
||||
public export
|
||||
(>=>) : Monad m => (a -> m b) -> (b -> m c) -> (a -> m c)
|
||||
(>=>) f g = \x => f x >>= g
|
||||
|
||||
public export
|
||||
||| Right-to-left Kleisli composition of monads, flipped version of `>=>`.
|
||||
(<=<) : Monad m => (b -> m c) -> (a -> m b) -> (a -> m c)
|
||||
(<=<) = flip (>=>)
|
||||
|
||||
public export
|
||||
||| Right-to-left monadic bind, flipped version of `>>=`.
|
||||
(=<<) : Monad m => (a -> m b) -> m a -> m b
|
||||
(=<<) = flip (>>=)
|
||||
|
@ -2,6 +2,7 @@ package contrib
|
||||
|
||||
modules = Control.Delayed,
|
||||
Control.Linear.LIO,
|
||||
Control.Monad.Syntax,
|
||||
|
||||
Data.Linear.Array,
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user