Module Accessor_async__.Import

module Accessor = Accessor_core
include Accessor.O
type at_least_one = [
| `at_least_one
]
type at_most_one = [
| `at_most_one
]
type coerce = [
| `coerce
]
type construct = [
| `construct
]
type get = [
| `get
]
type map = [
| `map
]
type constructor = construct
type equality = [
| get
| map
| at_most_one
| at_least_one
| construct
| coerce
]
type field = [
| get
| map
| at_most_one
| at_least_one
]
type getter = [
| get
| at_least_one
| at_most_one
]
type isomorphism = [
| get
| map
| at_most_one
| at_least_one
| construct
]
type many = [
| get
| map
]
type many_getter = get
type mapper = map
type nonempty = [
| get
| map
| at_least_one
]
type nonempty_getter = [
| get
| at_least_one
]
type optional = [
| get
| map
| at_most_one
]
type optional_getter = [
| get
| at_most_one
]
type variant = [
| get
| map
| at_most_one
| construct
]
val (@>) : ('middle'outer'kind) Accessor.t -> ('inner'middle'kind) Accessor.t -> ('inner'outer'kind) Accessor.t

a @> 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:

  • An isomorphism composed with a field is a field.
  • A field composed with a variant is an optional.
  • A 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.

val (.@()) : 'at -> (Base.unit -> 'a -> 'bBase.unit -> 'at -> 'bt[> getter ]) Accessor.t -> 'a

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 ]) Accessor.t -> 'a Base.option

x.@?(t) extracts at most one value from x as identified by t. The non-operator name is Accessor.get_option.

val (.@*()) : 'at -> (Base.unit -> 'a -> _Base.unit -> 'at -> _[> many_getter ]) Accessor.t -> 'a Base.list

x.@*(t) extracts any number of values from x as identified by t. The non-operator name is Accessor.to_list.

val (.@()<-) : 'at -> (_ -> _ -> 'bBase.unit -> 'at -> 'bt[> mapper ]) Accessor.t -> 'b -> 'bt

x.@(t) <- y replaces any number of values in x with y, as identified by t. The non-operator name is Accessor.set.