Hello, this is about a change in the prelude I'd like to suggest.

The following is obviously not what one would expect:

  Prelude> succ 10000000000::Integer

  Program error: {primIntegerToInt 10000000000}


However, with the prelude defining succ to be

  succ,                :: Enum a => a -> a
  succ                 =  toEnum . (+1) . fromEnum

we can't hope for anything better.

My suggestion is to make succ a member function of class Enum, with
the old definition as default, so that the instance Enum Integer
can define it to be simply (+1).

Another example is
  data Nat = Zero | Succ Nat
where succ=Succ is not only more natural, but also much more
efficient.

Of course the same holds for pred.

What do you think?
Are there any drawbacks?
Could it be like this in standard haskell?


Christian Sievers


Reply via email to