A Dict over any keys with a mapping to Strings.
Dict.Refined.Dict String k v
Dictionary over any keys with a function to map those keys to strings.
empty : (k -> String) -> Dict k v
Create an empty dictionary by suppling function used for comparing keys.
singleton : (k -> String) -> k -> v -> Dict k v
Create a dictionary with one key-value pair.
insert : k -> v -> Dict k v -> Dict k v
Insert a key-value pair into a dict. Replaces value when there is a collision.
update : k -> (Maybe v -> Maybe v) -> Dict k v -> Dict k v
Update the value of a dict for a specific key with a given function.
remove : k -> Dict k v -> Dict k v
Remove a key-value pair from a dict. If the key is not found, no changes are made.
isEmpty : Dict k v -> Basics.Bool
Determine if a dict is empty.
`isEmpty empty == True`
member : k -> Dict k v -> Basics.Bool
Determine if a whole key is in a dict.
get : k -> Dict k v -> Maybe v
Get the value associated with a key. If the key is not found, return
Nothing
.
size : Dict k v -> Basics.Int
Determine the number of key-value pairs in the dict.
keys : Dict k v -> List k
Get all of the keys in a dict, sorted from lowest to highest.
values : Dict k v -> List v
Get all of the values in a dict, in the order of their keys.
toList : Dict k v -> List ( k, v )
Convert a dict into an association list of key-value pairs, sorted by keys.
fromList : (k -> String) -> List ( k, v ) -> Dict k v
Convert an association list into a dict.
map : (k -> a -> b) -> Dict k a -> Dict k b
Apply a function to all values in a dict.
foldl : (k -> v -> b -> b) -> b -> Dict k v -> b
Fold over the key-value pairs in a dict from lowest key to highest key.
foldr : (k -> v -> b -> b) -> b -> Dict k v -> b
Fold over the key-value pairs in a dict from highest key to lowest key.
filter : (k -> v -> Basics.Bool) -> Dict k v -> Dict k v
Keep only the key-value pairs that pass the given test.
partition : (k -> v -> Basics.Bool) -> Dict k v -> ( Dict k v, Dict k v )
Partition a dict according to some test. The first dict contains all key-value pairs which passed the test, and the second contains the pairs that did not.
union : Dict k v -> Dict k v -> Dict k v
Combine two dicts. If there is a collision, preference is given to the first dict.
intersect : Dict k v -> Dict k v -> Dict k v
Keep a key-value pair when its key appears in the second dict. Preference is given to values in the first dictionary.
diff : Dict k v -> Dict k v -> Dict k v
Keep a key-value pair when its key does not appear in the second dict.
merge : (k -> a -> result -> result) -> (k -> a -> b -> result -> result) -> (k -> b -> result -> result) -> Dict k a -> Dict k b -> result -> result
The most general way of combining two dicts. You provide three accumulators for when a given key appears:
You then traverse all the keys from lowest to highest, building up whatever you want.