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

Remove/inline case expressions when there is only one clause #4

Open
Abhiroop opened this issue Mar 30, 2021 · 1 comment
Open

Remove/inline case expressions when there is only one clause #4

Abhiroop opened this issue Mar 30, 2021 · 1 comment
Labels
enhancement New feature or request frontend

Comments

@Abhiroop
Copy link
Collaborator

Here is an example program:

double : Int -> Int
double n = n * 2

main = double 5

This currently gets desugared to:

let v0 = \ v2 -> case v2 of {
  v1 -> v1 * 2
}
in v0 5

This can be further simplified to:

let v0 = \ v2 -> v2 * 2
in v0 5
@Rewbert
Copy link
Collaborator

Rewbert commented Mar 30, 2021

When functions are desugared pattern matches are turned into case expressions, and right now I believe it assumes there to be more than one pattern. Should be fairly simple (famous last words) to make it recognise that if there is only one pattern and that pattern is a variable, no case is needed.

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

No branches or pull requests

2 participants