[Haskell-cafe] better error messages for YAML
michael at snoyman.com
Thu Nov 3 09:55:01 UTC 2016
The Text.Libyaml module provides a streaming interface, which allows
more flexibility and doesn't jump through the aeson Value type at all.
Currently, it doesn't include location information, but I _think_ the
underlying libyaml C library makes that information available. I'd
certainly be open to a PR to add something like:
decodeWithPosition :: ByteString -> Producer m (Event, Position)
And that way you don't have to rewrite a parser or the FFI bindings.
On Thu, Nov 3, 2016 at 11:47 AM, Tobias Dammers <tdammers at gmail.com> wrote:
> Hello cafe,
> 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
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe