Transmitting Haskell values

Simon Peyton-Jones simonpj at
Wed Oct 29 11:47:31 EST 2003

| > The GHC versions are simply more efficient versions.  Show and Read
| > completely portable.
| AIIEE!  Now they tell me -- I've optimized one of my programs, and it
| now spends most of it's time 'read'ing.  So the thing is just to
| import GHC(read) instead of using the Prelude version?  I guess it's
| worth a try (although I expect I really need to go to binary IO)

No, you get the efficient ones when you import the Prelude.  GHC's Read
class has two extra methods, readPrec and readListPrec, which read using
a parser monad rather than the 'list of successes' that is (sadly) built
into the definition of the standard Read class.

When defining a new type, and making a Read instance for it, you'll get
more efficient reading if you define GHC's Read methods (the normal
readsPrec and readList will then be defined in terms of them).  There
are many examples in GHC.Base.Read

The underlying parser technology is Koen Claessens's parallel parser

This new parsing stuff is hardly documented at all (e.g.
.  If anyone would like to remedy this by writing Haddock documentation,
it'd be great.  (I'd be glad to hand-hold.)


More information about the Glasgow-haskell-users mailing list