Utility functions for constructing optics from lists of selectors.
path() = string() | binary() | non_neg_integer() | *
A single path component.
paths() = [path()]
A list of path components.
new/1 | Construct a list of optics from a path. |
new(Paths) -> optic:optics()
Paths = paths()
Paths
: A list of path components to convert.
returns: A list of opaque optic records.
Construct a list of optics from a path. The type of the path component determines the optic used:
-
string: A key for a map-like structure.
-
binary: A key for a map-like structure.
-
integer: An index into a list-like structure.
-
'*': All elements of a list.
This heavily depends on the optic_generic
module, see the optics
there for the full list of containers supported.
Example:
> optic:get(optic_path(["first"]), ${"first" => 1, "second" => 2}).
{ok,[1]}