Fwd: Add instance Monoid ((f :+: g) a)

Dannyu NDos ndospark320 at gmail.com
Tue Aug 6 19:51:15 UTC 2019


---------- Forwarded message ---------
보낸사람: Dannyu NDos <ndospark320 at gmail.com>
Date: 2019년 8월 7일 (수) 04:50
Subject: Re: Add instance Monoid ((f :+: g) a)
To: Haskell Libraries <libraries at haskell.org>


Ah, sorry. (:+:) is not an Applicative. It's still possible to make
instance Monoid:

instance Semigroup (f a) => Semigroup ((f :+: g) a) where
    InL x <> InL y = InL (x <> y)
    InL _ <> y = y
    x <> _ = x

instance Monoid (f a) => Monoid ((f :+: g) a) where
    mempty = InL mempty
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20190807/b977fb2d/attachment.html>


More information about the Libraries mailing list