Module type Monad.Basic2

Basic binary monad interface.

type ('a, 'e) t

(a,e) t is a type of monad, where a is a type of computation values, and e is a type of some extra information attached to the computation, usually a type of environment.

val bind : ('a, 'e) t -> ('a -> ('b, 'e) t) -> ('b, 'e) t

bind m f passes the result of computation m to function f

val map : [ `Define_using_bind | `Custom of ('a, 'e) t -> f:('a -> 'b) -> ('b, 'e) t ]

map function can be derived from bind or provided explicitly

val return : 'a -> ('a, _) t

return x creates a trivial computation that results in x