parseGlobPackageId =
parse
+++
- (do n <- parsePackageName; string "-*"
+ (do n <- parse
+ string "-*"
return (PackageIdentifier{ pkgName = n, pkgVersion = globVersion }))
-- globVersion means "all versions"
readParseDatabase :: PackageDBName -> IO (PackageDBName,PackageDB)
readParseDatabase filename = do
str <- readFile filename `Exception.catch` \_ -> return emptyPackageConfig
- let packages = read str
+ let packages = map convertPackageInfoIn $ read str
Exception.evaluate packages
`Exception.catch` \e->
die ("error while parsing " ++ filename ++ ": " ++ show e)
EQ -> pkgVersion p1 `compare` pkgVersion p2
where (p1,p2) = (package pkg1, package pkg2)
- match `exposedInPkg` pkg = any match (exposedModules pkg)
+ match `exposedInPkg` pkg = any match (map display $ exposedModules pkg)
pkg_map = map (\p -> (package p, p)) $ concatMap snd db_stack
show_func = if simple_output then show_simple else mapM_ (show_normal pkg_map)
where doc = text (display (package p))
show_simple db_stack = do
- let showPkg = if FlagNamesOnly `elem` flags then pkgName
+ let showPkg = if FlagNamesOnly `elem` flags then display . pkgName
else display
pkgs = map showPkg $ sortBy compPkgIdVer $
map package (concatMap snd db_stack)
-- -----------------------------------------------------------------------------
-- Manipulating package.conf files
+type InstalledPackageInfoString = InstalledPackageInfo_ String
+
+convertPackageInfoOut :: InstalledPackageInfo -> InstalledPackageInfoString
+convertPackageInfoOut
+ (pkgconf@(InstalledPackageInfo { exposedModules = e,
+ hiddenModules = h })) =
+ pkgconf{ exposedModules = map display e,
+ hiddenModules = map display h }
+
+convertPackageInfoIn :: InstalledPackageInfoString -> InstalledPackageInfo
+convertPackageInfoIn
+ (pkgconf@(InstalledPackageInfo { exposedModules = e,
+ hiddenModules = h })) =
+ pkgconf{ exposedModules = map convert e,
+ hiddenModules = map convert h }
+ where convert = fromJust . simpleParse
+
writeNewConfig :: FilePath -> [InstalledPackageInfo] -> IO ()
writeNewConfig filename packages = do
hPutStr stdout "Writing new package config file... "
if isPermissionError e
then die (filename ++ ": you don't have permission to modify this file")
else ioError e
- let shown = concat $ intersperse ",\n " $ map show packages
+ let shown = concat $ intersperse ",\n "
+ $ map (show . convertPackageInfoOut) packages
fileContents = "[" ++ shown ++ "\n]"
hPutStrLn h fileContents
hClose h