8 import Text.Regex.Posix
11 die errs = do mapM_ (hPutStrLn stderr) errs
14 dieOnErrors :: Either Errors a -> IO a
15 dieOnErrors (Left errs) = die errs
16 dieOnErrors (Right x) = return x
18 type Errors = [String]
20 maybeRead :: Read a => String -> Maybe a
21 maybeRead str = case reads str of
25 re :: String -> String -> Maybe [String]
26 re r str = case matchM r' str :: Maybe (String, String, String, [String]) of
27 Just (_, _, _, ms) -> Just ms
29 where r' = makeRegex r :: Regex
31 unSepList :: Eq a => a -> [a] -> [[a]]
32 unSepList x xs = case break (x ==) xs of
34 this : unSepList x xs'
38 sortByFst :: Ord a => [(a, b)] -> [(a, b)]
39 sortByFst = sortBy (compare `on` fst)