Skip to content

Commit

Permalink
feat(std): add Kleisli composition operators
Browse files Browse the repository at this point in the history
  • Loading branch information
Etherian committed Aug 9, 2020
1 parent bed7051 commit a384e04
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions std/monad.glu
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,19 @@ let (>>=) x f : [Monad m] -> m a -> (a -> m b) -> m b = flat_map f x

let join mm : [Monad m] -> m (m a) -> m a = mm >>= (\x -> x)

// Kleisli composition
#[infix(right, 9)]
let (<=<) g f : [Monad m] -> (b -> m c) -> (a -> m b) -> m c = flat_map g << f

#[infix(left, 9)]
let (>=>) f g : [Monad m] -> (a -> m b) -> (b -> m c) -> m c = f >> flat_map g

{
Monad,
flat_map,
(>>=),
(=<<),
join,
(<=<),
(>=>)
}

0 comments on commit a384e04

Please sign in to comment.