From ac10a4ccbe416e8612c6ca49b9f19c3a6f4cf25f Mon Sep 17 00:00:00 2001 From: Ɓukasz Hanuszczak Date: Mon, 10 Aug 2015 16:14:18 +0200 Subject: Fix weird-looking Hoogle output for familyless classes. --- haddock-api/src/Haddock/Backends/Hoogle.hs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'haddock-api/src/Haddock') diff --git a/haddock-api/src/Haddock/Backends/Hoogle.hs b/haddock-api/src/Haddock/Backends/Hoogle.hs index f4f5be90..f6ad9808 100644 --- a/haddock-api/src/Haddock/Backends/Hoogle.hs +++ b/haddock-api/src/Haddock/Backends/Hoogle.hs @@ -160,7 +160,7 @@ ppSig dflags x = ppSigWithDoc dflags x [] -- note: does not yet output documentation for class methods ppClass :: DynFlags -> TyClDecl Name -> [(Name, DocForDecl Name)] -> [String] -ppClass dflags decl subdocs = (out dflags decl' ++ " " ++ ppTyFams) : ppMethods +ppClass dflags decl subdocs = (out dflags decl' ++ ppTyFams) : ppMethods where decl' = decl { tcdSigs = [], tcdMeths = emptyBag @@ -170,10 +170,12 @@ ppClass dflags decl subdocs = (out dflags decl' ++ " " ++ ppTyFams) : ppMethods ppMethods = concat . map (ppSig' . unLoc) $ tcdSigs decl ppSig' = flip (ppSigWithDoc dflags) subdocs . addContext - ppTyFams = showSDocUnqual dflags . whereWrapper $ concat - [ map ppr (tcdATs decl) - , map (ppr . tyFamEqnToSyn . unLoc) (tcdATDefs decl) - ] + ppTyFams + | null $ tcdATs decl = "" + | otherwise = (" " ++) . showSDocUnqual dflags . whereWrapper $ concat + [ map ppr (tcdATs decl) + , map (ppr . tyFamEqnToSyn . unLoc) (tcdATDefs decl) + ] whereWrapper elems = vcat' [ text "where" <+> lbrace -- cgit v1.2.3