module type Basic =sig
..end
type 'a
t
val bind : 'a t -> ('a -> 'b t) -> 'b t
val return : 'a -> 'a t
val map : 'a t -> f:('a -> 'b) -> 'b t
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