Some functions from Elm 0.17
Pick the first Maybe that actually has a value. Useful when you want to
try a couple different things, but there is no default value.
oneOf [ Nothing, Just 42, Just 71 ] == Just 42
oneOf [ Nothing, Nothing, Just 71 ] == Just 71
oneOf [ Nothing, Nothing, Nothing ] == Nothing
Chain together many computations that may fail. It is helpful to see its definition:
This means we only continue with the callback if things are going well. For example, say you need to use (
head : List Int -> Maybe Int) to get the first month from aListand then make sure it is between 1 and 12:If
headfails and results inNothing(because theListwasempty), this entire chain of operations will short-circuit and result inNothing. IftoValidMonthresults inNothing, again the chain of computations will result inNothing.