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

Suggestion: Remove n * 1 simplification #198

Open
jfmengels opened this issue Sep 24, 2023 · 0 comments
Open

Suggestion: Remove n * 1 simplification #198

jfmengels opened this issue Sep 24, 2023 · 0 comments
Labels
question Further information is requested

Comments

@jfmengels
Copy link
Owner

Multiplication by 1 is one of the first and common complaints about this rule.
Here's an example of where people would like to keep it

module NBSeconds exposing (oneDay, oneWeek)
nbOfSecondsInADay = 60 * 60 * 24

oneWeek = 7 * nbOfSecondsInADay

oneDay = 1 * nbOfSecondsInADay

Given the code above, Simplify will tell the user to change oneDay to oneDay = nbOfSecondsInADay, which users feels is surprising and/or less readable.

I'm therefore wondering whether we should remove this simplification. I think we could still remove code like 1 * 1 as I'm having a lot more trouble imagining a situation where that is needed.

I think keeping 1 */* 1 prevents us from doing some simplifications (like n == 1 * n -> n == n -> True), although I believe we could special-case 1 * to be ignored in these situations.

@jfmengels jfmengels added the question Further information is requested label Sep 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant