
Thanks David,
I agree that having separate type classes for lower and upper bounds
would be the better design.
I really like your names, BoundedBelow and BoundedAbove, too!
Am Mi., 6. Mai 2020 um 21:13 Uhr schrieb David Feuer
The Bounded class is broken because it combines two distinct concepts: BoundedAbove and BoundedBelow. If Maybe is to have instances similar to what it has now, they should surely look like
instance BoundedBelow (Maybe a) where minBound = Nothing instance BoundedAbove a => BoundedAbove (Maybe a) where maxBound = Just maxBound
On Wed, May 6, 2020 at 1:52 PM Simon Jakobi via Libraries
wrote: Dear Henning,
I've re-read your email now and thought about it a bit more.
Unfortunately, Ord is dual use:
1. Comparison for magnitude as suggested by the mathematical symbols (<) and (>).
2. Some arbitrary but total order for use in Set and Map.
E.g. Set (Complex a) makes total sense, but 1:+0 > 0:+1 is unexpected. Ord instances on pairs is sensible for Set and Map, but (max (1,0) (0,1) == (1,0)) is strange.
Personally, I find nothing strange about (max (1,0) (0,1) == (1,0)), but I started wondering how other languages handle these examples. I tried Python:
$ python3 Python 3.5.2 (default, Apr 16 2020, 17:47:17) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information.
max((1,0),(0,1)) (1, 0) complex(1,0) > complex(0,1) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unorderable types: complex() > complex()
I also find the Ord Maybe instance quite intuitive: "Nothing is less than something (Just)"
It is also consistent with the interpretation of Maybe as a list of at most one element:
$ ghci
[] < [()] True
So in my view the Bounded Maybe instance still seems like a good idea.
Cheers, Simon _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries