[Haskell-cafe] No Enum for (,), no Enum or Bounded for Either
Tom Ellis
tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Fri Jun 1 18:32:55 UTC 2018
True. I think I would propose
instance (Bounded a, Bounded b, Enum a, Enum b) => Enum (Either a b)
instance (Bounded a, Bounded b) => Enum (Bounded a b)
instance (Bounded a, Bounded b, Enum a, Enum b) => Enum (a, b)
On Fri, Jun 01, 2018 at 02:23:58PM -0400, Li-yao Xia wrote:
> One issue is that (Int, Int) is too big to define toEnum/fromEnum.
>
> On 06/01/2018 02:10 PM, Tom Ellis wrote:
> > 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.
More information about the Haskell-Cafe
mailing list