diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2020-10-31 08:29:08 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-11-02 23:47:31 -0500 |
commit | a9e5f52c571ae3dfd4826e10a256d1a265f7e058 (patch) | |
tree | 271e7c7286019b16bf1e0441c6d63cdc911a2dc6 /compiler | |
parent | bfb1e272950169c17963adaf423890e47b908f4d (diff) | |
download | haskell-a9e5f52c571ae3dfd4826e10a256d1a265f7e058.tar.gz |
Expand type synonyms with :kind!
The User's Guide claims that `:kind!` should expand type synonyms,
but GHCi wasn't doing this in practice. Let's just update the implementation
to match the specification in the User's Guide.
Fixes #13795. Fixes #18828.
Co-authored-by: Ryan Scott <ryan.gl.scott@gmail.com>
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/GHC/Tc/Module.hs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/compiler/GHC/Tc/Module.hs b/compiler/GHC/Tc/Module.hs index 10461ad5fe..115c64f341 100644 --- a/compiler/GHC/Tc/Module.hs +++ b/compiler/GHC/Tc/Module.hs @@ -2625,12 +2625,13 @@ tcRnType hsc_env flexi normalise rdr_type -- Do validity checking on type ; checkValidType (GhciCtxt True) ty - ; ty' <- if normalise - then do { fam_envs <- tcGetFamInstEnvs - ; let (_, ty') - = normaliseType fam_envs Nominal ty - ; return ty' } - else return ty ; + -- Optionally (:k vs :k!) normalise the type. Does two things: + -- normaliseType: expand type-family applications + -- expandTypeSynonyms: expand type synonyms (#18828) + ; fam_envs <- tcGetFamInstEnvs + ; let ty' | normalise = expandTypeSynonyms $ snd $ + normaliseType fam_envs Nominal ty + | otherwise = ty ; return (ty', mkInfForAllTys kvs (tcTypeKind ty')) } |