Just Foo { foo = 42 } is valid Haskell syntax. I actually take advantage of this in patterns sometimes, although it can definitely be a bit confusing. (And in expressions, I 100% would have extra parentheses, otherwise it's too visually confusing.)

On Tue, Aug 18, 2026 at 7:45 AM Johannes Waldmann via Haskell-Cafe <haskell-cafe@haskell.org> wrote:
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 -- haskell-cafe@haskell.org
To (un)subscribe, modify options or view archives go to:
Only members subscribed via the mailman list are allowed to post.