Module Gist.Scalar

Operating on scalar types.

type 'a t = 'a scalar

The type for scalars of type 'a.

val meta : 'a scalar -> 'a Meta.t

meta s is the meta of s.

val zero : 'a scalar -> 'a

zero s is a zero value for s.

val type_name : 'a scalar -> type_name

type_name s is the OCaml type name of the scalar of s.

val with_meta : 'a Meta.t -> 'a scalar -> 'a scalar

with_meta meta s is s with meta meta.

val equal : 'a scalar -> '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 scalar -> '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.

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

pp s is a formatter for scalar s

val to_string : 'a scalar -> 'a -> string

to_string s v converts v to a string. This uses the Stdlib's corresponding M.to_string functions, except for:

  • char, UTF-8 compatible characters are output as is, otherwise hex escaped. TODO. What about simply interpreting the byte as a Unicode scalar value ? (that'd give a latin1 interpretation I think).
  • Uchar.t, the UTF-8 encoding of the character is returned