[Git][ghc/ghc][wip/sand-witch/modern-STV-extension-shuffling] Extension shuffling (#23291)

Andrei Borzenkov (@sand-witch) gitlab at gitlab.haskell.org
Tue Jun 6 06:48:05 UTC 2023



Andrei Borzenkov pushed to branch wip/sand-witch/modern-STV-extension-shuffling at Glasgow Haskell Compiler / GHC


Commits:
9781127d by Andrei Borzenkov at 2023-06-06T10:47:41+04:00
Extension shuffling (#23291)

Where introduced 3 new extensions:
  - PatternSignatures
  - ExtendedForAllScope
  - MethodTypeVariables

Tasks of ScopedTypeVariables extension were distributed between
PatternSignatures, ExtendedForAllScope and MethodTypeVariables according
to the proposal. Now ScopedTypeVaribles only implies these three exntesions.

- - - - -


29 changed files:

- compiler/GHC/Driver/DynFlags.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/Hs/Type.hs
- compiler/GHC/Rename/Bind.hs
- compiler/GHC/Rename/HsType.hs
- compiler/GHC/Rename/Module.hs
- compiler/GHC/Tc/Deriv.hs
- compiler/GHC/Tc/Deriv/Generate.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- docs/users_guide/9.8.1-notes.rst
- docs/users_guide/expected-undocumented-flags.txt
- docs/users_guide/exts/explicit_forall.rst
- docs/users_guide/exts/gadt.rst
- docs/users_guide/exts/scoped_type_variables.rst
- docs/users_guide/exts/type_abstractions.rst
- libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs
- testsuite/tests/driver/T4437.hs
- testsuite/tests/rename/should_fail/T11663.stderr
- testsuite/tests/showIface/DocsInHiFile1.stdout
- testsuite/tests/showIface/DocsInHiFileTH.stdout
- testsuite/tests/showIface/HaddockIssue849.stdout
- testsuite/tests/showIface/HaddockOpts.stdout
- testsuite/tests/showIface/LanguageExts.stdout
- testsuite/tests/showIface/MagicHashInHaddocks.stdout
- testsuite/tests/showIface/NoExportList.stdout
- testsuite/tests/showIface/PragmaDocs.stdout
- testsuite/tests/showIface/ReExports.stdout
- testsuite/tests/typecheck/should_fail/PatSynExistential.stderr


Changes:

=====================================
compiler/GHC/Driver/DynFlags.hs
=====================================
@@ -1417,7 +1417,13 @@ languageExtensions (Just GHC2021)
        LangExt.PostfixOperators,
        LangExt.RankNTypes,
        LangExt.ScopedTypeVariables,
-       LangExt.TypeAbstractions,     -- implied by ScopedTypeVariables according to GHC Proposal #448 "Modern Scoped Type Variables"
+
+       -- implied by ScopedTypeVariables according to GHC Proposal #448 "Modern Scoped Type Variables"
+       LangExt.TypeAbstractions,
+       LangExt.PatternSignatures,
+       LangExt.MethodTypeVariables,
+       LangExt.ExtendedForAllScope,
+
        LangExt.StandaloneDeriving,
        LangExt.StandaloneKindSignatures,
        LangExt.TupleSections,


=====================================
compiler/GHC/Driver/Session.hs
=====================================
@@ -2673,8 +2673,9 @@ xFlagsDeps = [
   flagSpec "ParallelListComp"                 LangExt.ParallelListComp,
   flagSpec "PartialTypeSignatures"            LangExt.PartialTypeSignatures,
   flagSpec "PatternGuards"                    LangExt.PatternGuards,
-  depFlagSpec' "PatternSignatures"            LangExt.ScopedTypeVariables
-    (deprecatedForExtension "ScopedTypeVariables"),
+  flagSpec "PatternSignatures"                LangExt.PatternSignatures,
+  flagSpec "MethodTypeVariables"              LangExt.MethodTypeVariables,
+  flagSpec "ExtendedForAllScope"              LangExt.ExtendedForAllScope,
   flagSpec "PatternSynonyms"                  LangExt.PatternSynonyms,
   flagSpec "PolyKinds"                        LangExt.PolyKinds,
   flagSpec "PolymorphicComponents"            LangExt.RankNTypes,
@@ -2767,6 +2768,9 @@ impliedXFlags
 
     -- In accordance with GHC Proposal #448 "Modern Scoped Type Variables"
     , (LangExt.ScopedTypeVariables,       turnOn, LangExt.TypeAbstractions)
+    , (LangExt.ScopedTypeVariables,       turnOn, LangExt.PatternSignatures)
+    , (LangExt.ScopedTypeVariables,       turnOn, LangExt.MethodTypeVariables)
+    , (LangExt.ScopedTypeVariables,       turnOn, LangExt.ExtendedForAllScope)
 
     , (LangExt.RebindableSyntax, turnOff, LangExt.ImplicitPrelude)      -- NB: turn off!
 


=====================================
compiler/GHC/Hs/Type.hs
=====================================
@@ -819,9 +819,9 @@ enabled. For example, the following will be rejected:
   instance (Eq a => Show (Maybe a)) where ...
 
 This restriction is partly motivated by an unusual quirk of instance
-declarations. Namely, if ScopedTypeVariables is enabled, then the type
-variables from the top of an instance will scope over the bodies of the
-instance methods, /even if the type variables are implicitly quantified/.
+declarations. Namely, if MethodTypeVariables (implied by ScopedTypeVariables) is enabled,
+then the type variables from the top of an instance will scope over the bodies
+of the instance methods, /even if the type variables are implicitly quantified/.
 For example, GHC will accept the following:
 
   instance Monoid a => Monoid (Identity a) where
@@ -841,20 +841,20 @@ Somewhat surprisingly, old versions of GHC would accept the instance above.
 Even though the `forall` only quantifies `a`, the outermost parentheses mean
 that the `forall` is nested, and per the forall-or-nothing rule, this means
 that implicit quantification would occur. Therefore, the `a` is explicitly
-bound and the `b` is implicitly bound. Moreover, ScopedTypeVariables would
-bring /both/ sorts of type variables into scope over the body of `m`.
+bound and the `b` is implicitly bound. Moreover, MethodTypeVariables
+would bring /both/ sorts of type variables into scope over the body of `m`.
 How utterly confusing!
 
 To avoid this sort of confusion, we simply disallow nested `forall`s in
 instance types, which makes things like the instance above become illegal.
 For the sake of consistency, we also disallow nested contexts, even though they
-don't have the same strange interaction with ScopedTypeVariables.
+don't have the same strange interaction with MethodTypeVariables.
 
 Just as we forbid nested `forall`s and contexts in normal instance
 declarations, we also forbid them in SPECIALISE instance pragmas (#18455).
-Unlike normal instance declarations, ScopedTypeVariables don't have any impact
-on SPECIALISE instance pragmas, but we use the same validity checks for
-SPECIALISE instance pragmas anyway to be consistent.
+Unlike normal instance declarations, MethodTypeVariables
+don't have any impact on SPECIALISE instance pragmas, but we use the same
+validity checks for SPECIALISE instance pragmas anyway to be consistent.
 
 -----
 -- Wrinkle: Derived instances
@@ -863,7 +863,7 @@ SPECIALISE instance pragmas anyway to be consistent.
 `deriving` clauses and standalone `deriving` declarations also permit bringing
 type variables into scope, either through explicit or implicit quantification.
 Unlike in the tops of instance declarations, however, one does not need to
-enable ScopedTypeVariables for this to take effect.
+enable MethodTypeVariables for this to take effect.
 
 Just as GHC forbids nested `forall`s in the top of instance declarations, it
 also forbids them in types involved with `deriving`:


=====================================
compiler/GHC/Rename/Bind.hs
=====================================
@@ -920,7 +920,8 @@ rnMethodBinds is_cls_decl cls ktv_names binds sigs
        -- Rename the bindings RHSs.  Again there's an issue about whether the
        -- type variables from the class/instance head are in scope.
        -- Answer no in Haskell 2010, but yes if you have -XScopedTypeVariables
-       ; (binds'', bind_fvs) <- bindSigTyVarsFV ktv_names $
+       -- or -XMethodTypeVariables
+       ; (binds'', bind_fvs) <- bindClassInstanceHeadTyVarsFV ktv_names $
               do { binds_w_dus <- mapBagM (rnLBind (mkScopedTvFn other_sigs')) binds'
                  ; let bind_fvs = foldr (\(_,_,fv1) fv2 -> fv1 `plusFV` fv2)
                                            emptyFVs binds_w_dus


=====================================
compiler/GHC/Rename/HsType.hs
=====================================
@@ -31,7 +31,8 @@ module GHC.Rename.HsType (
         -- Binding related stuff
         bindHsOuterTyVarBndrs, bindHsForAllTelescope,
         bindLHsTyVarBndr, bindLHsTyVarBndrs, WarnUnusedForalls(..),
-        rnImplicitTvOccs, bindSigTyVarsFV, bindHsQTyVars,
+        rnImplicitTvOccs, bindSigTyVarsFV, bindClassInstanceHeadTyVarsFV ,
+        bindHsQTyVars,
         FreeKiTyVars, filterInScopeM,
         extractHsTyRdrTyVars, extractHsTyRdrTyVarsKindVars,
         extractHsTysRdrTyVars, extractRdrKindSigVars,
@@ -150,14 +151,14 @@ rnHsPatSigType :: HsPatSigTypeScoping
                -> (HsPatSigType GhcRn -> RnM (a, FreeVars))
                -> RnM (a, FreeVars)
 -- Used for
---   - Pattern type signatures, which are only allowed with ScopedTypeVariables
+--   - Pattern type signatures, which are only allowed with PatternSignatures
 --   - Signatures on binders in a RULE, which are allowed even if
---     ScopedTypeVariables isn't enabled
+--     PatternSignatures isn't enabled
 -- Wildcards are allowed
 --
 -- See Note [Pattern signature binders and scoping] in GHC.Hs.Type
 rnHsPatSigType scoping ctx sig_ty thing_inside
-  = do { ty_sig_okay <- xoptM LangExt.ScopedTypeVariables
+  = do { ty_sig_okay <- xoptM LangExt.PatternSignatures
        ; checkErr ty_sig_okay (unexpectedPatSigTypeErr sig_ty)
        ; free_vars <- filterInScopeM (extractHsTyRdrTyVars pat_sig_ty)
        ; (nwc_rdrs', tv_rdrs) <- partition_nwcs free_vars
@@ -900,18 +901,25 @@ notInKinds _ _ = return ()
 *                                                      *
 ***************************************************** -}
 
-bindSigTyVarsFV :: [Name]
-                -> RnM (a, FreeVars)
-                -> RnM (a, FreeVars)
 -- Used just before renaming the defn of a function
 -- with a separate type signature, to bring its tyvars into scope
--- With no -XScopedTypeVariables, this is a no-op
+-- With no -XExtendedForAllScope/-XMethodTypeVariables, this is a no-op
+bindSigTyVarsFV, bindClassInstanceHeadTyVarsFV :: [Name]
+                                               -> RnM (a, FreeVars)
+                                               -> RnM (a, FreeVars)
+
 bindSigTyVarsFV tvs thing_inside
-  = do  { scoped_tyvars <- xoptM LangExt.ScopedTypeVariables
-        ; if not scoped_tyvars then
-                thing_inside
-          else
-                bindLocalNamesFV tvs thing_inside }
+  = do { extended_for_all_scope <- xoptM LangExt.ExtendedForAllScope
+       ; if extended_for_all_scope
+           then bindLocalNamesFV tvs thing_inside
+           else thing_inside }
+
+bindClassInstanceHeadTyVarsFV tvs thing_inside
+  = do { method_type_variables <- xoptM LangExt.MethodTypeVariables
+       ; if method_type_variables
+           then bindLocalNamesFV tvs thing_inside
+           else thing_inside }
+
 
 ---------------
 bindHsQTyVars :: forall a b.


=====================================
compiler/GHC/Rename/Module.hs
=====================================
@@ -198,7 +198,7 @@ rnSrcDecls group@(HsGroup { hs_valds   = val_decls,
 
    -- (H) Rename Everything else
 
-   (rn_rule_decls,    src_fvs2) <- setXOptM LangExt.ScopedTypeVariables $
+   (rn_rule_decls,    src_fvs2) <- setXOptM LangExt.PatternSignatures $
                                    rnList rnHsRuleDecls rule_decls ;
                            -- Inside RULES, scoped type variables are on
    (rn_foreign_decls, src_fvs3) <- rnList rnHsForeignDecl foreign_decls ;


=====================================
compiler/GHC/Tc/Deriv.hs
=====================================
@@ -273,7 +273,9 @@ renameDeriv inst_infos bagBinds
     setXOptM LangExt.EmptyCase $
     -- Derived decls (for empty types) can have
     --    case x of {}
-    setXOptM LangExt.ScopedTypeVariables $
+    setXOptM LangExt.MethodTypeVariables $
+    setXOptM LangExt.PatternSignatures $
+    setXOptM LangExt.ExtendedForAllScope $
     setXOptM LangExt.KindSignatures $
     -- Derived decls (for newtype-deriving) can use ScopedTypeVariables &
     -- KindSignatures


=====================================
compiler/GHC/Tc/Deriv/Generate.hs
=====================================
@@ -1875,9 +1875,9 @@ of the method. For example, recall:
                   join
 
 In the example above, it is imperative that the `a` in the instance signature
-for `join` scope over the body of `join` by way of ScopedTypeVariables.
-This might sound obvious, but note that in gen_Newtype_binds, which is
-responsible for generating the code above, the type in `join`'s instance
+for `join` scope over the body of `join` by way of ExtendedForallScope (implied
+by ScopedTypeVariables). This might sound obvious, but note that in gen_Newtype_binds,
+which is responsible for generating the code above, the type in `join`'s instance
 signature is given as a Core type, whereas gen_Newtype_binds will eventually
 produce HsBinds (i.e., source Haskell) that is renamed and typechecked. We
 must ensure that `a` is in scope over the body of `join` during renaming


=====================================
compiler/GHC/Tc/Errors/Ppr.hs
=====================================
@@ -1637,9 +1637,7 @@ instance Diagnostic TcRnMessage where
              nest 4 (text "in the section:" <+> quotes (ppr section))]
 
     TcRnUnexpectedPatSigType ty
-      -> mkSimpleDecorated $
-           hang (text "Illegal type signature:" <+> quotes (ppr ty))
-              2 (text "Type signatures are only allowed in patterns with ScopedTypeVariables")
+      -> mkSimpleDecorated $ text "Illegal type signature:" <+> quotes (ppr ty)
 
     TcRnIllegalKindSignature ty
       -> mkSimpleDecorated $ text "Illegal kind signature:" <+> quotes (ppr ty)
@@ -3011,7 +3009,7 @@ instance Diagnostic TcRnMessage where
     TcRnSectionPrecedenceError{}
       -> noHints
     TcRnUnexpectedPatSigType{}
-      -> [suggestExtension LangExt.ScopedTypeVariables]
+      -> [suggestExtension LangExt.PatternSignatures]
     TcRnIllegalKindSignature{}
       -> [suggestExtension LangExt.KindSignatures]
     TcRnUnusedQuantifiedTypeVar{}


=====================================
compiler/GHC/Tc/Errors/Types.hs
=====================================
@@ -2381,7 +2381,7 @@ data TcRnMessage where
     -> TcRnMessage
 
   {-| TcRnUnexpectedPatSigType is an error occurring when there is
-      a type signature in a pattern without -XScopedTypeVariables extension
+      a type signature in a pattern without -XPatternSignatures extension
 
       Examples:
         f (a :: Bool) = ...


=====================================
docs/users_guide/9.8.1-notes.rst
=====================================
@@ -10,6 +10,11 @@ Language
   sized primitive literals, e.g. ``123#Int8`` is a literal of type ``Int8#``.
   See the GHC proposal `#451 <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0451-sized-literals.rst>`_.
 
+- :extension:`ScopedTypeVariables` was split into several new extensions:
+  :extension:`PatternSignatures`, :extension:`ExtendedForAllScope`, :extension:`MethodTypeVariables`.
+  You can set :extension:`ScopedTypeVariables` to enable them all or enable them individually
+  for more fine-grained control of features that you want to have.
+
 Compiler
 ~~~~~~~~
 


=====================================
docs/users_guide/expected-undocumented-flags.txt
=====================================
@@ -14,7 +14,6 @@
 -XMonomorphismRestriction
 -XParallelArrays
 -XPatternGuards
--XPatternSignatures
 -XPolymorphicComponents
 -XRecordPuns
 -XRelaxedLayout


=====================================
docs/users_guide/exts/explicit_forall.rst
=====================================
@@ -114,7 +114,7 @@ The ``forall``-or-nothing rule takes effect in the following places:
 
 Notes:
 
-- :ref:`pattern-type-sigs` are a notable example of a place where
+- :extension:`PatternSignatures` are a notable example of a place where
   types do *not* obey the ``forall``-or-nothing rule. For example, GHC will
   accept the following: ::
 


=====================================
docs/users_guide/exts/gadt.rst
=====================================
@@ -194,7 +194,7 @@ also sets :extension:`GADTSyntax` and :extension:`MonoLocalBinds`.
 
    In the function clause for ``g``, GHC first checks ``MkF``, the outermost
    pattern, followed by the inner ``Nothing`` pattern. This outside-in order
-   can interact somewhat counterintuitively with :ref:`pattern-type-sigs`.
+   can interact somewhat counterintuitively with :extension:`PatternSignatures`.
    Consider the following variation of ``g``: ::
 
        g2 :: F a a -> a


=====================================
docs/users_guide/exts/scoped_type_variables.rst
=====================================
@@ -6,9 +6,13 @@ Lexically scoped type variables
 ===============================
 
 .. extension:: ScopedTypeVariables
-    :shortdesc: Enable lexically-scoped type variables.
+    :shortdesc: Enable lexically-scoped type variables everywhere.
 
-    :implies: :extension:`ExplicitForAll`
+    :implies: :extension:`ExplicitForAll`,
+      :extension:`PatternSignatures`,
+      :extension:`ExtendedForAllScope`,
+      :extension:`MethodTypeVariables`,
+      :extension:`TypeAbstractions`
 
     :since: 6.8.1
 
@@ -26,7 +30,7 @@ Lexically scoped type variables
     To trigger those forms of :extension:`ScopedTypeVariables`, the ``forall`` must appear against the top-level signature (or outer expression)
     but *not* against nested signatures referring to the same type variables.
 
-    Explicit ``forall`` is not always required -- see :ref:`pattern signature equivalent <pattern-equiv-form>` for the example in this section, or :ref:`pattern-type-sigs`.
+    Explicit ``forall`` is not always required -- see :ref:`pattern signature equivalent <pattern-equiv-form>` for the example in this section, or :extension:`PatternSignatures`.
 
 GHC supports *lexically scoped type variables*, without which some type
 signatures are simply impossible to write. For example: ::
@@ -48,7 +52,7 @@ possible to do so.
 
 .. _pattern-equiv-form:
 
-An equivalent form for that example, avoiding explicit ``forall`` uses :ref:`pattern-type-sigs`: ::
+An equivalent form for that example, avoiding explicit ``forall`` uses :extension:`PatternSignatures`: ::
 
     f :: [a] -> [a]
     f (xs :: [aa]) = xs ++ ys
@@ -84,9 +88,9 @@ A *lexically scoped type variable* can be bound by:
 
 -  An expression type signature (:ref:`exp-type-sigs`)
 
--  A pattern type signature (:ref:`pattern-type-sigs`)
+-  A pattern type signature (:extension:`PatternSignatures`)
 
--  Class and instance declarations (:ref:`cls-inst-scoped-tyvars`)
+-  Class and instance declarations (:extension:`MethodTypeVariables`)
 
 In Haskell, a programmer-written type signature is implicitly quantified
 over its free type variables (`Section
@@ -100,14 +104,31 @@ scope is *not* universally quantified. For example, if type variable
       (e :: b -> b)     means     (e :: forall b. b->b)
       (e :: a -> b)     means     (e :: forall b. a->b)
 
+Extended ForAll Scope
+=====================
+
+.. extension:: ExtendedForAllScope
+    :shortdesc: Enable lexically-scoped type variables in function bindings,
+                pattern synonyms and expression type signatures.
+
+    :since: 9.8.1
+
+    :implied by: :extension:`ScopedTypeVariables`
+
+    :status: Included in :extension:`GHC2021`
+
+    Enable lexical scoping of type variables explicitly introduced with
+    a ``forall`` in function bindings, pattern synonyms and expression type signatures.
+
 .. _decl-type-sigs:
 
 Declaration type signatures
 ---------------------------
 
-A declaration type signature that has *explicit* quantification (using
-``forall``) brings into scope the explicitly-quantified type variables,
-in the definition of the named function. For example: ::
+When :extension:`ExtendedForAllScope` is enabled, a declaration type signature
+that has *explicit* quantification (using ``forall``) brings into scope the
+explicitly-quantified type variables, in the definition of the named function.
+For example: ::
 
       f :: forall a. [a] -> [a]
       f (x:xs) = xs ++ [ x :: a ]
@@ -171,9 +192,9 @@ This only happens if:
 Expression type signatures
 --------------------------
 
-An expression type signature that has *explicit* quantification (using
-``forall``) brings into scope the explicitly-quantified type variables,
-in the annotated expression. For example: ::
+When :extension:`ExtendedForAllScope` is enabled, an expression type signature
+that has *explicit* quantification (using ``forall``) brings into scope the
+explicitly-quantified type variables, in the annotated expression. For example: ::
 
     f = runST ( (op >>= \(x :: STRef s Int) -> g x) :: forall s. ST s Bool )
 
@@ -181,13 +202,22 @@ Here, the type signature ``forall s. ST s Bool`` brings the type
 variable ``s`` into scope, in the annotated expression
 ``(op >>= \(x :: STRef s Int) -> g x)``.
 
-.. _pattern-type-sigs:
+Pattern Signatures
+==================
+
+.. extension:: PatternSignatures
+    :shortdesc: Allow type signatures in patterns.
 
-Pattern type signatures
------------------------
+    :since: 9.8.1
 
-A type signature may occur in any pattern; this is a *pattern type
-signature*. For example: ::
+    :implied by: :extension:`ScopedTypeVariables`
+
+    :status: Included in :extension:`GHC2021`
+
+    Allow type signatures and type variable bindings in patterns.
+
+When :extension:`PatternSignatures` is enabled, a type signature may occur
+in any pattern; this is a *pattern type signature*. For example: ::
 
     -- f and g assume that 'a' is already in scope
     f = \(x::Int, y::a) -> x
@@ -259,12 +289,21 @@ they are both legal whether or not ``a`` is already in scope.
 They differ in that *if* ``a`` is already in scope, the signature constrains
 the pattern, rather than the pattern binding the variable.
 
-.. _cls-inst-scoped-tyvars:
+Method Type Variables
+=====================
+
+.. extension:: MethodTypeVariables
+    :shortdesc: Enable lexically-scoped type variables in class and instance declarations.
+
+    :since: 9.8.1
+
+    :implied by: :extension:`ScopedTypeVariables`
+
+    :status: Included in :extension:`GHC2021`
 
-Class and instance declarations
--------------------------------
+    Enable lexical scoping of type variables explicitly introduced by class and instance heads.
 
-:extension:`ScopedTypeVariables` allow the type variables bound by the top of a
+:extension:`MethodTypeVariables` allow the type variables bound by the top of a
 ``class`` or ``instance`` declaration to scope over the methods defined in the
 ``where`` part. Unlike :ref:`decl-type-sigs`, type variables from class and
 instance declarations can be lexically scoped without an explicit ``forall``
@@ -286,11 +325,11 @@ declaration; see :ref:`explicit-foralls`). For example: ::
       instance forall b. C b => C [b] where
         op xs = reverse (head (xs :: [[b]]))
 
-While :extension:`ScopedTypeVariables` is required for type variables from the
+While :extension:`MethodTypeVariables` is required for type variables from the
 top of a class or instance declaration to scope over the /bodies/ of the
 methods, it is not required for the type variables to scope over the /type
 signatures/ of the methods. For example, the following will be accepted without
-explicitly enabling :extension:`ScopedTypeVariables`: ::
+explicitly enabling :extension:`MethodTypeVariables`: ::
 
       class D a where
         m :: [a] -> a
@@ -302,11 +341,11 @@ explicitly enabling :extension:`ScopedTypeVariables`: ::
 Note that writing ``m :: [a] -> [a]`` requires the use of the
 :extension:`InstanceSigs` extension.
 
-Similarly, :extension:`ScopedTypeVariables` is not required for type variables
+Similarly, :extension:`MethodTypeVariables` is not required for type variables
 from the top of the class or instance declaration to scope over associated type
 families, which only requires the :extension:`TypeFamilies` extension. For
 instance, the following will be accepted without explicitly enabling
-:extension:`ScopedTypeVariables`: ::
+:extension:`MethodTypeVariables`: ::
 
       class E a where
         type T a


=====================================
docs/users_guide/exts/type_abstractions.rst
=====================================
@@ -6,6 +6,8 @@ Type abstractions
 
     :since: 9.8.1
 
+    :implied by: :extension:`ScopedTypeVariables`
+
     :status: Partially implemented
 
     Allow the use of type abstraction syntax.


=====================================
libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs
=====================================
@@ -153,6 +153,9 @@ data Extension
    | OverloadedRecordUpdate
    | TypeAbstractions
    | ExtendedLiterals
+   | PatternSignatures
+   | ExtendedForAllScope
+   | MethodTypeVariables
    deriving (Eq, Enum, Show, Generic, Bounded)
 -- 'Ord' and 'Bounded' are provided for GHC API users (see discussions
 -- in https://gitlab.haskell.org/ghc/ghc/merge_requests/2707 and


=====================================
testsuite/tests/driver/T4437.hs
=====================================
@@ -38,7 +38,9 @@ check title expected got
 expectedGhcOnlyExtensions :: [String]
 expectedGhcOnlyExtensions =
     [ "TypeAbstractions",
-      "ExtendedLiterals"
+      "ExtendedLiterals",
+      "MethodTypeVariables",
+      "ExtendedForAllScope"
     ]
 
 expectedCabalOnlyExtensions :: [String]


=====================================
testsuite/tests/rename/should_fail/T11663.stderr
=====================================
@@ -1,20 +1,16 @@
 
 T11663.hs:6:12: error: [GHC-74097]
     Illegal type signature: ‘Int’
-      Type signatures are only allowed in patterns with ScopedTypeVariables
-    Suggested fix: Perhaps you intended to use ScopedTypeVariables
+    Suggested fix: Perhaps you intended to use PatternSignatures
 
 T11663.hs:7:9: error: [GHC-74097]
     Illegal type signature: ‘Int’
-      Type signatures are only allowed in patterns with ScopedTypeVariables
-    Suggested fix: Perhaps you intended to use ScopedTypeVariables
+    Suggested fix: Perhaps you intended to use PatternSignatures
 
 T11663.hs:8:22: error: [GHC-74097]
     Illegal type signature: ‘Int’
-      Type signatures are only allowed in patterns with ScopedTypeVariables
-    Suggested fix: Perhaps you intended to use ScopedTypeVariables
+    Suggested fix: Perhaps you intended to use PatternSignatures
 
 T11663.hs:9:32: error: [GHC-74097]
     Illegal type signature: ‘Int’
-      Type signatures are only allowed in patterns with ScopedTypeVariables
-    Suggested fix: Perhaps you intended to use ScopedTypeVariables
+    Suggested fix: Perhaps you intended to use PatternSignatures


=====================================
testsuite/tests/showIface/DocsInHiFile1.stdout
=====================================
@@ -144,5 +144,7 @@ docs:
          StandaloneKindSignatures
          FieldSelectors
          TypeAbstractions
+         PatternSignatures
+         ExtendedForAllScope
+         MethodTypeVariables
 extensible fields:
-


=====================================
testsuite/tests/showIface/DocsInHiFileTH.stdout
=====================================
@@ -287,5 +287,7 @@ docs:
          StandaloneKindSignatures
          FieldSelectors
          TypeAbstractions
+         PatternSignatures
+         ExtendedForAllScope
+         MethodTypeVariables
 extensible fields:
-


=====================================
testsuite/tests/showIface/HaddockIssue849.stdout
=====================================
@@ -67,5 +67,7 @@ docs:
          StandaloneKindSignatures
          FieldSelectors
          TypeAbstractions
+         PatternSignatures
+         ExtendedForAllScope
+         MethodTypeVariables
 extensible fields:
-


=====================================
testsuite/tests/showIface/HaddockOpts.stdout
=====================================
@@ -59,5 +59,7 @@ docs:
          StandaloneKindSignatures
          FieldSelectors
          TypeAbstractions
+         PatternSignatures
+         ExtendedForAllScope
+         MethodTypeVariables
 extensible fields:
-


=====================================
testsuite/tests/showIface/LanguageExts.stdout
=====================================
@@ -23,4 +23,3 @@ docs:
          CUSKs
          FieldSelectors
 extensible fields:
-


=====================================
testsuite/tests/showIface/MagicHashInHaddocks.stdout
=====================================
@@ -69,5 +69,7 @@ docs:
          StandaloneKindSignatures
          FieldSelectors
          TypeAbstractions
+         PatternSignatures
+         ExtendedForAllScope
+         MethodTypeVariables
 extensible fields:
-


=====================================
testsuite/tests/showIface/NoExportList.stdout
=====================================
@@ -95,5 +95,7 @@ docs:
          StandaloneKindSignatures
          FieldSelectors
          TypeAbstractions
+         PatternSignatures
+         ExtendedForAllScope
+         MethodTypeVariables
 extensible fields:
-


=====================================
testsuite/tests/showIface/PragmaDocs.stdout
=====================================
@@ -69,5 +69,7 @@ docs:
          StandaloneKindSignatures
          FieldSelectors
          TypeAbstractions
+         PatternSignatures
+         ExtendedForAllScope
+         MethodTypeVariables
 extensible fields:
-


=====================================
testsuite/tests/showIface/ReExports.stdout
=====================================
@@ -66,5 +66,7 @@ docs:
          StandaloneKindSignatures
          FieldSelectors
          TypeAbstractions
+         PatternSignatures
+         ExtendedForAllScope
+         MethodTypeVariables
 extensible fields:
-


=====================================
testsuite/tests/typecheck/should_fail/PatSynExistential.stderr
=====================================
@@ -1,4 +1,5 @@
-PatSynExistential.hs:6:1: [GHC-33973]
-     The result type of the signature for ‘P’, namely ‘x -> Maybe x’
+
+PatSynExistential.hs:6:1: error: [GHC-33973]
+    • The result type of the signature for ‘P’, namely ‘x -> Maybe x’
         mentions existential type variable ‘x’
-     In the declaration for pattern synonym ‘P’
+    • In the declaration for pattern synonym ‘P’



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9781127dbf7d25354237a56d7aaaa0b446c65ac9

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9781127dbf7d25354237a56d7aaaa0b446c65ac9
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230606/3262180b/attachment-0001.html>


More information about the ghc-commits mailing list