Skip to content
This repository
Browse code

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 1 changed file with 7 additions and 1 deletion. Show diff stats Hide diff stats

  1. +7 1 Distribution/Simple/Program/HcPkg.hs
8 Distribution/Simple/Program/HcPkg.hs
@@ -51,6 +51,8 @@ import Distribution.Verbosity
51 51 import Distribution.Compat.Exception
52 52 ( catchExit )
53 53
  54 +import Data.Char
  55 + ( isSpace )
54 56 import Control.Monad
55 57 ( liftM )
56 58
@@ -135,8 +137,12 @@ dump verbosity hcPkg packagedb = do
135 137 --TODO: this could be a lot faster. We're doing normaliseLineEndings twice
136 138 -- and converting back and forth with lines/unlines.
137 139 splitPkgs :: String -> [String]
138   - splitPkgs = map unlines . splitWith ("---" ==) . lines
  140 + splitPkgs = checkEmpty . map unlines . splitWith ("---" ==) . lines
139 141 where
  142 + -- Handle the case of there being no packages at all.
  143 + checkEmpty [s] | all isSpace s = []
  144 + checkEmpty ss = ss
  145 +
140 146 splitWith :: (a -> Bool) -> [a] -> [[a]]
141 147 splitWith p xs = ys : case zs of
142 148 [] -> []

0 comments on commit f15ba81

Please sign in to comment.
Something went wrong with that request. Please try again.