summaryrefslogtreecommitdiff
path: root/utils/genprimopcode
diff options
context:
space:
mode:
authormniip <mniip@mniip.com>2020-04-22 23:43:39 +0300
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-04-23 18:33:21 -0400
commit0ac29c885fba7ed69de83a597cdbd03696c9ed13 (patch)
tree9d502f1e790d0d840a8dfb0326921ad739244eb1 /utils/genprimopcode
parent2c23e2e37d6c937a425c53da643aec90bda01ef6 (diff)
downloadhaskell-0ac29c885fba7ed69de83a597cdbd03696c9ed13.tar.gz
GHC.Prim docs: note and test
Diffstat (limited to 'utils/genprimopcode')
-rw-r--r--utils/genprimopcode/Main.hs16
1 files changed, 16 insertions, 0 deletions
diff --git a/utils/genprimopcode/Main.hs b/utils/genprimopcode/Main.hs
index 63b51b9f5d..576dbc9a20 100644
--- a/utils/genprimopcode/Main.hs
+++ b/utils/genprimopcode/Main.hs
@@ -789,6 +789,22 @@ gen_switch_from_attribs attrib_name fn_name (Info defaults entries)
-> unlines alternatives
++ fn_name ++ " _ = " ++ getAltRhs xx ++ "\n"
+{-
+Note [GHC.Prim Docs]
+~~~~~~~~~~~~~~~~~~~~
+For haddocks of GHC.Prim we generate a dummy haskell file (gen_hs_source) that
+contains the type signatures and the commends (but no implementations)
+specifically for consumption by haddock.
+
+GHCi's :doc command reads directly from ModIface's though, and GHC.Prim has a
+wired-in iface that has nothing to do with the above haskell file. The code
+below converts primops.txt into an intermediate form that would later be turned
+into a proper DeclDocMap.
+
+We output the docs as a list of pairs (name, docs). We use stringy names here
+because mapping names to "Name"s is difficult for things like primtypes and
+pseudoops.
+-}
gen_wired_in_docs :: Info -> String
gen_wired_in_docs (Info _ entries)
= "primOpDocs =\n [ " ++ intercalate "\n , " (catMaybes $ map mkDoc $ concatMap desugarVectorSpec entries) ++ "\n ]\n"