aboutsummaryrefslogtreecommitdiff
path: root/src/Haddock
diff options
context:
space:
mode:
authorNeil Mitchell <unknown>2008-07-10 15:53:00 +0000
committerNeil Mitchell <unknown>2008-07-10 15:53:00 +0000
commitf55439cfcdef0f65b0be79f9efa17bf3fba5be9a (patch)
tree2802509123b32749e7faa142c59fee40e162ddd9 /src/Haddock
parent8a57a3cbb683eef73749cac779ae7e01d2f89362 (diff)
Put brackets round operators in more places in the Hoogle output
Diffstat (limited to 'src/Haddock')
-rw-r--r--src/Haddock/Backends/Hoogle.hs16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/Haddock/Backends/Hoogle.hs b/src/Haddock/Backends/Hoogle.hs
index f0eced51..33dd5da8 100644
--- a/src/Haddock/Backends/Hoogle.hs
+++ b/src/Haddock/Backends/Hoogle.hs
@@ -75,7 +75,12 @@ out = f . unwords . map (dropWhile isSpace) . lines . showSDocUnqual . ppr
typeSig :: String -> [String] -> String
-typeSig name flds = name ++ " :: " ++ concat (intersperse " -> " flds)
+typeSig name flds = operator name ++ " :: " ++ concat (intersperse " -> " flds)
+
+
+operator :: String -> String
+operator (x:xs) | not (isAlphaNum x) && x `notElem` " ([{" = "(" ++ x:xs ++ ")"
+operator x = x
---------------------------------------------------------------------
@@ -117,7 +122,12 @@ ppData x = showData x{tcdCons=[],tcdDerivs=Nothing} :
concatMap (ppCtor x . unL) (tcdCons x)
where
-- GHC gives out "data Bar =", we want to delete the equals
- showData = reverse . dropWhile (`elem` " =") . reverse . out
+ -- also writes data : a b, when we want data (:) a b
+ showData x = unwords $ map f $ if last xs == "=" then init xs else xs
+ where
+ xs = words $ out x
+ nam = out $ tcdLName x
+ f x = if x == nam then operator nam else x
ppCtor :: TyClDecl Name -> ConDecl Name -> [String]
@@ -133,7 +143,7 @@ ppCtor dat con = ldoc (con_doc con) ++ f (con_details con)
name = out $ unL $ con_name con
resType = case con_res con of
- ResTyH98 -> unwords $ out (tcdLName dat) : map out (tcdTyVars dat)
+ ResTyH98 -> unwords $ operator (out (tcdLName dat)) : map out (tcdTyVars dat)
ResTyGADT x -> out $ unL x