[Haskell-cafe] Embarrassed Haskeller -- why is Read so bad? What are alternatives?

malcolm.wallace malcolm.wallace at me.com
Tue Oct 15 15:49:33 UTC 2013


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 messages.
Regards,
    Malcolm

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".

Argh!,
  -Ryan

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe at haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20131015/d6f3b1a1/attachment.html>


More information about the Haskell-Cafe mailing list