Accessor.OSourceTo use Accessor in your own code, it is recommended to add the following to your import.ml:
module Accessor =
(* Consider using something like [Accessor_base], [Accessor_core], or
[Accessor_async], instead. *)
Accessor
include Accessor.OThe O module contains a few operators and type aliases that are unlikely to clash with anything else.
val (@>) :
('middle, 'outer, 'kind) t ->
('inner, 'middle, 'kind) t ->
('inner, 'outer, 'kind) ta @> b is the composition of the two accessors a and b. From left to right, a chain of composed accessors goes from outermost to innermost values. The resulting accessor kind is determined by the least powerful argument. Here are a few examples:
isomorphism composed with a field is a field.field composed with a variant is an optional.getter composed with a variant is an optional_getter.It's normally more intuitive to think of the operations you need than to think of exactly which kind of accessor you are creating. For example, if you are trying to extract a value from a data structure using a field, you would probably use get. However, if you compose the field with an optional, get no longer makes sense; you must use something like get_option, instead.
The non-operator name is Accessor.compose.
x.@(t) extracts a single value from x as identified by t. The non-operator name is Accessor.get.
val (.@?()) :
'at ->
(Base.unit -> 'a -> _, Base.unit -> 'at -> _, [> optional_getter ]) t ->
'a Base.optionx.@?(t) extracts at most one value from x as identified by t. The non-operator name is Accessor.get_option.