summaryrefslogtreecommitdiff
path: root/compiler/GHC/Tc/Module.hs
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2020-07-05 16:15:01 -0400
committerRyan Scott <ryan.gl.scott@gmail.com>2020-10-30 19:38:31 -0400
commite9b2578fa17989f13ec6ba8fae0c35b2dac4d900 (patch)
tree2032245a504f20b62c0980cd84208673f45c2ac4 /compiler/GHC/Tc/Module.hs
parent31fcb55f4ff8c06c5ab100a6817cae8b571295a9 (diff)
downloadhaskell-wip/T16762.tar.gz
Replace HsImplicitBndrs with HsOuterTyVarBndrswip/T16762
This refactors the GHC AST to remove `HsImplicitBndrs` and replace it with `HsOuterTyVarBndrs`, a type which records whether the outermost quantification in a type is explicit (i.e., with an outermost, invisible `forall`) or implicit. As a result of this refactoring, it is now evident in the AST where the `forall`-or-nothing rule applies: it's all the places that use `HsOuterTyVarBndrs`. See the revamped `Note [forall-or-nothing rule]` in `GHC.Hs.Type` (previously in `GHC.Rename.HsType`). Moreover, the places where `ScopedTypeVariables` brings lexically scoped type variables into scope are a subset of the places that adhere to the `forall`-or-nothing rule, so this also makes places that interact with `ScopedTypeVariables` easier to find. See the revamped `Note [Lexically scoped type variables]` in `GHC.Hs.Type` (previously in `GHC.Tc.Gen.Sig`). `HsOuterTyVarBndrs` are used in type signatures (see `HsOuterSigTyVarBndrs`) and type family equations (see `HsOuterFamEqnTyVarBndrs`). The main difference between the former and the latter is that the former cares about specificity but the latter does not. There are a number of knock-on consequences: * There is now a dedicated `HsSigType` type, which is the combination of `HsOuterSigTyVarBndrs` and `HsType`. `LHsSigType` is now an alias for an `XRec` of `HsSigType`. * Working out the details led us to a substantial refactoring of the handling of explicit (user-written) and implicit type-variable bindings in `GHC.Tc.Gen.HsType`. Instead of a confusing family of higher order functions, we now have a local data type, `SkolemInfo`, that controls how these binders are kind-checked. It remains very fiddly, not fully satisfying. But it's better than it was. Fixes #16762. Bumps the Haddock submodule. Co-authored-by: Simon Peyton Jones <simonpj@microsoft.com> Co-authored-by: Richard Eisenberg <rae@richarde.dev> Co-authored-by: Zubin Duggal <zubin@cmi.ac.in>
Diffstat (limited to 'compiler/GHC/Tc/Module.hs')
-rw-r--r--compiler/GHC/Tc/Module.hs14
1 files changed, 7 insertions, 7 deletions
diff --git a/compiler/GHC/Tc/Module.hs b/compiler/GHC/Tc/Module.hs
index 94582b00a9..4ca90ff86a 100644
--- a/compiler/GHC/Tc/Module.hs
+++ b/compiler/GHC/Tc/Module.hs
@@ -2474,14 +2474,14 @@ getGhciStepIO = do
let ghciM = nlHsAppTy (nlHsTyVar ghciTy) (nlHsTyVar a_tv)
ioM = nlHsAppTy (nlHsTyVar ioTyConName) (nlHsTyVar a_tv)
- step_ty = noLoc $ HsForAllTy
- { hst_tele = mkHsForAllInvisTele
- [noLoc $ UserTyVar noExtField SpecifiedSpec (noLoc a_tv)]
- , hst_xforall = noExtField
- , hst_body = nlHsFunTy ghciM ioM }
+ step_ty :: LHsSigType GhcRn
+ step_ty = noLoc $ HsSig
+ { sig_bndrs = HsOuterImplicit{hso_ximplicit = [a_tv]}
+ , sig_ext = noExtField
+ , sig_body = nlHsFunTy ghciM ioM }
stepTy :: LHsSigWcType GhcRn
- stepTy = mkEmptyWildCardBndrs (mkEmptyImplicitBndrs step_ty)
+ stepTy = mkEmptyWildCardBndrs step_ty
return (noLoc $ ExprWithTySig noExtField (nlHsVar ghciStepIoMName) stepTy)
@@ -2614,7 +2614,7 @@ tcRnType hsc_env flexi normalise rdr_type
; traceTc "tcRnType" (vcat [ppr wcs, ppr rn_type])
; (_tclvl, wanted, (ty, kind))
<- pushLevelAndSolveEqualitiesX "tcRnType" $
- tcNamedWildCardBinders wcs $ \ wcs' ->
+ bindNamedWildCardBinders wcs $ \ wcs' ->
do { mapM_ emitNamedTypeHole wcs'
; tcInferLHsTypeUnsaturated rn_type }