<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Counterargument: overlapping instances<br>
</p>
<pre> instance (Bounded b, Enum b) => Enum (Either a b)
instance (Bounded b) => Bounded (Either a b)
instance (Applicative f, Bounded a) => Bounded (f a)
instance (Bounded a, Enum a) => Enum (Either a b)
instance (Bounded a) => Bounded (Either a b)
instance (Bounded a, Enum a, Monoid b) => Enum (a, b)
instance (Bounded b, Enum b, Monoid a) => Enum (a, b)
</pre>
Also note that what you're talking about is a special type of
objects, namely<br>
<pre> type BoundedEnum a = (Bounded a, Enum a) -- using ConstraintKinds</pre>
(I'm sure the mathematicians have a better name for this)<br>
<br>
So IF someone where to add these somewhere, might I suggest also
adding essentials like<br>
<pre> enumAll :: (Bounded a, Enum a) => [a]
-- i.e. enumAll :: (BoundedEnum a) => [a]
</pre>
Lastly, because it's its own type of objects, I'm sure there's a
library out there doing just that. (Plus maybe other stuff like
EnumMap's).<br>
<br>
<div class="moz-cite-prefix">On 2018-06-01 20:32, Tom Ellis wrote:<br>
</div>
<blockquote type="cite"
cite="mid:20180601183255.eukdyjlxbq6jq4bs@weber">
<pre wrap="">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:
</pre>
<blockquote type="cite">
<pre wrap="">One issue is that (Int, Int) is too big to define toEnum/fromEnum.
On 06/01/2018 02:10 PM, Tom Ellis wrote:
</pre>
<blockquote type="cite">
<pre wrap="">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.
</pre>
</blockquote>
</blockquote>
</blockquote>
<br>
</body>
</html>