[GHC] #13998: Default Signature messes up arity of type constructor
GHC
ghc-devs at haskell.org
Wed Jul 19 15:17:55 UTC 2017
#13998: Default Signature messes up arity of type constructor
-------------------------------------+-------------------------------------
Reporter: andrewthad | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Changes (by RyanGlScott):
* cc: RyanGlScott (added)
Comment:
It works on GHC 8.0.1 and earlier, but not on 8.0.2 or later. This can be
explained by the fact that the way GHC typechecks default implementations
received a drastic overhaul in 8.0.2. Unfortunately, that's been the root
of many bugs...
That being said, I have a hunch what is going on here. From inspecting the
`-ddump-tc-trace` output, one can observe that GHC gives the following
type signature for `$dmeqForallPoly`:
{{{
tcInferId
Main.$dmeqForallPoly :: forall k (f :: k -> *).
EqForallPoly f =>
forall (a :: k) (b :: k). TestEquality f => f a
-> f b -> Bool
}}}
Notice that the `k` comes //before// `f`. However, in the generated
`EqForallPoly Value` instance (which can be seen with `-ddump-deriv`):
{{{
Main.EqForallPoly [Main.Atom, Main.Value]
Main.eqForallPoly = Main.$dmeqForallPoly @(Main.Value)
}}}
It's using `TypeApplications` to instantiate `k` to `Value`. This is
wrong, however, since we really want to be instantiating //`f`// to
`Value`. That is, we'd rather generate this code:
{{{
instance EqForallPoly Value where
eqForallPoly = $dmeqForallPoly @Atom @Value
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13998#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list