Module Rel.Col

Column descriptions.

This module defines a type to describe columns. A column is defined by its name, its type, an optional default value and how to project it from the row representation it belongs to.

Columns

type name = string

The type for column names.

type 'a param = ..

The type for extensible column parameters. Warning this may be removed in the future.

type 'a default = [
  1. | `Expr of string
  2. | `Value of 'a
]

The type for column defaults.

type ('r, 'a) t

The type for a column with values represented by type 'a and which are part of a row represented by type 'r.

type 'r v =
  1. | V : ('r, 'a) t -> 'r v

The type for existential columns for a row of type 'r.

type 'r value =
  1. | Value : ('r, 'a) t * 'a -> 'r value

The type for a column value for a row of type 'r.

val v : ?params:'a param list -> ?default:'a default -> string -> 'a Type.t -> ('r -> 'a) -> ('r, 'a) t

v ?default name t proj is a column named name with type t, row projection function proj and default default (defaults to None).

val name : ('r, 'a) t -> name

name c is the name of c.

val name' : 'r v -> name

name c is the name of c.

val type' : ('r, 'a) t -> 'a Type.t

type' is the type of c.

val proj : ('r, 'a) t -> 'r -> 'a

proj c is the projection function of c.

val default : ('r, 'a) t -> 'a default option

default is the default value of c (if any).

val params : ('r, 'a) t -> 'a param list

params c are the parameters of c.

val no_proj : 'r -> 'a

no_proj raises Invalid_argument.

Predicates

val equal_name : ('r, 'a) t -> ('s, 'b) t -> bool

equal_name c0 c1 is true if c0 and c1 have the same name.

Formatters

val pp : Stdlib.Format.formatter -> ('r, 'a) t -> unit

pp formats column descriptions.

val pp_name : Stdlib.Format.formatter -> ('r, 'a) t -> unit

pp_name formats the column name.

val value_pp : ('r, 'a) t -> Stdlib.Format.formatter -> 'r -> unit

value_pp formats a row's column value.

val pp_value : Stdlib.Format.formatter -> 'r value -> unit

pp_value ppf v formats v's value.

val pp_sep : Stdlib.Format.formatter -> unit -> unit

pp_sep formats a separator for columns.