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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Dannyu NDos
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

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

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

Dannyu NDos

---------- Forwarded message ---------
보낸사람: Dannyu NDos <[hidden email]>
Date: 2019년 8월 7일 (수) 04:50
Subject: Re: Add instance Monoid ((f :+: g) a)
To: Haskell Libraries <[hidden email]>


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

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries