[Git][ghc/ghc][wip/T24817a] Complete the patch

Simon Peyton Jones (@simonpj) gitlab at gitlab.haskell.org
Fri Aug 16 22:20:44 UTC 2024



Simon Peyton Jones pushed to branch wip/T24817a at Glasgow Haskell Compiler / GHC


Commits:
446045e7 by Simon Peyton Jones at 2024-08-16T23:20:16+01:00
Complete the patch

..still needs documentation

- - - - -


3 changed files:

- compiler/GHC/Builtin/Types.hs
- compiler/GHC/Tc/Utils/Monad.hs
- compiler/GHC/Tc/Zonk/Type.hs


Changes:

=====================================
compiler/GHC/Builtin/Types.hs
=====================================
@@ -184,7 +184,7 @@ import GHC.Core.ConLike
 import GHC.Core.TyCon
 import GHC.Core.Class     ( Class, mkClass )
 import GHC.Core.Map.Type  ( TypeMap, emptyTypeMap, extendTypeMap, lookupTypeMap )
-import qualified GHC.Core.TyCo.Rep as TyCoRep ( Type(TyConApp), mkNakedFunTy )
+import qualified GHC.Core.TyCo.Rep as TyCoRep ( Type(TyConApp) )
 
 import GHC.Types.TyThing
 import GHC.Types.SourceText
@@ -309,6 +309,7 @@ wiredInTyCons = map (dataConTyCon . snd) boxingDataCons
                 , soloTyCon
 
                 , anyTyCon
+                , zonkAnyTyCon
                 , boolTyCon
                 , charTyCon
                 , stringTyCon
@@ -510,17 +511,16 @@ zonkAnyTyConName =
 
 zonkAnyTyCon :: TyCon
 -- ZonkAnyTyCon :: forall k. Nat -> k
-zonkAnyTyCon = mkFamilyTyCon zonkAnyTyConName binders res_kind Nothing
+zonkAnyTyCon = mkFamilyTyCon zonkAnyTyConName
+                         [ mkNamedTyConBinder Specified kv
+                         , mkAnonTyConBinder nat_kv ]
+                         (mkTyVarTy kv)
+                         Nothing
                          (ClosedSynFamilyTyCon Nothing)
                          Nothing
                          NotInjective
   where
-    binders@[kv] = mkTemplateKindTyConBinders [liftedTypeKind]
-
-    res_kind :: Kind
-    res_kind = -- Nat -> k
-               TyCoRep.mkNakedFunTy FTF_T_T naturalTy (mkTyVarTy (binderVar kv))
-
+    [kv,nat_kv] = mkTemplateKindVars [liftedTypeKind, naturalTy]
 
 -- | Make a fake, recovery 'TyCon' from an existing one.
 -- Used when recovering from errors in type declarations


=====================================
compiler/GHC/Tc/Utils/Monad.hs
=====================================
@@ -142,7 +142,7 @@ module GHC.Tc.Utils.Monad(
   getCCIndexM, getCCIndexTcM,
 
   -- * Zonking
-  liftZonkM,
+  liftZonkM, newZonkAnyType,
 
   -- * Complete matches
   localAndImportedCompleteMatches, getCompleteMatchesTcM,
@@ -156,6 +156,7 @@ import GHC.Prelude
 
 
 import GHC.Builtin.Names
+import GHC.Builtin.Types( zonkAnyTyCon )
 
 import GHC.Tc.Errors.Types
 import GHC.Tc.Types     -- Re-export all
@@ -178,6 +179,7 @@ import GHC.Core.UsageEnv
 import GHC.Core.Multiplicity
 import GHC.Core.InstEnv
 import GHC.Core.FamInstEnv
+import GHC.Core.Type( mkNumLitTy )
 
 import GHC.Driver.Env
 import GHC.Driver.Session
@@ -1809,6 +1811,8 @@ chooseUniqueOccTc fn =
      ; return occ }
 
 newZonkAnyType :: Kind -> TcM Type
+-- Return a type (ZonkAny @k n), where n is fresh
+-- Recall  ZonkAny :: forall k. Natural -> k
 newZonkAnyType kind
   = do { env <- getGblEnv
        ; let zany_n_var = tcg_zany_n env


=====================================
compiler/GHC/Tc/Zonk/Type.hs
=====================================
@@ -54,7 +54,7 @@ import GHC.Tc.Types.TcRef
 import GHC.Tc.TyCl.Build ( TcMethInfo, MethInfo )
 import GHC.Tc.Utils.Env ( tcLookupGlobalOnly )
 import GHC.Tc.Utils.TcType
-import GHC.Tc.Utils.Monad ( setSrcSpanA, liftZonkM, traceTc, addErr )
+import GHC.Tc.Utils.Monad ( newZonkAnyType, setSrcSpanA, liftZonkM, traceTc, addErr )
 import GHC.Tc.Types.Constraint
 import GHC.Tc.Types.Evidence
 import GHC.Tc.Errors.Types



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/446045e785685c1ed46f131e62157ca05b3d0dfa

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/446045e785685c1ed46f131e62157ca05b3d0dfa
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/20240816/c5bcc01e/attachment-0001.html>


More information about the ghc-commits mailing list