andre-dietrich/elm-conditional/1.0.0

Conditional.Dict

A collection of conditional functions for maipulating dictionaries

Build

insertIf : Bool -> comparable -> v -> Dict comparable v -> Dict comparable v

Conditional dict insertion

insertWhen : Maybe comparable -> v -> Dict comparable v -> Dict comparable v

Insert into dict, if the key is not Nothing

insertWhenValue : comparable -> Maybe v -> Dict comparable v -> Dict comparable v

Insert into dict, if the value is not Nothing

Bool
-> comparable
-> (Maybe v -> Maybe v)
-> Dict comparable v
-> Dict comparable v

Conditional dict update

Maybe comparable
-> (Maybe v -> Maybe v)
-> Dict comparable v
-> Dict comparable v

Update dict, if the key is not Nothing

comparable
-> Maybe (Maybe v -> Maybe v)
-> Dict comparable v
-> Dict comparable v

Update dict, if the value is not Nothing

removeIf : Bool -> comparable -> Dict comparable v -> Dict comparable v

Conditional dict removal

removeWhen : Maybe comparable -> Dict comparable v -> Dict comparable v

Remove an entry from a dict, if the key is not Nothing

Transform

mapIf : Bool -> (k -> a -> a) -> Dict k a -> Dict k a

Apply the mapping function only if the first parameter evalutes to True.

Bool
-> (comparable -> v -> Bool)
-> Dict comparable v
-> Dict comparable v

Conditional filtering.

Combine

unionIf : Bool -> Dict comparable v -> Dict comparable v -> Dict comparable v

If the first parameter evalutes to True, then both Dicts are unified, otherwise the second Dict defines the result

intersectIf : Bool -> Dict comparable v -> Dict comparable v -> Dict comparable v

Conditional intersection.