diff --git a/Ganeti/HTools/Utils.hs b/Ganeti/HTools/Utils.hs index 7ae236777044918c87e8e74fa05781a9ffa776d8..84e8152ee94fcaae1a126bf71c49a3b6001eadd8 100644 --- a/Ganeti/HTools/Utils.hs +++ b/Ganeti/HTools/Utils.hs @@ -73,13 +73,13 @@ debugXy a b = debug a `seq` b commaJoin :: [String] -> String commaJoin = intercalate "," --- | Split a string on a separator and return an array. -sepSplit :: Char -> String -> [String] +-- | Split a list on a separator and return an array. +sepSplit :: Eq a => a -> [a] -> [[a]] sepSplit sep s - | x == "" && xs == [] = [] - | xs == [] = [x] - | ys == [] = [x,""] - | otherwise = x:sepSplit sep ys + | null s = [] + | null xs = [x] + | null ys = [x,[]] + | otherwise = x:sepSplit sep ys where (x, xs) = break (== sep) s ys = drop 1 xs