Refactor (~) to reduce the superclass stack
Currently (see Note [The equality types story]
in TysPrim
) we have
-- Hetereogeneous equality
class a ~# b => a ~~ b
instance a ~# b => a ~~ b
-- Homogeneous equality
class a ~~ b => (a :: k) ~ (b :: k)
instance a ~~ b => a ~ b
Note that (~#)
is a superclass of (~~)
, and (~~)
is a superclass of (~)
. This means that in the common case of using (~)
we need two superclass selections to get to the (~#)
we want.
Nothing really wrong with that, but it bloats programs, and is confusing to read when debugging. I propose to change this to
-- Homogeneous equality
class a ~# b => (a :: k) ~ (b :: k)
instance a ~# b => a ~ b
That is, implement (~)
in precisely the same way as (~~)
.
This makes (~)
a tiny bit more baked-in to the compiler, but in exchange it behaves in the same way as (~~)
, instead of behaving in a slightly different way.
There should be no observable effect for users.
Trac metadata
Trac field | Value |
---|---|
Version | 8.4.3 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |