The unary minus is removed in the pattern of case expressions #49

Closed
opened 2017-08-19 19:59:49 +02:00 by dplusic · 4 comments
dplusic commented 2017-08-19 19:59:49 +02:00 (Migrated from github.com)

input:

module Main where
foo n = case n of
  1 -> True
  -1 -> False

output:

module Main where
foo n = case n of
  1 -> True
  1 -> False
input: ```haskell module Main where foo n = case n of 1 -> True -1 -> False ``` output: ```haskell module Main where foo n = case n of 1 -> True 1 -> False ```
lspitzner commented 2017-08-19 20:11:01 +02:00 (Migrated from github.com)

Thanks for reporting, I can reproduce and already see the cause - the minus is represented in the AST only as an annotation. Of course still an error on brittany's end. I'll fix this later.

Thanks for reporting, I can reproduce and already see the cause - the minus is represented in the AST only as an annotation. Of course still an error on brittany's end. I'll fix this later.
lspitzner commented 2017-08-19 23:50:26 +02:00 (Migrated from github.com)

@dplusic
The fix is not as easy as I had hoped because .. technical details. I have to contact the ghc-exactprint maintainers to put the blame on them 👿 see if there is chance to improve the interface so this is not as cumbersome to fix on brittany's end.

I discovered a workaround: Enable -XNegativeLiterals (just in the brittany config, your code can stay the same).

I could fix just this particular instance of this bug relatively quickly, but then it would reappear when the negative literals appeared in some nested position in a pattern, so that's no good.

@dplusic The fix is not as easy as I had hoped because .. technical details. I have to contact the ghc-exactprint maintainers to ~~put the blame on them~~ 👿 see if there is chance to improve the interface so this is not as cumbersome to fix on brittany's end. I discovered a workaround: Enable -XNegativeLiterals (just in the brittany config, your code can stay the same). I could fix just this particular instance of this bug relatively quickly, but then it would reappear when the negative literals appeared in some nested position in a pattern, so that's no good.
lspitzner commented 2017-08-20 00:35:52 +02:00 (Migrated from github.com)

Nevermind, the fix turned out even easier than I had initially assumed. I just had to read the ghc sourcecode to make sense of its API. Fixed on dev branch.

Nevermind, the fix turned out even easier than I had initially assumed. I just had to read the ghc sourcecode to make sense of its API. Fixed on `dev` branch.
dplusic commented 2017-08-21 05:58:15 +02:00 (Migrated from github.com)

I checked fixed on dev. Thanks!

I checked fixed on `dev`. Thanks!
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: hexagoxel/brittany#49
There is no content yet.