danielnarey/elm-toolkit/6.1.0

NOTE: this package is not compatible with Elm 0.19.1

Toolkit.Maybe

Helpers for error handling

zip : ( Maybe a, Maybe b ) -> Maybe ( a, b )

Given a 2-tuple of Maybe values, if both values are defined, return Just the 2-tuple of values; otherwise, return Nothing

Toolkit.Maybe.zip (Just 1, Just 2)    --> Just (1,2)
Toolkit.Maybe.zip (Just 1, Nothing)    --> Nothing
zip3 : ( Maybe a, Maybe b, Maybe c ) -> Maybe ( a, b, c )

Given a 3-tuple of Maybe values, if all three values are defined, return Just the 3-tuple of values; otherwise, return Nothing

zip4 : ( Maybe a, Maybe b, Maybe c, Maybe d ) -> Maybe ( a, b, c, d )

Given a 4-tuple of Maybe values, if all four values are defined, return Just the 4-tuple of values; otherwise, return Nothing

zipList : List (Maybe a) -> Maybe (List a)

Given a list of Maybe values, if all values are defined, return Just the list of values; otherwise, return Nothing. When passed an empty list, returns Just an empty list.

Toolkit.Maybe.zipList [Just 1, Just 2]    --> Just [1,2]
Toolkit.Maybe.zipList [Just 1, Nothing]   --> Nothing
Toolkit.Maybe.zipList []                  --> Just []
filter : List (Maybe a) -> List a

Given a list of Maybe values, return a list containing only the defined values.

Toolkit.Maybe.filter [ Just 1, Just 2, Nothing ]   --> [1, 2]