[Git][ghc/ghc][master] 2 commits: Improve haddocks of template-haskell Con datatype

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Sat Apr 1 22:29:06 UTC 2023



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
3da69346 by sheaf at 2023-04-01T18:28:37-04:00
Improve haddocks of template-haskell Con datatype

This adds a bit more information, in particular about the lists of
constructors in the GadtC and RecGadtC cases.

- - - - -
3b7bbb39 by sheaf at 2023-04-01T18:28:37-04:00
TH: revert changes to GadtC & RecGadtC

Commit 3f374399 included a breaking-change to the template-haskell
library when it made the GadtC and RecGadtC constructors take non-empty
lists of names. As this has the potential to break many users' packages,
we decided to revert these changes for now.

- - - - -


15 changed files:

- compiler/GHC/HsToCore/Quote.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/Splice.hs
- compiler/GHC/ThToHs.hs
- compiler/GHC/Types/Error/Codes.hs
- docs/users_guide/9.8.1-notes.rst
- libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs
- libraries/template-haskell/Language/Haskell/TH/Ppr.hs
- libraries/template-haskell/Language/Haskell/TH/Syntax.hs
- libraries/template-haskell/changelog.md
- testsuite/tests/th/T10828.hs
- testsuite/tests/th/T10828b.hs
- testsuite/tests/th/T10828b.stderr
- testsuite/tests/th/T11345.hs


Changes:

=====================================
compiler/GHC/HsToCore/Quote.hs
=====================================
@@ -95,7 +95,7 @@ import Language.Haskell.Syntax.Basic (FieldLabelString(..))
 import Data.ByteString ( unpack )
 import Control.Monad
 import Data.List (sort, sortBy)
-import Data.List.NonEmpty ( NonEmpty(..) )
+import Data.List.NonEmpty ( NonEmpty(..), toList )
 import Data.Function
 import Control.Monad.Trans.Reader
 import Control.Monad.Trans.Class
@@ -2742,19 +2742,16 @@ repGadtDataCons :: NonEmpty (LocatedN Name)
                 -> LHsType GhcRn
                 -> MetaM (Core (M TH.Con))
 repGadtDataCons cons details res_ty
-    = do ne_tycon   <- lift $ dsLookupTyCon nonEmptyTyConName
-         name_tycon <- lift $ dsLookupTyCon nameTyConName
-         let mk_nonEmpty = coreListNonEmpty ne_tycon (mkTyConTy name_tycon)
-         cons' <- mapM lookupLOcc cons -- See Note [Binders and occurrences]
+    = do cons' <- mapM lookupLOcc cons -- See Note [Binders and occurrences]
          case details of
            PrefixConGADT ps -> do
              arg_tys <- repPrefixConArgs ps
              res_ty' <- repLTy res_ty
-             rep2 gadtCName [unC (mk_nonEmpty cons'), unC arg_tys, unC res_ty']
+             rep2 gadtCName [ unC (nonEmptyCoreList' cons'), unC arg_tys, unC res_ty']
            RecConGADT ips _ -> do
              arg_vtys <- repRecConArgs ips
              res_ty'  <- repLTy res_ty
-             rep2 recGadtCName [unC (mk_nonEmpty cons'), unC arg_vtys,
+             rep2 recGadtCName [unC (nonEmptyCoreList' cons'), unC arg_vtys,
                                 unC res_ty']
 
 -- TH currently only supports linear constructors.
@@ -3060,6 +3057,9 @@ nonEmptyCoreList :: [Core a] -> Core [a]
 nonEmptyCoreList []           = panic "coreList: empty argument"
 nonEmptyCoreList xs@(MkC x:_) = MkC (mkListExpr (exprType x) (map unC xs))
 
+nonEmptyCoreList' :: NonEmpty (Core a) -> Core [a]
+nonEmptyCoreList' xs@(MkC x:|_) = MkC (mkListExpr (exprType x) (toList $ fmap unC xs))
+
 coreStringLit :: MonadThings m => FastString -> m (Core String)
 coreStringLit s = do { z <- mkStringExprFS s; return (MkC z) }
 


=====================================
compiler/GHC/Tc/Errors/Ppr.hs
=====================================
@@ -4831,6 +4831,10 @@ pprConversionFailReason = \case
     text "Implicit parameters mixed with other bindings"
   InvalidCCallImpent from ->
     text (show from) <+> text "is not a valid ccall impent"
+  RecGadtNoCons ->
+    quotes (text "RecGadtC") <+> text "must have at least one constructor name"
+  GadtNoCons ->
+    quotes (text "GadtC") <+> text "must have at least one constructor name"
   InvalidTypeInstanceHeader tys ->
     text "Invalid type instance header:"
     <+> text (show tys)


=====================================
compiler/GHC/Tc/Errors/Types.hs
=====================================
@@ -3683,6 +3683,8 @@ data ConversionFailReason
   | CasesExprWithoutAlts
   | ImplicitParamsWithOtherBinds
   | InvalidCCallImpent !String -- ^ Source
+  | RecGadtNoCons
+  | GadtNoCons
   | InvalidTypeInstanceHeader !TH.Type
   | InvalidTyFamInstLHS !TH.Type
   | InvalidImplicitParamBinding


=====================================
compiler/GHC/Tc/Gen/Splice.hs
=====================================
@@ -143,7 +143,6 @@ import Unsafe.Coerce    ( unsafeCoerce )
 import Control.Monad
 import Data.Binary
 import Data.Binary.Get
-import qualified Data.List.NonEmpty as NE ( singleton )
 import Data.Maybe
 import qualified Data.ByteString as B
 import qualified Data.ByteString.Lazy as LB
@@ -2235,7 +2234,7 @@ reifyDataCon isGadtDataCon tys dc
                                          dcdBangs r_arg_tys)
               | not (null fields) -> do
                   { res_ty <- reifyType g_res_ty
-                  ; return $ TH.RecGadtC (NE.singleton name)
+                  ; return $ TH.RecGadtC [name]
                                      (zip3 (map reifyFieldLabel fields)
                                       dcdBangs r_arg_tys) res_ty }
                 -- We need to check not isGadtDataCon here because GADT
@@ -2248,7 +2247,7 @@ reifyDataCon isGadtDataCon tys dc
                   ; return $ TH.InfixC (s1,r_a1) name (s2,r_a2) }
               | isGadtDataCon -> do
                   { res_ty <- reifyType g_res_ty
-                  ; return $ TH.GadtC (NE.singleton name)
+                  ; return $ TH.GadtC [name]
                                  (dcdBangs `zip` r_arg_tys) res_ty }
               | otherwise ->
                   return $ TH.NormalC name (dcdBangs `zip` r_arg_tys)


=====================================
compiler/GHC/ThToHs.hs
=====================================
@@ -276,7 +276,11 @@ cvtDec (DataD ctxt tc tvs ksig constrs derivs)
 cvtDec (NewtypeD ctxt tc tvs ksig constr derivs)
   = do  { (ctxt', tc', tvs') <- cvt_tycl_hdr ctxt tc tvs
         ; ksig' <- cvtKind `traverse` ksig
-        ; con' <- cvtConstr (NE.head $ get_cons_names constr) cNameN constr
+        ; let first_datacon =
+                case get_cons_names constr of
+                  []  -> panic "cvtDec: empty list of constructors"
+                  c:_ -> c
+        ; con' <- cvtConstr first_datacon cNameN constr
         ; derivs' <- cvtDerivs derivs
         ; let defn = HsDataDefn { dd_ext = noExtField
                                 , dd_cType = Nothing
@@ -348,8 +352,10 @@ cvtDec (DataFamilyD tc tvs kind)
 cvtDec (DataInstD ctxt bndrs tys ksig constrs derivs)
   = do { (ctxt', tc', bndrs', typats') <- cvt_datainst_hdr ctxt bndrs tys
        ; ksig' <- cvtKind `traverse` ksig
-
-       ; let first_datacon = NE.head $ get_cons_names $ head constrs
+       ; let first_datacon =
+                case get_cons_names $ head constrs of
+                  []  -> panic "cvtDec: empty list of constructors"
+                  c:_ -> c
        ; cons' <- mapM (cvtConstr first_datacon cNameN) constrs
        ; derivs' <- cvtDerivs derivs
        ; let defn = HsDataDefn { dd_ext = noExtField
@@ -372,7 +378,11 @@ cvtDec (DataInstD ctxt bndrs tys ksig constrs derivs)
 cvtDec (NewtypeInstD ctxt bndrs tys ksig constr derivs)
   = do { (ctxt', tc', bndrs', typats') <- cvt_datainst_hdr ctxt bndrs tys
        ; ksig' <- cvtKind `traverse` ksig
-       ; con' <- cvtConstr (NE.head $ get_cons_names $ constr) cNameN constr
+       ; let first_datacon =
+                case get_cons_names constr of
+                  []  -> panic "cvtDec: empty list of constructors"
+                  c:_ -> c
+       ; con' <- cvtConstr first_datacon cNameN constr
        ; derivs' <- cvtDerivs derivs
        ; let defn = HsDataDefn { dd_ext = noExtField
                                , dd_cType = Nothing
@@ -507,7 +517,10 @@ cvtGenDataDec type_data ctxt tc tvs ksig constrs derivs
         ; (ctxt', tc', tvs') <- cvt_tycl_hdr ctxt tc tvs
         ; ksig' <- cvtKind `traverse` ksig
 
-        ; let first_datacon = NE.head $ get_cons_names $ head constrs
+        ; let first_datacon =
+                case get_cons_names $ head constrs of
+                  []  -> panic "cvtGenDataDec: empty list of constructors"
+                  c:_ -> c
         ; cons' <- mapM (cvtConstr first_datacon con_name) constrs
 
         ; derivs' <- cvtDerivs derivs
@@ -709,18 +722,22 @@ cvtConstr parent_con do_con_name (ForallC tvs ctxt con)
       where
         all_tvs = tvs' ++ ex_tvs
 
-cvtConstr _ do_con_name (GadtC cs strtys ty)
-  = do { cs'     <- mapM do_con_name cs
-       ; args    <- mapM cvt_arg strtys
-       ; ty'     <- cvtType ty
-       ; mk_gadt_decl cs' (PrefixConGADT $ map hsLinear args) ty'}
-
-cvtConstr parent_con do_con_name (RecGadtC cs varstrtys ty)
-  = do { cs'      <- mapM do_con_name cs
-       ; ty'      <- cvtType ty
-       ; rec_flds <- mapM (cvt_id_arg parent_con) varstrtys
-       ; lrec_flds <- returnLA rec_flds
-       ; mk_gadt_decl cs' (RecConGADT lrec_flds noHsUniTok) ty' }
+cvtConstr _ do_con_name (GadtC c strtys ty) = case nonEmpty c of
+    Nothing -> failWith GadtNoCons
+    Just c -> do
+        { c'      <- mapM do_con_name c
+        ; args    <- mapM cvt_arg strtys
+        ; ty'     <- cvtType ty
+        ; mk_gadt_decl c' (PrefixConGADT $ map hsLinear args) ty'}
+
+cvtConstr parent_con do_con_name (RecGadtC c varstrtys ty) = case nonEmpty c of
+    Nothing -> failWith RecGadtNoCons
+    Just c -> do
+        { c'       <- mapM do_con_name c
+        ; ty'      <- cvtType ty
+        ; rec_flds <- mapM (cvt_id_arg parent_con) varstrtys
+        ; lrec_flds <- returnLA rec_flds
+        ; mk_gadt_decl c' (RecConGADT lrec_flds noHsUniTok) ty' }
 
 mk_gadt_decl :: NonEmpty (LocatedN RdrName) -> HsConDeclGADTDetails GhcPs -> LHsType GhcPs
              -> CvtM (LConDecl GhcPs)


=====================================
compiler/GHC/Types/Error/Codes.hs
=====================================
@@ -622,6 +622,8 @@ type family GhcDiagnosticCode c = n | n -> c where
   GhcDiagnosticCode "CasesExprWithoutAlts"                          = 91745
   GhcDiagnosticCode "ImplicitParamsWithOtherBinds"                  = 42974
   GhcDiagnosticCode "InvalidCCallImpent"                            = 60220
+  GhcDiagnosticCode "RecGadtNoCons"                                 = 18816
+  GhcDiagnosticCode "GadtNoCons"                                    = 38140
   GhcDiagnosticCode "InvalidTypeInstanceHeader"                     = 37056
   GhcDiagnosticCode "InvalidTyFamInstLHS"                           = 78486
   GhcDiagnosticCode "InvalidImplicitParamBinding"                   = 51603
@@ -705,8 +707,6 @@ type family GhcDiagnosticCode c = n | n -> c where
   GhcDiagnosticCode "TcRnNameByTemplateHaskellQuote"                = 40027
   GhcDiagnosticCode "TcRnIllegalBindingOfBuiltIn"                   = 69639
   GhcDiagnosticCode "TcRnMixedSelectors"                            = 40887
-  GhcDiagnosticCode "RecGadtNoCons"                                 = 18816
-  GhcDiagnosticCode "GadtNoCons"                                    = 38140
 
 {- *********************************************************************
 *                                                                      *


=====================================
docs/users_guide/9.8.1-notes.rst
=====================================
@@ -104,10 +104,6 @@ Runtime system
 ``template-haskell`` library
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-- The ``GadtC`` and ``RecGadtC`` constructors of the ``Con`` datatype now take
-  non-empty lists of constructors. This means that the ``gadtC`` and ``recGadtC``
-  smart constructors also expect non-empty lists as arguments.
-
 - Record fields now belong to separate ``NameSpace``s, keyed by the parent of
   the record field. This is the name of the first constructor of the parent type,
   even if this constructor does not have the field in question.


=====================================
libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs
=====================================
@@ -23,7 +23,7 @@ import qualified Language.Haskell.TH.Syntax as TH
 import Control.Applicative(liftA, Applicative(..))
 import qualified Data.Kind as Kind (Type)
 import Data.Word( Word8 )
-import Data.List.NonEmpty ( NonEmpty(..), toList )
+import Data.List.NonEmpty ( NonEmpty(..) )
 import GHC.Exts (TYPE)
 import Prelude hiding (Applicative(..))
 
@@ -680,10 +680,10 @@ forallC ns ctxt con = do
   con'  <- con
   pure $ ForallC ns' ctxt' con'
 
-gadtC :: Quote m => NonEmpty Name -> [m StrictType] -> m Type -> m Con
+gadtC :: Quote m => [Name] -> [m StrictType] -> m Type -> m Con
 gadtC cons strtys ty = liftA2 (GadtC cons) (sequenceA strtys) ty
 
-recGadtC :: Quote m => NonEmpty Name -> [m VarStrictType] -> m Type -> m Con
+recGadtC :: Quote m => [Name] -> [m VarStrictType] -> m Type -> m Con
 recGadtC cons varstrtys ty = liftA2 (RecGadtC cons) (sequenceA varstrtys) ty
 
 -------------------------------------------------------------------------------
@@ -1177,7 +1177,7 @@ docCons :: (Q Con, Maybe String, [Maybe String]) -> Q ()
 docCons (c, md, arg_docs) = do
   c' <- c
   -- Attach docs to the constructors
-  sequence_ [ putDoc (DeclDoc nm) d | Just d <- [md], nm <- toList $ get_cons_names c' ]
+  sequence_ [ putDoc (DeclDoc nm) d | Just d <- [md], nm <- get_cons_names c' ]
   -- Attach docs to the arguments
   case c' of
     -- Record selector documentation isn't stored in the argument map,
@@ -1188,6 +1188,6 @@ docCons (c, md, arg_docs) = do
                 ]
     _ ->
       sequence_ [ putDoc (ArgDoc nm i) arg_doc
-                    | nm <- toList $ get_cons_names c'
+                    | nm <- get_cons_names c'
                     , (i, Just arg_doc) <- zip [0..] arg_docs
                 ]


=====================================
libraries/template-haskell/Language/Haskell/TH/Ppr.hs
=====================================
@@ -11,7 +11,6 @@ module Language.Haskell.TH.Ppr where
 import Text.PrettyPrint (render)
 import Language.Haskell.TH.PprLib
 import Language.Haskell.TH.Syntax
-import qualified Data.List.NonEmpty as NE ( toList )
 import Data.Word ( Word8 )
 import Data.Char ( toLower, chr)
 import GHC.Show  ( showMultiLineString )
@@ -684,21 +683,21 @@ instance Ppr Con where
                          <+> pprBangType st2
 
     ppr (ForallC ns ctxt (GadtC cs sts ty))
-        = commaSepApplied (NE.toList cs) <+> dcolon <+> pprForall ns ctxt
+        = commaSepApplied cs <+> dcolon <+> pprForall ns ctxt
       <+> pprGadtRHS sts ty
 
     ppr (ForallC ns ctxt (RecGadtC cs vsts ty))
-        = commaSepApplied (NE.toList cs) <+> dcolon <+> pprForall ns ctxt
+        = commaSepApplied cs <+> dcolon <+> pprForall ns ctxt
       <+> pprRecFields vsts ty
 
     ppr (ForallC ns ctxt con)
         = pprForall ns ctxt <+> ppr con
 
     ppr (GadtC cs sts ty)
-        = commaSepApplied (NE.toList cs) <+> dcolon <+> pprGadtRHS sts ty
+        = commaSepApplied cs <+> dcolon <+> pprGadtRHS sts ty
 
     ppr (RecGadtC cs vsts ty)
-        = commaSepApplied (NE.toList cs) <+> dcolon <+> pprRecFields vsts ty
+        = commaSepApplied cs <+> dcolon <+> pprRecFields vsts ty
 
 instance Ppr PatSynDir where
   ppr Unidir        = text "<-"


=====================================
libraries/template-haskell/Language/Haskell/TH/Syntax.hs
=====================================
@@ -48,7 +48,6 @@ import System.IO        ( hPutStrLn, stderr )
 import Data.Char        ( isAlpha, isAlphaNum, isUpper, ord )
 import Data.Int
 import Data.List.NonEmpty ( NonEmpty(..) )
-import qualified Data.List.NonEmpty as NE ( singleton )
 import Data.Void        ( Void, absurd )
 import Data.Word
 import Data.Ratio
@@ -2685,7 +2684,7 @@ data DecidedStrictness = DecidedLazy -- ^ Field inferred to not have a bang.
                        | DecidedUnpack -- ^ Field inferred to be unpacked.
         deriving (Show, Eq, Ord, Data, Generic)
 
--- | A single data constructor.
+-- | A data constructor.
 --
 -- The constructors for 'Con' can roughly be divided up into two categories:
 -- those for constructors with \"vanilla\" syntax ('NormalC', 'RecC', and
@@ -2718,16 +2717,36 @@ data DecidedStrictness = DecidedLazy -- ^ Field inferred to not have a bang.
 -- Multiplicity annotations for data types are currently not supported
 -- in Template Haskell (i.e. all fields represented by Template Haskell
 -- will be linear).
-data Con = NormalC Name [BangType]       -- ^ @C Int a@
-         | RecC Name [VarBangType]       -- ^ @C { v :: Int, w :: a }@
-         | InfixC BangType Name BangType -- ^ @Int :+ a@
-         | ForallC [TyVarBndr Specificity] Cxt Con -- ^ @forall a. Eq a => C [a]@
-         | GadtC (NonEmpty Name) [BangType]
-                 Type                    -- See Note [GADT return type]
-                                         -- ^ @C :: a -> b -> T b Int@
-         | RecGadtC (NonEmpty Name) [VarBangType]
-                    Type                 -- See Note [GADT return type]
-                                         -- ^ @C :: { v :: Int } -> T b Int@
+data Con =
+  -- | @C Int a@
+    NormalC Name [BangType]
+
+  -- | @C { v :: Int, w :: a }@
+  | RecC Name [VarBangType]
+
+  -- | @Int :+ a@
+  | InfixC BangType Name BangType
+
+  -- | @forall a. Eq a => C [a]@
+  | ForallC [TyVarBndr Specificity] Cxt Con
+
+  -- @C :: a -> b -> T b Int@
+  | GadtC [Name]
+            -- ^ The list of constructors, corresponding to the GADT constructor
+            -- syntax @C1, C2 :: a -> T b at .
+            --
+            -- Invariant: the list must be non-empty.
+          [BangType] -- ^ The constructor arguments
+          Type -- ^ See Note [GADT return type]
+
+  -- | @C :: { v :: Int } -> T b Int@
+  | RecGadtC [Name]
+             -- ^ The list of constructors, corresponding to the GADT record
+             -- constructor syntax @C1, C2 :: { fld :: a } -> T b at .
+             --
+             -- Invariant: the list must be non-empty.
+             [VarBangType] -- ^ The constructor arguments
+             Type -- ^ See Note [GADT return type]
         deriving (Show, Eq, Ord, Data, Generic)
 
 -- Note [GADT return type]
@@ -2925,14 +2944,14 @@ thenCmp :: Ordering -> Ordering -> Ordering
 thenCmp EQ o2 = o2
 thenCmp o1 _  = o1
 
-get_cons_names :: Con -> NonEmpty Name
-get_cons_names (NormalC n _)     = NE.singleton n
-get_cons_names (RecC n _)        = NE.singleton n
-get_cons_names (InfixC _ n _)    = NE.singleton n
+get_cons_names :: Con -> [Name]
+get_cons_names (NormalC n _)     = [n]
+get_cons_names (RecC n _)        = [n]
+get_cons_names (InfixC _ n _)    = [n]
 get_cons_names (ForallC _ _ con) = get_cons_names con
 -- GadtC can have multiple names, e.g
 -- > data Bar a where
 -- >   MkBar1, MkBar2 :: a -> Bar a
 -- Will have one GadtC with [MkBar1, MkBar2] as names
 get_cons_names (GadtC ns _ _)    = ns
-get_cons_names (RecGadtC ns _ _) = ns
\ No newline at end of file
+get_cons_names (RecGadtC ns _ _) = ns


=====================================
libraries/template-haskell/changelog.md
=====================================
@@ -2,10 +2,6 @@
 
 ## 2.21.0.0
 
-  * The `GadtC` and `RecGadtC` constructors of the `Con` datatype now take
-    non-empty lists of constructors. This means that the `gadtC` and `recGadtC`
-    smart constructors also expect non-empty lists as arguments.
-
   * Record fields now belong to separate `NameSpace`s, keyed by the parent of
     the record field. This is the name of the first constructor of the parent type,
     even if this constructor does not have the field in question.  


=====================================
testsuite/tests/th/T10828.hs
=====================================
@@ -6,7 +6,6 @@ module T10828 where
 import Language.Haskell.TH hiding (Type)
 import System.IO
 import Data.Kind (Type)
-import qualified Data.List.NonEmpty as NE ( singleton )
 
 $( do { decl <- [d| data family D a :: Type -> Type
                     data instance D Int Bool :: Type where
@@ -34,7 +33,7 @@ $( return
    [ DataD [] (mkName "T")
            [ PlainTV (mkName "a") () ]
            (Just StarT)
-           [ GadtC (NE.singleton (mkName "MkT"))
+           [ GadtC [mkName "MkT"]
                    [ ( Bang NoSourceUnpackedness NoSourceStrictness
                      , VarT (mkName "a")
                      )
@@ -47,7 +46,7 @@ $( return
            , ForallC [PlainTV (mkName "a") SpecifiedSpec, PlainTV (mkName "b") SpecifiedSpec]
                      [AppT (AppT EqualityT (VarT $ mkName "a"  ) )
                                            (ConT $ mkName "Int") ] $
-             RecGadtC (NE.singleton (mkName "MkC"))
+             RecGadtC [mkName "MkC"]
                   [ ( mkName "foo"
                     , Bang NoSourceUnpackedness NoSourceStrictness
                     , VarT (mkName "a")


=====================================
testsuite/tests/th/T10828b.hs
=====================================
@@ -4,7 +4,6 @@ module T10828b where
 
 import Language.Haskell.TH
 import System.IO
-import qualified Data.List.NonEmpty as NE ( singleton )
 
 -- attempting to mix GADT and normal constructors
 $( return
@@ -24,7 +23,7 @@ $( return
                      [AppT (AppT EqualityT (VarT $ mkName "a"  ) )
                                            (ConT $ mkName "Int") ] $
              RecGadtC
-                 (NE.singleton (mkName "MkC"))
+                 [mkName "MkC"]
                  [ ( mkName "foo"
                    , Bang NoSourceUnpackedness NoSourceStrictness
                    , VarT (mkName "a")


=====================================
testsuite/tests/th/T10828b.stderr
=====================================
@@ -1,5 +1,5 @@
 
-T10828b.hs:10:2: error: [GHC-24104]
+T10828b.hs:9:2: error: [GHC-24104]
     Cannot mix GADT constructors with Haskell 98 constructors
     When splicing a TH declaration:
       data T a :: *


=====================================
testsuite/tests/th/T11345.hs
=====================================
@@ -5,7 +5,6 @@
 module Main (main) where
 
 import Language.Haskell.TH
-import qualified Data.List.NonEmpty as NE ( singleton )
 
 infixr 7 :***:
 data GADT a where
@@ -17,11 +16,11 @@ $(do gadtName   <- newName "GADT2"
      infixName  <- newName ":****:"
      a          <- newName "a"
      return [ DataD [] gadtName [KindedTV a () StarT] Nothing
-              [ GadtC (NE.singleton prefixName)
+              [ GadtC [prefixName]
                 [ (Bang NoSourceUnpackedness NoSourceStrictness,ConT ''Int)
                 , (Bang NoSourceUnpackedness NoSourceStrictness,ConT ''Int)
                 ] (AppT (ConT gadtName) (ConT ''Int))
-              , GadtC (NE.singleton infixName)
+              , GadtC [infixName]
                 [ (Bang NoSourceUnpackedness NoSourceStrictness,ConT ''Int)
                 , (Bang NoSourceUnpackedness NoSourceStrictness,ConT ''Int)
                 ] (AppT (ConT gadtName) (ConT ''Int))



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6e2eb275a1b6d3d1dae9c2864f001bea69d20c2a...3b7bbb39f28c926f8cfd30744253a418854bee31

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6e2eb275a1b6d3d1dae9c2864f001bea69d20c2a...3b7bbb39f28c926f8cfd30744253a418854bee31
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/20230401/69d0fd3d/attachment-0001.html>


More information about the ghc-commits mailing list