Ticket #126 (new modification)

Opened 1 year ago

Instances of Read on bounded integral types should fail on overflow

Reported by: bos@serpentine.com Assigned to: ijones
Priority: major Milestone:
Component: HaskellPrime Version:
Keywords: Cc:
Impact: Adopt:
Topic: Unclassfied

Description

The behaviour of the instances of Read on bounded integral types in H98 is rather unfortunate:

{{{> read "33333333333333333333333333333" :: Int -3520117339065068203}}}

The behaviour is similar for types in Data.Int and Data.Word.

It would be much better if such instances were to detect wraparound errors, and throw an exception. Having parsers silently do the wrong thing is rather at odds with the language's goal of safety.

I will be happy to provide a sample implementation that does the right thing, upon request.