ucsd-progsys / liquidhaskell

Liquid Types For Haskell
BSD 3-Clause "New" or "Revised" License
1.19k stars 138 forks source link

[GADTs] Small example of a forgotten refinement #2090

Open plredmond opened 1 year ago

plredmond commented 1 year ago

This GADT has a phantom type that gets refined (GHC-sense) by its constructor(s). That phantom type has a refinement (LH-sense) in the GADT-signature of its constructor. When we pattern match on the GADT constructor, GHC learns its type, but LH doesn't learn the refinement-type.

{-@
data Foo result where A :: Foo {i:Int | i == 0 } @-}
data Foo result where A :: Foo Int

foo :: Foo result -> result
foo A = 123

http://goto.ucsd.edu:8090/index.html#?demo=permalink%2F1667027035_14060.hs

facundominguez commented 5 months ago

Another fix here could be to have LH reject the spec of the data constructor A.

plredmond commented 4 months ago

Yeah, if refining phantom types on gadt constructors isn't supported, then LH reject it early in the pipeline.