The point is that someone can write instance Monoid Thingy where mempty = <something> mappend a b = <something else> mconcat ls = <another thing> deriving instance Semigroup Thingy via (WrappedMonoid Thingy) Most of the benefit is not having to look up "stimesMonoid" over and over again. On Sat, Sep 14, 2019 at 3:36 PM John Villarreal via Libraries <libraries@haskell.org> wrote:
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 _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries