X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=distrib%2Fcompare%2FUtils.hs;h=e2da6b55fa1e4e0d36ccfdb6056fcc7f0b359f8c;hb=aa538c1db99be4efb2724bb8c4a378b9d68a28ec;hp=58298c12ddfadfd0ce8e12a3763226ba958f550f;hpb=29a05730930cd2c5986ebb22d550e893d9fa20cc;p=ghc-hetmet.git diff --git a/distrib/compare/Utils.hs b/distrib/compare/Utils.hs index 58298c1..e2da6b5 100644 --- a/distrib/compare/Utils.hs +++ b/distrib/compare/Utils.hs @@ -1,6 +1,8 @@ module Utils where +import Data.Function +import Data.List import System.Exit import System.IO import Text.Regex.Posix @@ -26,3 +28,13 @@ re r str = case matchM r' str :: Maybe (String, String, String, [String]) of Nothing -> Nothing where r' = makeRegex r :: Regex +unSepList :: Eq a => a -> [a] -> [[a]] +unSepList x xs = case break (x ==) xs of + (this, _ : xs') -> + this : unSepList x xs' + (this, []) -> + [this] + +sortByFst :: Ord a => [(a, b)] -> [(a, b)] +sortByFst = sortBy (compare `on` fst) +