package batteries

  1. Overview
  2. Docs
A community-maintained standard library extension

Install

Dune Dependency

Authors

Maintainers

Sources

v3.9.0.tar.gz
md5=ea26b5c72e6731e59d856626049cca4d
sha512=55975b62c26f6db77433a3ac31f97af609fc6789bb62ac38b267249c78fd44ff37fe81901f1cf560857b9493a6046dd37b0d1c0234c66bd59e52843aac3ce6cb

doc/batteries.unthreaded/BatBounded/index.html

Module BatBoundedSource

Bounded values

This module implements values which must fall within given bounds.

  • author Hezekiah M. Carty
  • since 2.0
Sourcetype 'a bound_t = [
  1. | `o of 'a
  2. | `c of 'a
  3. | `u
]

`open or `closed or `unbounded bounds

Sourcetype ('a, 'b) bounding_f = bounds:('a bound_t * 'a bound_t) -> 'a -> 'b

The type of a bounding function with limits specified by bounds

Sourceval bounding_of_ord : default_low:'b -> default_high:'b -> ('a -> 'b) -> ('a -> 'a -> BatOrd.order) -> ('a, 'b) bounding_f

bounding_of_ord ~default_low ~default_high conv ord will returning a bounding function using ord for value comparison and default_low and default_high for values which fall outside of the requested range. conv is used to convert values which are in-range to the result type.

Sourceval bounding_of_ord_chain : low:('a -> 'b) -> high:('a -> 'b) -> ('a -> 'b) -> ('a -> 'a -> BatOrd.order) -> ('a, 'b) bounding_f

bounding_of_ord_chain ?low ?high ord is like bounding_of_ord except that functions are used to handle out of range values rather than single default values.

Sourceval saturate_of_ord : bounds:('a bound_t * 'a bound_t) -> ('a -> 'a -> BatOrd.order) -> 'a -> 'a

saturate_of_ord ~bounds:(low, high) ord will returning a bounding function using ord for value comparison and low and high for values which fall outside of the requested range.

Sourceval opt_of_ord : bounds:('a bound_t * 'a bound_t) -> ('a -> 'a -> BatOrd.order) -> 'a -> 'a option

opt_of_ord ~bounds:(low, high) ord will returning a bounding function using ord for value comparison and None for values which fall outside of the requested range.

Sourcemodule type BoundedType = sig ... end
Sourcemodule type BoundedNumericType = sig ... end
Sourcemodule type S = sig ... end
Sourcemodule type NumericSig = sig ... end
Sourcemodule Make (M : BoundedType) : S with type base_u = M.base_t with type u = M.t with type t = private M.t

Functor to build an implementation of a bounded type given the bounded values definition M

Sourcemodule MakeNumeric (M : BoundedNumericType) : NumericSig with type base_u = M.base_t with type u = M.t with type t = private M.t
OCaml

Innovation. Community. Security.