Std.Dict
Immutable key-value dictionaries backed by Erlang maps.
Functions
new
fun new : Unit -> Dict k vCreates an empty dictionary.
from_list
fun from_list : (pairs: List (k, v)) -> Dict k v where {k: Eq}Creates a dictionary from a list of key-value pairs.
get
fun get : (key: k) -> (dict: Dict k v) -> Maybe v where {k: Eq}Returns the value for a key, or Nothing if not present.
put
fun put : (key: k) -> (value: v) -> (dict: Dict k v) -> Dict k v where {k: Eq}Inserts or replaces a key-value pair.
remove
fun remove : (key: k) -> (dict: Dict k v) -> Dict k v where {k: Eq}Removes a key from the dictionary. Returns the dict unchanged if key is not present.
member
fun member : (key: k) -> (dict: Dict k v) -> Bool where {k: Eq}Returns True if the key is present in the dictionary.
size
fun size : (dict: Dict k v) -> IntReturns the number of entries in the dictionary.
is_empty
fun is_empty : Dict k v -> BoolReturns True if the dictionary has no entries.
keys
fun keys : (dict: Dict k v) -> List kReturns all keys as a list.
values
fun values : (dict: Dict k v) -> List vReturns all values as a list.
to_list
fun to_list : (dict: Dict k v) -> List (k, v)Converts the dictionary to a list of key-value pairs.
map
fun map : (f: v -> v2) -> (dict: Dict k v) -> Dict k v2Applies a function to every value, returning a new dictionary.
filter
fun filter : (pred: k -> v -> Bool) -> (dict: Dict k v) -> Dict k vReturns a dictionary containing only entries where the predicate returns True.
fold
fun fold : (f: a -> k -> v -> a) -> (init: a) -> (dict: Dict k v) -> aFolds over all entries, left to right.
merge
fun merge : (base: Dict k v) -> (overrides: Dict k v) -> Dict k v where {k: Eq}Merges two dictionaries. Values from the overrides dict win on key conflicts.
update
fun update : (key: k) -> (f: v -> v) -> (dict: Dict k v) -> Dict k v where {k: Eq}Updates the value at a key by applying a function. No-op if key is not present.