Module mapz

Data Types

path()

path() = [term()]

A list of keys that are used to iterate deeper into a map of maps.

Function Index

deep_find/2Returns a tuple {ok,Value}, where Value is the value associated with Path, or error if no value is associated with Path in Map.
deep_get/2Returns value Value associated with Path if Map contains Path.
deep_get/3Returns value Value associated with Path if Map contains Path.
deep_merge/1Merges a list of maps recursively into a single map.
deep_merge/2Equivalent to deep_merge([Map1, Map2]).
deep_merge/3Merges a list of maps Maps recursively into a single map Target.
deep_put/3Associates Path with value Value and inserts the association into map Map2.
deep_remove/2Removes the last existing key of Path, and its associated value from Map1 and returns a new map Map2 without that key.
deep_update/3If Path exists in Map1, the old associated value is replaced by value Value.
deep_update_with/3Update a value in a Map1 associated with Path by calling Fun on the old value to get a new value.
inverse/1Inverts Map by inserting each value as the key with its corresponding key as the value.

Function Details

deep_find/2

deep_find(Path::path(), Map::map()) -> {ok, term()} | error

Returns a tuple {ok,Value}, where Value is the value associated with Path, or error if no value is associated with Path in Map.

The call can raise the following exceptions:

deep_get/2

deep_get(Path::path(), Map::map()) -> term()

Returns value Value associated with Path if Map contains Path.

The call can raise the following exceptions:

deep_get/3

deep_get(Path::path(), Map::map(), Default::term()) -> term()

Returns value Value associated with Path if Map contains Path. If no value is associated with Path, Default is returned.

The call can raise the following exceptions:

deep_merge/1

deep_merge(Maps::[map()]) -> map()

Equivalent to deep_merge(fun (_, V) -> V end, #{}, Maps).

Merges a list of maps recursively into a single map. If a path exist in several maps, the value in the first nested map is superseded by the value in a following nested map.

The call can raise the following exceptions:

deep_merge/2

deep_merge(Map1::map(), Map2::map()) -> map()

Equivalent to deep_merge([Map1, Map2]).

deep_merge/3

deep_merge(Fun::fun((Old::term(), New::term()) -> term()), Target::map(), Maps::map() | [map()]) -> map()

Merges a list of maps Maps recursively into a single map Target. If a path exist in several maps, the function Fun is called with the previous and the conflicting value to resolve the conflict. The return value from the function is put into the resulting map.

The call can raise the following exceptions: map.

deep_put/3

deep_put(Path::path(), Value::term(), Map1::map()) -> map()

Associates Path with value Value and inserts the association into map Map2. If path Path already exists in map Map1, the old associated value is replaced by value Value. The function returns a new map Map2 containing the new association and the old associations in Map1.

The call can raise the following exceptions:

deep_remove/2

deep_remove(Path::path(), Map::map()) -> map()

Removes the last existing key of Path, and its associated value from Map1 and returns a new map Map2 without that key. Any deeper non-existing keys are ignored.

The call can raise the following exceptions:

deep_update/3

deep_update(Path::path(), Value::term(), Map1::map()) -> map()

If Path exists in Map1, the old associated value is replaced by value Value. The function returns a new map Map2 containing the new associated value.

The call can raise the following exceptions:

deep_update_with/3

deep_update_with(Path::path(), Fun::fun((term()) -> term()), Map1::map()) -> map()

Update a value in a Map1 associated with Path by calling Fun on the old value to get a new value.

The call can raise the following exceptions:

inverse/1

inverse(Map::map()) -> map()

Inverts Map by inserting each value as the key with its corresponding key as the value. If two keys have the same value, one of the keys will be overwritten by the other in an undefined order.

The call can raise the following exceptions:


Generated by EDoc