From b31434e9bafff7e44afa4737cb471b9ee86eb500 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Wed, 29 Jul 2009 14:16:53 +0000 Subject: define unpackPackageId (it was removed from GHC) --- src/Haddock/GhcUtils.hs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src') 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) -- cgit v1.2.3