Cindiary/elm-id/4.1.0

NOTE: the latest version is 7.1.0

ID.Dict

type alias Dict id value =
Dict () id value

A Dict for ID-value pairs

empty : Dict (ID a) value

Create a empty Dict

singleton : ID a -> value -> Dict (ID a) value

Create a dictionary with a single ID-value pair

fromList : List ( ID a, value ) -> Dict (ID a) value

Convert an list of ID-value pairs into a dictionary.

toList : Dict counter (ID a) value -> List ( ID a, value )

Convert a dictionary into an list of ID-value pairs, sorted by IDs.

isEmpty : Dict counter (ID a) value -> Bool

Determine if a dictionary is empty.

size : Dict counter (ID a) value -> Int

Determine the number of ID-value pairs in the dictionary.

member : ID a -> Dict counter (ID a) value -> Bool

Determine if a ID is in a dictionary.

get : ID a -> Dict counter (ID a) value -> Maybe value

Get the value associated with a ID. If the ID is not found, return Nothing.

getFrom : Dict counter (ID a) value -> ID a -> Maybe value

Same as get but with the arguments swapped, useful for pipelines.

ID a
-> value
-> Dict counter (ID a) value
-> Dict counter (ID a) value

Insert a ID-value pair into a dictionary. Replaces value when there is a collision.

remove : ID a -> Dict counter (ID a) value -> Dict counter (ID a) value

Remove a ID-value pair from a dictionary. If the ID is not found, no changes are made.

ID a
-> (value -> value)
-> Dict counter (ID a) value
-> Dict counter (ID a) value

Update the value of a dictionary for a specific ID with a given function. If the ID is not found, no changes are made.

map : (ID a -> b -> c) -> Dict counter (ID a) b -> Dict counter (ID a) c

Apply a function to all values in a dictionary.

(ID a -> value -> Bool)
-> Dict counter (ID a) value
-> Dict counter (ID a) value

Keep only the ID-value pairs that pass the given test.

(ID a -> b -> Maybe c)
-> Dict counter (ID a) b
-> Dict counter (ID a) c

Apply a function to all values in the dictionary and filter out the values that return Nothing.

fold : (ID a -> value -> c -> c) -> c -> Dict counter (ID a) value -> c

Fold over the ID-value pairs in a dictionary from lowest ID to highest ID.

ids : Dict counter (ID a) value -> List (ID a)

Get all of the IDs in a dictionary, sorted from lowest to highest.

values : Dict counter (ID a) value -> List value

Get all of the values in a dictionary, in the order of their IDs.

(ID a -> value -> Bool)
-> Dict counter (ID a) value
-> ( Dict (ID a) value, Dict (ID a) value )

Partition a dictionary according to some test. The first dictionary contains all ID-value pairs which passed the test, and the second contains the pairs that did not.

Dict counter1 (ID a) b
-> Dict counter2 (ID a) c
-> Dict counter1 (ID a) b

Keep a ID-value pair when its ID does not appear in the second dictionary.

Dict counter1 (ID a) b
-> Dict counter2 (ID a) c
-> Dict counter1 (ID a) b

Keep a ID-value pair when its ID appears in the second dictionary. Preference is given to values in the first dictionary.

Dict counter1 (ID a) value
-> Dict counter2 (ID a) value
-> Dict (ID a) value

Combine two dictionaries. If there is a collision, preference is given to the first dictionary.

(ID a -> b -> c -> d)
-> Dict c1 (ID a) b
-> Dict c2 (ID a) c
-> Dict (ID a) d

Apply a function to values that appear in both dictionaries and create a new dictionary with the results, values that don't appear in all dictionaries are skipped.

(ID a -> b -> c -> d -> e)
-> Dict c1 (ID a) b
-> Dict c2 (ID a) c
-> Dict c3 (ID a) d
-> Dict (ID a) e

Same as ID.Dict.map2 but for 3 dictionaries

(ID a -> b -> c -> d -> e -> f)
-> Dict c1 (ID a) b
-> Dict c2 (ID a) c
-> Dict c3 (ID a) d
-> Dict c4 (ID a) e
-> Dict (ID a) f

Same as ID.Dict.map2 but for 4 dictionaries

Json

encode : (value -> Value) -> Dict id value -> Value

Encode a Dict to a JSON value

decoder : Decoder value -> Decoder (Dict id value)

JSON Decoder for Dict