<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Based on <a href="http://git.haskell.org/ghc.git/blob/refs/heads/ghc-7.10:/libraries/base/Data/Monoid.hs" class="">http://git.haskell.org/ghc.git/blob/refs/heads/ghc-7.10:/libraries/base/Data/Monoid.hs</a><div class="">only First and Last have Functor, Applicative and Monad; Foldable, Traversable and Data are missing.<br class=""><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 22 Feb 2015, at 09:56, Edward Kmett <<a href="mailto:ekmett@gmail.com" class="">ekmett@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Many instances for data types in Data.Monoid have already been added in 7.10.<div class=""><br class=""></div><div class="">Are these still missing?</div><div class=""><br class=""></div><div class="">-Edward</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Sat, Feb 21, 2015 at 10:34 AM, Oleg Grenrus <span dir="ltr" class=""><<a href="mailto:oleg.grenrus@iki.fi" target="_blank" class="">oleg.grenrus@iki.fi</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I propose to add Functor, Applicative, Monad, Foldable, and Traversable and maybe even MonadFix instances to wrapper newtypes in the Data.Monoid module.<br class="">
The same way as in the semigroups package, e.g. <a href="https://hackage.haskell.org/package/semigroups-0.16.1/docs/Data-Semigroup.html#t:Min" target="_blank" class="">https://hackage.haskell.org/package/semigroups-0.16.1/docs/Data-Semigroup.html#t:Min</a> <<a href="https://hackage.haskell.org/package/semigroups-0.16.1/docs/Data-Semigroup.html#t:Min" target="_blank" class="">https://hackage.haskell.org/package/semigroups-0.16.1/docs/Data-Semigroup.html#t:Min</a>><br class="">
<br class="">
Basically:<br class="">
<br class="">
instance Functor Sum where<br class="">
fmap f (Sum x) = Sum (f x)<br class="">
<br class="">
instance Foldable Sum where<br class="">
foldMap f (Sum a) = f a<br class="">
<br class="">
instance Traversable Sum where<br class="">
traverse f (Sum a) = Sum <$> f a<br class="">
<br class="">
instance Applicative Sum where<br class="">
pure = Sum<br class="">
a <* _ = a<br class="">
_ *> a = a<br class="">
Sum f <*> Sum x = Sum (f x)<br class="">
<br class="">
instance Monad Sum where<br class="">
return = Sum<br class="">
_ >> a = a<br class="">
Sum a >>= f = f a<br class="">
<br class="">
instance MonadFix Sum where<br class="">
mfix f = fix (f . getSum)<br class="">
<br class="">_______________________________________________<br class="">
Libraries mailing list<br class="">
<a href="mailto:Libraries@haskell.org" class="">Libraries@haskell.org</a><br class="">
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" target="_blank" class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br class="">
<br class=""></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></div></body></html>