Hello Georgi,


I'm confused about WrappedMonoid. How can something have a Monoid instance already without having a Semigroup instance in the first place?

But also what is the benefit of WrappedMonoid over the standard way of defining Semigroups and Monoids for your example

data List a = Nil | Cons a (List a)

instance Semigroup (List a) where
  Nil       <> ys = ys
  Cons x xs <> ys = Cons x (xs <> ys)

instance Monoid (List a) where mempty = Nil

?

Cheers,
John


On Saturday, 14 September 2019, 19:18:01 UTC, Georgi Lyubenov <godzbanebane@gmail.com> wrote:


Hello!

Sorry if this is not the right place to ask!

As of right now (14.09.2019) Data.Semigroup.WrappedMonoid is slated to be deprecated.

I believe that this newtype is actually useful in tandem with DerivingVia, as it allows you to derive the Semigroup instance for something that has a Monoid instance already, as discussed in this twitter thread.

Would it be possible to *not* deprecate it in the future, and instead keep it around for exactly this purpose?

Cheers,
Georgi
_______________________________________________
Libraries mailing list
Libraries@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries