diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2019-11-19 16:51:22 +0000 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2019-12-10 11:44:28 +0000 |
commit | 1b63f576940e9d77b3028c324a419ac4d30c4e63 (patch) | |
tree | 9b72b340cdc2e90d43096bc8392cea7f7190a565 | |
parent | 421a5f57eb97f5f2adb273edacebbc2034f739b2 (diff) | |
download | haskell-1b63f576940e9d77b3028c324a419ac4d30c4e63.tar.gz |
Improve Note [No derived kind equalities]
-rw-r--r-- | compiler/typecheck/TcFlatten.hs | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/compiler/typecheck/TcFlatten.hs b/compiler/typecheck/TcFlatten.hs index 5d5589df9a..b8b210d5de 100644 --- a/compiler/typecheck/TcFlatten.hs +++ b/compiler/typecheck/TcFlatten.hs @@ -732,11 +732,21 @@ yields a better error message anyway.) Note [No derived kind equalities] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -A kind-level coercion can appear in types, via mkCastTy. So, whenever -we are generating a coercion in a dependent context (in other words, -in a kind) we need to make sure that our flavour is never Derived -(as Derived constraints have no evidence). The noBogusCoercions function -changes the flavour from Derived just for this purpose. +A kind-level coercion can appear in types, via mkCastTy. For example + [D] Proxy ki ty ~ Proxy alpha beta +We flatten both sides. (Well, we'd decompose, but perhaps the RHS +wasn't yet (Proxy alpha beta).) Flattening the LHS gives + [D] Proxy flat_ki (flat_ty |> ki_co) ~ Proxy alpha beta +where ki_co :: ki ~ flat_ki. + +Now we'll *unify* beta := flat_ty |> ki_co. So ki_co must jolly well +exist, even though the original equality is Derived. + +So, whenever we are generating a coercion in a dependent context (in +other words, in a kind) we need to make sure that our flavour is never +Derived (as Derived constraints have no evidence). The +noBogusCoercions function changes the flavour from Derived just for +this purpose. -} |