Skip to content

Add support for LambdaCase #33

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

Merged
merged 7 commits into from
Mar 19, 2014
Merged

Conversation

daoo
Copy link
Contributor

@daoo daoo commented Sep 8, 2013

Implemented support for the LambdaCase extension by adding a new expression constructor (LCase).

I have tested this with hlint, and it worked (!).

I'm eagerly waiting for comments/input on how to improve this patch.

Daniel Oom added 2 commits September 8, 2013 23:22
Fixes exact printing and the broken test.
@niklasbroberg
Copy link
Member

Two comments, one easier to fix than the other.

First, there's a discrepancy in the parser vs the exact-printer. You treat the '' 'case' as two different lexemes (like GHC does), but the exact-printer treats them as a single "printeme". That means that the last of your commits should be un-done, and the exact-printer updated accordingly.

Test code:

foo = \    case { _ -> True }

Second, and much harder to fix, GHC allows LambdaCase to play with NonDecreasingIndentation. Implementing this requires that the lexer distinguishes between the case in a normal case and the case in a lambda case, which in turn requires that the lexer can inspect the previous token in the stream. That in turn requires rewriting the internals of the parser monad.

I would be happy to merge the patch even without support for this though, but we shouldn't forget that the problem isn't fixed.

@daoo
Copy link
Contributor Author

daoo commented Jan 8, 2014

I tried to come up with a relevant test case for your second point but was unsuccessful. I didn't get anything to work in GHC, maybe I've not understood the extension properly. Maybe it should be noted as a bug report as well, I could make one.

@ndmitchell
Copy link
Contributor

Note that users in HLint are asking for this feature, so it would be useful.

@bergmark
Copy link
Member

+1, this is important for stylish-haskell, verified that building it against this works.

@UnkindPartition
Copy link
Member

Merging based on @niklasbroberg initial feedback and popular demand.

@niklasbroberg regarding your second point — please open a separate issue with a test case.

@daoo — thanks for your work and patience :)

UnkindPartition added a commit that referenced this pull request Mar 19, 2014
Add support for LambdaCase
@UnkindPartition UnkindPartition merged commit ce195e5 into haskell-suite:master Mar 19, 2014
@robstewart57
Copy link

Is there a timescale for uploading a fresh release to hackage that'll incorporate this merged commit? An increasing number of users (e.g. hlint users) may stumble into this problem as use of LambdaCase become more frequent. I don't think the 1.14.0.1 version on hackage reflects this commit.

@UnkindPartition
Copy link
Member

Initially I was going to wait for #54 / #90 to get reviewed/merged in, but I don't have much free time now (and neither does @niklasbroberg), so maybe I should release what we have by now.

Hopefully will do it this weekend, then.

@mgsloan
Copy link
Contributor

mgsloan commented Apr 12, 2014

@feuerbach That's fine with me - feel free to ping me to rebase the changes in #90 atop whatever gets released.

@nh2
Copy link
Contributor

nh2 commented May 3, 2014

Version 1.15.0.1 on Hackage contains the LCase constructor, but the README still claims to not support it.

Was it forgotten to update that?

@UnkindPartition
Copy link
Member

Updated the readme.

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

Successfully merging this pull request may close these issues.

8 participants