Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix HcPkg.dump for the case of an empty database
Previously it returned the value [emptyInstalledPackageInfo]
  • Loading branch information
dcoutts committed Feb 10, 2011
1 parent 7c26a02 commit f15ba81
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Distribution/Simple/Program/HcPkg.hs
Expand Up @@ -51,6 +51,8 @@ import Distribution.Verbosity
import Distribution.Compat.Exception
( catchExit )

import Data.Char
( isSpace )
import Control.Monad
( liftM )

Expand Down Expand Up @@ -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
[] -> []
Expand Down

0 comments on commit f15ba81

Please sign in to comment.