Module Rel.Type

Column types.

This module defines a type whose values describes the type of columns and how they are represented in OCaml.

Types

type ('a, 'b) coded

The type for type 'a encoded as type 'b, see Coded.

type 'a t = ..

The type for the type of columns. The type 'a is the type used to represent the column values in OCaml. Warning the open type may be closed in the future.

type t +=
  1. | Bool : bool t
    (*

    Stored as 0 and 1

    *)
  2. | Int : int t
    (*

    Stored as int64

    *)
  3. | Int64 : int64 t
  4. | Float : float t
  5. | Text : string t
  6. | Blob : string t
  7. | Option : 'a t -> 'a option t
    (*

    Column with NULLs or values of given type.

    *)
  8. | Coded : ('a, 'b) coded -> 'a t
    (*

    An OCaml fiction.

    *)

Type of columns supported by all database management systems. Note that these are NOT NULL columns unless you use Option.

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

pp ppf t formats an unspecified representation of t on ppf. Raises Invalid_argument if t is unknown to the module.

module Coded : sig ... end

Coded types.

Predicates

val is_option : 'a t -> bool

is_option t is true iff t is an option type, that is a column that allows NULLs.

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

equal t0 t1 is true iff t0 and t1 have the underlying type. For Coded values this check equality of Coded.repr. Warning this returns false on unknown types.

Values of types

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

value_equal t v0 v1 is true iff v0 and v1 of type t are equal. Note that for now this is simply ( = ) but we may add a notion of equality to coded at some point.

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

value_pp t is a formatter for values of type t. Raises Invalid_argument if t is unknown to the module.

Invalid types

Since the type is extensible and larger than it should be these functions can be used for failing in functions that process type values.

val invalid_unknown : unit -> 'a

invalid_unknown () raises Invalid_argument indicating that the type is unknown.

val invalid_nested_option : unit -> 'a

invalid_nested_option raises Invalid_argument indicating that nested option types are not supported.