[Haskell-cafe] ReadS with Maybe

Jon Cast jcast at ou.edu
Wed Jan 5 11:11:22 EST 2005

Henning Thielemann <lemming at henning-thielemann.de> wrote:

> What is the reason for the definition

>  ReadS a = [(a, String)]

> not being

>  ReadS a = Maybe (a, String)

> ? The latter one reflects that either one or no value is read, whereas
> the first definition allows an arbitrary number of read values which
> is confusing and unsafe in my opinion.

List is a backtracking monad, while Maybe is merely an error monad.  You
have to have backtracking to bet better than LL(1) or LR(1) parsing, and
LL(1) is not an acceptable restriction for a fundamental function like

Jonathan Cast

More information about the Haskell-Cafe mailing list