[Haskell-cafe] RE: Enum class

Arjun Guha GUHAARJU at grinnell.edu
Sun Jan 9 07:54:51 EST 2005


Well, you already have succ:: (Enum a) => a -> a defined for all data of the 
Enum class.  You also need Bounded so that you can check maxBound.


This (untested) code should do it:

> next:: (Enum a, Bounded a) => a -> a
> next v = if (toEnum v) == (toEnum (maxBound))
>            then minBound
>            else succ v

--
Arjun Guha <guhaarju at grinnell.edu>



More information about the Haskell-Cafe mailing list