Library
Module
Module type
Parameter
Class
Class type
Note: These lenses are mostly meant for getting, set
is generally inefficient.
l1 |-- l2
is an infix operator for compose l2 l1
.
val get : 'a -> ('a, 'b) lens -> 'b option
val set : 'a -> 'b -> ('a, 'b) lens -> 'a option
val get_exn : 'a -> ('a, 'b) lens -> 'b
get_exn a l
is Option.get (get a l)
.
val set_exn : 'a -> 'b -> ('a, 'b) lens -> 'a
set_exn a v l
is Option.get (set a v l)
.
val (.@()) : 'a -> ('a, 'b) lens -> 'b option
(.@())
is an indexing operator for get
.
val (.@()<-) : 'a -> ('a, 'b) lens -> 'b -> 'a option
(.@()<-)
is an indexing operator for set
: it allows you to write document.@(lens) <- value
instead of set document value lens
.
val update : ('b -> 'b option) -> 'a -> ('a, 'b) lens -> 'a option
Lens to node.annot
as an option
. Pass None
to remove the annotation.
val args : (node, annot_value list) lens
Lens to node.args
.
val arg : int -> (node, annot_value) lens
arg n
is a lens to the n
-th argument of a node, starting at 0. This operates in O(n) time.
val prop : string -> (node, annot_value) lens
Lens to the property with the specific name. Operates in O(n) time.
node ?annot name
is a lens to the first node with the specific name in a list. The search optionally can be narrowed by passing ?annot
.
Same as node
, but returns all possible matches instead of the first one.
child ?annot name
is children |-- node ?annot name
.
child_many ?annot name
is children |-- node_many ?annot name
.
val value : (annot_value, value) lens
Lens to value
in the annot_value
pair.
val annot : (annot_value, string) lens
Lens to annot
in the annot_value
pair.
val annot_opt : (annot_value, string option) lens
Lens to annot
as an option
. Pass None
to unset the annotation.
val string : ([> `String of string ], string) lens
Lens to a string value.
val int : ([> `Int of int ], int) lens
Lens to an int value.
val raw_int : ([> `RawInt of string ], string) lens
Lens to a raw int value.
val float : ([> `Float of float ], float) lens
Lens to a float value.
Lens to any numeric KDL value.
val bool : ([> `Bool of bool ], bool) lens
Lens to a boolean value.
val null : ([> `Null ], unit) lens
Lens to a null value.
val string_value : (annot_value, string) lens
string_value
is value |-- string
.
val int_value : (annot_value, int) lens
int_value
is value |-- int
.
val raw_int_value : (annot_value, string) lens
raw_int_value
is value |-- raw_int
.
val float_value : (annot_value, float) lens
float_value
is value |-- float
.
val bool_value : (annot_value, bool) lens
bool_value
is value |-- bool
.
val null_value : (annot_value, unit) lens
null_value
is value |-- null
.
val top : ('a list, 'a) lens
Lens to the first element of a list.
val nth : int -> ('a list, 'a) lens
Lens to the n
-th element of a list, starting at 0.
val filter : ('a -> bool) -> ('a list, 'a list) lens