Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix HcPkg.dump for the case of an empty database

Previously it returned the value [emptyInstalledPackageInfo]
  • Loading branch information...
commit f15ba81e770a432268e04bd0062eaf6e4ee88293 1 parent 7c26a02
Duncan Coutts dcoutts authored
Showing with 7 additions and 1 deletion.
  1. +7 −1 Distribution/Simple/Program/HcPkg.hs
8 Distribution/Simple/Program/HcPkg.hs
View
@@ -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
[] -> []
Please sign in to comment.
Something went wrong with that request. Please try again.