Module Monad

module Monad: sig .. end
Although map can be defined in terms of bind and return, it is almost always better to define it directly. We require it in Basic, which is the argument to the Make functor, to encourage direct definition.

For situations where defining map in terms of bind is fine, you can do:

        let map t ~f = Monad.map_via_bind t ~f ~return ~bind
      


module type Basic = sig .. end
module type Infix = sig .. end
val map_via_bind : 'a 'b 'c 'd.
'c ->
f:('a -> 'b) -> return:('b -> 'd) -> bind:('c -> ('a -> 'd) -> 'd) -> 'd
module type S = sig .. end
module Make: 
functor (M : Basic) -> sig .. end
module type Basic2 = sig .. end
Multi parameter monad.
module type Infix2 = sig .. end
Same as Infix, except the monad type has two arguments.
module type S2 = sig .. end
The same as S except the monad type has two arguments.
module Check_S2_refines_S: 
functor (X : S) -> sig .. end
module Make2: 
functor (M : Basic2) -> sig .. end

Although map can be defined in terms of bind and return, it is almost always better to define it directly. We require it in Basic, which is the argument to the Make functor, to encourage direct definition.

For situations where defining map in terms of bind is fine, you can do:

        let map t ~f = Monad.map_via_bind t ~f ~return ~bind
      


t >>= f returns a computation that sequences the computations represented by two monad elements. The resulting computation first does t to yield a value v, and then runs the computation returned by f v.

t >>| f is t >>= (fun a -> return (f a)).

A monad is an abstraction of the concept of sequencing of computations. A value of type 'a monad represents a computation that returns a value of type 'a.

bind t f = t >>= f

return v returns the (trivial) computation that returns v.

map t ~f is t >>| f.

join t is t >>= (fun t' -> t').

ignore t = map t ~f:(fun _ -> ()).

Multi parameter monad. The second parameter get unified across all the computation. This is used to encode monads working on a multi parameter data structure like (('a,'b result)).

Same as Infix, except the monad type has two arguments. The second is always just passed through.

The same as S except the monad type has two arguments. The second is always just passed through.