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

if inside case #229

Open
miniBill opened this issue Oct 2, 2023 · 1 comment
Open

if inside case #229

miniBill opened this issue Oct 2, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@miniBill
Copy link
Contributor

miniBill commented Oct 2, 2023

What the rule should do:
Infer the value from a simple case statement to use it to simplify if expressions

What problems does it solve:
It helps during refactorings, especially when switching from if to case, and copying the old content inside branches

Example of things the rule would report:

case category of
    "Rock" ->
        if category == "Rock" then a else b
-->
case category of
    "Rock" ->
        a

Should this be part of the Simplify rule or should it be a new rule?
Part of simplify. It ties into the inference code.

I am looking for:

  • Feedback
  • Someone to implement it with/for me
@jfmengels jfmengels added the enhancement New feature or request label Oct 2, 2023
@jfmengels
Copy link
Owner

We should also handle the opposite, when the case expression is inside the if:

if category == "Rock" then
  case category of
    "Rock" ->
		1
    _ ->
        2
else
   3
-->
if category == "Rock" then
  1
else
  3

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

No branches or pull requests

2 participants