Behavior of fromInteger on out-of-range arguments

Wolfgang Jeltsch wolfgang@jeltsch.net
Tue, 26 Feb 2002 22:41:00 +0100


On Tuesday, February 26, 2002, 15:36:18 EST, David Feuer wrote:
> [...]
> Question:  Is there any standard way in Haskell of determining the maximal 
> and minimal Int values?

There is one. Use maxBound :: Int and minBound :: Int.

> [...]

By the way, the report says: "Class Enum defines operations on sequentially 
ordered types." I think the "sequentially" means that multiple applications 
of succ to a value shall not result in the same value. That's why I think 
that succ (maxBound :: Int) should be an error and not minBound :: Int. 
Because i + 1 should be equal to succ i for every Int value i, (maxBound :: 
Int) + 1 should also be an error and so should every arithmetic operation 
that overflows or underflows.

Wolfgang