123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187(** This module extends {!Base.Container}. *)open!ImportopenPerms.ExportopenBase.ContainermoduleContinue_or_stop=Continue_or_stopmoduletypeS0_permissions=sigtypeelttype-'permissionst(** Checks whether the provided element is there. *)valmem:[>read]t->elt->boolvallength:[>read]t->intvalis_empty:[>read]t->bool(** [iter t ~f] calls [f] on each element of [t]. *)valiter:[>read]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:[>read]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:[>read]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]. *)valfold_until:[>read]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:[>read]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:[>read]t->f:(elt->bool)->bool(** Returns the number of elements for which the provided function evaluates to true. *)valcount:[>read]t->f:(elt->bool)->int(** Returns the sum of [f i] for i in the container *)valsum:(moduleSummablewithtypet='sum)->[>read]t->f:(elt->'sum)->'sum(** Returns as an [option] the first element for which [f] evaluates to true. *)valfind:[>read]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:[>read]t->f:(elt->'boption)->'boptionvalto_list:[>read]t->eltlistvalto_array:[>read]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:[>read]t->compare:(elt->elt->int)->eltoptionvalmax_elt:[>read]t->compare:(elt->elt->int)->eltoptionendmoduletypeS1_permissions=sigtype('a,-'permissions)t(** Checks whether the provided element is there. *)valmem:('a,[>read])t->'a->equal:('a->'a->bool)->boolvallength:(_,[>read])t->intvalis_empty:(_,[>read])t->bool(** [iter t ~f] calls [f] on each element of [t]. *)valiter:('a,[>read])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,[>read])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,[>read])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]. *)valfold_until:('a,[>read])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,[>read])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,[>read])t->f:('a->bool)->bool(** Returns the number of elements for which the provided function evaluates to true. *)valcount:('a,[>read])t->f:('a->bool)->int(** Returns the sum of [f i] for i in the container *)valsum:(moduleSummablewithtypet='sum)->('a,[>read])t->f:('a->'sum)->'sum(** Returns as an [option] the first element for which [f] evaluates to true. *)valfind:('a,[>read])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,[>read])t->f:('a->'boption)->'boptionvalto_list:('a,[>read])t->'alistvalto_array:('a,[>read])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,[>read])t->compare:('a->'a->int)->'aoptionvalmax_elt:('a,[>read])t->compare:('a->'a->int)->'aoptionendmoduletypeS1_with_creators_permissions=sigincludeS1_permissionsvalof_list:'alist->('a,[<_perms])tvalof_array:'aarray->('a,[<_perms])tvalappend:('a,[>read])t->('a,[>read])t->('a,[<_perms])tvalconcat:(('a,[>read])t,[>read])t->('a,[<_perms])tvalmap:('a,[>read])t->f:('a->'b)->('b,[<_perms])tvalfilter:('a,[>read])t->f:('a->bool)->('a,[<_perms])tvalfilter_map:('a,[>read])t->f:('a->'boption)->('b,[<_perms])tvalconcat_map:('a,[>read])t->f:('a->('b,[>read])t)->('b,[<_perms])tvalpartition_tf:('a,[>read])t->f:('a->bool)->('a,[<_perms])t*('a,[<_perms])tvalpartition_map:('a,[>read])t->f:('a->('b,'c)Either.t)->('b,[<_perms])t*('c,[<_perms])tendmoduletypeContainer=sig(** @open *)includemoduletypeofstructincludeBase.ContainerendmoduletypeS0_permissions=S0_permissionsmoduletypeS1_permissions=S1_permissionsmoduletypeS1_with_creators_permissions=S1_with_creators_permissionsend