<div dir="ltr">The BoundedEnum thing is already something of a sunk cost, since there's already magic behavior of Enum when a type is also Bounded. (Go look at how Enum deriving is specified.)</div><br><div class="gmail_quote"><div dir="ltr">On Fri, Jun 1, 2018 at 3:28 PM MarLinn <<a href="mailto:monkleyon@gmail.com">monkleyon@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div 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="m_-5603657107320096703moz-cite-prefix">On 2018-06-01 20:32, Tom Ellis wrote:<br>
</div>
<blockquote type="cite">
<pre>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>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>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>
</div>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>brandon s allbery kf8nh sine nomine associates</div><div><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a> <a href="mailto:ballbery@sinenomine.net" target="_blank">ballbery@sinenomine.net</a></div><div>unix, openafs, kerberos, infrastructure, xmonad <a href="http://sinenomine.net" target="_blank">http://sinenomine.net</a></div></div></div>