Monad
Definitions
def <=<(f1: b -> m[c] \ ef1, f2: a -> m[b] \ ef2): a -> m[c] \ ef1 + ef2
Source<=<
is an operator alias for kleisliRight
.
def >=>(f1: a -> m[b] \ ef1, f2: b -> m[c] \ ef2): a -> m[c] \ ef1 + ef2
Source>=>
is an operator alias for kleisliLeft
.
def >>=(x: m[a], k: a -> m[b] \ ef): m[b] \ ef
Source>>=
is the operator =<<
with its arguments flipped.
>>=
is the monadic bind operator.
def flatten(x: m[m[a]]): m[a]
SourceThe monadic join
operator.
Flatten x
- a monadic action nested in an outer monadic layer - to a single layer.
E.g. for the Option monad: flatten(Some(Some(1)))
becomes Some(1)
.
def kleisliLeft(f1: a -> m[b] \ ef1, f2: b -> m[c] \ ef2, x: a): m[c] \ ef1 + ef2
SourceThe left-to-right Kleisli composition operator for monads.
Map x
with the monadic function f1
and then map its result with the function f2
.
def kleisliRight(f1: b -> m[c] \ ef1, f2: a -> m[b] \ ef2, x: a): m[c] \ ef1 + ef2
SourceThe right-to-left Kleisli composition operator for monads.
Map x
with the monadic function f2
and then map its result with the function f1
.