Edward Kmett
2018-05-09 02:15:40 UTC
minBound = Left minBound <= Left a < Right b <= Right maxBound = maxBound
fits with the behavior of the existing Ord instance.
On the other hand, Left (), being strictly less than minBound would rather
drastically undermine the expected interaction of Ord and Bounded.
-Edward
On Tue, May 8, 2018 at 1:06 AM, Ivan Lazar Miljenovic <
`minBound = Right minBound` as well. Though as Maybe and Either don't
have Enum instances this may be less of an issue.
--
Ivan Lazar Miljenovic
http://IvanMiljenovic.wordpress.com
_______________________________________________
Libraries mailing list
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
fits with the behavior of the existing Ord instance.
On the other hand, Left (), being strictly less than minBound would rather
drastically undermine the expected interaction of Ord and Bounded.
-Edward
On Tue, May 8, 2018 at 1:06 AM, Ivan Lazar Miljenovic <
We can write
instance Bounded a => Bounded (Maybe a) where
minBound = Nothing
maxBound = Just maxBound
instance (Bounded a, Bounded b) => Bounded (Either a b) where
minBound = Left minBound
maxBound = Right maxBound
While Bounded intentionally does not have an Ord superclass, I think it's
worth mentioning that these are the instances that arise naturally from
theinstance Bounded a => Bounded (Maybe a) where
minBound = Nothing
maxBound = Just maxBound
instance (Bounded a, Bounded b) => Bounded (Either a b) where
minBound = Left minBound
maxBound = Right maxBound
While Bounded intentionally does not have an Ord superclass, I think it's
worth mentioning that these are the instances that arise naturally from
Ord instances for the types in question.
Except these may be surprising to people; e.g. someone may expect that`minBound = Right minBound` as well. Though as Maybe and Either don't
have Enum instances this may be less of an issue.
--
Ivan Lazar Miljenovic
http://IvanMiljenovic.wordpress.com
_______________________________________________
Libraries mailing list
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries