diff options
author | simonmar <unknown> | 2005-11-25 09:56:59 +0000 |
---|---|---|
committer | simonmar <unknown> | 2005-11-25 09:56:59 +0000 |
commit | 2c6f7109e521e906fda9e3ed7c78b85b7bffcea1 (patch) | |
tree | 2da05198510f47497d990d651fe3d7401b9feff3 /ghc/utils | |
parent | b7430a56c97b21d116977e7920cc8b87e02561c8 (diff) | |
download | haskell-2c6f7109e521e906fda9e3ed7c78b85b7bffcea1.tar.gz |
[project @ 2005-11-25 09:56:59 by simonmar]
sort packages by name and version in the 'ghc-pkg list' output
Diffstat (limited to 'ghc/utils')
-rw-r--r-- | ghc/utils/ghc-pkg/Main.hs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/ghc/utils/ghc-pkg/Main.hs b/ghc/utils/ghc-pkg/Main.hs index 2f8be4578d..8dd520614c 100644 --- a/ghc/utils/ghc-pkg/Main.hs +++ b/ghc/utils/ghc-pkg/Main.hs @@ -456,8 +456,21 @@ listPackages flags mPackageName = do map (\(conf,pkgs) -> (conf, filter (this `matchesPkg`) pkgs)) db_stack | otherwise = db_stack + + db_stack_sorted + = [ (db, sort_pkgs pkgs) | (db,pkgs) <- db_stack_filtered ] + where sort_pkgs = sortBy cmpPkgIds + cmpPkgIds pkg1 pkg2 = + case pkgName p1 `compare` pkgName p2 of + LT -> LT + GT -> GT + EQ -> pkgVersion p1 `compare` pkgVersion p2 + where (p1,p2) = (package pkg1, package pkg2) + show_func = if simple_output then show_easy else mapM_ show_regular - show_func (reverse db_stack_filtered) + + show_func (reverse db_stack_sorted) + where show_regular (db_name,pkg_confs) = hPutStrLn stdout (render $ text (db_name ++ ":") $$ nest 4 packages @@ -467,6 +480,7 @@ listPackages flags mPackageName = do | exposed p = doc | otherwise = parens doc where doc = text (showPackageId (package p)) + show_easy db_stack = do let pkgs = map showPackageId $ sortBy compPkgIdVer $ map package (concatMap snd db_stack) |