nixpkgs/pkgs/misc/ghc68extraLibs/plugins-darcs.patch
2008-08-06 16:56:05 +00:00

167 lines
6.5 KiB
Diff

diff --git a/src/System/Plugins/Env.hs b/src/System/Plugins/Env.hs
index 64a840c..8bb0e8d 100644
--- a/src/System/Plugins/Env.hs
+++ b/src/System/Plugins/Env.hs
@@ -73,7 +73,9 @@ import System.IO.Error ( catch, ioError, isDoesNotExistError )
import Control.Concurrent.MVar ( MVar(), newMVar, withMVar )
-import Distribution.Package
+import Distribution.Package hiding (PackageName, packageName, depends)
+import Distribution.Text (display, simpleParse)
+
import Text.ParserCombinators.ReadP
import qualified Data.Map as M
@@ -284,9 +286,9 @@ addPkgConf f = do
union :: PkgEnvs -> [PackageConfig] -> PkgEnvs
union ls ps' =
let fm = emptyFM -- new FM for this package.conf
- in foldr (\p fm' -> if packageName_ p == "base" -- ghc doesn't supply a version with 'base'
+ in foldr (\p fm' -> if display (packageName_ p) == "base" -- ghc doesn't supply a version with 'base'
-- for some reason.
- then addToFM (addToFM fm' (packageName_ p) p) (packageName p) p
+ then addToFM (addToFM fm' (packageName p) p) (packageName p) p
else addToFM fm' (packageName p) p) fm ps' : ls
--
@@ -330,7 +332,7 @@ addStaticPkg pkg = modifyStaticPkgEnv env $ \set -> return $ S.insert pkg set
isStaticPkg :: PackageName -> IO Bool
isStaticPkg pkg
- = case readP_to_S parsePackageName pkg of
+ = case reads pkg of
((pkgName,_):_) -> withStaticPkgEnv env $ \set -> return $ S.member pkgName set
[] -> return False
@@ -513,4 +515,3 @@ addMerge a b z = modifyMerged env $ \fm -> return $ addToFM fm (a,b) z
--
(</>) :: FilePath -> FilePath -> FilePath
[] </> b = b
-a </> b = a ++ "/" ++ b
diff --git a/src/System/Plugins/PackageAPI.hs b/src/System/Plugins/PackageAPI.hs
index 7ac4201..ba8db23 100644
--- a/src/System/Plugins/PackageAPI.hs
+++ b/src/System/Plugins/PackageAPI.hs
@@ -40,7 +40,8 @@ module System.Plugins.PackageAPI (
#if CABAL == 1 || __GLASGOW_HASKELL__ >= 604
import Distribution.InstalledPackageInfo
-import Distribution.Package
+import Distribution.Package hiding (PackageName, packageName, depends)
+import Distribution.Text (display)
#else
import System.Plugins.Package
#endif
@@ -57,9 +58,9 @@ type PackageName = String
type PackageConfig = InstalledPackageInfo
-packageName = showPackageId . package
+packageName = display . package
packageName_ = pkgName . package
-packageDeps = (map showPackageId) . depends
+packageDeps = (map display) . depends
updImportDirs f pk@(InstalledPackageInfo { importDirs = idirs }) =
pk { importDirs = f idirs }
diff --git a/src/System/Plugins/ParsePkgConfCabal.hs b/src/System/Plugins/ParsePkgConfCabal.hs
index eba427e..2f7c13b 100644
--- a/src/System/Plugins/ParsePkgConfCabal.hs
+++ b/src/System/Plugins/ParsePkgConfCabal.hs
@@ -6,18 +6,27 @@ module System.Plugins.ParsePkgConfCabal (
) where
import Distribution.InstalledPackageInfo
-import Distribution.Package
+import Distribution.Package hiding (depends)
+import Distribution.ModuleName (components, ModuleName)
+import Distribution.Text (simpleParse)
+
import Distribution.Version
import Data.Char ( isSpace, isAlpha, isAlphaNum, isUpper, isDigit )
-import Data.List ( break )
+import Data.List ( break, intercalate )
+import Data.Maybe ( fromJust )
import Data.Array
+
#if __GLASGOW_HASKELL__ >= 503
import GHC.Exts
#else
import GlaExts
#endif
+moduleName :: [String] -> [ModuleName]
+moduleName = map (sParse "module name")
+sParse what = (\s -> maybe (error ("couldn't parse " ++ what ++ ", string: " ++ s)) id (simpleParse s))
+
-- parser produced by Happy Version 1.15
newtype HappyAbsSyn = HappyAbsSyn (() -> ())
@@ -269,8 +278,8 @@ happyReduction_13 happy_x_3
case happyOut16 happy_x_3 of { happy_var_3 ->
happyIn9
(\p -> case happy_var_1 of
- "exposedModules" -> p{exposedModules = happy_var_3}
- "hiddenModules" -> p{hiddenModules = happy_var_3}
+ "exposedModules" -> p{exposedModules = moduleName happy_var_3 }
+ "hiddenModules" -> p{hiddenModules = moduleName happy_var_3}
"importDirs" -> p{importDirs = happy_var_3}
"libraryDirs" -> p{libraryDirs = happy_var_3}
"hsLibraries" -> p{hsLibraries = happy_var_3}
@@ -316,7 +325,7 @@ happyReduction_15 (happy_x_10 `HappyStk`
= case happyOutTok happy_x_5 of { (ITstring happy_var_5) ->
case happyOut11 happy_x_9 of { happy_var_9 ->
happyIn10
- (PackageIdentifier{ pkgName = happy_var_5,
+ (PackageIdentifier{ pkgName = sParse "package name" happy_var_5,
pkgVersion = happy_var_9 }
) `HappyStk` happyRest}}
diff --git a/src/System/Plugins/ParsePkgConfCabal.y_in b/src/System/Plugins/ParsePkgConfCabal.y_in
index ddd4516..38bb068 100644
--- a/src/System/Plugins/ParsePkgConfCabal.y_in
+++ b/src/System/Plugins/ParsePkgConfCabal.y_in
@@ -36,12 +36,18 @@ module System.Plugins.ParsePkgConfCabal (
) where
import Distribution.InstalledPackageInfo
-import Distribution.Package
+import Distribution.Package hiding (depends)
import Distribution.Version
+import Distribution.ModuleName (components, ModuleName)
+import Distribution.Text (simpleParse)
import Data.Char ( isSpace, isAlpha, isAlphaNum, isUpper, isDigit )
-import Data.List ( break )
+import Data.List ( break, intercalate )
+import Data.Maybe ( fromJust )
+moduleName :: [String] -> [ModuleName]
+moduleName = map (sParse "module name")
+sParse what = (\s -> maybe (error ("couldn't parse " ++ what ++ ", string: " ++ s)) id (simpleParse s))
}
%token
@@ -102,8 +108,8 @@ field :: { PackageConfig -> PackageConfig }
| VARID '=' strlist
{\p -> case $1 of
- "exposedModules" -> p{exposedModules = $3}
- "hiddenModules" -> p{hiddenModules = $3}
+ "exposedModules" -> p{exposedModules = moduleName $3}
+ "hiddenModules" -> p{hiddenModules = moduleName $3}
"importDirs" -> p{importDirs = $3}
"libraryDirs" -> p{libraryDirs = $3}
"hsLibraries" -> p{hsLibraries = $3}
@@ -130,7 +136,7 @@ field :: { PackageConfig -> PackageConfig }
pkgid :: { PackageIdentifier }
: CONID '{' VARID '=' STRING ',' VARID '=' version '}'
- { PackageIdentifier{ pkgName = $5,
+ { PackageIdentifier{ pkgName = sParse "package name" $5,
pkgVersion = $9 } }
version :: { Version }