module Monad: Monadmodule 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) -> 'dmodule type S =sig..end
module Make:
module type Basic2 =sig..end
module type Infix2 =sig..end
module type S2 =sig..end
module Check_S2_refines_S:
module Make2:
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)).bind t f = t >>= freturn 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 _ -> ()).('a,'b result)).