[Git][ghc/ghc][wip/soulomoon/suggest-UnliftedNewtypes-unlifted-data-family-25593] Check we defaults the result kind of the data instance correctly

Patrick (@soulomoon) gitlab at gitlab.haskell.org
Wed Jan 8 04:38:01 UTC 2025



Patrick pushed to branch wip/soulomoon/suggest-UnliftedNewtypes-unlifted-data-family-25593 at Glasgow Haskell Compiler / GHC


Commits:
9f236601 by Patrick at 2025-01-08T12:37:07+08:00
Check we defaults the result kind of the data instance correctly

- - - - -


3 changed files:

- compiler/GHC/Tc/TyCl/Instance.hs
- testsuite/tests/indexed-types/should_compile/all.T
- + testsuite/tests/indexed-types/should_compile/dataInstanceKindsDefaults.hs


Changes:

=====================================
compiler/GHC/Tc/TyCl/Instance.hs
=====================================
@@ -1015,9 +1015,10 @@ tcDataFamInstHeader mb_clsinfo skol_info fam_tc hs_outer_bndrs fixity
     -- See Note [Implementation of UnliftedNewtypes] in GHC.Tc.TyCl, families (2),
     -- and Note [Implementation of UnliftedDatatypes].
     tc_kind_sig Nothing
-      = do { unlifted_datatypes <- xoptM LangExt.UnliftedDatatypes
+      = do { unlifted_newtypes  <- xoptM LangExt.UnliftedNewtypes
+           ; unlifted_datatypes <- xoptM LangExt.UnliftedDatatypes
            ; case new_or_data of
-               NewType                       -> newOpenTypeKind
+               NewType  | unlifted_newtypes  -> newOpenTypeKind
                DataType | unlifted_datatypes -> newOpenTypeKind
                _                             -> pure liftedTypeKind
            }


=====================================
testsuite/tests/indexed-types/should_compile/all.T
=====================================
@@ -311,3 +311,4 @@ test('T22717_fam_orph', normal, multimod_compile, ['T22717_fam_orph', '-v0'])
 test('T23408', normal, compile, [''])
 test('T24134', normal, compile, [''])
 test('T25611', normal, compile, [''])
+test('dataInstanceKindsDefaults', normal, compile, [''])


=====================================
testsuite/tests/indexed-types/should_compile/dataInstanceKindsDefaults.hs
=====================================
@@ -0,0 +1,16 @@
+{-# language DataKinds, PolyKinds, GADTs, TypeFamilies, RankNTypes,
+             TypeOperators, ConstraintKinds #-}
+
+module dataInstanceKindsDefaults where
+
+import Data.Kind
+
+-- this test check if we defaults the kind of the data instance correctly
+-- error would be caught by the validity checker `checkNewDataCon` from `GHC.Tc.TyCl`
+
+data family D :: k -> k
+newtype instance D a = MkD a
+
+data family B :: k -> k
+data instance B a = MkB a
+



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9f2366010330664990206a2784689500db78739e

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9f2366010330664990206a2784689500db78739e
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/20250107/1d47b4d3/attachment-0001.html>


More information about the ghc-commits mailing list