Add newtype for Alternative using QuantifiedConstraints in base-4.13

Carter Schonwald carter.schonwald at gmail.com
Sat Feb 16 00:11:35 UTC 2019


this looks quite pretty, though I must admit that im not the most savvy at
quantified constraints yet

wouldn't this newtype also benefit from a semigroup and monoid instance
too? (or am I overlooking some reason why you can't do them too?)

On Fri, Feb 15, 2019 at 7:05 PM theindigamer <theindigamer15 at gmail.com>
wrote:

> Thoughts on adding a newtype with the following Alternative instance?
>
> (The name chosen is a placeholder, I don't have any particular preference).
>
> newtype Mon f a = Mon { unMon :: f a }
>
> instance (forall a. Monoid (f a)) => Alternative (Mon f) where
>   empty = Mon mempty
>   (<|>) (Mon m1) (Mon m2) = Mon (m1 <> m2)
>
> _______________________________________________
> 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/20190215/3d10b8f9/attachment.html>


More information about the Libraries mailing list