krisajenkins/elm-exts/26.3.0

NOTE: this package is not compatible with Elm 0.19.1

Exts.Maybe

Extensions to the core Maybe library.

isJust : Maybe a -> Bool

Boolean checks.

isNothing : Maybe a -> Bool
maybe : b -> (a -> b) -> Maybe a -> b

Apply a function to a value, returning the default if the value is Nothing.

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

Join two Maybes together as though they were one.

catMaybes : List (Maybe a) -> List a

Extract all the Just values from a List of Maybes.

join : (a -> b -> c) -> Maybe a -> Maybe b -> Maybe c

Join together two Maybe values using the supplied function. If either value is Nothing, the result is Nothing.

maybeDefault : a -> Maybe a -> Maybe a

If x is a Just _ value, return it, otherwise return Just default.

matches : (a -> Bool) -> Maybe a -> Maybe a

Check the if value in the Maybe matches a predicate. If it does, pass it through, if not, return nothing.

matches isEven (Just 2) => Just 2
matches isEven (Just 3) => Nothing
matches isEven Nothing => Nothing
validate : (a -> Bool) -> a -> Maybe a

Validate a value against a predicate, returning a Maybe.

validate isEven 2 => Just 2
validate isEven 3 => Nothing
when : Bool -> a -> Maybe a

When test returns true, return Just value, otherwise return Nothing.

oneOf : List (Maybe a) -> Maybe a

Return the first non-Nothing entry in the list.