123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775(** 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. *)open!ImportmoduleExport=struct(** [Continue_or_stop.t] is used by the [f] argument to [fold_until] in order to
indicate whether folding should continue, or stop early.
@canonical Base.Container.Continue_or_stop
*)moduleContinue_or_stop=structtype('a,'b)t=|Continueof'a|Stopof'bendendincludeExport(** @canonical Base.Container.Summable *)moduletypeSummable=sigtypet(** The result of summing no values. *)valzero:t(** An operation that combines two [t]'s and handles [zero + x] by just returning [x],
as well as in the symmetric case. *)val(+):t->t->tend(** Signature for monomorphic container - a container for a specific element type, e.g.,
string, which is a container of characters ([type elt = char]) and never of anything
else. *)moduletypeS0=sigtypettypeelt(** Checks whether the provided element is there, using equality on [elt]s. *)valmem:t->elt->boolvallength:t->intvalis_empty:t->bool(** [iter] must allow exceptions raised in [f] to escape, terminating the iteration
cleanly. The same holds for all functions below taking an [f]. *)valiter:t->f:(elt->unit)->unit(** [fold t ~init ~f] returns [f (... f (f (f init e1) e2) e3 ...) en], where [e1..en]
are the elements of [t]. *)valfold:t->init:'acc->f:('acc->elt->'acc)->'acc(** [fold_result t ~init ~f] is a short-circuiting version of [fold] that runs in the
[Result] monad. If [f] returns an [Error _], that value is returned without any
additional invocations of [f]. *)valfold_result:t->init:'acc->f:('acc->elt->('acc,'e)Result.t)->('acc,'e)Result.t(** [fold_until t ~init ~f ~finish] is a short-circuiting version of [fold]. If [f]
returns [Stop _] the computation ceases and results in that value. If [f] returns
[Continue _], the fold will proceed. If [f] never returns [Stop _], the final result
is computed by [finish].
Example:
{[
type maybe_negative =
| Found_negative of int
| All_nonnegative of { sum : int }
(** [first_neg_or_sum list] returns the first negative number in [list], if any,
otherwise returns the sum of the list. *)
let first_neg_or_sum =
List.fold_until ~init:0
~f:(fun sum x ->
if x < 0
then Stop (Found_negative x)
else Continue (sum + x))
~finish:(fun sum -> All_nonnegative { sum })
;;
let x = first_neg_or_sum [1; 2; 3; 4; 5]
val x : maybe_negative = All_nonnegative {sum = 15}
let y = first_neg_or_sum [1; 2; -3; 4; 5]
val y : maybe_negative = Found_negative -3
]} *)valfold_until:t->init:'acc->f:('acc->elt->('acc,'final)Continue_or_stop.t)->finish:('acc->'final)->'final(** Returns [true] if and only if there exists an element for which the provided
function evaluates to [true]. This is a short-circuiting operation. *)valexists:t->f:(elt->bool)->bool(** Returns [true] if and only if the provided function evaluates to [true] for all
elements. This is a short-circuiting operation. *)valfor_all:t->f:(elt->bool)->bool(** Returns the number of elements for which the provided function evaluates to true. *)valcount:t->f:(elt->bool)->int(** Returns the sum of [f i] for all [i] in the container. *)valsum:(moduleSummablewithtypet='sum)->t->f:(elt->'sum)->'sum(** Returns as an [option] the first element for which [f] evaluates to true. *)valfind:t->f:(elt->bool)->eltoption(** Returns the first evaluation of [f] that returns [Some], and returns [None] if there
is no such element. *)valfind_map:t->f:(elt->'aoption)->'aoptionvalto_list:t->eltlistvalto_array:t->eltarray(** Returns a min (resp. max) element from the collection using the provided [compare]
function. In case of a tie, the first element encountered while traversing the
collection is returned. The implementation uses [fold] so it has the same
complexity as [fold]. Returns [None] iff the collection is empty. *)valmin_elt:t->compare:(elt->elt->int)->eltoptionvalmax_elt:t->compare:(elt->elt->int)->eltoptionendmoduletypeS0_phantom=sigtypeelttype'at(** Checks whether the provided element is there, using equality on [elt]s. *)valmem:_t->elt->boolvallength:_t->intvalis_empty:_t->boolvaliter:_t->f:(elt->unit)->unit(** [fold t ~init ~f] returns [f (... f (f (f init e1) e2) e3 ...) en], where [e1..en]
are the elements of [t]. *)valfold:_t->init:'acc->f:('acc->elt->'acc)->'acc(** [fold_result t ~init ~f] is a short-circuiting version of [fold] that runs in the
[Result] monad. If [f] returns an [Error _], that value is returned without any
additional invocations of [f]. *)valfold_result:_t->init:'acc->f:('acc->elt->('acc,'e)Result.t)->('acc,'e)Result.t(** [fold_until t ~init ~f ~finish] is a short-circuiting version of [fold]. If [f]
returns [Stop _] the computation ceases and results in that value. If [f] returns
[Continue _], the fold will proceed. If [f] never returns [Stop _], the final result
is computed by [finish].
Example:
{[
type maybe_negative =
| Found_negative of int
| All_nonnegative of { sum : int }
(** [first_neg_or_sum list] returns the first negative number in [list], if any,
otherwise returns the sum of the list. *)
let first_neg_or_sum =
List.fold_until ~init:0
~f:(fun sum x ->
if x < 0
then Stop (Found_negative x)
else Continue (sum + x))
~finish:(fun sum -> All_nonnegative { sum })
;;
let x = first_neg_or_sum [1; 2; 3; 4; 5]
val x : maybe_negative = All_nonnegative {sum = 15}
let y = first_neg_or_sum [1; 2; -3; 4; 5]
val y : maybe_negative = Found_negative -3
]} *)valfold_until:_t->init:'acc->f:('acc->elt->('acc,'final)Continue_or_stop.t)->finish:('acc->'final)->'final(** Returns [true] if and only if there exists an element for which the provided
function evaluates to [true]. This is a short-circuiting operation. *)valexists:_t->f:(elt->bool)->bool(** Returns [true] if and only if the provided function evaluates to [true] for all
elements. This is a short-circuiting operation. *)valfor_all:_t->f:(elt->bool)->bool(** Returns the number of elements for which the provided function evaluates to true. *)valcount:_t->f:(elt->bool)->int(** Returns the sum of [f i] for all [i] in the container. The order in which the
elements will be summed is unspecified. *)valsum:(moduleSummablewithtypet='sum)->_t->f:(elt->'sum)->'sum(** Returns as an [option] the first element for which [f] evaluates to true. *)valfind:_t->f:(elt->bool)->eltoption(** Returns the first evaluation of [f] that returns [Some], and returns [None] if there
is no such element. *)valfind_map:_t->f:(elt->'aoption)->'aoptionvalto_list:_t->eltlistvalto_array:_t->eltarray(** Returns a min (resp max) element from the collection using the provided [compare]
function, or [None] if the collection is empty. In case of a tie, the first element
encountered while traversing the collection is returned. *)valmin_elt:_t->compare:(elt->elt->int)->eltoptionvalmax_elt:_t->compare:(elt->elt->int)->eltoptionend(** Signature for polymorphic container, e.g., ['a list] or ['a array]. *)moduletypeS1=sigtype'at(** Checks whether the provided element is there, using [equal]. *)valmem:'at->'a->equal:('a->'a->bool)->boolvallength:'at->intvalis_empty:'at->boolvaliter:'at->f:('a->unit)->unit(** [fold t ~init ~f] returns [f (... f (f (f init e1) e2) e3 ...) en], where [e1..en]
are the elements of [t] *)valfold:'at->init:'acc->f:('acc->'a->'acc)->'acc(** [fold_result t ~init ~f] is a short-circuiting version of [fold] that runs in the
[Result] monad. If [f] returns an [Error _], that value is returned without any
additional invocations of [f]. *)valfold_result:'at->init:'acc->f:('acc->'a->('acc,'e)Result.t)->('acc,'e)Result.t(** [fold_until t ~init ~f ~finish] is a short-circuiting version of [fold]. If [f]
returns [Stop _] the computation ceases and results in that value. If [f] returns
[Continue _], the fold will proceed. If [f] never returns [Stop _], the final result
is computed by [finish].
Example:
{[
type maybe_negative =
| Found_negative of int
| All_nonnegative of { sum : int }
(** [first_neg_or_sum list] returns the first negative number in [list], if any,
otherwise returns the sum of the list. *)
let first_neg_or_sum =
List.fold_until ~init:0
~f:(fun sum x ->
if x < 0
then Stop (Found_negative x)
else Continue (sum + x))
~finish:(fun sum -> All_nonnegative { sum })
;;
let x = first_neg_or_sum [1; 2; 3; 4; 5]
val x : maybe_negative = All_nonnegative {sum = 15}
let y = first_neg_or_sum [1; 2; -3; 4; 5]
val y : maybe_negative = Found_negative -3
]} *)valfold_until:'at->init:'acc->f:('acc->'a->('acc,'final)Continue_or_stop.t)->finish:('acc->'final)->'final(** Returns [true] if and only if there exists an element for which the provided
function evaluates to [true]. This is a short-circuiting operation. *)valexists:'at->f:('a->bool)->bool(** Returns [true] if and only if the provided function evaluates to [true] for all
elements. This is a short-circuiting operation. *)valfor_all:'at->f:('a->bool)->bool(** Returns the number of elements for which the provided function evaluates to true. *)valcount:'at->f:('a->bool)->int(** Returns the sum of [f i] for all [i] in the container. *)valsum:(moduleSummablewithtypet='sum)->'at->f:('a->'sum)->'sum(** Returns as an [option] the first element for which [f] evaluates to true. *)valfind:'at->f:('a->bool)->'aoption(** Returns the first evaluation of [f] that returns [Some], and returns [None] if there
is no such element. *)valfind_map:'at->f:('a->'boption)->'boptionvalto_list:'at->'alistvalto_array:'at->'aarray(** Returns a minimum (resp maximum) element from the collection using the provided
[compare] function, or [None] if the collection is empty. In case of a tie, the first
element encountered while traversing the collection is returned. The implementation
uses [fold] so it has the same complexity as [fold]. *)valmin_elt:'at->compare:('a->'a->int)->'aoptionvalmax_elt:'at->compare:('a->'a->int)->'aoptionendmoduletypeS1_phantom=sigtype('a,'phantom)t(** Checks whether the provided element is there, using [equal]. *)valmem:('a,_)t->'a->equal:('a->'a->bool)->boolvallength:(_,_)t->intvalis_empty:(_,_)t->boolvaliter:('a,_)t->f:('a->unit)->unit(** [fold t ~init ~f] returns [f (... f (f (f init e1) e2) e3 ...) en], where [e1..en]
are the elements of [t]. *)valfold:('a,_)t->init:'acc->f:('acc->'a->'acc)->'acc(** [fold_result t ~init ~f] is a short-circuiting version of [fold] that runs in the
[Result] monad. If [f] returns an [Error _], that value is returned without any
additional invocations of [f]. *)valfold_result:('a,_)t->init:'acc->f:('acc->'a->('acc,'e)Result.t)->('acc,'e)Result.t(** [fold_until t ~init ~f ~finish] is a short-circuiting version of [fold]. If [f]
returns [Stop _] the computation ceases and results in that value. If [f] returns
[Continue _], the fold will proceed. If [f] never returns [Stop _], the final result
is computed by [finish].
Example:
{[
type maybe_negative =
| Found_negative of int
| All_nonnegative of { sum : int }
(** [first_neg_or_sum list] returns the first negative number in [list], if any,
otherwise returns the sum of the list. *)
let first_neg_or_sum =
List.fold_until ~init:0
~f:(fun sum x ->
if x < 0
then Stop (Found_negative x)
else Continue (sum + x))
~finish:(fun sum -> All_nonnegative { sum })
;;
let x = first_neg_or_sum [1; 2; 3; 4; 5]
val x : maybe_negative = All_nonnegative {sum = 15}
let y = first_neg_or_sum [1; 2; -3; 4; 5]
val y : maybe_negative = Found_negative -3
]} *)valfold_until:('a,_)t->init:'acc->f:('acc->'a->('acc,'final)Continue_or_stop.t)->finish:('acc->'final)->'final(** Returns [true] if and only if there exists an element for which the provided
function evaluates to [true]. This is a short-circuiting operation. *)valexists:('a,_)t->f:('a->bool)->bool(** Returns [true] if and only if the provided function evaluates to [true] for all
elements. This is a short-circuiting operation. *)valfor_all:('a,_)t->f:('a->bool)->bool(** Returns the number of elements for which the provided function evaluates to true. *)valcount:('a,_)t->f:('a->bool)->int(** Returns the sum of [f i] for all [i] in the container. *)valsum:(moduleSummablewithtypet='sum)->('a,_)t->f:('a->'sum)->'sum(** Returns as an [option] the first element for which [f] evaluates to true. *)valfind:('a,_)t->f:('a->bool)->'aoption(** Returns the first evaluation of [f] that returns [Some], and returns [None] if there
is no such element. *)valfind_map:('a,_)t->f:('a->'boption)->'boptionvalto_list:('a,_)t->'alistvalto_array:('a,_)t->'aarray(** Returns a min (resp max) element from the collection using the provided [compare]
function. In case of a tie, the first element encountered while traversing the
collection is returned. The implementation uses [fold] so it has the same complexity
as [fold]. Returns [None] iff the collection is empty. *)valmin_elt:('a,_)t->compare:('a->'a->int)->'aoptionvalmax_elt:('a,_)t->compare:('a->'a->int)->'aoptionendmoduletypeGeneric=sigtype('a,'phantom1,'phantom2)ttype'aeltvallength:(_,_,_)t->intvalis_empty:(_,_,_)t->boolvalmem:('a,_,_)t->'aelt->equal:('aelt->'aelt->bool)->boolvaliter:('a,_,_)t->f:('aelt->unit)->unitvalfold:('a,_,_)t->init:'acc->f:('acc->'aelt->'acc)->'accvalfold_result:('a,_,_)t->init:'acc->f:('acc->'aelt->('acc,'e)Result.t)->('acc,'e)Result.tvalfold_until:('a,_,_)t->init:'acc->f:('acc->'aelt->('acc,'final)Continue_or_stop.t)->finish:('acc->'final)->'finalvalexists:('a,_,_)t->f:('aelt->bool)->boolvalfor_all:('a,_,_)t->f:('aelt->bool)->boolvalcount:('a,_,_)t->f:('aelt->bool)->intvalsum:(moduleSummablewithtypet='sum)->('a,_,_)t->f:('aelt->'sum)->'sumvalfind:('a,_,_)t->f:('aelt->bool)->'aeltoptionvalfind_map:('a,_,_)t->f:('aelt->'boption)->'boptionvalto_list:('a,_,_)t->'aeltlistvalto_array:('a,_,_)t->'aeltarrayvalmin_elt:('a,_,_)t->compare:('aelt->'aelt->int)->'aeltoptionvalmax_elt:('a,_,_)t->compare:('aelt->'aelt->int)->'aeltoptionendmoduletypeS0_with_creators=sigincludeS0valof_list:eltlist->tvalof_array:eltarray->t(** E.g., [append (of_list [a; b]) (of_list [c; d; e])] is [of_list [a; b; c; d; e]] *)valappend:t->t->t(** Concatenates a nested container. The elements of the inner containers are
concatenated together in order to give the result. *)valconcat:tlist->t(** [map f (of_list [a1; ...; an])] applies [f] to [a1], [a2], ..., [an], in order, and
builds a result equivalent to [of_list [f a1; ...; f an]]. *)valmap:t->f:(elt->elt)->t(** [filter t ~f] returns all the elements of [t] that satisfy the predicate [f]. *)valfilter:t->f:(elt->bool)->t(** [filter_map t ~f] applies [f] to every [x] in [t]. The result contains every [y] for
which [f x] returns [Some y]. *)valfilter_map:t->f:(elt->eltoption)->t(** [concat_map t ~f] is equivalent to [concat (map t ~f)]. *)valconcat_map:t->f:(elt->t)->t(** [partition_tf t ~f] returns a pair [t1, t2], where [t1] is all elements of [t] that
satisfy [f], and [t2] is all elements of [t] that do not satisfy [f]. The "tf"
suffix is mnemonic to remind readers that the result is (trues, falses). *)valpartition_tf:t->f:(elt->bool)->t*t(** [partition_map t ~f] partitions [t] according to [f]. *)valpartition_map:t->f:(elt->(elt,elt)Either0.t)->t*tendmoduletypeS1_with_creators=sigincludeS1valof_list:'alist->'atvalof_array:'aarray->'at(** E.g., [append (of_list [1; 2]) (of_list [3; 4; 5])] is [of_list [1; 2; 3; 4; 5]] *)valappend:'at->'at->'at(** Concatenates a nested container. The elements of the inner containers are
concatenated together in order to give the result. *)valconcat:'att->'at(** [map f (of_list [a1; ...; an])] applies [f] to [a1], [a2], ..., [an], in order, and
builds a result equivalent to [of_list [f a1; ...; f an]]. *)valmap:'at->f:('a->'b)->'bt(** [filter t ~f] returns all the elements of [t] that satisfy the predicate [f]. *)valfilter:'at->f:('a->bool)->'at(** [filter_map t ~f] applies [f] to every [x] in [t]. The result contains every [y] for
which [f x] returns [Some y]. *)valfilter_map:'at->f:('a->'boption)->'bt(** [concat_map t ~f] is equivalent to [concat (map t ~f)]. *)valconcat_map:'at->f:('a->'bt)->'bt(** [partition_tf t ~f] returns a pair [t1, t2], where [t1] is all elements of [t] that
satisfy [f], and [t2] is all elements of [t] that do not satisfy [f]. The "tf"
suffix is mnemonic to remind readers that the result is (trues, falses). *)valpartition_tf:'at->f:('a->bool)->'at*'at(** [partition_map t ~f] partitions [t] according to [f]. *)valpartition_map:'at->f:('a->('b,'c)Either0.t)->'bt*'ctendmoduletypeGeneric_with_creators=sigtype(_,_,_)concatincludeGenericvalof_list:'aeltlist->('a,_,_)tvalof_array:'aeltarray->('a,_,_)tvalappend:('a,'p1,'p2)t->('a,'p1,'p2)t->('a,'p1,'p2)tvalconcat:(('a,'p1,'p2)t,'p1,'p2)concat->('a,'p1,'p2)tvalmap:('a,'p1,'p2)t->f:('aelt->'belt)->('b,'p1,'p2)tvalfilter:('a,'p1,'p2)t->f:('aelt->bool)->('a,'p1,'p2)tvalfilter_map:('a,'p1,'p2)t->f:('aelt->'beltoption)->('b,'p1,'p2)tvalconcat_map:('a,'p1,'p2)t->f:('aelt->('b,'p1,'p2)t)->('b,'p1,'p2)tvalpartition_tf:('a,'p1,'p2)t->f:('aelt->bool)->('a,'p1,'p2)t*('a,'p1,'p2)tvalpartition_map:('a,'p1,'p2)t->f:('aelt->('belt,'celt)Either0.t)->('b,'p1,'p2)t*('c,'p1,'p2)tendmoduletypeMake_gen_arg=sigtype('a,'phantom1,'phantom2)ttype'aeltvalfold:('a,'phantom1,'phantom2)t->init:'acc->f:('acc->'aelt->'acc)->'acc(** The [iter] argument to [Container.Make] specifies how to implement the
container's [iter] function. [`Define_using_fold] means to define [iter]
via:
{[
iter t ~f = Container.iter ~fold t ~f
]}
[`Custom] overrides the default implementation, presumably with something more
efficient. Several other functions returned by [Container.Make] are defined in
terms of [iter], so passing in a more efficient [iter] will improve their efficiency
as well. *)valiter:[`Define_using_fold|`Customof('a,'phantom1,'phantom2)t->f:('aelt->unit)->unit](** The [length] argument to [Container.Make] specifies how to implement the
container's [length] function. [`Define_using_fold] means to define
[length] via:
{[
length t ~f = Container.length ~fold t ~f
]}
[`Custom] overrides the default implementation, presumably with something more
efficient. Several other functions returned by [Container.Make] are defined in
terms of [length], so passing in a more efficient [length] will improve their
efficiency as well. *)vallength:[`Define_using_fold|`Customof('a,'phantom1,'phantom2)t->int]endmoduletypeMake_arg=sigtype'atincludeMake_gen_argwithtype('a,_,_)t:='atandtype'aelt:='aendmoduletypeMake0_arg=sigmoduleElt:sigtypetvalequal:t->t->boolendtypetincludeMake_gen_argwithtype('a,_,_)t:=tandtype'aelt:=Elt.tendmoduletypeMake_common_with_creators_arg=sigincludeMake_gen_argtype(_,_,_)concatvalof_list:'aeltlist->('a,_,_)tvalof_array:'aeltarray->('a,_,_)tvalconcat:(('a,_,_)t,_,_)concat->('a,_,_)tendmoduletypeMake_gen_with_creators_arg=sigincludeMake_common_with_creators_argvalconcat_of_array:'aarray->('a,_,_)concatendmoduletypeMake_with_creators_arg=sigtype'atincludeMake_common_with_creators_argwithtype('a,_,_)t:='atandtype'aelt:='aandtype('a,_,_)concat:='atendmoduletypeMake0_with_creators_arg=sigmoduleElt:sigtypetvalequal:t->t->boolendtypetincludeMake_common_with_creators_argwithtype('a,_,_)t:=tandtype'aelt:=Elt.tandtype('a,_,_)concat:='alistendmoduletypeDerived=sig(** 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,'acc)fold='t->init:'acc->f:('acc->'a->'acc)->'acctype('t,'a)iter='t->f:('a->unit)->unittype'tlength='t->intvaliter:fold:('t,'a,unit)fold->('t,'a)itervalcount:fold:('t,'a,int)fold->'t->f:('a->bool)->intvalmin_elt:fold:('t,'a,'aoption)fold->'t->compare:('a->'a->int)->'aoptionvalmax_elt:fold:('t,'a,'aoption)fold->'t->compare:('a->'a->int)->'aoptionvallength:fold:('t,_,int)fold->'t->intvalto_list:fold:('t,'a,'alist)fold->'t->'alistvalsum:fold:('t,'a,'sum)fold->(moduleSummablewithtypet='sum)->'t->f:('a->'sum)->'sumvalfold_result:fold:('t,'a,'acc)fold->init:'acc->f:('acc->'a->('acc,'e)Result.t)->'t->('acc,'e)Result.tvalfold_until:fold:('t,'a,'acc)fold->init:'acc->f:('acc->'a->('acc,'final)Continue_or_stop.t)->finish:('acc->'final)->'t->'final(** Generic definitions of container operations in terms of [iter] and [length]. *)valis_empty:iter:('t,'a)iter->'t->boolvalmem:iter:('t,'a)iter->'t->'a->equal:('a->'a->bool)->boolvalexists:iter:('t,'a)iter->'t->f:('a->bool)->boolvalfor_all:iter:('t,'a)iter->'t->f:('a->bool)->boolvalfind:iter:('t,'a)iter->'t->f:('a->bool)->'aoptionvalfind_map:iter:('t,'a)iter->'t->f:('a->'boption)->'boptionvalto_array:length:'tlength->iter:('t,'a)iter->'t->'aarrayendmoduletypeContainer=sigincludemoduletypeofstructincludeExportendmoduletypeS0=S0moduletypeS0_phantom=S0_phantommoduletypeS0_with_creators=S0_with_creatorsmoduletypeS1=S1moduletypeS1_phantom=S1_phantommoduletypeS1_with_creators=S1_with_creatorsmoduletypeDerived=DerivedmoduletypeGeneric=GenericmoduletypeGeneric_with_creators=Generic_with_creatorsmoduletypeSummable=SummableincludeDerived(** The idiom for using [Container.Make] is to bind the resulting module and to
explicitly import each of the functions that one wants:
{[
module C = Container.Make (struct ... end)
let count = C.count
let exists = C.exists
let find = C.find
(* ... *)
]}
This is preferable to:
{[
include Container.Make (struct ... end)
]}
because the [include] makes it too easy to shadow specialized implementations of
container functions ([length] being a common one).
[Container.Make0] is like [Container.Make], but for monomorphic containers like
[string]. *)moduleMake(T:Make_arg):S1withtype'at:='aT.tmoduleMake0(T:Make0_arg):S0withtypet:=T.tandtypeelt:=T.Elt.tmoduleMake_gen(T:Make_gen_arg):Genericwithtype('a,'phantom1,'phantom2)t:=('a,'phantom1,'phantom2)T.tandtype'aelt:='aT.eltmoduleMake_with_creators(T:Make_with_creators_arg):S1_with_creatorswithtype'at:='aT.tmoduleMake0_with_creators(T:Make0_with_creators_arg):S0_with_creatorswithtypet:=T.tandtypeelt:=T.Elt.tmoduleMake_gen_with_creators(T:Make_gen_with_creators_arg):Generic_with_creatorswithtype('a,'phantom1,'phantom2)t:=('a,'phantom1,'phantom2)T.tandtype'aelt:='aT.eltandtype('a,'phantom1,'phantom2)concat:=('a,'phantom1,'phantom2)T.concatend