Page
Library
Module
Module type
Parameter
Class
Class type
Source
RecordLayouts
The representation of record types. 's is usually a phantom type. Two interfaces are provided for creating layouts, in Unsafe and Safe.
val field_name : ('a, 's) field -> stringGet the name of the field (as passed to field).
val declare : string -> 's layoutCreate a new layout with the given name.
Add a field to a layout. This modifies the layout and returns the field.
val seal : 's layout -> unitMake the layout unmodifiable. It is necessary before constructing values.
val layout_name : 's layout -> stringGet the name that was given to a layout.
Records
val declare0 : name:string -> 's layoutShortcut to build a layout with no fields.
Shortcut to build a layout with 1 field.
val declare2 :
name:string ->
f1_name:string ->
f1_type:'a1 Type.t ->
f2_name:string ->
f2_type:'a2 Type.t ->
's layout * ('a1, 's) field * ('a2, 's) fieldShortcut to build a layout with 2 fields.
val declare3 :
name:string ->
f1_name:string ->
f1_type:'a1 Type.t ->
f2_name:string ->
f2_type:'a2 Type.t ->
f3_name:string ->
f3_type:'a3 Type.t ->
's layout * ('a1, 's) field * ('a2, 's) field * ('a3, 's) fieldShortcut to build a layout with 3 fields.
val declare4 :
name:string ->
f1_name:string ->
f1_type:'a1 Type.t ->
f2_name:string ->
f2_type:'a2 Type.t ->
f3_name:string ->
f3_type:'a3 Type.t ->
f4_name:string ->
f4_type:'a4 Type.t ->
's layout
* ('a1, 's) field
* ('a2, 's) field
* ('a3, 's) field
* ('a4, 's) fieldShortcut to build a layout with 4 fields.
Raised by make when the corresponding layout has not been sealed.
module Type : sig ... endmodule Field : sig ... endmodule Polid : sig ... endmodule Unsafe : sig ... endmodule Safe : sig ... endMiscellaneous
val to_json : 'a t -> Yojson.Basic.jsonConvert a record to JSON.
val of_json : 'a layout -> Yojson.Basic.json -> 'a tConvert a JSON value into a given schema.
val to_yojson : 'a t -> Yojson.Safe.jsonConvert a record to JSON.
val of_yojson :
'a layout ->
Yojson.Safe.json ->
[ `Ok of 'a t | `Error of string ]Convert a JSON value into a given schema.
module Util : sig ... endval equal : 'a layout -> 'b layout -> ('a, 'b) Polid.equalEquality predicate.
val format : Format.formatter -> 'a t -> unitPrint the JSON representation of a record to a formatter.