diff options
author | David Waern <davve@dtek.chalmers.se> | 2007-09-29 14:01:32 +0000 |
---|---|---|
committer | David Waern <davve@dtek.chalmers.se> | 2007-09-29 14:01:32 +0000 |
commit | 4866f38861d7ebc578dcc5754e40b51fffca8b2f (patch) | |
tree | 419c1a14962e665d52f4f121371facdd237e02fe /src/Haddock | |
parent | b41afcbad12d337e268ca5464a4e6d4311708fef (diff) |
FIX: prefix types used as operators should be quoted
Diffstat (limited to 'src/Haddock')
-rw-r--r-- | src/Haddock/Backends/Html.hs | 15 | ||||
-rw-r--r-- | src/Haddock/GHC/Utils.hs | 2 |
2 files changed, 16 insertions, 1 deletions
diff --git a/src/Haddock/Backends/Html.hs b/src/Haddock/Backends/Html.hs index a958cb75..d3e4478c 100644 --- a/src/Haddock/Backends/Html.hs +++ b/src/Haddock/Backends/Html.hs @@ -864,6 +864,11 @@ ppAsst n ts = ppDocName n <+> hsep (map ppParendType ts) orig (L _ (NoLink name)) = name orig _ = error "orig" + +lDocLinkName (L _ (NoLink name)) = name +lDocLinkName (L _ (Link name)) = name + + -- TODO: print contexts ppShortDataDecl :: Bool -> LinksInfo -> SrcSpan -> Maybe (HsDoc DocName) -> TyClDecl DocName -> Html @@ -1236,7 +1241,10 @@ ppr_mono_ty ctxt_prec (HsAppTy fun_ty arg_ty) ppr_mono_ty ctxt_prec (HsOpTy ty1 op ty2) = maybeParen ctxt_prec pREC_OP $ - ppr_mono_lty pREC_OP ty1 <+> ppLDocName op <+> ppr_mono_lty pREC_OP ty2 + ppr_mono_lty pREC_OP ty1 <+> ppr_op <+> ppr_mono_lty pREC_OP ty2 + where + ppr_op = if not (isNameSymOcc name) then quote (ppLDocName op) else ppLDocName op + name = lDocLinkName op ppr_mono_ty ctxt_prec (HsParTy ty) = parens (ppr_mono_lty pREC_TOP ty) @@ -1371,6 +1379,11 @@ char c = toHtml [c] empty :: Html empty = noHtml + +quote :: Html -> Html +quote h = char '`' +++ h +++ '`' + + parens, brackets, braces :: Html -> Html parens h = char '(' +++ h +++ char ')' brackets h = char '[' +++ h +++ char ']' diff --git a/src/Haddock/GHC/Utils.hs b/src/Haddock/GHC/Utils.hs index 8e70057f..26860116 100644 --- a/src/Haddock/GHC/Utils.hs +++ b/src/Haddock/GHC/Utils.hs @@ -52,6 +52,8 @@ modulePkgStr = packageIdString . modulePackageId -- misc +isNameSymOcc = isSymOcc . nameOccName + -- there should be a better way to check this using the GHC API isConSym n = head (nameOccString n) == ':' |