Up

Module Lazy_list = Lazy_list

Signature

type 'a t
include Core.Std.Monad.S with type 'a t := 'a t
type 'a t
include Monad_intf.S_without_syntax with type 'a t := 'a t
type 'a t

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.

include Monad_intf.Infix with type 'a t := 'a t
type 'a t
val (>>=) : 'a t -> ('a -> 'b t) -> 'b t

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.

val (>>|) : 'a t -> ('a -> 'b) -> 'b t

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

module Monad_infix : Monad_intf.Infix with type 'a t := 'a t
val bind : 'a t -> ('a -> 'b t) -> 'b t

bind t f = t >>= f

val return : 'a -> 'a t

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

val map : 'a t -> f:('a -> 'b) -> 'b t

map t ~f is t >>| f.

val join : 'a t t -> 'a t

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

val ignore_m : 'a t -> unit t

ignore_m t is map t ~f:(fun _ -> ()). ignore_m used to be called ignore, but we decided that was a bad name, because it shadowed the widely used Pervasives.ignore. Some monads still do let ignore = ignore_m for historical reasons.

val all : 'a t list -> 'a list t
val all_ignore : unit t list -> unit t
include Monad_intf.Syntax with type 'a t := 'a t
type 'a t
module Let_syntax : sig .. end
val empty : unit -> 'a t
val is_empty : 'a t -> bool
val length : 'a t -> int
val decons : 'a t -> ('a * 'a t) option
val cons : 'a -> 'a t -> 'a t
val snoc : 'a t -> 'a -> 'a t
val append : 'a t -> 'a t -> 'a t
val map : 'a t -> f:('a -> 'b) -> 'b t
val concat : 'a t t -> 'a t
val nth : 'a t -> int -> 'a option
val concat_list : 'a list t -> 'a t
val find : f:('a -> bool) -> 'a t -> 'a option
val filter : f:('a -> bool) -> 'a t -> 'a t
val filter_opt : 'a option t -> 'a t
val filter_map : f:('a -> 'b option) -> 'a t -> 'b t
val fold_left : f:('a -> 'b -> 'a) -> init:'a -> 'b t -> 'a
val fold_right : f:('a -> 'b -> 'b) -> 'a t -> init:'b -> 'b
val foldr : 'a t -> f:('a -> 'b Lazy_m.t -> 'b) -> init:'b -> 'b Lazy_m.t
val iter : 'a t -> f:('a -> unit) -> unit
val of_iterator : curr:('a -> 'b option) -> next:('a -> 'a) -> init:'a -> 'b t
val build : f:('s -> ('a * 's) option) -> seed:'s -> 'a t
val unfold : f:('a -> 'a option) -> init:'a -> 'a t
val uniter : f:(unit -> 'a option) -> 'a t
val of_list : 'a list -> 'a t
val to_rev_list : 'a t -> 'a list
val to_list : 'a t -> 'a list
val of_array : 'a array -> 'a t
val to_array : 'a t -> 'a array
val cartesian_product : 'a t t -> 'a t t
val merge : cmp:('a -> 'a -> int) -> 'a t -> 'a t -> 'a t
val unify : cmp:('a -> 'b -> int) -> 'a t -> 'b t -> [
| `Left of 'a
| `Right of 'b
| `Both of 'a * 'b
] t
val sort : cmp:('a -> 'a -> int) -> 'a t -> 'a t
val lazy_sort : cmp:('a -> 'a -> int) -> 'a t -> 'a t
module Of_container : sig .. end
module Iterator : sig .. end