mwin...@brocku.ca wrote:
Hi,
I am using parsec to parse a small programming language. The language is typed
and
I need to do some type checking, too. I have decided to do the parsing and type
checking
simultaneously in the my parsec parser. This approach avoids to keep source
code positions
in the data type in order to produce suitable error messages during type
checking. Anyhow,
because type errors are usually detected after parsing some code I need produce
error
messages with an earlier source position. Unfortunately, there is no function that produces
an error taking a position as parameter.
If you already know what position you want to report the error at, then
why bother calling setPosition to let parsec know? Just do:
> fail (show pos ++ ": " ++ msg)
Parsec will then result in a ParseError with its own ideas of location,
but you can ignore that.
HTH,
Martijn.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe