Module Core_kernel.Container

Provides generic signatures for container data structures.

These signatures include functions (iter, fold, exists, for_all, ...) that you would expect to find in any container. Used by including Container.S0 or Container.S1 in the signature for every container-like data structure (Array, List, String, ...) to ensure a consistent interface.

These signatures extend signatures exported by Base.Container_intf.

include module type of struct include Base.Container end
module Continue_or_stop : sig ... end

Continue_or_stop.t is used by the f argument to fold_until in order to indicate whether folding should continue, or stop early.

module type S0 = sig ... end
module type S0_phantom = sig ... end
module type S1 = sig ... end
module type S1_phantom_invariant = sig ... end
module type S1_phantom = sig ... end
module type Generic = sig ... end
module type Generic_phantom = sig ... end
module type Summable = sig ... end

Generic definitions of container operations in terms of fold.

E.g.: iter ~fold t ~f = fold t ~init:() ~f:(fun () a -> f a).

type ('t, 'a, 'accum) fold = 't -> init:'accum -> f:('accum -> 'a -> 'accum) -> 'accum
type ('t, 'a) iter = 't -> f:('a -> unit) -> unit
type 't length = 't -> int
val iter : fold:('t'a, unit) fold -> ('t'a) iter
val count : fold:('t'a, int) fold -> 't -> f:('a -> bool) -> int
val min_elt : fold:('t'a'a option) fold -> 't -> compare:('a -> 'a -> int) -> 'a option
val max_elt : fold:('t'a'a option) fold -> 't -> compare:('a -> 'a -> int) -> 'a option
val length : fold:('t_, int) fold -> 't -> int
val to_list : fold:('t'a'a list) fold -> 't -> 'a list
val sum : fold:('t'a'sum) fold -> (module Summable with type t = 'sum) -> 't -> f:('a -> 'sum) -> 'sum
val fold_result : fold:('t'a'b) fold -> init:'b -> f:('b -> 'a -> ('b'e) Base.Result.t) -> 't -> ('b'e) Base.Result.t
val fold_until : fold:('t'a'b) fold -> init:'b -> f:('b -> 'a -> ('b'final) Continue_or_stop.t) -> finish:('b -> 'final) -> 't -> 'final
val is_empty : iter:('t'a) iter -> 't -> bool

Generic definitions of container operations in terms of iter and length.

val exists : iter:('t'a) iter -> 't -> f:('a -> bool) -> bool
val for_all : iter:('t'a) iter -> 't -> f:('a -> bool) -> bool
val find : iter:('t'a) iter -> 't -> f:('a -> bool) -> 'a option
val find_map : iter:('t'a) iter -> 't -> f:('a -> 'b option) -> 'b option
val to_array : length:'t length -> iter:('t'a) iter -> 't -> 'a array
module Make (T : sig ... end) : S1 with type 'a t := 'a T.t

The idiom for using Container.Make is to bind the resulting module and to explicitly import each of the functions that one wants:

module Make0 (T : sig ... end) : S0 with type t := T.t and type elt := T.Elt.t
module type S1_permissions = Container_intf.S1_permissions