[Haskell-cafe] No Enum for (,), no Enum or Bounded for Either

Jon Fairbairn jon.fairbairn at cl.cam.ac.uk
Sat Jun 2 09:36:56 UTC 2018


Tom Ellis <tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk> writes:

> I'm a bit surprised that whilst `Either` and `(,)` have instances for `Ord`
>
> * `(,)` has no instance for `Enum`
> * `Either` has no instance for `Enum` or `Bounded`
>
> Is there a particular reason for that?  It might be tricky to implement
>
>     toEnum :: Int -> a
>     fromEnum :: a -> Int
>
> but in the presence of `Bounded` that should be possible.

You don’t need Bounded to do that. For example, you could start
at (0,0) and go out in diamond shaped rings. A more pressing
reason is that there are too many possible enumerations, and if
we picked one it would probably be the wrong one for most
applications.

-- 
Jón Fairbairn                                 Jon.Fairbairn at cl.cam.ac.uk




More information about the Haskell-Cafe mailing list