From 45d72d1d46dda593823bd6aedf860d18d60f3ab2 Mon Sep 17 00:00:00 2001 From: Ɓukasz Hanuszczak Date: Mon, 10 Aug 2015 16:04:08 +0200 Subject: Improve formatting of class details output in Hoogle backend. --- haddock-api/src/Haddock/Backends/Hoogle.hs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'haddock-api') diff --git a/haddock-api/src/Haddock/Backends/Hoogle.hs b/haddock-api/src/Haddock/Backends/Hoogle.hs index 71e7cbc4..f4f5be90 100644 --- a/haddock-api/src/Haddock/Backends/Hoogle.hs +++ b/haddock-api/src/Haddock/Backends/Hoogle.hs @@ -175,6 +175,12 @@ ppClass dflags decl subdocs = (out dflags decl' ++ " " ++ ppTyFams) : ppMethods , map (ppr . tyFamEqnToSyn . unLoc) (tcdATDefs decl) ] + whereWrapper elems = vcat' + [ text "where" <+> lbrace + , nest 4 . vcat . map (<> semi) $ elems + , rbrace + ] + addContext (TypeSig name (L l sig) nwcs) = TypeSig name (L l $ f sig) nwcs addContext (MinimalSig src sig) = MinimalSig src sig addContext _ = error "expected TypeSig" @@ -390,9 +396,6 @@ escape = concatMap f f x = [x] -semiSeparate :: [SDoc] -> SDoc -semiSeparate = sep . punctuate semi - - -whereWrapper :: [SDoc] -> SDoc -whereWrapper xs = text "where" <+> braces (space <> semiSeparate xs <> space) +-- | Just like 'vcat' but uses '($+$)' instead of '($$)'. +vcat' :: [SDoc] -> SDoc +vcat' = foldr ($+$) empty -- cgit v1.2.3