aboutsummaryrefslogtreecommitdiff
path: root/src/Haddock/Backends/Hoogle.hs
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2012-03-26 09:14:23 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2012-03-26 09:14:23 +0100
commit1e6e6c01babee971420e1876cdffdfb0bf673c1e (patch)
tree892a4b3be7d2bd68ddb3bc50543a1e2834590092 /src/Haddock/Backends/Hoogle.hs
parent730d3e622268f59fd78d29026d164486c4e68fcb (diff)
Follow refactoring of TyClDecl/HsTyDefn
Diffstat (limited to 'src/Haddock/Backends/Hoogle.hs')
-rw-r--r--src/Haddock/Backends/Hoogle.hs19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/Haddock/Backends/Hoogle.hs b/src/Haddock/Backends/Hoogle.hs
index 593f03bc..c0569006 100644
--- a/src/Haddock/Backends/Hoogle.hs
+++ b/src/Haddock/Backends/Hoogle.hs
@@ -111,9 +111,10 @@ operator x = x
ppExport :: ExportItem Name -> [String]
ppExport (ExportDecl decl dc subdocs _) = doc (fst dc) ++ f (unL decl)
where
- f (TyClD d@TyData{}) = ppData d subdocs
+ f (TyClD d@TyDecl{})
+ | isDataDecl d = ppData d subdocs
+ | otherwise = ppSynonym d
f (TyClD d@ClassDecl{}) = ppClass d
- f (TyClD d@TySynonym{}) = ppSynonym d
f (ForD (ForeignImport name typ _ _)) = ppSig $ TypeSig [name] typ
f (ForD (ForeignExport name typ _ _)) = ppSig $ TypeSig [name] typ
f (SigD sig) = ppSig sig
@@ -131,10 +132,6 @@ ppSig (TypeSig names sig) = [operator prettyNames ++ " :: " ++ outHsType typ]
ppSig _ = []
-ppSynonym :: TyClDecl Name -> [String]
-ppSynonym x = [out x]
-
-
-- note: does not yet output documentation for class methods
ppClass :: TyClDecl Name -> [String]
ppClass x = out x{tcdSigs=[]} :
@@ -154,10 +151,15 @@ ppInstance :: ClsInst -> [String]
ppInstance x = [dropComment $ out x]
+ppSynonym :: TyClDecl Name -> [String]
+ppSynonym x = [out x]
+
ppData :: TyClDecl Name -> [(Name, DocForDecl Name)] -> [String]
-ppData x subdocs = showData x{tcdCons=[],tcdDerivs=Nothing} :
- concatMap (ppCtor x subdocs . unL) (tcdCons x)
+ppData decl@(TyDecl { tcdTyDefn = defn }) subdocs
+ = showData decl{ tcdTyDefn = defn { td_cons=[],td_derivs=Nothing }} :
+ concatMap (ppCtor decl subdocs . unL) (td_cons defn)
where
+
-- GHC gives out "data Bar =", we want to delete the equals
-- also writes data : a b, when we want data (:) a b
showData d = unwords $ map f $ if last xs == "=" then init xs else xs
@@ -165,6 +167,7 @@ ppData x subdocs = showData x{tcdCons=[],tcdDerivs=Nothing} :
xs = words $ out d
nam = out $ tcdLName d
f w = if w == nam then operator nam else w
+ppData _ _ = panic "ppData"
-- | for constructors, and named-fields...
lookupCon :: [(Name, DocForDecl Name)] -> Located Name -> Maybe (Doc Name)