summaryrefslogtreecommitdiff
path: root/compiler/GHC/Core
diff options
context:
space:
mode:
authorZubin Duggal <zubin@cmi.ac.in>2022-03-12 00:07:56 +0000
committerMatthew Pickering <matthewtpickering@gmail.com>2022-03-22 22:16:48 +0000
commit26819793f836f29f7c04ac0ac9c43d363eb5beb8 (patch)
tree406809b6a923bb84d1370874500017e69c6681d9 /compiler/GHC/Core
parentd45bb70178e044bc8b6e8215da7bc8ed0c95f2cb (diff)
downloadhaskell-wip/hi-haddock2021.tar.gz
hi haddock: Lex and store haddock docs in interface fileswip/hi-haddock2021
Names appearing in Haddock docstrings are lexed and renamed like any other names appearing in the AST. We currently rename names irrespective of the namespace, so both type and constructor names corresponding to an identifier will appear in the docstring. Haddock will select a given name as the link destination based on its own heuristics. This patch also restricts the limitation of `-haddock` being incompatible with `Opt_KeepRawTokenStream`. The export and documenation structure is now computed in GHC and serialised in .hi files. This can be used by haddock to directly generate doc pages without reparsing or renaming the source. At the moment the operation of haddock is not modified, that's left to a future patch. Updates the haddock submodule with the minimum changes needed.
Diffstat (limited to 'compiler/GHC/Core')
-rw-r--r--compiler/GHC/Core/FamInstEnv.hs10
-rw-r--r--compiler/GHC/Core/InstEnv.hs10
2 files changed, 14 insertions, 6 deletions
diff --git a/compiler/GHC/Core/FamInstEnv.hs b/compiler/GHC/Core/FamInstEnv.hs
index 78ed3a104c..bfbd2000cb 100644
--- a/compiler/GHC/Core/FamInstEnv.hs
+++ b/compiler/GHC/Core/FamInstEnv.hs
@@ -16,7 +16,7 @@ module GHC.Core.FamInstEnv (
FamInstEnvs, FamInstEnv, emptyFamInstEnv, emptyFamInstEnvs,
unionFamInstEnv, extendFamInstEnv, extendFamInstEnvList,
- famInstEnvElts, famInstEnvSize, familyInstances,
+ famInstEnvElts, famInstEnvSize, familyInstances, familyNameInstances,
-- * CoAxioms
mkCoAxBranch, mkBranchedCoAxiom, mkUnbranchedCoAxiom, mkSingleCoAxiom,
@@ -397,11 +397,15 @@ famInstEnvElts (FamIE _ rm) = elemsRM rm
-- size.
familyInstances :: (FamInstEnv, FamInstEnv) -> TyCon -> [FamInst]
-familyInstances (pkg_fie, home_fie) fam
+familyInstances envs tc
+ = familyNameInstances envs (tyConName tc)
+
+familyNameInstances :: (FamInstEnv, FamInstEnv) -> Name -> [FamInst]
+familyNameInstances (pkg_fie, home_fie) fam
= get home_fie ++ get pkg_fie
where
get :: FamInstEnv -> [FamInst]
- get (FamIE _ env) = lookupRM [RML_KnownTc (tyConName fam)] env
+ get (FamIE _ env) = lookupRM [RML_KnownTc fam] env
-- | Makes no particular effort to detect conflicts.
diff --git a/compiler/GHC/Core/InstEnv.hs b/compiler/GHC/Core/InstEnv.hs
index e223a7cd87..63dde6f6b5 100644
--- a/compiler/GHC/Core/InstEnv.hs
+++ b/compiler/GHC/Core/InstEnv.hs
@@ -27,6 +27,7 @@ module GHC.Core.InstEnv (
memberInstEnv,
instIsVisible,
classInstances, instanceBindFun,
+ classNameInstances,
instanceCantMatch, roughMatchTcs,
isOverlappable, isOverlapping, isIncoherent
) where
@@ -435,8 +436,8 @@ instEnvElts :: InstEnv -> [ClsInst]
instEnvElts (InstEnv rm) = elemsRM rm
-- See Note [InstEnv determinism]
-instEnvEltsForClass :: InstEnv -> Class -> [ClsInst]
-instEnvEltsForClass (InstEnv rm) cls = lookupRM [RML_KnownTc (className cls)] rm
+instEnvEltsForClass :: InstEnv -> Name -> [ClsInst]
+instEnvEltsForClass (InstEnv rm) cls_nm = lookupRM [RML_KnownTc cls_nm] rm
-- N.B. this is not particularly efficient but used only by GHCi.
instEnvClasses :: InstEnv -> UniqDSet Class
@@ -457,7 +458,10 @@ instIsVisible vis_mods ispec
| otherwise -> True
classInstances :: InstEnvs -> Class -> [ClsInst]
-classInstances (InstEnvs { ie_global = pkg_ie, ie_local = home_ie, ie_visible = vis_mods }) cls
+classInstances envs cls = classNameInstances envs (className cls)
+
+classNameInstances :: InstEnvs -> Name -> [ClsInst]
+classNameInstances (InstEnvs { ie_global = pkg_ie, ie_local = home_ie, ie_visible = vis_mods }) cls
= get home_ie ++ get pkg_ie
where
get :: InstEnv -> [ClsInst]