logo       

RE: RE: Enum class: msg#00129

lang.haskell.cafe

Subject: RE: RE: Enum class

Sorry, that was a stupid error. I meant to use fromEnum:

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

I don't think this will quite work if fromEnum:: a -> Int for type a, were not
injective. However, that might be part of the specification... I don't
remember.

It should be fine, so long as the preimage of (fromEnum maxBound) is
{maxBound}.

-Arjun

--
Arjun Guha <guhaarju@xxxxxxxxxxxx>


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise