Cindiary/elm-id/7.1.0

Id.List

type alias List id value =
List ( id, value )

A ordered list of Id-value pairs, is constructed as a List of Id-value Tuples.

empty : List id value

Create a empty List

singleton : id -> value -> List id value

Create a Id.List with a single Id-value pair

isEmpty : List id value -> Bool

Determine if a Id.List is empty.

length : List id value -> Int

Determine the number of Id-value pairs in the List.

member : id -> List id value -> Bool

Determine if a Id is in a Id.List.

get : id -> List id value -> Maybe value

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

getFrom : List id value -> id -> Maybe value

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

insert : id -> value -> List id value -> List id value

Insert a Id-value pair into a Id.List. If there is a existing pair with the same Id if will be replaced. If there isn't a existing pair the pair will be inserted at the start of the list.

insertAt : Int -> id -> value -> List id value -> List id value

Insert a Id-value pair into a given index into a Id.List. This will remove any existing value with the same Id. Indexes lower than 0 will be inserted at index 0. Indexes higher than the length of the list will inserted at the end of the list.

move : id -> Int -> List id value -> List id value

Move a existing value to a new index. Does nothing if the item is not present.

remove : id -> List id value -> List id value

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

update : id -> (value -> value) -> List id value -> List id value

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

accountForIds : List (Id a) value -> Counter (Id a) -> Counter (Id a)

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

map : (id -> b -> c) -> List id b -> List id c

Apply a function to all values in a Id.List.

removeDuplicateIds : List ( id, value ) -> List id value

Removes pairs that have a duplicate Id. Retains the last pair.

filter : (id -> value -> Bool) -> List id value -> List id value

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

filterMap : (id -> b -> Maybe c) -> List id b -> List id c

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

foldl : (id -> value -> c -> c) -> c -> List id value -> c

Reduce the list from the left.

foldr : (id -> value -> c -> c) -> c -> List id value -> c

Reduce the list from the left.

ids : List id value -> List id

Get all of the Ids in the List.

values : List id value -> List value

Get all of the values in the List.

(id -> value -> Bool)
-> List id value
-> ( List id value, List id value )

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

diff : List id b -> List id c -> List id b

Keep a Id-value pair when its Id does not appear in the second List.

intersect : List id b -> List id c -> List id b

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

append : List id value -> List id value -> List id value

Combine two Lists. If there is a collision, preference is given to the first List.

unzip : List id ( a, b ) -> ( List id a, List id b )

Decompose a list of tuples into a tuple of lists.

map2 : (id -> a -> b -> c) -> List id a -> List id b -> List id c

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

map3 : (id -> a -> b -> c -> d) -> List id a -> List id b -> List id c -> List id d

Same as Id.List.map2 but for 3 Lists

(id -> a -> b -> c -> d -> e)
-> List id a
-> List id b
-> List id c
-> List id d
-> List id e

Same as Id.List.map2 but for 4 Lists

Json

encode : (value -> Value) -> List (Id id) value -> Value

Encode a List to a JSON value

decoder : Decoder value -> Decoder (List (Id id) value)

JSON Decoder for List

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

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