Cindiary/elm-id/7.1.0

Id.Dict

type alias Dict id value =
Dict_ () id value

A Dict for Id-value pairs

type alias Dict_ counter id value =
Dict counter id value

A type that can represent Id.Dict and Id.CounterDict

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.

accountForIds : Dict_ counter (Id a) value -> Counter (Id a) -> Counter (Id a)

Same as Id.Counter.accountForIds but can be used with a Dict

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_ counter (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_ c1 (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_ c1 (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_ c1 (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

leakyDecoder : Decoder value -> Decoder (Dict (Id id) value)

A 'leaky' JSON Decoder for Dict. If any items in the dictionary cannot be decoded they will be skipped instead of failing the entire decoder.