On 09 Jan 2005 07:56:58 +0100, Peter Simons <[EMAIL PROTECTED]> wrote:
> Jaime Nino writes:
> 
>  > I would like to write a function with type
>  >    next :: Enum a => a -> a
>  > which will wrap a values around [...].
> 
> You'll need (Bounded a, Enum a) to implement that. The
> function you are looking for is 'maxBound'. Enumerable types
> are not necessarily bounded in the general case, just think
> of the natural numbers for an example of an enumerable set
> that is not.
> 

He'll also need Eq a, right? How else does he investigate wether the
value is equal to maxBound?

One could use exceptions, I suppose, and catch the exception which
arises from trying to use succ on maxBound. But then  you'll need to
be in the IO monad, unless you use unsafePerformIO =)

/S
-- 
Sebastian Sylvan
+46(0)736-818655
UIN: 44640862
_______________________________________________
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to