Replace HsImplicitBndrs with HsOuterTyVarBndrs
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>
Showing
- compiler/GHC/Core/Coercion.hs 2 additions, 2 deletionscompiler/GHC/Core/Coercion.hs
- compiler/GHC/Hs/Decls.hs 33 additions, 53 deletionscompiler/GHC/Hs/Decls.hs
- compiler/GHC/Hs/Extension.hs 9 additions, 3 deletionscompiler/GHC/Hs/Extension.hs
- compiler/GHC/Hs/Instances.hs 9 additions, 4 deletionscompiler/GHC/Hs/Instances.hs
- compiler/GHC/Hs/Type.hs 387 additions, 162 deletionscompiler/GHC/Hs/Type.hs
- compiler/GHC/Hs/Utils.hs 12 additions, 7 deletionscompiler/GHC/Hs/Utils.hs
- compiler/GHC/HsToCore/Docs.hs 15 additions, 15 deletionscompiler/GHC/HsToCore/Docs.hs
- compiler/GHC/HsToCore/Quote.hs 116 additions, 101 deletionscompiler/GHC/HsToCore/Quote.hs
- compiler/GHC/Iface/Ext/Ast.hs 37 additions, 43 deletionscompiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Parser.y 47 additions, 35 deletionscompiler/GHC/Parser.y
- compiler/GHC/Parser/PostProcess.hs 17 additions, 19 deletionscompiler/GHC/Parser/PostProcess.hs
- compiler/GHC/Parser/PostProcess/Haddock.hs 19 additions, 11 deletionscompiler/GHC/Parser/PostProcess/Haddock.hs
- compiler/GHC/Rename/HsType.hs 78 additions, 115 deletionscompiler/GHC/Rename/HsType.hs
- compiler/GHC/Rename/Module.hs 65 additions, 83 deletionscompiler/GHC/Rename/Module.hs
- compiler/GHC/Rename/Names.hs 1 addition, 2 deletionscompiler/GHC/Rename/Names.hs
- compiler/GHC/Rename/Utils.hs 4 additions, 7 deletionscompiler/GHC/Rename/Utils.hs
- compiler/GHC/Tc/Deriv.hs 8 additions, 11 deletionscompiler/GHC/Tc/Deriv.hs
- compiler/GHC/Tc/Deriv/Generate.hs 11 additions, 12 deletionscompiler/GHC/Tc/Deriv/Generate.hs
- compiler/GHC/Tc/Errors.hs 8 additions, 3 deletionscompiler/GHC/Tc/Errors.hs
- compiler/GHC/Tc/Gen/Bind.hs 1 addition, 1 deletioncompiler/GHC/Tc/Gen/Bind.hs
Loading
Please register or sign in to comment