Module Option.Ops_monad

include Monadic with type 'x t := 'x t
val return : 'x -> 'x t
val bind : 'x t -> ('x -> 'y t) -> 'y t
val (>>=) : 'a t -> ('a -> 'b t) -> 'b t

monadic binding

val (>>) : 'x t -> 'y t -> 'y t

monadic sequencing

NB if expr1 and expr2 both incur side effects, expr1 >> expr2 will usually incur side effects of expr2 first and then expr1, which is usually not what the programmer expects

val (>|=) : 'x t -> ('x -> 'y) -> 'y t

monadic mapping

val returning : 'a -> 'b -> 'a t

monadic version of constant

val mlift : ('a -> 'b) -> 'a -> 'b t
val mwrap : ('a -> 'b) -> 'a t -> 'b t
val do_cond : bool -> ('a -> 'b t) -> ('a -> 'b t) -> 'a -> 'b t

m >>= do_cond cond f_true f_false performs f_true or f_false on value enclosed in m, respectively when cond is true or false;

functionally equiv. to fun c f1 f2 -> if c then f1 else f2 but return type of f1 and f2 is restricted to _ t

val do_if : bool -> ('a -> unit t) -> 'a -> unit t

m >>= do_if cond f is equiv. to m >>= do_cond cond f (returning ())

val sequence_list : 'a t list -> 'a list t
val (>>=*) : 'x t list -> ('x list -> 'y t) -> 'y t

monadic binding version of sequence_list