Convenience functions for working with Dict
Create a dictionary from a list of values, by passing a function that can get a key from any such value.
If the function does not return unique keys, earlier values are discarded.
This can, for instance, be useful when constructing Dicts from a List of records with id fields:
jack = {id=2, name="Jack"}
jill = {id=1, name="Jill"}
fromListBy .id [jack, jill] == Dict.fromList [(1, jack), (2, jill)]Remove elements which satisfies the predicate.
removeWhen (\c v -> v == 1) Dict.fromList [("Mary", 1), ("Jack", 2), ("Jill", 1)] == Dict.fromList [("Jack", 2)]Remove a key-value pair if its key appears in the set.
Keep a key-value pair if its key appears in the set.
Apply a function to all keys in a dictionary
Takes a key-fn and a list. Creates a
Dictwhich maps the key to a list of matching elements.