package ogre

  1. Overview
  2. Docs

Ogre type system.

Ogre type system is extremely simple, it has only four types: 1. boolean - a logical type that has only two values (true,false); 2. int - an integral number that maps to OCaml's int64; 3. float - a real number that maps to OCaml's float; 4. str - an arbitrary string, represented as string in OCaml.

A scheme is a first class value, that describes how to construct attributes from fields, and how to deconstruct them.

A field is a pair of a name and a type, and is used to reference to construct attributes, and to reference to attribute objects in queries.

type 'a t

type descriptor.

val int : int64 t

int is represented with OCaml's int64, and has a corresponding representation

val bool : bool t

bool is either true or false.

val str : string t

str represented by a sequence of characters. If the sequence contains whitespaces or parenthesis then the sequence should be delimited with quotes. Note, the requirements are for the database backend implementations. A user of the library shouldn't be bothered by the representation.

val float : float t
val scheme : 'a field -> (('a -> 'r) -> 'r, ('a -> 'p) -> 'p) scheme

scheme field defines a scheme with one field.

val ($) : ('a -> 'b -> 'r, 'd -> 'b -> 'p) scheme -> 'b field -> ('a -> 'r, 'd -> 'p) scheme

scm $field adds a field to a scheme scm.

Usually, all the fields are combined in a one expression, starting with the call to a function scheme, e.g.,

scheme name $ age $ salary

The scheme had type (('a -> 'r) -> 'r, ('a -> 'p) -> 'p) scheme, then the type of a resulting scheme would be [(('a -> 'b -> 'r) -> 'r, ('a -> 'b -> 'p) -> 'p) scheme], i.e., a type of $field will be attached to the scheme.

For example, the scheme name $age $salary expression will have a type (assuming, that name, age and salary are represented with string, int, and int, correspondingly):

(string -> int64 -> int64 -> 'a) -> 'a,
(string -> int64 -> int64 -> 'b) -> 'b

The scheme is used to construct an attribute. See below.

val def : string -> 'a t -> 'a field

def name t defines a field with the give name and type t.

val (%:) : string -> 'a t -> 'a field

name : t is the same as def name t