aboutsummaryrefslogtreecommitdiff
path: root/src/HaddockModuleTree.hs
diff options
context:
space:
mode:
authordavve <davve@dtek.chalmers.se>2006-08-19 20:07:55 +0000
committerdavve <davve@dtek.chalmers.se>2006-08-19 20:07:55 +0000
commita7d3efef2e17273fb28a3d711d00843c1c875a17 (patch)
treec441da71c6e5cf4fb12e0303f204d3e7759e3494 /src/HaddockModuleTree.hs
parent7ef7e7beb6e79166dec2f31cfbd16f7170066a6b (diff)
Adapt to latest GHC
Diffstat (limited to 'src/HaddockModuleTree.hs')
-rw-r--r--src/HaddockModuleTree.hs19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/HaddockModuleTree.hs b/src/HaddockModuleTree.hs
index ffc8b98e..e32cb960 100644
--- a/src/HaddockModuleTree.hs
+++ b/src/HaddockModuleTree.hs
@@ -1,15 +1,18 @@
module HaddockModuleTree ( ModuleTree(..), mkModuleTree ) where
-import HaddockTypes ( DocName )
-import GHC ( HsDoc, Name )
-import Module ( Module, moduleString )
+import HaddockTypes ( DocName )
+import GHC ( HsDoc, Name )
+import Module ( Module, moduleNameString, moduleName, modulePackageId )
+import PackageConfig ( packageIdString )
data ModuleTree = Node String Bool (Maybe String) (Maybe (HsDoc Name)) [ModuleTree]
-mkModuleTree :: [(Module, Maybe String, Maybe (HsDoc Name))] -> [ModuleTree]
-mkModuleTree mods =
- foldr fn [] [ (splitModule mod, pkg, short) | (mod,pkg,short) <- mods ]
- where
+mkModuleTree :: Bool -> [(Module, Maybe (HsDoc Name))] -> [ModuleTree]
+mkModuleTree showPkgs mods =
+ foldr fn [] [ (splitModule mod, modPkg mod, short) | (mod, short) <- mods ]
+ where
+ modPkg mod | showPkgs = Just (packageIdString (modulePackageId mod))
+ | otherwise = Nothing
fn (mod,pkg,short) trees = addToTrees mod pkg short trees
addToTrees :: [String] -> Maybe String -> Maybe (HsDoc Name) -> [ModuleTree] -> [ModuleTree]
@@ -29,7 +32,7 @@ mkSubTree [s] pkg short = [Node s True pkg short []]
mkSubTree (s:ss) pkg short = [Node s (null ss) Nothing Nothing (mkSubTree ss pkg short)]
splitModule :: Module -> [String]
-splitModule mod = split (moduleString mod)
+splitModule mod = split (moduleNameString (moduleName mod))
where split mod0 = case break (== '.') mod0 of
(s1, '.':s2) -> s1 : split s2
(s1, _) -> [s1]