diff options
author | Dr. ERDI Gergo <gergo@erdi.hu> | 2014-01-09 01:42:55 -0600 |
---|---|---|
committer | Austin Seipp <austin@well-typed.com> | 2014-01-19 15:35:16 -0600 |
commit | 7c905816eb12981840efe4136989799db437f357 (patch) | |
tree | 254618be017084ab4a1a61e499aae85ff4479b11 /src/Haddock/Backends/Xhtml/Names.hs | |
parent | 764a6b85b686dee3d93e130bd650ee33a985aca2 (diff) |
Support for -XPatternSynonyms
Signed-off-by: Austin Seipp <austin@well-typed.com>
Diffstat (limited to 'src/Haddock/Backends/Xhtml/Names.hs')
-rw-r--r-- | src/Haddock/Backends/Xhtml/Names.hs | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/Haddock/Backends/Xhtml/Names.hs b/src/Haddock/Backends/Xhtml/Names.hs index 2f2b82ed..280a888c 100644 --- a/src/Haddock/Backends/Xhtml/Names.hs +++ b/src/Haddock/Backends/Xhtml/Names.hs @@ -12,7 +12,7 @@ ----------------------------------------------------------------------------- module Haddock.Backends.Xhtml.Names ( ppName, ppDocName, ppLDocName, ppRdrName, ppUncheckedLink, - ppBinder, ppBinder', + ppBinder, ppBinderInfix, ppBinder', ppModule, ppModuleRef, ppIPName, linkId @@ -105,16 +105,23 @@ ppName name = toHtml (getOccString name) ppBinder :: Bool -> OccName -> Html -- The Bool indicates whether we are generating the summary, in which case -- the binder will be a link to the full definition. -ppBinder True n = linkedAnchor (nameAnchorId n) << ppBinder' n +ppBinder True n = linkedAnchor (nameAnchorId n) << ppBinder' False n ppBinder False n = namedAnchor (nameAnchorId n) ! [theclass "def"] - << ppBinder' n + << ppBinder' False n +ppBinderInfix :: Bool -> OccName -> Html +ppBinderInfix True n = linkedAnchor (nameAnchorId n) << ppBinder' True n +ppBinderInfix False n = namedAnchor (nameAnchorId n) ! [theclass "def"] + << ppBinder' True n -ppBinder' :: OccName -> Html -ppBinder' n - | isVarSym n = parens $ ppOccName n - | otherwise = ppOccName n - +ppBinder' :: Bool -> OccName -> Html +-- The Bool indicates if it is to be rendered in infix notation +ppBinder' is_infix n = wrap $ ppOccName n + where + wrap | is_infix && not is_sym = quote + | not is_infix && is_sym = parens + | otherwise = id + is_sym = isVarSym n || isConSym n linkId :: Module -> Maybe Name -> Html -> Html linkId mdl mbName = linkIdOcc mdl (fmap nameOccName mbName) |