[Git][ghc/ghc][wip/T25647] Enhance documentation on FamArgFlavour handling in type families and clarify...
Patrick (@soulomoon)
gitlab at gitlab.haskell.org
Wed Mar 5 12:40:31 UTC 2025
Patrick pushed to branch wip/T25647 at Glasgow Haskell Compiler / GHC
Commits:
6ab0b7c9 by Patrick at 2025-03-05T20:40:21+08:00
Enhance documentation on FamArgFlavour handling in type families and clarify implementation details in TyCon and HsType modules
- - - - -
2 changed files:
- compiler/GHC/Core/TyCon.hs
- compiler/GHC/Tc/Gen/HsType.hs
Changes:
=====================================
compiler/GHC/Core/TyCon.hs
=====================================
@@ -3053,6 +3053,12 @@ For instance, for an instance declaration like
the first two underscores (free arguments) would yield TyVarTv’s while the last two underscores (a class
argument and a signature argument) would produce TauTv's.
+<Implemenation Detail>
+The ClassArg and FreeArg are generated in `mkFamilyTyCon` and store at `famTcParent` field at `FamilyTyCon`.
+When typechecking type families, the `FamArgFlavour's passed in `tcAnonWildCardOcc` when dancing around
+inside `tcInferTyApps` and `SigArg` is passed down at `HsKindSig` branch of `tcHsType` in the dance.
+
+
<More on SigArg>
Example from T14366
=====================================
compiler/GHC/Tc/Gen/HsType.hs
=====================================
@@ -1286,6 +1286,7 @@ tcHsType mode rn_ty@(HsOpTy{}) exp_kind = tc_app_ty mode rn_ty exp_kind
tcHsType mode rn_ty@(HsKindSig _ ty sig) exp_kind
= do { let mode' = (updateFamArgFlavour SigArg $ mode { mode_tyki = KindLevel})
+ -- see Note [FamArgFlavour]
; traceTc "tcHsType:sig0" (ppr ty <+> ppr (mode_holes mode'))
; sig' <- tc_lhs_kind_sig mode' KindSigCtxt sig
-- We must typecheck the kind signature, and solve all
@@ -1578,7 +1579,7 @@ tcInferTyApps, tcInferTyApps_nosat
-> LHsType GhcRn -- ^ Function (for printing only)
-> TcType -- ^ Function
-> [LHsTypeArg GhcRn] -- ^ Args
- -> [FamArgFlavour] -- ^ Args
+ -> [FamArgFlavour] -- ^ Args flavours see Note [FamArgFlavour] and
-> TcM (TcType, TcKind) -- ^ (f args, result kind)
tcInferTyApps mode hs_ty fun hs_args famArgFlvs
= do { (f_args, res_k) <- tcInferTyApps_nosat mode hs_ty fun hs_args famArgFlvs
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6ab0b7c9a0edd1931a456166320b73b72a037b1b
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6ab0b7c9a0edd1931a456166320b73b72a037b1b
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/20250305/7e6c1a1f/attachment-0001.html>
More information about the ghc-commits
mailing list