package kdl
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Module Kdl.L
Source
Basic partial "lenses" for accessing deeply-nested KDL structures.
Note: These lenses are mostly meant to be used for getting, set
is generally inefficient.
The partial lens. More formally, it is also known as affine traversal (the combination of lens and prism).
l1 // l2
is an infix operator for compose l2 l1
.
Alias for (//)
, the lens composition.
Run the getter (lens.get
). Results in Some value
if the lens successfully matches, or None
otherwise.
(.@()<-)
is an indexing operator for set
: it allows one to write document.@(lens) <- value
instead of set document value lens
.
(.@!())
is an indexing operator for get_exn
(raising version of (.@())
).
(.@!()<-)
is an indexing operator for set_exn
(raising version of (.@()<-)
).
The combination of get
and set
.
Lens to node.annot
, the optional type annotation of a node (if the annotation is not set, the partial lens fails).
Lens to node.annot
as an option
. Pass None
to remove the annotation.
Lens to node.args
, the node arguments.
arg n
is a lens to the n
-th argument of a node, starting at 0. Operates in O(n) time.
first_arg
is arg 0
.
Lens to the property with the given name. Operates in O(n) time.
node ?nth ?annot name
is a lens to the n
-th node with the given name in a list. n
is specified by the ?nth
optional argument and defaults to the first node, i.e. 0. The search can optionally be narrowed by passing ?annot
.
Same as node
, but returns all possible matches.
child ?nth ?annot name
is children // node ?nth ?annot name
.
child_many ?annot name
is children // node_many ?annot name
.
Lens to value
in the annot_value
pair.
Lens to annot
in the annot_value
pair.
Lens to annot
as an option
. Pass None
to unset the annotation.
Lens to a numeric value represented as nativeint
.
string_value
is value // string
.
number_value
is value // number
.
string_number_value
is value // string_number
.
float_number_value
is value // float_number
.
int_number_value
is value // int_number
.
int32_number_value
is value // int32_number
.
int64_number_value
is value // int64_number
.
nativeint_number_value
is value // nativeint_number
.
bool_value
is value // bool
.
null_value
is value // null
.
Apply a lens to multiple items. Example: top // child_many "paragraph" // each (arg 0 // value)
.