Перейти до Домашньої сторінки Груп Google    comp.lang.haskell
Re: reads

Dirk Thierbach <dthierb...@usenet.arcornews.de>

Mark T.B. Carroll <Mark.Carr...@aetion.com> wrote:

> Frank Poettgen <Frank.Poett...@Post.RxWyTxH-AyAzCyHzEyN.de> writes:

>> I would expect

>> reads "1.2" :: [(Int,String)]

>> to be evaluated to

>> [(1,".2")]

>> but using Hugs (Version Sep 2006) it is just

>> []

>> Bug or feature?
> Good question. GHCi, version 6.8.2, agrees with Hugs.

The reason at least in GHC is that all numeric instances use the same
function to parse the string. The string is then converted, unless
conversion fails. Because of that, one also gets e.g.

> reads "1e2" :: [(Int,String)]

[(100,"")]

AFAIK the report doesn't specify exactly how to parse a number, so I
strongly suspect "feature". But I never noticed that before, too.

- Dirk