View Source Pathex.Accessibility (Pathex v2.4.0)

Helpers to create paths from Access.t() and lists

Note:
This module is separate because functions presented in this module are suboptimal. You should try use Pathex.path/2 first, and only if its not applicable to you use-case, you should use functions from this module

Link to this section Summary

Functions

Creates path-closure from Access.t().

Creates path from list of items. The list of items should not be known at runtime, therefore some optimizations of paths are not possible. Use this function only when Pathex.path/2 is not applicable

Converts path-closure to Access.t()

Link to this section Types

@type access() :: [term(), ...]

Link to this section Functions

@spec from_access(access()) :: Pathex.t()

Creates path-closure from Access.t().

Note: Paths created using this function do not support force operations yet

Example:

iex> import Pathex
iex> p = from_access [:x, :y]
iex> 10 = view!(%{x: [y: 10]}, p)
Link to this function

from_list(list, mod \\ :naive)

View Source
@spec from_list([any()], Pathex.mod()) :: Pathex.t()

Creates path from list of items. The list of items should not be known at runtime, therefore some optimizations of paths are not possible. Use this function only when Pathex.path/2 is not applicable

Example:

iex> import Pathex
iex> p = from_list [:x, 1, :y]
iex> 10 = view!(%{x: [1, [y: 10]]}, p)
@spec to_access(Pathex.t()) :: [Access.access_fun(any(), any())]

Converts path-closure to Access.t()

Example:

iex> import Pathex
iex> access = to_access path(:x / 0, :map)
iex> 1 = get_in(%{x: %{0 => 1}}, access)