Commit 2c23e2e3 authored by mniip's avatar mniip Committed by Marge Bot
Browse files

Include docs for non-primop entries in primops.txt as well

parent 72da0c29
......@@ -167,9 +167,15 @@ primOpFixity :: PrimOp -> Maybe Fixity
\subsubsection{Docs}
* *
************************************************************************
@primOpDocs@ contains the documentation from @primops.txt@ as a list of
pairs (name, docs). We use stringy names here because wired-in names are
not available yet, and not all of them are a @PrimOp@ (they could be
tycons or pseudoops for example)
-}
primOpDocs :: PrimOp -> Maybe String
primOpDocs :: [(String, String)]
#include "primop-docs.hs-incl"
{-
......
......@@ -75,7 +75,7 @@ import GHC.Builtin.Types.Literals ( typeNatTyCons )
import GHC.Hs.Doc
import Control.Applicative ((<|>))
import Data.List ( intercalate )
import Data.List ( intercalate , find )
import Data.Array
import Data.Maybe
import qualified Data.Map as Map
......@@ -260,8 +260,15 @@ ghcPrimExports
| tc <- funTyCon : exposedPrimTyCons, let n = tyConName tc ]
ghcPrimDeclDocs :: DeclDocMap
ghcPrimDeclDocs = DeclDocMap $ Map.fromList $ mapMaybe mkDeclDoc allThePrimOps
where mkDeclDoc po = fmap (\doc -> (idName (primOpId po), mkHsDocString doc)) $ primOpDocs po
ghcPrimDeclDocs = DeclDocMap $ Map.fromList $ mapMaybe findName primOpDocs
where
names = map idName ghcPrimIds ++
map (idName . primOpId) allThePrimOps ++
map tyConName (funTyCon : exposedPrimTyCons)
findName (nameStr, doc)
| Just name <- find ((nameStr ==) . getOccString) names
= Just (name, mkHsDocString doc)
| otherwise = Nothing
{-
************************************************************************
......
......@@ -388,6 +388,7 @@ getName PrimOpSpec{ name = n } = Just n
getName PrimVecOpSpec{ name = n } = Just n
getName PseudoOpSpec{ name = n } = Just n
getName PrimTypeSpec{ ty = TyApp tc _ } = Just (show tc)
getName PrimVecTypeSpec{ ty = TyApp tc _ } = Just (show tc)
getName _ = Nothing
{- Note [Placeholder declarations]
......@@ -790,15 +791,11 @@ gen_switch_from_attribs attrib_name fn_name (Info defaults entries)
gen_wired_in_docs :: Info -> String
gen_wired_in_docs (Info _ entries)
= unlines $ catMaybes (map mkAlt (filter is_primop entries)) ++ [funName ++ " _ = Nothing"]
= "primOpDocs =\n [ " ++ intercalate "\n , " (catMaybes $ map mkDoc $ concatMap desugarVectorSpec entries) ++ "\n ]\n"
where
mkAlt po | null (desc po) = Nothing
| otherwise = Just (funName ++ " " ++ mkLHS po ++ " = Just " ++ show (unlatex (desc po)))
mkLHS po = case vecOptions po of
[] -> cons po
_ -> "(" ++ cons po ++ " _ _ _)"
funName = "primOpDocs"
mkDoc po | Just poName <- getName po
, not $ null $ desc po = Just $ show (poName, unlatex $ desc po)
| otherwise = Nothing
------------------------------------------------------------------
-- Create PrimOpInfo text from PrimOpSpecs -----------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment