[commit: ghc] master: Small refactoring in ghc-pkg (7a310c7)

Ian Lynagh igloo at earth.li
Mon Apr 29 00:20:28 CEST 2013


Repository : http://darcs.haskell.org/ghc.git/

On branch  : master

https://github.com/ghc/ghc/commit/7a310c7b3fab3b18160380a710ee5bbf0c7f1a09

>---------------------------------------------------------------

commit 7a310c7b3fab3b18160380a710ee5bbf0c7f1a09
Author: Ian Lynagh <ian at well-typed.com>
Date:   Sun Apr 28 21:59:28 2013 +0100

    Small refactoring in ghc-pkg

>---------------------------------------------------------------

 utils/ghc-pkg/Main.hs | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/utils/ghc-pkg/Main.hs b/utils/ghc-pkg/Main.hs
index 3cda838..532bc02 100644
--- a/utils/ghc-pkg/Main.hs
+++ b/utils/ghc-pkg/Main.hs
@@ -1153,17 +1153,15 @@ describeField :: Verbosity -> [Flag] -> PackageArg -> [String] -> Bool -> IO ()
 describeField verbosity my_flags pkgarg fields expand_pkgroot = do
   (_, _, flag_db_stack) <- 
       getPkgDatabases verbosity False True{-use cache-} expand_pkgroot my_flags
-  fns <- toFields fields
+  fns <- mapM toField fields
   ps <- findPackages flag_db_stack pkgarg
   mapM_ (selectFields fns) ps
   where showFun = if FlagSimpleOutput `elem` my_flags
                   then showSimpleInstalledPackageInfoField
                   else showInstalledPackageInfoField
-        toFields [] = return []
-        toFields (f:fs) = case showFun f of
-            Nothing -> die ("unknown field: " ++ f)
-            Just fn -> do fns <- toFields fs
-                          return (fn:fns)
+        toField f = case showFun f of
+                    Nothing -> die ("unknown field: " ++ f)
+                    Just fn -> return fn
         selectFields fns pinfo = mapM_ (\fn->putStrLn (fn pinfo)) fns
 
 





More information about the ghc-commits mailing list