Rel.Row
Row definitions.
A row is defined by a cartesian product of columns definitions and a function for injecting them into the OCaml type that represents them.
The type for constructing a cartesian product whose final result is represented by OCaml values of type 'r
.
type 'r t = ('r, 'r) prod
The type for a row represented by OCaml values of type 'r
.
val unit : 'a -> ('r, 'a) prod
unit f
is a (virtual) unit column with constructor f
to be saturated by prod
.
prod r c
is the product of columns r
with c
.
cat r ~proj row
is the product of columns r
with the columns of row
, proj
is used to project row
values from the result of r
. Warning this may be removed in the future.
val empty : unit t
empty
is the empty product unit ()
. This can be used as a specification for the result of side effecting SQL statements like UPDATE.
These functions contructs rows with columns that have no parameters and a default projection of Col.no_proj
. They can be used to quickly devise rows for query results.
Warning. Since by default these column constructors lack projection Row.value_pp
cannot be used on them. Those created with tuple constructors do however (re)define projection.
col n t
is column named n
of type t
.
val bool : ?proj:('r -> bool) -> string -> ('r, bool) Col.t
bool n
is a boolean column named n
.
val int : ?proj:('r -> int) -> string -> ('r, int) Col.t
int n
is an integer column named n
.
val int64 : ?proj:('r -> int64) -> string -> ('r, int64) Col.t
int64 n
is an 64-bit integer column named n
.
val float : ?proj:('r -> float) -> string -> ('r, float) Col.t
float n
is a float column named n
.
val text : ?proj:('r -> string) -> string -> ('r, string) Col.t
text n
is a text column named n
.
val blob : ?proj:('r -> string) -> string -> ('r, string) Col.t
blob n
is a blob column named n
.
option t n
is a nullable t
column named n
.
t1
construct and deconstructs values with the given column. This redefines the projection to the identity.
t2
constructs and deconstructs pairs with the given column types. This redefine the projections of the columns.
t3
constructs and deconstructs triplets with the given column types. This redefine the projections of the columns.
t4
constructs and deconstructs quadruplets with the given column types. This redefine the projections of the columns.
val t5 :
(_, 'a) Col.t ->
(_, 'b) Col.t ->
(_, 'c) Col.t ->
(_, 'd) Col.t ->
(_, 'e) Col.t ->
('a * 'b * 'c * 'd * 'e) t
t5
constructs and deconstructs quintuplets with the given column types. This redefine the projections of the columns.
val t6 :
(_, 'a) Col.t ->
(_, 'b) Col.t ->
(_, 'c) Col.t ->
(_, 'd) Col.t ->
(_, 'e) Col.t ->
(_, 'f) Col.t ->
('a * 'b * 'c * 'd * 'e * 'f) t
t6
constructs and deconstructs sextuplets with the given column types. This redefine the projections of the columns.
fold f acc r
folds over the columns of f
from right-to-left.
cols r
are the columns in row r
, from left-to-right, untyped.
val col_count : ('r, 'a) prod -> int
col_count r
is the number of columns in row r
.
value_pp_list
formats list of values of r
, one per line. If header
is true
, starts by formatting the headers of r
.
module Repr : sig ... end
Low-level representation (unstable).