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

Consider adding "recoverWith" to the Result-module #1100

Open
ghost opened this issue Feb 26, 2021 · 1 comment
Open

Consider adding "recoverWith" to the Result-module #1100

ghost opened this issue Feb 26, 2021 · 1 comment

Comments

@ghost
Copy link

ghost commented Feb 26, 2021

I'm simply requesting you to consider adding this function to the Result-module:

recoverWith : (error - value) -> Result error value -> value
recoverWith toValue result =
    case result of
        Ok value ->
            value

        Err error ->
            toValue error
  • I've implemented this function enough times to at least want to make this suggestion.
  • withDefault is easily derived from this as recoverWith << always
  • The current Result-module doesn't support "recovering" from an error without pattern-matching directly.
  • elm-community/result-extra implements this function as Result.Extra.extract, which isn't very descriptive IMO
@github-actions
Copy link

Thanks for reporting this! To set expectations:

  • Issues are reviewed in batches, so it can take some time to get a response.
  • Ask questions a community forum. You will get an answer quicker that way!
  • If you experience something similar, open a new issue. We like duplicates.

Finally, please be patient with the core team. They are trying their best with limited resources.

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

0 participants