elm-community / maybe-extra

Convenience functions for working with Maybe.

Home Page:http://package.elm-lang.org/packages/elm-community/maybe-extra/latest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

new function: andThenAttempt

skyqrose opened this issue · comments

Like andThen, but it can fall back to the original value if the function fails.

andThenAttempt : (a -> Maybe a) -> Maybe a -> Maybe a
andThenAttempt f a =
    a
        |> Maybe.andThen f
        |> orElse a

This would require some investigation to see if it's a common enough use case to include. If you would use this in your projects, comment with your use case.