mrkkrp / megaparsec

Industrial-strength monadic parser combinator library
Other
920 stars 87 forks source link

get col, row (as Int's) and error message of the first TrivialError #544

Closed KeesBleijenberg closed 1 year ago

KeesBleijenberg commented 1 year ago

The tutorial is not clear to me. It is about displaying error messages, not getting the value of the col and row. I can get the offset of an error. But how do I calculate the col and row from the offset?

mrkkrp commented 1 year ago

I think you are looking for attachSourcePos. You can run your parser with runParser' to get PosState s (it will be inside State s e).

KeesBleijenberg commented 1 year ago

Thank you. This solved the problem.