Don't eta expand cons when deriving Data
This eta expansion was introduced with the initial commit for Linear types. I believe this isn't needed any longer. My guess is it is an artifact from the initial linear types implementation: data constructors are linear, but they shouldn't need to be eta expanded to be used as higher order functions. I suppose in the early days this wasn't true. For instance, this works now: data T x = T x f = \(x :: forall y. y -> T y) -> x True f T -- ok! T is linear, but can be passed where an unrestricted higher order function is expected. I recall there being some magic around to make this work for data constructors... Since this works, there's no need to eta_expand the data constructors in the derived Data instances.
Showing
- compiler/GHC/Tc/Deriv/Generate.hs 2 additions, 11 deletionscompiler/GHC/Tc/Deriv/Generate.hs
- testsuite/tests/deriving/should_compile/T14682.stderr 2 additions, 3 deletionstestsuite/tests/deriving/should_compile/T14682.stderr
- testsuite/tests/typecheck/should_fail/T15883e.stderr 18 additions, 63 deletionstestsuite/tests/typecheck/should_fail/T15883e.stderr
Loading
Please register or sign in to comment