package batteries

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

Install

Dune Dependency

Authors

Maintainers

Sources

v3.5.1.tar.gz
md5=d3d16ffc960e832a1c0e21b7123194e9
sha512=36c8561079aa9fefc864c2f03bd8ae20aa05987bb67e7a9beac3ab4f440dbf7d44f141c172b05fddb1a5b618fc55a27962bb45fc39bd7b3a15d56e0ed3ff3870

doc/batteries.unthreaded/BatBounded/index.html

Module BatBounded

Bounded values

This module implements values which must fall within given bounds.

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

`open or `closed or `unbounded bounds

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

The type of a bounding function with limits specified by bounds

val 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.

val 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.

val 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.

val 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.

module type BoundedType = sig ... end
module type BoundedNumericType = sig ... end
module type S = sig ... end
module type NumericSig = sig ... end
module 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

module 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.