From f15ba81e770a432268e04bd0062eaf6e4ee88293 Mon Sep 17 00:00:00 2001 From: Duncan Coutts Date: Thu, 10 Feb 2011 20:01:11 +0000 Subject: [PATCH] Fix HcPkg.dump for the case of an empty database Previously it returned the value [emptyInstalledPackageInfo] --- Distribution/Simple/Program/HcPkg.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Distribution/Simple/Program/HcPkg.hs b/Distribution/Simple/Program/HcPkg.hs index a884d019371..465a03baa44 100644 --- a/Distribution/Simple/Program/HcPkg.hs +++ b/Distribution/Simple/Program/HcPkg.hs @@ -51,6 +51,8 @@ import Distribution.Verbosity import Distribution.Compat.Exception ( catchExit ) +import Data.Char + ( isSpace ) import Control.Monad ( liftM ) @@ -135,8 +137,12 @@ dump verbosity hcPkg packagedb = do --TODO: this could be a lot faster. We're doing normaliseLineEndings twice -- and converting back and forth with lines/unlines. splitPkgs :: String -> [String] - splitPkgs = map unlines . splitWith ("---" ==) . lines + splitPkgs = checkEmpty . map unlines . splitWith ("---" ==) . lines where + -- Handle the case of there being no packages at all. + checkEmpty [s] | all isSpace s = [] + checkEmpty ss = ss + splitWith :: (a -> Bool) -> [a] -> [[a]] splitWith p xs = ys : case zs of [] -> []