diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2019-07-26 19:05:35 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-10-07 12:00:59 -0400 |
commit | 825c108bd26f20accf1eaef2ba652a2ee12924bb (patch) | |
tree | 3af901344da47b45fc041664c3af59188e113bb4 /ghc | |
parent | 241921a0c238a047326b0c0f599f1c24222ff66c (diff) | |
download | haskell-825c108bd26f20accf1eaef2ba652a2ee12924bb.tar.gz |
Only flatten up to type family arity in coreFlattenTyFamApp (#16995)
Among other uses, `coreFlattenTyFamApp` is used by Core Lint as a
part of its check to ensure that each type family axiom reduces
according to the way it is defined in the source code. Unfortunately,
the logic that `coreFlattenTyFamApp` uses to flatten type family
applications disagreed with the logic in `TcFlatten`, which caused
it to spuriously complain this program:
```hs
type family Param :: Type -> Type
type family LookupParam (a :: Type) :: Type where
LookupParam (f Char) = Bool
LookupParam x = Int
foo :: LookupParam (Param ())
foo = 42
```
This is because `coreFlattenTyFamApp` tries to flatten the `Param ()`
in `LookupParam (Param ())` to `alpha` (where `alpha` is a flattening
skolem), and GHC is unable to conclude that `alpha` is apart from
`f Char`. This patch spruces up `coreFlattenTyFamApp` so that it
instead flattens `Param ()` to `alpha ()`, which GHC _can_ know for
sure is apart from `f Char`. See
`Note [Flatten], wrinkle 3` in `FamInstEnv`.
Diffstat (limited to 'ghc')
0 files changed, 0 insertions, 0 deletions