Module Rel.Col

Column definitions.

A column is defined by its name, its type, an optional default value and how to project it from the OCaml row representation it is part of.

Columns

type 'a param = ..

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

type name = string

The type for column names.

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

    This value.

    *)
]

The type for column value defaults.

type ('r, 'a) t

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

type 'r def =
  1. | Def : ('r, 'a) t -> 'r def

The type for existential column definitions part of a row of type 'r.

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

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

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

make name type' proj is a column definition with:

  • name, the name of the column.
  • type', the type of the column.
  • proj, the projection function from the type 'r representing the row the column is part of.
  • default, the default value of the column (if any).
  • params, a list of parameters for the column.
val name : ('r, 'a) t -> name

name c is the name of c.

val name' : 'r def -> 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 : ('r, 'a) t fmt

pp formats column definitions.

val pp_name : ('r, 'a) t fmt

pp_name formats the column name.

val value_pp : ('r, 'a) t -> 'r fmt

value_pp c formats the column value c of row.

val pp_value : 'r value fmt

pp_value formats column value.

val pp_named_value : 'r value fmt

pp_named_value formats column values prefixed by their name.

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

pp_sep formats a separator for columns.