Combinators for ReadP

Malcolm Wallace Malcolm.Wallace at
Mon Jul 26 06:00:31 EDT 2004

John Meacham <john at> writes:

> possible to use ReadP as a simple standard (as in comes with the
> libraries) very lightweight parsing monad

Errm, "comes with the libraries" does not necessarily make it standard.
As the file header says, Text.ParserCombinators.ReadP is non-portable
because it uses local universal quantification.

Martin Sjögren <msjogren at> writes:

> While we're discussing changes, is there an overwhelmingly good reason
> for the use of local quantification beyond making the type signatures
> simpler? Writing
>   newtype ReadP r a = R ((a -> P r) -> P r)
> (like in ContT) would make ReadP completely Haskell98 as far as I can tell.

I think you'll find that without the local universal quantifier,
you cannot make ReadP a (useful) instance of Monad, because your
'r' parameter would be fixed across >>=, whereas it really needs to
be variable.


More information about the Libraries mailing list