Module optic_dict
April 27, 2019 ยท View on GitHub
A set of optics specific to dicts.
Function Index
| all/0 | |
| all/1 | |
| association/1 | |
| association/2 | Focus on the association for a dict key. |
| associations/0 | |
| associations/1 | Focus on all associations of a dict. |
| key/1 | |
| key/2 | Focus on the value of a dict key. |
| keys/0 | |
| keys/1 | Focus on all keys of a dict. |
| values/0 | |
| values/1 | Focus on all values of a dict. |
Function Details
all/0
all() -> optic:optic()
See also: values/1.
all/1
all(Options) -> optic:optic()
Options = optic:variations()
See also: values/1.
association/1
association(Key) -> optic:optic()
Key = term()
See also: association/2.
association/2
association(Key, Options) -> optic:optic()
Key = term()Options = optic:variations()
Key: The key to focus on.Options: Common optic options.
returns: An opaque optic record.
Focus on the association for a dict key. An association is the tuple of a dict key and value. If the key is modified, the optic is no longer well behaved.
Example:
> optic:get([optic_dict:association(first)],
dict:from_list([{first, 1}, {second, 2}])).
{ok,[{first,1}]}
associations/0
associations() -> optic:optic()
See also: associations/1.
associations/1
associations(Options) -> optic:optic()
Options = optic:variations()
Options: Common optic options.
returns: An opaque optic record.
Focus on all associations of a dict. An association is a tuple of the key and value for each entry.
Example:
> optic:get([optic_dict:associations()],
dict:from_list([{first, 1}, {second, 2}])).
{ok,[{first,1},{second,2}]}
key/1
key(Key) -> optic:optic()
Key = term()
See also: key/2.
key/2
key(Key, Options) -> optic:optic()
Key = term()Options = optic:variations()
Key: The key to focus on.Options: Common optic options.
returns: An opaque optic record.
Focus on the value of a dict key.
Example:
> optic:get([optic_dict:key(first)],
dict:from_list([{first, 1}, {second, 2}])).
{ok,[1]}
keys/0
keys() -> optic:optic()
See also: keys/1.
keys/1
keys(Options) -> optic:optic()
Options = optic:variations()
Options: Common optic options.
returns: An opaque optic record.
Focus on all keys of a dict.
Example:
> optic:get([optic_dict:keys()],
dict:from_list([{first, 1}, {second, 2}])).
{ok,[first,second]}
values/0
values() -> optic:optic()
See also: values/1.
values/1
values(Options) -> optic:optic()
Options = optic:variations()
Options: Common optic options.
returns: An opaque optic record.
Focus on all values of a dict.
Example:
> optic:get([optic_dict:values()],
dict:from_list([{first, 1}, {second, 2}])).
{ok,[1,2]}