A dictionary mapping unique keys to values. Unlike in the elm Dict, the elements can be any type that can be converted to an elm 'comparable'.
This is helpful if you have values that are really just a comparable underneath, but you want to keep them separate using the type system. For instance
type TagId = TagId Int
type CustomerId = CustomerId Int
emptyTagDict = TDict.empty ((TagId id) -> id) TagId String emptyCustomerDict = TDict.empty ((CustomerId id) -> id) CustomerId String
So this works: TDict.insert ((TagId 1), "some string of interest") emptyTagDict
But not this: TDict.insert ((TagId 1), "some string of interest") emptyCustomerDict
Insert a key-value pair into a dictionary. Replaces value when there is a collision.
Update the value of a dictionary for a specific key with a given function.
Remove a key-value pair from a dictionary. If the key is not found, no changes are made.
Get the value associated with a key. If the key is not found, return
Nothing. This is useful when you are not sure if a key will be in the
dictionary.
Get all of the keys in a dictionary, sorted from lowest to highest.
Get all of the values in a dictionary, in the order of their keys.
Convert a dictionary into an association list of key-value pairs, sorted by keys.
Merge an association list into a dictionary.
Apply a function to all values in a dictionary.
Fold over the key-value pairs in a dictionary, in order from lowest key to highest key.
Fold over the key-value pairs in a dictionary, in order from highest key to lowest key.
Keep a key-value pair when it satisfies a predicate.
Partition a dictionary according to a predicate. The first dictionary contains all key-value pairs which satisfy the predicate, and the second contains the rest.
Combine two dictionaries. If there is a collision, preference is given to the first dictionary.
Keep a key-value pair when its key appears in the second dictionary. Preference is given to values in the first dictionary.
Keep a key-value pair when its key does not appear in the second dictionary.
The most general way of combining two dictionaries. 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.
A dictionary of keys and values. So a
(Dict String User)is a dictionary that lets you look up aString(such as user names) and find the associatedUser.