From 68a78932b5b004945f6681bd51e8080e868fc0ee Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Sun, 9 Mar 2014 16:32:36 +0100 Subject: Group similar fixities together Identical fixities declared for the same line should now render using syntax like: infix 4 <, >=, >, <= --- src/Haddock/Backends/Xhtml/Decl.hs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Haddock/Backends/Xhtml/Decl.hs b/src/Haddock/Backends/Xhtml/Decl.hs index 5cc86d48..42f06280 100644 --- a/src/Haddock/Backends/Xhtml/Decl.hs +++ b/src/Haddock/Backends/Xhtml/Decl.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE TransformListComp #-} ----------------------------------------------------------------------------- -- | -- Module : Haddock.Backends.Html.Decl @@ -34,6 +35,7 @@ import Data.Monoid ( mempty ) import Text.XHtml hiding ( name, title, p, quote ) import GHC +import GHC.Exts import Name @@ -158,15 +160,20 @@ ppTypeOrFunSig summary links loc docnames typ (doc, argDocs) (pref1, pref2, sep) = [(leader <+> ppType unicode qual t, argDoc n, [])] ppFixities :: [(DocName, Fixity)] -> Qualification -> Html -ppFixities fs qual = vcat $ map ppFix fs +ppFixities fs qual = vcat $ map ppFix uniq_fs where - ppFix (n, Fixity p d) = toHtml (ppDir d) <+> toHtml (show p) - <+> ppDocName qual Infix False n + ppFix (ns, p, d) = toHtml d <+> toHtml (show p) <+> ppNames ns ppDir InfixR = "infixr" ppDir InfixL = "infixl" ppDir InfixN = "infix" + ppNames = concatHtml . intersperse (stringToHtml ", ") . map (ppDocName qual Infix False) + + uniq_fs = [ (n, the p, the d') | (n, Fixity p d) <- fs + , let d' = ppDir d + , then group by Down (p,d') using groupWith ] + ppTyVars :: LHsTyVarBndrs DocName -> [Html] ppTyVars tvs = map ppTyName (tyvarNames tvs) -- cgit v1.2.3