like "deriving Read" but faster?

Johannes Waldmann via Haskell-Cafe <[email protected]>
Newsgroups gmane.comp.lang.haskell.cafe
Message-ID <[email protected]>
Dear Cafe,

I could use a parser that is equivalent
to the one produced by "deriving Read" but ...

A) faster, and using less space (Data.Text(.Lazy) instead of String)
B) streaming (parse a long list literal "[0,1,2, ... ]" in constant space,
   produce the first cons of the result right after reading "[0")
C) with some minimal error reporting (e.g., some prefix of not-consumed input)

perhaps attoparsec with some form of early-commited choice?

I do have something (only for A) at
https://codeberg.org/jwaldmann/text-read  (attoparsec on lazy text)
and it seems twice as fast as "deriving Read" in my tests.


NB: I was quite shocked to see that "deriving Read" accepts
"Just Foo { foo = 42 }" (no parentheses around the record literal)
(while "deriving Show" produces them).

- J.W.

_______________________________________________
Haskell-Cafe mailing list -- [email protected]
To (un)subscribe, modify options or view archives go to:
Only members subscribed via the mailman list are allowed to post.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.