The id-dict is a data type that lets us store values in a dictionary using unique identifiers. This can be used as a dictionary where the keys do not matter.
The benefit of the id-dict is that it generates the keys FOR you. This way, you do not need to generate identifiers yourself.
Insert a new value into the id-dict. Given that the id-dict generates its key, the function returns both the updated id-dict as the newly generated key.
x = empty |> insert "hello" -- ( 0, <Iddict with value "hello"> )
case x of
( _, id-dict ) ->
get 0 id-dict -- Just "hello"Update the value of an id-dict for a specific key with a given function. This is also the only option that allows you to insert values at a specific key, so be careful with this feature!
Remove a key-value pair from the id-dict. If the key is not found, no changes are made.
Convert an id-dict into an association list of key-value pairs, sorted by keys.
Fold over the key-value pairs in an id-dict from lowest key to highest key.
Fold over the key-value pairs in an id-dict from highest key to lowest key.
Keep only the key-value pairs that pass the given test.
Partition an id-dict according to some test. The first id-dict contains all key-value pairs which passed the test, and the second contains the pairs that did not.
Combine two id-dicts. If there is a collision, preference is given to the first id-dict.
Keep a key-value pair when its key appears in the second id-dict. Preference is given to values in the first id-dict.
Keep a key-value pair when its key does not appear in the second id-dict.
The most general way of combining two id-dicts. You provide three accumulators for when a given key appears:
1. Only in the left id-dict.
2. In both id-dicts.
3. Only in the right id-dict.You then traverse all the keys from lowest to highest, building up whatever you want.
The Iddict data type.