Instances of Read on bounded integral types should fail on overflow
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.
Trac metadata
| Trac field | Value |
|---|---|
| Version | |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | HaskellPrime |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |