Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new function: andThenAttempt #60

Open
skyqrose opened this issue Apr 29, 2021 · 0 comments
Open

new function: andThenAttempt #60

skyqrose opened this issue Apr 29, 2021 · 0 comments

Comments

@skyqrose
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant