red-g / service-collections / Service.Dict

Service.Dicts provide the exact same functionality as Elm's built-in Dict type, while allowing for easy and safe extension with custom key types.


type Dict k v

A mapping of unique keys to values.

max : Dict k v -> Maybe ( k, v )

Get the highest key-value pair in the dictionary.

foldl : Fold ( k, v ) b -> Fold (Dict k v) b

Reduce the key-value pairs in the dictionary from lowest to highest.

foldr : Fold ( k, v ) b -> Fold (Dict k v) b

Reduce the key-value pairs in the dictionary from highest to lowest.

fold : Sorter k -> Fold ( k, v ) (Dict k v)

Insert a key-value pair into the dictionary.

fromList : Sorter k -> List ( k, v ) -> Dict k v

Convert an association list into a dictionary.

get : Sorter k -> k -> Dict k v -> Maybe v

Get the value of a key in the dictionary.

isEmpty : Filter (Dict k v)

Check if the dictionary is empty.

previous : Sorter k -> k -> Dict k v -> Maybe ( k, v )

Get the next smallest key-value pair in the dictionary.

member : Sorter k -> k -> Filter (Dict k v)

Check if the given key exists in the dictionary.

middle : Dict k v -> Maybe ( k, v )

Get the middle key-value pair of the dictionary.

next : Sorter k -> k -> Dict k v -> Maybe ( k, v )

Get the next highest key-value pair in the dictionary

remove : Sorter k -> k -> Dict k v -> Dict k v

Remove a key from a dict. If the key is not found, no changes are made.

min : Dict k v -> Maybe ( k, v )

Get the smallest key-value pair in the dictionary.

filter : Sorter k -> Filter ( k, v ) -> Dict k v -> Dict k v

Keep key-value pairs that pass the filter.

size : Dict k v -> Basics.Int

Get the number of entries in the dictionary.

insert : Sorter k -> k -> v -> Dict k v -> Dict k v

Insert a value at the given key.

keys : Dict k v -> List k

Get a list of the keys in the dictionary.

values : Dict k v -> List v

Get a list of the values in the dictionary.

map : (k -> a -> b) -> Dict k a -> Dict k b

Apply a function to each value in the dictionary.

update : Sorter k -> k -> (Maybe v -> Maybe v) -> Dict k v -> Dict k v

Update the value of the given key.

singleton : k -> v -> Dict k v

Create a dictionary with one entry.

fromList : Sorter k -> List ( k, v ) -> Dict k v

Convert an association list into a dictionary.