logo       

Re: ReadS with Maybe: msg#00046

lang.haskell.cafe

Subject: Re: ReadS with Maybe

Henning Thielemann <lemming@xxxxxxxxxxxxxxxxxxxxx> 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
read.

Jonathan Cast


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise