Using the MegaParsec parse
function, I'm able to run a parser, and get a ParseErrorBundle
if it fails.
I know that I'm able to pretty print the ParseErrorBundle
, and get an error message for the entire parse failure, which will include the line and character numbers, using errorBundlePretty
.
I also know that I'm able to get a list of ParseError
's from a ParseErrorBundle
, using bundleErrors
. And that I can pretty print these with either parseErrorPretty
or parseErrorTextPretty
.
I want to be able to run a parser, and if it fails, get a list of (SourcePos, Text)
, so that I know both the individual error messages, and the location of each error.
I can't figure out an elegant way to do this. While I could in theory crib fairly heavily from the source code to errorBundlePretty
, I feel like folding over the errors and using reachOffset
to advance the PosState
can't be the easiest way to go about this?.