Core.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 = Base.Container.Continue_or_stop
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 = Base.Container.S0
module type S0_phantom = Base.Container.S0_phantom
module type S0_with_creators = Base.Container.S0_with_creators
module type S1 = Base.Container.S1
module type S1_phantom = Base.Container.S1_phantom
module type S1_with_creators = Base.Container.S1_with_creators
module type Derived = Base.Container.Derived
module type Generic = Base.Container.Generic
module type Generic_with_creators = Base.Container.Generic_with_creators
module type Summable = Base.Container.Summable
include Derived
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 Base.Container.Summable with type t = 'sum) ->
't ->
f:('a -> 'sum) ->
'sum
val fold_result :
fold:('t, 'a, 'acc) fold ->
init:'acc ->
f:('acc -> 'a -> ('acc, 'e) Base.Result.t) ->
't ->
('acc, 'e) Base.Result.t
val fold_until :
fold:('t, 'a, 'acc) fold ->
init:'acc ->
f:('acc -> 'a -> ('acc, 'final) Base.Container.Continue_or_stop.t) ->
finish:('acc -> 'final) ->
't ->
'final
Generic definitions of container operations in terms of iter
and length
.
val is_empty : iter:('t, 'a) iter -> 't -> bool
val mem : iter:('t, 'a) iter -> 't -> 'a -> equal:('a -> 'a -> bool) -> bool
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
module Make = Base.Container.Make
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 = Base.Container.Make0
module Make_gen = Base.Container.Make_gen
module Make_with_creators = Base.Container.Make_with_creators
module Make0_with_creators = Base.Container.Make0_with_creators
module Make_gen_with_creators = Base.Container.Make_gen_with_creators
module type S0_permissions = Container_intf.S0_permissions
module type S1_permissions = Container_intf.S1_permissions
module type S1_with_creators_permissions =
Container_intf.S1_with_creators_permissions