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

Tom Ellis tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Sat Jun 2 09:48:45 UTC 2018


On Sat, Jun 02, 2018 at 10:36:56AM +0100, Jon Fairbairn wrote:
> 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.

This is all true, but I was implicitly assuming that Bounded and Enum ought
to agree with Ord.  We've already picked Ords for (,) and Either so why not
also pick the Enums and Boundeds that agree with them?


More information about the Haskell-Cafe mailing list