megaparsec/old-tests/Util.hs

14 lines
304 B
Haskell

module Util where
import Text.Megaparsec
import Text.Megaparsec.String (Parser)
-- | Returns the error messages associated with a failed parse.
parseErrors :: Parser a -> String -> [String]
parseErrors p input =
case parse p "" input of
Left err -> drop 1 $ lines $ show err
Right _ -> []