[Haskell-cafe] Embarrassed Haskeller -- why is Read so bad? What are alternatives?
rrnewton at gmail.com
Tue Oct 15 20:46:51 UTC 2013
Also, any way to get line numbers in the errors when parsing a big string?
On Tue, Oct 15, 2013 at 3:38 PM, Ryan Newton <rrnewton at gmail.com> wrote:
> Hmm, currently trying to learn how to incorporate DriFT into a cabal
> package. Polyparse doesn't support any other deriving mechanisms does it?
> (GHC.Generics, or TemplateHaskell based, or Neil Mitchell's "derive"
> On Tue, Oct 15, 2013 at 3:01 PM, Ryan Newton <rrnewton at gmail.com> wrote:
>> That looks perfect and that is exactly what my googling failed to turn up.
>> On Tue, Oct 15, 2013 at 11:49 AM, malcolm.wallace <malcolm.wallace at me.com
>> > wrote:
>>> The polyparse package has a complete drop-in replacement for Read,
>>> called Text.Parse. Its lexer is derived closely from Haskell Prelude lex.
>>> It already has instances for all of the standard datatypes, and you can
>>> use DrIFT to generate instances for any datatypes outside the usual Prelude
>>> types. The parser is fast, lazy, and space-efficient. It gives good error
>>> On 15 Oct, 2013,at 04:01 PM, Ryan Newton <rrnewton at gmail.com> wrote:
>>> We have great tools for [de]serializing both to binary and to JSON
>>> (binary, cereal, json, aeson, etc). But we have rather weak support for
>>> [de]serializing to human readable Haskell-ish external formats.
>>> Read instances are both (1) slow, because they take Strings, and (2)
>>> they don't allow sensible error messages! (Historical decision choosing
>>> Maybe rather than Either.)
>>> Right now I'm working on a project with a Racketeer who is trying to
>>> read a 6000 line file as a single list data structure. The derived Read
>>> instance is just telling him it won't parse, with NO error information,
>>> line number etc. To someone used to Scheme readers, that's rather poor.
>>> I wish I had something better to tell him! I am not aware of a library
>>> to recommend other than switching to JSON format on disk. OR manually
>>> kludging together a parsing hack that, for example, puts one element of the
>>> list on each line and makes much smaller calls to "read".
>>> Haskell-Cafe mailing list
>>> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe