6 import Text.Regex.Posix
9 die errs = do mapM_ (hPutStrLn stderr) errs
12 dieOnErrors :: Either Errors a -> IO a
13 dieOnErrors (Left errs) = die errs
14 dieOnErrors (Right x) = return x
16 type Errors = [String]
18 maybeRead :: Read a => String -> Maybe a
19 maybeRead str = case reads str of
23 re :: String -> String -> Maybe [String]
24 re r str = case matchM r' str :: Maybe (String, String, String, [String]) of
25 Just (_, _, _, ms) -> Just ms
27 where r' = makeRegex r :: Regex
29 unSepList :: Eq a => a -> [a] -> [[a]]
30 unSepList x xs = case break (x ==) xs of
32 this : unSepList x xs'