Module Gist.Scalar

Scalar types for gist processors.

Scalars

type 'a t =
  1. | Unit : unit t
  2. | Bool : bool t
  3. | Char : char t
  4. | Uchar : Stdlib.Uchar.t t
  5. | Int : int t
  6. | Int32 : int32 t
  7. | Int64 : int64 t
  8. | Nativeint : nativeint t
  9. | Float : float t

The type for representing scalar types of type 'a.

val applied_name : 'a t -> applied_name

applied_name s is the OCaml nullary type constructor of scalar s"unit", "bool", "char", etc.

Generic operations

Constants

val zero : 'a t -> 'a

zero s is a zero value for the scalar type s.

val min_scalar : 'a t -> 'a

min_scalar s is the minimal value for the scalar type s.

val max_scalar : 'a t -> 'a

max_scalar s is the maximal value for the scalar type s.

Predicates and comparisons

val equal : 'a t -> 'a -> 'a -> bool

equal s v0 v1 is true iff v0 and v1 are the same value as per the Stdlib's corresponding M.equal function.

val compare : 'a t -> 'a -> 'a -> int

equal s v0 v1 is true iff v0 and v1 are the same value as per the Stdlib's corresponding M.compare function.

Formatting

val pp_char : Stdlib.Format.formatter -> char -> unit

pp_char formats char OCaml literals as follows:

  • Char.Ascii.is_print except single quote and slash are printed verbatim between single quotes.
  • Characters '\'', '\\', '\n', '\r' and '\t' are printed just as written here.
  • Other characters use hex escapes '\xhh'.
val pp_uchar : Stdlib.Format.formatter -> Stdlib.Uchar.t -> unit

pp_uchar formats Uchar.t pseudo OCaml literals (the notation does not exist) between quotes. It escapes, with the OCaml Unicode escape notation: C0 control characters (U+0000-U+001F), C1 control characters (U+0080-U+009F), line separator (U+2028) and paragraph separator (U+2029). In practice lots of funny stuff can still happen.

val pp : 'a t -> Stdlib.Format.formatter -> 'a -> unit

pp s is a formatter for values of the scalar type s. This formats numbers in decimal, uses "%g" for floats and pp_char and pp_uchar for characters.