diff options
author | Simon Marlow <marlowsd@gmail.com> | 2009-07-29 14:16:53 +0000 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2009-07-29 14:16:53 +0000 |
commit | b31434e9bafff7e44afa4737cb471b9ee86eb500 (patch) | |
tree | b27b8377c5e6952effd0324f3c1760141ce18ead /src/Haddock/GhcUtils.hs | |
parent | d081a94054ccfbbf2741d9339310c527505cba98 (diff) |
define unpackPackageId (it was removed from GHC)
Diffstat (limited to 'src/Haddock/GhcUtils.hs')
-rw-r--r-- | src/Haddock/GhcUtils.hs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/Haddock/GhcUtils.hs b/src/Haddock/GhcUtils.hs index 99b707df..b720aa8c 100644 --- a/src/Haddock/GhcUtils.hs +++ b/src/Haddock/GhcUtils.hs @@ -22,6 +22,10 @@ import qualified Data.Map as Map import Control.Arrow import Data.Foldable hiding (concatMap) import Data.Traversable +#if __GLASGOW_HASKELL__ >= 611 +import Distribution.Compat.ReadP +import Distribution.Text +#endif import Outputable import Name @@ -49,6 +53,19 @@ modulePackageInfo modu = case unpackPackageId pkg of Just x -> (display $ pkgName x, showVersion (pkgVersion x)) where pkg = modulePackageId modu +#if __GLASGOW_HASKELL__ >= 611 +-- This was removed from GHC 6.11 +-- XXX we shouldn't be using it, probably + +-- | Try and interpret a GHC 'PackageId' as a cabal 'PackageIdentifer'. Returns @Nothing@ if +-- we could not parse it as such an object. +unpackPackageId :: PackageId -> Maybe PackageIdentifier +unpackPackageId p + = case [ pid | (pid,"") <- readP_to_S parse str ] of + [] -> Nothing + (pid:_) -> Just pid + where str = packageIdString p +#endif mkModuleNoPackage :: String -> Module mkModuleNoPackage str = mkModule (stringToPackageId "") (mkModuleName str) |