megaparsec/old-tests/Util.hs

14 lines
304 B
Haskell
Raw Normal View History

2014-09-25 05:10:39 +04:00
module Util where
import Text.Megaparsec
import Text.Megaparsec.String (Parser)
2015-07-28 16:32:19 +03:00
-- | Returns the error messages associated with a failed parse.
2014-09-25 05:10:39 +04:00
parseErrors :: Parser a -> String -> [String]
parseErrors p input =
case parse p "" input of
2015-07-28 16:32:19 +03:00
Left err -> drop 1 $ lines $ show err
Right _ -> []