Module Type.Custom

Custom types.

Custom types allow DBMS backend to extend the set of base types defined by Rel to support datatypes specific to the DBMS. To store encodings of OCaml values use Coded types.

type 'a type' = ..

The type for custom types. A custom type adds a case to this type.

type 'a ops

The type for generic operations on custom values.

type 'a t = 'a type' * 'a ops

The type for custom types.

val make : ?doc:string -> ?pp:'a fmt -> ?equal:'a eq -> name:string -> 'a type' -> 'a t

make ~name type' is a custom column type with:

  • name, the name of the custom type.
  • type', the case that identifies the type.
  • equal, an equality function on the values of the type. Defaults to Stdlib.(=)
  • pp, a pretty printer for the type values.
  • doc, a doc string for the custom type.
val name : 'a t -> string

name c is name of c.

val doc : 'a t -> string

doc c is the documentation string of c.

val equal : 'a t -> 'a eq

equal c tests the values of c for equality.

val pp : 'a t -> 'a fmt

pp c is formats values of c

val invalid_unknown : 'a t -> 'b

invalid_unknown c raises Invalid_argument indicating that the custom type c is unknown and cannot be handled.