Permalink
Browse files

Fix HcPkg.dump for the case of an empty database

Previously it returned the value [emptyInstalledPackageInfo]
  • Loading branch information...
1 parent 7c26a02 commit f15ba81e770a432268e04bd0062eaf6e4ee88293 @dcoutts dcoutts committed Feb 10, 2011
Showing with 7 additions and 1 deletion.
  1. +7 −1 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
[] -> []

0 comments on commit f15ba81

Please sign in to comment.