Preface_specs.MonadA Monad allow to sequences operations that are dependent from one to another, in contrast to Applicative, which executes a series of independent actions.
To have a predictable behaviour, the instance of Monad must obey some laws.
return a >>= f = f am >>= return = m(m >>= f) >>= g = m >>= (fun x +> f x >>= g)join % join = join % (map join)join % return = id = join % map puremap id = idmap (g % f) = map g % map fmap f % join = join % map (map f)map f % pure = pure % freturn >=> g = gf >=> return = f(f >=> g) >=> h = f >=> (g >=> h)module type WITH_RETURN = sig ... endMinimal interface using map and product.
module type WITH_RETURN_AND_BIND = sig ... endMinimal definition using return and bind.
module type WITH_RETURN_MAP_AND_JOIN = sig ... endMinimal definition using return, map and join.
module type WITH_RETURN_AND_KLEISLI_COMPOSITION = sig ... endMinimal definition using return and compose_left_to_right.
module type CORE = sig ... endBasis operations.
module type OPERATION = sig ... endAdditional operations.
module type SYNTAX = sig ... endSyntax extensions.
module type INFIX = sig ... endInfix operators.
module type API = sig ... endThe complete interface of a Monad.
A standard representation of a monad transformer. (It is likely that not all transformers respect this interface)
module type TRANSFORMER = sig ... end