Proposal: add Bounded instances for Maybe and Either

Edward Kmett ekmett at gmail.com
Tue May 8 03:41:45 UTC 2018


Clever. I'm surprised those instances weren't already there.

On Mon, May 7, 2018 at 11:19 PM, David Feuer <david.feuer at gmail.com> wrote:

> 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 the
> Ord instances for the types in question.
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20180507/c729fff6/attachment.html>


More information about the Libraries mailing list