Skip to content
Snippets Groups Projects
Commit 7a310c7b authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Small refactoring in ghc-pkg

parent 0c3a9679
No related branches found
No related tags found
No related merge requests found
...@@ -1153,17 +1153,15 @@ describeField :: Verbosity -> [Flag] -> PackageArg -> [String] -> Bool -> IO () ...@@ -1153,17 +1153,15 @@ describeField :: Verbosity -> [Flag] -> PackageArg -> [String] -> Bool -> IO ()
describeField verbosity my_flags pkgarg fields expand_pkgroot = do describeField verbosity my_flags pkgarg fields expand_pkgroot = do
(_, _, flag_db_stack) <- (_, _, flag_db_stack) <-
getPkgDatabases verbosity False True{-use cache-} expand_pkgroot my_flags getPkgDatabases verbosity False True{-use cache-} expand_pkgroot my_flags
fns <- toFields fields fns <- mapM toField fields
ps <- findPackages flag_db_stack pkgarg ps <- findPackages flag_db_stack pkgarg
mapM_ (selectFields fns) ps mapM_ (selectFields fns) ps
where showFun = if FlagSimpleOutput `elem` my_flags where showFun = if FlagSimpleOutput `elem` my_flags
then showSimpleInstalledPackageInfoField then showSimpleInstalledPackageInfoField
else showInstalledPackageInfoField else showInstalledPackageInfoField
toFields [] = return [] toField f = case showFun f of
toFields (f:fs) = case showFun f of Nothing -> die ("unknown field: " ++ f)
Nothing -> die ("unknown field: " ++ f) Just fn -> return fn
Just fn -> do fns <- toFields fs
return (fn:fns)
selectFields fns pinfo = mapM_ (\fn->putStrLn (fn pinfo)) fns selectFields fns pinfo = mapM_ (\fn->putStrLn (fn pinfo)) fns
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment