<div dir="ltr"><div>I don't know if there is generally, but some people would use the lens library to do such things.<br><br>import Control.Lens<br>> sumOf (each . _Just) (Just 1, Nothing, Just 2)<br>3<br><br></div>Just keep in mind that each member of the tuple must be the same type.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 1, 2016 at 11:42 AM, Lai Boon Hui <span dir="ltr"><<a href="mailto:laiboonh@gmail.com" target="_blank">laiboonh@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi all,<div><br></div><div>Is it possible to sum a tuple of monoids for example</div><div><br></div><div>sum (Just 1, Nothing)<br clear="all"><div><br></div><div>expected result Just 1</div><div><br></div><div>sum (Just 1, Just 2)</div><div><br></div><div>expected result Just 3</div><span class="HOEnZb"><font color="#888888"><div><br></div>-- <br><div class="m_-1089990967628235132gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Best Regards,<div>Boon Hui</div></div></div>
</font></span></div></div>
<br>______________________________<wbr>_________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br></div>