andre-dietrich / elm-conditional / Conditional.Dict

A collection of conditional functions for maipulating dictionaries

Build

insertIf : Basics.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

updateIf : Basics.Bool -> comparable -> (Maybe v -> Maybe v) -> Dict comparable v -> Dict comparable v

Conditional dict update

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

Update dict, if the key is not Nothing

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

Update dict, if the value is not Nothing

removeIf : Basics.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 : Basics.Bool -> (k -> a -> a) -> Dict k a -> Dict k a

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

filterIf : Basics.Bool -> (comparable -> v -> Basics.Bool) -> Dict comparable v -> Dict comparable v

Conditional filtering.

Combine

unionIf : Basics.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 : Basics.Bool -> Dict comparable v -> Dict comparable v -> Dict comparable v

Conditional intersection.