Page
Library
Module
Module type
Parameter
Class
Class type
Source
Pidgin.ReprSourceBroadly speaking, Pidgin describes a "generic" key-value language that serves as an intermediate format between several other key-value formats (such as JSON, TOML, YAML, etc.). Repr describes the abstract representation of this language.
The generic representation of the language is relatively straightforward (and compact), closely resembling the representation chosen to describe JSON.
To construct terms that are more complex than those offered by the generic representation, the module provides combinators that allow for a high degree of flexibility in description.
Since type t is non-abstract, this allows for the creation of data structures that may seem unusual (such as empty records); however, in practice, checking static invariants complicates the use of the library and results in a lack of flexibility. Since conversion functions to t` are generally associated with validation functions, it is assumed that the validations will handle these unusual cases.
The generic representation of language.
Describes a module in which t can be projected into a pidgin representation.
Combinators for constructing values in the representation t.
Build a record. If the flag normalize_keys is true (default value) keys are lowercased and trimmed.
Make use of the minimal nature of ASTs to construct more complex expressions. Mostly using records.
option conv converter for option. use null for describing None and conv for Some.
sum f x produce a sum-type for a given x. The function f return a couple of constructor-name and value. The result is wrapped into the following record: {constr = "constr-name"; value = value}.
pair fst snd (a, b) produce a product type for a given pair a, b. The result is wrapped into the following record: {first = a; second = b}.
result ~ok ~error is a converter for result values. It uses sum under the hood.
either ~ok ~error is a converter for Either values. It uses sum under the hood.
triple ca cb cd is a converter for triples. Under the hood, triple are pair.
int32 is a converter for int32. It use {constr = "int32"; value = string n} as an underlying representation.
int64 is a converter for int64. It use {constr = "int64"; value = string n} as an underlying representation.
into (module Proj) converts value using Proj.to_pidgin.
using f conv is a contramap. If we have a function from b to a, then we can get a conversion from a to t to b to t.
Enables case analysis by using folds (catamorphisms) to standardize access to the various branches of the AST.
val fold :
null:(unit -> 'a) ->
bool:(bool -> 'a) ->
int:(int -> 'a) ->
float:(float -> 'a) ->
string:(string -> 'a) ->
list:(t list -> 'a) ->
record:((string * t) list -> 'a) ->
t ->
'aExhaustive match over t.
val fold_partial :
?null:(unit -> 'a) ->
?bool:(bool -> 'a) ->
?int:(int -> 'a) ->
?float:(float -> 'a) ->
?string:(string -> 'a) ->
?list:(t list -> 'a) ->
?record:((string * t) list -> 'a) ->
(t -> 'a) ->
t ->
'aPartial match over t.