[Git][ghc/ghc][wip/soulomoon/25647-allow-newtype-instance-in-gadt-syntax] format

Patrick (@soulomoon) gitlab at gitlab.haskell.org
Wed Jan 22 16:14:53 UTC 2025



Patrick pushed to branch wip/soulomoon/25647-allow-newtype-instance-in-gadt-syntax at Glasgow Haskell Compiler / GHC


Commits:
6df0b1b3 by Patrick at 2025-01-23T00:14:45+08:00
format

- - - - -


2 changed files:

- compiler/GHC/Tc/TyCl.hs
- compiler/GHC/Tc/TyCl/Instance.hs


Changes:

=====================================
compiler/GHC/Tc/TyCl.hs
=====================================
@@ -14,7 +14,7 @@
 
 -- | Typecheck type and class declarations
 module GHC.Tc.TyCl (
-        UserHeaderKindSig(..),
+        HasHeaderKindSig(..),
         tcTyAndClassDecls,
         -- Functions used by GHC.Tc.TyCl.Instance to check
         -- data/type family instance declarations
@@ -1775,8 +1775,8 @@ kcTyClDecl (DataDecl { tcdLName    = (L _ _name)
     do { traceTc "kcTyClDecl" (ppr tycon $$ ppr (tyConTyVars tycon) $$ ppr (tyConResKind tycon))
        ; _ <- tcHsContext ctxt
        ; kcConDecls (tyConResKind tycon) (if (isJust kindSig)
-                                          then UserHeaderKindSig
-                                          else NoUserHeaderKindSig) cons
+                                          then HasHeaderKindSig
+                                          else NoHeaderKindSig) cons
        }
 
 kcTyClDecl (SynDecl { tcdLName = L _ _name, tcdRhs = rhs }) tycon
@@ -1841,16 +1841,16 @@ kcConGADTArgs exp_kind con_args = case con_args of
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Specifically for GADT style declarations.
 User supplied header kind signature as in
-`data xxx :: UserHeaderKindSig where ...`
+`data xxx :: HasHeaderKindSig where ...`
 See (KCD4) in Note [kcConDecls: kind-checking data type decls]
 for why we need to check this.
 -}
 -- see Note [Header kind signatures for GADTs]
-data UserHeaderKindSig = UserHeaderKindSig | NoUserHeaderKindSig deriving Eq
+data HasHeaderKindSig = HasHeaderKindSig | NoHeaderKindSig deriving Eq
 
 kcConDecls :: TcKind  -- Result kind of tycon
                       -- Used only in H98 case
-           -> UserHeaderKindSig
+           -> HasHeaderKindSig
            -> DataDefnCons (LConDecl GhcRn) -> TcM ()
 -- See Note [kcConDecls: kind-checking data type decls]
 kcConDecls tc_res_kind usrk cons
@@ -1863,7 +1863,7 @@ kcConDecls tc_res_kind usrk cons
 -- declared with data or newtype, and we need to know the result kind of
 -- this type. See Note [Implementation of UnliftedNewtypes] for why
 -- we need the first two arguments.
-kcConDecl :: NewOrData -> UserHeaderKindSig -> TcKind -> ConDecl GhcRn -> TcM ()
+kcConDecl :: NewOrData -> HasHeaderKindSig -> TcKind -> ConDecl GhcRn -> TcM ()
 kcConDecl new_or_data _usrk tc_res_kind
           (ConDeclH98 { con_name = name, con_ex_tvs = ex_tvs
                       , con_mb_cxt = ex_ctxt, con_args = args })
@@ -1898,7 +1898,7 @@ kcConDecl new_or_data usrk tc_res_kind
        ; traceTc "kcConDecl:GADT {" (ppr names $$ ppr res_ty $$ ppr tc_res_kind)
        -- We handle the case of newtypes without user header kind signatures specially
        -- see (KCD4) in Note [kcConDecls: kind-checking data type decls]
-       ; con_res_kind <-  if NewType == new_or_data && NoUserHeaderKindSig == usrk
+       ; con_res_kind <-  if NewType == new_or_data && NoHeaderKindSig == usrk
                           then return tc_res_kind
                           else newOpenTypeKind
        ; _ <- tcCheckLHsTypeInContext res_ty $ (TheKind con_res_kind)


=====================================
compiler/GHC/Tc/TyCl/Instance.hs
=====================================
@@ -946,10 +946,10 @@ tcDataFamInstHeader mb_clsinfo skol_info fam_tc hs_outer_bndrs fixity
                   -- Add constraints from the data constructors
                   -- Fix #25611
                   -- See DESIGN CHOICE in Note [Kind inference for data family instances]
-                  ; when is_H98_or_newtype $ kcConDecls lhs_applied_kind  (if (isJust m_ksig)
-                                          then UserHeaderKindSig
-                                          else NoUserHeaderKindSig)
-                                          hs_cons
+                  ; when is_H98_or_newtype $
+                      kcConDecls lhs_applied_kind  (if (isJust m_ksig)
+                                                   then HasHeaderKindSig
+                                                   else NoHeaderKindSig) hs_cons
 
 
                   -- Check that the result kind of the TyCon applied to its args



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6df0b1b34b6bd307db0087ce9d3852bf24980c01

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6df0b1b34b6bd307db0087ce9d3852bf24980c01
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/20250122/083e3102/attachment-0001.html>


More information about the ghc-commits mailing list