aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Mitchell <unknown>2008-06-16 07:09:49 +0000
committerNeil Mitchell <unknown>2008-06-16 07:09:49 +0000
commitf8d50701d2abc8fa5e89cf5d02e97f090dc769ee (patch)
tree0c93e8710fc277d9187caf857abf76e426daf42f
parent47ec4e22e31e0531f2d412e754fd66eb4f7ba34f (diff)
Add modulePkgInfo to Haddock.GHC.Utils, which gives back package name and version info
-rw-r--r--src/Haddock/GHC/Utils.hs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/Haddock/GHC/Utils.hs b/src/Haddock/GHC/Utils.hs
index 062d015e..97a682d4 100644
--- a/src/Haddock/GHC/Utils.hs
+++ b/src/Haddock/GHC/Utils.hs
@@ -13,6 +13,7 @@ module Haddock.GHC.Utils where
import Data.Char
+import Data.Version
import qualified Data.Map as Map
import GHC
@@ -27,9 +28,17 @@ moduleString :: Module -> String
moduleString = moduleNameString . moduleName
+-- return the name of the package, with version info
modulePkgStr = packageIdString . modulePackageId
+-- return the (name,version) of the package
+modulePkgInfo mod = case unpackPackageId pkg of
+ Nothing -> (packageIdString pkg, "")
+ Just x -> (pkgName x, showVersion (pkgVersion x))
+ where pkg = modulePackageId mod
+
+
mkModuleNoPkg :: String -> Module
mkModuleNoPkg str = mkModule (stringToPackageId "") (mkModuleName str)