package tezos-base

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Signature for an interval of (included values) with an encoding and projection functions towards the underlying ocaml datatype.

type t

Internal representation of a bounded value.

type ocaml_type

Underlying OCaml representation for the bounded value.

include BOUNDS with type ocaml_type := ocaml_type
val min_value : ocaml_type

min_value represents the minimal value (included) reprensatable.

val max_value : ocaml_type

max_value represents the maximal value (included) reprensatable.

include Tezos_stdlib.Compare.S with type t := t
val (=) : t -> t -> bool

x = y iff compare x y = 0

val (<>) : t -> t -> bool

x <> y iff compare x y <> 0

val (<) : t -> t -> bool

x < y iff compare x y < 0

val (<=) : t -> t -> bool

x <= y iff compare x y <= 0

val (>=) : t -> t -> bool

x >= y iff compare x y >= 0

val (>) : t -> t -> bool

x > y iff compare x y > 0

val compare : t -> t -> int

compare an alias for the functor parameter's compare function

val equal : t -> t -> bool

equal x y iff compare x y = 0

val max : t -> t -> t

max x y is x if x >= y otherwise it is y

val min : t -> t -> t

min x y is x if x <= y otherwise it is y

val encoding : t Data_encoding.t

A (partial) encoding of the datatype. If the encoded value is out of bounds, an exception may be raised. See Data_encoding.conv_with_guard.

val pp : Format.formatter -> t -> unit

A pretty-printer for values of type t.

val to_value : t -> ocaml_type

to_value t is a projection to the OCaml representation of the bounded value t.

val of_value : ocaml_type -> t option

of_value ocaml_value represents ocaml_value as a bounded value. Returns None if the value is outside of the bounds specified by min_value and max_value.