[Haskell-cafe] better error messages for YAML
tdammers at gmail.com
Thu Nov 3 09:47:48 UTC 2016
I have a bit of a conundrum here.
The situation is such that I'm using the YAML package to parse YAML
configuration files; some of the values in the file format require
further parsing (using my own ginger library), and all that works fine.
One problem though; since this is aimed at end users, I want to preset
error messages that pinpoint the exact error location in case the ginger
parse fails. However, the ginger parser doesn't get to see the entire
YAML source, because it runs on just an individual string value inside
the YAML, and the YAML parser itself doesn't report source positions
either. The unfortunate result is that while I get "technically correct"
parser errors from Ginger, the source positions they report are relative
to the string value, i.e., all errors are reported as being on line 1 of
an unnamed source file.
The relevant code is here:
The only solution I can think of right now involves writing my own YAML
parser, and probably also an Aeson drop-in replacement; I don't really
want to do that though.
Is there any other way to get what I want?
Tobias Dammers - tdammers at gmail.com
More information about the Haskell-Cafe