We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
|> Result.toMaybe |> Maybe.map foo |> Maybe.withDefault default
⬇️
|> Result.map foo |> Result.withDefault default
Slack thread: https://elmlang.slack.com/archives/C010RT4D1PT/p1707473993252109 (The main result is that we should focus on the single Maybe.map first, and only handle sequences of multiple Maybe.maps as a nice-to-have later.)
Maybe.map
What the rule should do: Remove an unneeded conversion from Result to Maybe if all we do with the Maybe later is to map+withDefault it.
Now that I write this, there is also a simpler variant without the maps:
|> Result.toMaybe |> Maybe.withDefault default
|> Result.withDefault default
So in its full generality, the rule should handle 0+ Maybe.maps in the same way.
What problems does it solve: Needless conversion that could be skipped
Example of things the rule would report:
|> Result.toMaybe |> Maybe.map foo |> Maybe.map bar |> Maybe.withDefault default
|> Result.map foo |> Result.map bar |> Result.withDefault default
Should this be part of the Simplify rule or should it be a new rule?
Should be part of Simplify. We intentionally don't have an opinion on fusing maps together in this simplification, so it should be non-controversial.
I am looking for:
The text was updated successfully, but these errors were encountered:
No branches or pull requests
⬇️
Slack thread: https://elmlang.slack.com/archives/C010RT4D1PT/p1707473993252109
(The main result is that we should focus on the single
Maybe.map
first, and only handle sequences of multipleMaybe.map
s as a nice-to-have later.)What the rule should do:
Remove an unneeded conversion from Result to Maybe if all we do with the Maybe later is to map+withDefault it.
Now that I write this, there is also a simpler variant without the maps:
⬇️
So in its full generality, the rule should handle 0+ Maybe.maps in the same way.
What problems does it solve:
Needless conversion that could be skipped
Example of things the rule would report:
0 Maybe.maps:
⬇️
1 Maybe.map:
⬇️
(Nice to have) 2+ Maybe.maps:
⬇️
Should this be part of the Simplify rule or should it be a new rule?
Should be part of Simplify. We intentionally don't have an opinion on fusing maps together in this simplification, so it should be non-controversial.
I am looking for:
The text was updated successfully, but these errors were encountered: