rikvdkleij / intellij-haskell

IntelliJ plugin for Haskell
https://rikvdkleij.github.io/intellij-haskell/
Apache License 2.0
1.32k stars 94 forks source link

Case splitting doesn't work with records that have named fields #609

Open L7R7 opened 4 years ago

L7R7 commented 4 years ago

Case splitting works for newtypes and plain records, but using it with named fields produces the following:

image

rikvdkleij commented 4 years ago

Thanks for reporting!

Got it working for this case, also fixed the parser error on deriving.

The reason why case splitting not works for placeholders for more than one character is the GHCi does not give type info in that case... So it's okay to not show the case split intention in that case.

L7R7 commented 4 years ago

Can confirm this case works now :+1:

However, I found another case which leads to a non-compiling result:

newtype Base = Base String
newtype PhantomInt a = PhantomInt Int

data BarType = BarType Base (PhantomInt String)

fun :: BarType -> String
fun d = ""

case splits to

fun :: BarType -> String
fun (BarType n (m i)) = ""

I guess the problem is the PhantomInt newtype. This is probably an edge case, but it's interesting nonetheless. If this type is a parameter of a function the case splitting is not possible. for example:

fun2 :: PhantomInt String -> String
fun2 p = ""
rikvdkleij commented 4 years ago

Thanks. Will try to fix the case with the phantom type.

rikvdkleij commented 4 years ago

@L7R7 The BarType case should be fixed in beta81. https://github.com/rikvdkleij/intellij-haskell/releases/tag/v1.0.0-beta81

The fun2 case is not yet fixed.

rikvdkleij commented 4 years ago

Btw, found also an issue with not up-to-date PSI-tree after case-splitting which in beta81 should be solved.