Combinators for ReadP

Martin Sjögren msjogren at
Tue Jul 27 10:15:42 EDT 2004

On Tue, 27 Jul 2004 14:31:21 +0100, Simon Peyton-Jones
<simonpj at> wrote:
> You could do this, I believe, but it'd make ReadP less covenient for most users, because they'd have to add these redundant (and inexplicable) 'r' parameters.  By "inexplicable" I mean that given a value
>         p::ReadP r a
> we can say that p is a parser that parses some input, returning a value of type 'a'... but what's this 'r' thing?
> Wrapping up a polymorphic fn in a newtype is very standard, even though it is not H98.
> I'd be pretty reluctant to make this change

Oh I agree. Having to pass around the extra parameter sucks.
Unfortunately, nhc98 doesn't support forall. :) Would it be possible
to do something like

newtype Parser r a = R ((a -> P r) -> P r)
#ifndef __NHC98__
type ReadP a = forall r. Parser r a

or something like that? Would that work? Does it even make sense?


More information about the Libraries mailing list