summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorVladislav Zavialov <vlad.z.4096@gmail.com>2023-01-09 21:45:15 +0300
committerMarge Bot <ben+marge-bot@smart-cactus.org>2023-01-11 00:58:03 -0500
commitbc1257750f507218059ac6bad05d9c96a8b88d67 (patch)
tree25890b5ab5dc528f0907816d1d0e1a4895011378 /compiler
parent5f17e21af6368ec0e615af7de714a3194181f46a (diff)
downloadhaskell-bc1257750f507218059ac6bad05d9c96a8b88d67.tar.gz
Introduce the TypeAbstractions language flag
GHC Proposals #448 "Modern scoped type variables" and #425 "Invisible binders in type declarations" introduce a new language extension flag: TypeAbstractions. Part of the functionality guarded by this flag has already been implemented, namely type abstractions in constructor patterns, but it was guarded by a combination of TypeApplications and ScopedTypeVariables instead of a dedicated language extension flag. This patch does the following: * introduces a new language extension flag TypeAbstractions * requires TypeAbstractions for @a-syntax in constructor patterns instead of TypeApplications and ScopedTypeVariables * creates a User's Guide page for TypeAbstractions and moves the "Type Applications in Patterns" section there To avoid a breaking change, the new flag is implied by ScopedTypeVariables and is retroactively added to GHC2021. Metric Decrease: MultiLayerModulesTH_OneShot
Diffstat (limited to 'compiler')
-rw-r--r--compiler/GHC/Driver/Session.hs5
-rw-r--r--compiler/GHC/Rename/Pat.hs8
2 files changed, 8 insertions, 5 deletions
diff --git a/compiler/GHC/Driver/Session.hs b/compiler/GHC/Driver/Session.hs
index 29dff3650f..57d89a15b1 100644
--- a/compiler/GHC/Driver/Session.hs
+++ b/compiler/GHC/Driver/Session.hs
@@ -1412,6 +1412,7 @@ languageExtensions (Just GHC2021)
LangExt.PostfixOperators,
LangExt.RankNTypes,
LangExt.ScopedTypeVariables,
+ LangExt.TypeAbstractions, -- implied by ScopedTypeVariables according to GHC Proposal #448 "Modern Scoped Type Variables"
LangExt.StandaloneDeriving,
LangExt.StandaloneKindSignatures,
LangExt.TupleSections,
@@ -3766,6 +3767,7 @@ xFlagsDeps = [
flagSpec "TraditionalRecordSyntax" LangExt.TraditionalRecordSyntax,
flagSpec "TransformListComp" LangExt.TransformListComp,
flagSpec "TupleSections" LangExt.TupleSections,
+ flagSpec "TypeAbstractions" LangExt.TypeAbstractions,
flagSpec "TypeApplications" LangExt.TypeApplications,
flagSpec "TypeData" LangExt.TypeData,
depFlagSpec' "TypeInType" LangExt.TypeInType
@@ -3902,6 +3904,9 @@ impliedXFlags
, (LangExt.MultiParamTypeClasses, turnOn, LangExt.ConstrainedClassMethods) -- c.f. #7854
, (LangExt.TypeFamilyDependencies, turnOn, LangExt.TypeFamilies)
+ -- In accordance with GHC Proposal #448 "Modern Scoped Type Variables"
+ , (LangExt.ScopedTypeVariables, turnOn, LangExt.TypeAbstractions)
+
, (LangExt.RebindableSyntax, turnOff, LangExt.ImplicitPrelude) -- NB: turn off!
, (LangExt.DerivingVia, turnOn, LangExt.DerivingStrategies)
diff --git a/compiler/GHC/Rename/Pat.hs b/compiler/GHC/Rename/Pat.hs
index 9c4f3dd9fb..169c2e508c 100644
--- a/compiler/GHC/Rename/Pat.hs
+++ b/compiler/GHC/Rename/Pat.hs
@@ -640,16 +640,14 @@ rnConPatAndThen mk con (PrefixCon tyargs pats)
where
check_lang_exts :: RnM ()
check_lang_exts = do
- scoped_tyvars <- xoptM LangExt.ScopedTypeVariables
- type_app <- xoptM LangExt.TypeApplications
- unless (scoped_tyvars && type_app) $
+ type_abs <- xoptM LangExt.TypeAbstractions
+ unless type_abs $
case listToMaybe tyargs of
Nothing -> pure ()
Just tyarg -> addErr $ mkTcRnUnknownMessage $ mkPlainError noHints $
hang (text "Illegal visible type application in a pattern:"
<+> quotes (ppr tyarg))
- 2 (text "Both ScopedTypeVariables and TypeApplications are"
- <+> text "required to use this feature")
+ 2 (text "Perhaps you intended to use TypeAbstractions")
rnConPatTyArg (HsConPatTyArg at t) = do
t' <- liftCpsWithCont $ rnHsPatSigTypeBindingVars HsTypeCtx t
return (HsConPatTyArg at t')