Cf_data_renderRendering data according to an abstract model.
This module facilitates the rendering of data conforming to an abstract model using any interchange language provided with a basis module defining the emitter type and some basic emitters and emitter composers.
Data models are functionally composable. Optional affix convenience operators are provide an indiomatic syntax.
With a fully composed data models and the render specialization of an interchange language, you produce an emitter that produces output of well-typed values according to the corresponding model.
A data model represents either the "primitive" type of a scalar value or a "composed" type of a group of values.
A primitive model represents an OCaml value identified by a Cf_type.nym. Some nyms are conventionally accepted by every interchange language in the Orsetto distribution:
Cf_type.Unit A type with exactly one value, e.g. the JSON "null" value.Cf_type.Bool A boolean value type.Cf_type.Int An integer value in the range that an OCaml nt can represent.Cf_type.Int32 An integer value in the range that an OCaml nt32 can represent.Cf_type.Int64 An integer value in the range that an OCaml nt64 can represent.Cf_type.Float An IEEE 754 floating point value in the range that an OCaml float can represent.Cf_type.String An octet string, not necessarily associated with a particular encoding.Cf_type.Opaque An opaque value conventionally representing any scalar or group value in the underlying interchange language. (Note well: opaque values may contain interchange language specific elements that cannot expressed in other interchange languages.)A group model takes one of the following forms:
The types and values in this section facilitate the composition of abstract data models for use in constructing emitters with interchange languages for which a render specialization is defined.
The type constructor 'v model represents the rendering of 'v values encoded to some interchange language.
val primitive : 'v Cf_type.nym -> 'v modelUse primitive nym to compose a model that corresponds to all the values of the type associated with nym.
Use cast f m to compose a model that corresponds to the values produced by applying f to rendered values for the model m.
Use default v m to compose a model for rendered optional values in the model m where v is output when the rendered value is None.
Use choice f s to compose a model that applies f to the rendered value to select the index of the model in s used to produce the output.
Use vector m to compose a model that corresponds to a variable length array of values produced by the emitter for the model m.
class 'key index : ?cmp:('key ->
'key ->
int) -> ?model:'key model -> 'key Cf_type.nym -> object ... endUse new index nym to create an index object for the type indicated by nym required for composing table, structure and variant group models. Use the optional ~cmp argument to specify a concrete comparator function to use instead of Stdlib.( = ). Use the optional ~model argument to specify the model explicitly, otherwise the primitive model for nym is used for the domain or index in the compoed group model.
Use table k v to compose a model that corresponds to a variable length array of pairs comprising a domain value of the type described by the index k and a codomain value of the type described by the model v. Use the optional ~unsorted argument to specify that the emitter does not sort the rendered array.
The abstract type parameter for group elements where the position in the sequence indicates the model for the element.
The type constructor ['g, 'p] bind represents the model of a specific element in a group with fields or elements of disparate type. In the case where type 'g is element, the type 'p corresponds to the type indicated by the position in the sequence. In the case where type 'g is 'k index, the type 'p corresponds to the type indicated by its index value.
module Element : sig ... endA submodule containing composers for elements indexed by position.
Use record s to compose a model that corresponds to variable length array of elements corresponding to the projection of the rendered value with all the element binders in s in sequence.
module Field : sig ... endA submodule containing composers for elements indexed by some totally ordered domain type.
Use structure d s to compose a model that corresponds to variable length array of pairs comprising a key of the type described by the index d and a value of a type indicated by the field in s associated with the key. Use the optional ~unsorted argument to specify that the emitter does not sort the rendered array by their keys.
Use variant d f s to compose a model that corresponds to a pair comprising a key of the type described by the index d obtained by applying f to the rendered value, and a value of a type indicated by, and a value obtained according to the field bind associated with the key.
module Affix : sig ... endA submodule containing affix operators the provide a convenient and idiosyncratic syntax for composing record and structure models.
Usage of generalized data models with a specific interchange language entails composing a render specialization for it. The types and values in this section are provided for that purpose.
The extensible control type. Facilitates composing data models with features extended by the render specialization for unique features of the interchange language. A value of type ('a, 'b) control represents a conversion of a model of type 'a model to a model of type 'b model as a side effect of any additional constraints applied.
A control value Cast f represents the operation of applying f to the rendered value to produce the value rendered by the model under control.
A control value Default v represents the conversion of an optional rendered value into a required value by using v in the event the rendered value is None.
Use control m c to compose a new model comprising the application of c to the model m.
type 'k pair = [ | `Table of 'k Cf_type.nym| `Structure of 'k Cf_type.nym| `Variant of 'k Cf_type.nym ]Values of type 'k pair are used to describe the structure of pair elements in sequences that comprise group data models indexed by values of type 'k.
Values of type 'k container are used to describe the structure of sequences that comprise group data models.
module type Basis = sig ... endDefine a module of type Basis to create a render specialization.
module type Profile = sig ... endThe module type of render specializations.