Haskell 98: Enum class

Dylan Thurston dpt@math.harvard.edu
Thu, 25 Oct 2001 00:07:45 +0900

On Wed, Oct 24, 2001 at 07:51:12AM -0700, Simon Peyton-Jones wrote:
> The Report is (regrettably) silent about what the Integer
> instances for succ and pred should be, but they should definitely simply
> add 1 (resp subtract 1).  They should emphatically not use the default
> methods.   I will add something to that effect in 6.3.4.
> ...
> 3.  Specify that succ and pred on numeric types just add/subtract 1
> (subject to (2) above).

Can you write some code people can cut&paste for instance of Enum on
ordered numeric types, just so this is crystal clear?  You might even
put in some bounds checking:

succ x = let y = x+1 in if y > x then y else error "succ overflowed"