Parameter Make.1-X
val bind : 'a t -> f:('a -> 'b t) -> 'b t
val return : 'a -> 'a t
The following identities ought to hold (for some value of =):
return x >>= f = f x
t >>= fun x -> return x = t
(t >>= f) >>= g = t >>= fun x -> (f x >>= g)
Note:
>>=
is the infix notation forbind
)
val map : [ `Define_using_bind | `Custom of 'a t -> f:('a -> 'b) -> 'b t ]
The
map
argument toMonad.Make
says how to implement the monad'smap
function.`Define_using_bind
means to definemap t ~f = bind t ~f:(fun a -> return (f a))
.`Custom
overrides the default implementation, presumably with something more efficient.Some other functions returned by
Monad.Make
are defined in terms ofmap
, so passing in a more efficientmap
will improve their efficiency as well.