Invisible binders in type declarations (#22560)
This patch implements @k-binders introduced in GHC Proposal #425 and guarded behind the TypeAbstractions extension: type D :: forall k j. k -> j -> Type data D @k @j a b = ... ^^ ^^ To represent the new syntax, we modify LHsQTyVars as follows: - hsq_explicit :: [LHsTyVarBndr () pass] + hsq_explicit :: [LHsTyVarBndr (HsBndrVis pass) pass] HsBndrVis is a new data type that records the distinction between type variable binders written with and without the @ sign: data HsBndrVis pass = HsBndrRequired | HsBndrInvisible (LHsToken "@" pass) The rest of the patch updates GHC, template-haskell, and haddock to handle the new syntax. Parser: The PsErrUnexpectedTypeAppInDecl error message is removed. The syntax it used to reject is now permitted. Renamer: The @ sign does not affect the scope of a binder, so the changes to the renamer are minimal. See rnLHsTyVarBndrVisFlag. Type checker: There are three code paths that were updated to deal with the newly introduced invisible type variable binders: 1. checking SAKS: see kcCheckDeclHeader_sig, matchUpSigWithDecl 2. checking CUSK: see kcCheckDeclHeader_cusk 3. inference: see kcInferDeclHeader, rejectInvisibleBinders Helper functions bindExplicitTKBndrs_Q_Skol and bindExplicitTKBndrs_Q_Tv are generalized to work with HsBndrVis. Updates the haddock submodule. Metric Increase: MultiLayerModulesTH_OneShot Co-authored-by:Simon Peyton Jones <simon.peytonjones@gmail.com>
Showing
- compiler/GHC/Builtin/Names/TH.hs 28 additions, 3 deletionscompiler/GHC/Builtin/Names/TH.hs
- compiler/GHC/Core/TyCon.hs 11 additions, 8 deletionscompiler/GHC/Core/TyCon.hs
- compiler/GHC/Hs/Instances.hs 5 additions, 0 deletionscompiler/GHC/Hs/Instances.hs
- compiler/GHC/Hs/Type.hs 22 additions, 2 deletionscompiler/GHC/Hs/Type.hs
- compiler/GHC/HsToCore/Quote.hs 22 additions, 10 deletionscompiler/GHC/HsToCore/Quote.hs
- compiler/GHC/Parser/Errors/Ppr.hs 0 additions, 10 deletionscompiler/GHC/Parser/Errors/Ppr.hs
- compiler/GHC/Parser/Errors/Types.hs 0 additions, 3 deletionscompiler/GHC/Parser/Errors/Types.hs
- compiler/GHC/Parser/PostProcess.hs 13 additions, 14 deletionscompiler/GHC/Parser/PostProcess.hs
- compiler/GHC/Rename/HsType.hs 22 additions, 2 deletionscompiler/GHC/Rename/HsType.hs
- compiler/GHC/Tc/Errors/Ppr.hs 36 additions, 0 deletionscompiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs 45 additions, 1 deletioncompiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/HsType.hs 102 additions, 103 deletionscompiler/GHC/Tc/Gen/HsType.hs
- compiler/GHC/Tc/Gen/Splice.hs 42 additions, 5 deletionscompiler/GHC/Tc/Gen/Splice.hs
- compiler/GHC/Tc/TyCl.hs 272 additions, 105 deletionscompiler/GHC/Tc/TyCl.hs
- compiler/GHC/Tc/Utils/TcType.hs 1 addition, 45 deletionscompiler/GHC/Tc/Utils/TcType.hs
- compiler/GHC/Tc/Zonk/TcType.hs 6 additions, 1 deletioncompiler/GHC/Tc/Zonk/TcType.hs
- compiler/GHC/ThToHs.hs 9 additions, 4 deletionscompiler/GHC/ThToHs.hs
- compiler/GHC/Types/Error/Codes.hs 6 additions, 1 deletioncompiler/GHC/Types/Error/Codes.hs
- compiler/GHC/Types/Hint.hs 8 additions, 0 deletionscompiler/GHC/Types/Hint.hs
- compiler/GHC/Types/Hint/Ppr.hs 2 additions, 0 deletionscompiler/GHC/Types/Hint/Ppr.hs
Loading
Please register or sign in to comment