# Module Container_intf

    module Container_intf: sig .. end

This file has generic signatures for container data structures, with standard functions (iter, fold, exists, for_all, ...) that one would expect to find in any container. The idea is to include `Container.S0` or `Container.S1` in the signature for every container-like data structure (Array, List, String, ...) to ensure a consistent interface.

This file has generic signatures for container data structures, with standard functions (iter, fold, exists, for_all, ...) that one would expect to find in any container. The idea is to include `Container.S0` or `Container.S1` in the signature for every container-like data structure (Array, List, String, ...) to ensure a consistent interface.

    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 S1_permissions = sig .. end

    module type Generic = sig .. end

    module type Generic_phantom = sig .. end

    module type Make_arg = sig .. end

    module type Container = sig .. end

This file has generic signatures for container data structures, with standard functions (iter, fold, exists, for_all, ...) that one would expect to find in any container. The idea is to include `Container.S0` or `Container.S1` in the signature for every container-like data structure (Array, List, String, ...) to ensure a consistent interface.
Checks whether the provided element is there using the default equality test, using the provided `equal` function if it is not
`iter` must allow exceptions raised in `f` to escape, terminating the iteration cleanly. The same holds for all functions below taking an `f`.
`fold t ~init ~f` returns `f (... f (f (f init e1) e2) e3 ...) en`, where `e1..en` are the elements of `t`
Returns `true` if and only if there exists an element for which the provided function evaluates to `true`. This is a short-circuiting operation.
Returns `true` if and only if the provided function evaluates to `true` for all elements. This is a short-circuiting operation.
Returns the number of elements for which the provided function evaluates to true.
Returns the sum of `f i` for i in the container
Returns as an `option` the first element for which `f` evaluates to true.
Returns the first evaluation of `f` that returns `Some`, and returns `None` if there is no such element.
Returns a min (resp max) element from the collection using the provided `cmp` 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.
Checks whether the provided element is there using the default equality test, using the provided `equal` function if it is not
`fold t ~init ~f` returns `f (... f (f (f init e1) e2) e3 ...) en`, where `e1..en` are the elements of `t`
Returns `true` if and only if there exists an element for which the provided function evaluates to `true`. This is a short-circuiting operation.
Returns `true` if and only if the provided function evaluates to `true` for all elements. This is a short-circuiting operation.
Returns the number of elements for which the provided function evaluates to true.
Returns the sum of `f i` for i in the container
Returns as an `option` the first element for which `f` evaluates to true.
Returns the first evaluation of `f` that returns `Some`, and returns `None` if there is no such element.
Returns a min (resp max) element from the collection using the provided `cmp` function, or `None` if the collection is empty. In case of a tie, the first element encountered while traversing the collection is returned.
Checks whether the provided element is there, using polymorphic compare if `equal` is not provided
`fold t ~init ~f` returns `f (... f (f (f init e1) e2) e3 ...) en`, where `e1..en` are the elements of `t`
Returns `true` if and only if there exists an element for which the provided function evaluates to `true`. This is a short-circuiting operation.
Returns `true` if and only if the provided function evaluates to `true` for all elements. This is a short-circuiting operation.
Returns the number of elements for which the provided function evaluates to true.
Returns the sum of `f i` for i in the container
Returns as an `option` the first element for which `f` evaluates to true.
Returns the first evaluation of `f` that returns `Some`, and returns `None` if there is no such element.
Returns a minimum (resp maximum) element from the collection using the provided `cmp` 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`.
Checks whether the provided element is there, using polymorphic compare if `equal` is not provided
`fold t ~init ~f` returns `f (... f (f (f init e1) e2) e3 ...) en`, where `e1..en` are the elements of `t`
Returns `true` if and only if there exists an element for which the provided function evaluates to `true`. This is a short-circuiting operation.
Returns `true` if and only if the provided function evaluates to `true` for all elements. This is a short-circuiting operation.
Returns the number of elements for which the provided function evaluates to true.
Returns the sum of `f i` for i in the container
Returns as an `option` the first element for which `f` evaluates to true.
Returns the first evaluation of `f` that returns `Some`, and returns `None` if there is no such element.
Returns a min (resp max) element from the collection using the provided `cmp` 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.
Checks whether the provided element is there, using polymorphic compare if `equal` is not provided
`fold t ~init ~f` returns `f (... f (f (f init e1) e2) e3 ...) en`, where `e1..en` are the elements of `t`
Returns `true` if and only if there exists an element for which the provided function evaluates to `true`. This is a short-circuiting operation.
Returns `true` if and only if the provided function evaluates to `true` for all elements. This is a short-circuiting operation.
Returns the number of elements for which the provided function evaluates to true.
Returns the sum of `f i` for i in the container
Returns as an `option` the first element for which `f` evaluates to true.
Returns the first evaluation of `f` that returns `Some`, and returns `None` if there is no such element.
Returns a min (resp max) element from the collection using the provided `cmp` 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.
The `iter` argument to `Container.Make` says 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.
Generic definitions of container operations in terms of `fold`.

E.g.: `iter ~fold t ~f = fold t ~init:() ~f:(fun () a -> f a)`.
Generic definitions of container operations in terms of `iter`.
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).