Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Orec.Default
SourceDefault namespace for record fields
include Namespace.S
The type of record within the namespace
The type of a field getter or updater
type 'info get = (('a, 'mut) Type_data.getter * 'res) field_action constraint 'info = < x : 'a ; mut : 'mut ; ret : 'res >
Aliases for the type of fields
Create a new open record from a list of field updater : create [ field1 ^= value1; field2 ^= value2; ... ]
Only const updater make sense in this context, since there is no fields present.
Creation of a new fields. Note that the type 'ty would be weakly polymorphic once the field created. However, in this specific use case, it seems reasonable to annotate the field type by using one of the field type aliases.
Constant field updater: record.{ field ^= v }
sets the value of field
to v
and is equivalent to record.{ put field v }
Field map: record.{field |= f }
or record.{ fmap field f }
are equivalent to record.{ field ^= fmap f record.{field} }
if the field exists, and do nothing otherwise
Field combinator orec.%{ x & y }
is orec.%{x}.%{y}
val and_then :
(Type_data.any, t) update ->
(Type_data.any, t) update ->
(Type_data.any, t) update
Copy a mutable field
Delete a field, if the field does not exist, do nothing
(.%{} )
operator:
record.%{field}
returns the value of the fieldrecord.%{field ^= value}
returns a functional update of record record.%{field |= f}
is equivalent to record.{ field ^= f record.{field} }
record.%{delete field}
returns an updated version of record without this fieldval transmute :
(< x : 'a ; mut : 'm.. > as 'x) get ->
('a, 'b) bijection ->
< x : 'b ; mut : 'm ; ret : 'b option > get
Use the type equality implied by the bijection 'a⟺'b
to create a new 'b
field getter from a 'a
field getter. The new field getter uses option access
val (@:) :
(< x : 'a ; mut : 'm.. > as 'x) get ->
('a, 'b) bijection ->
< x : 'b ; mut : 'm ; ret : 'b option > get
Operator version of transmute