<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Sep 7, 2015 at 10:08 AM, DreamApart AtHaskells <span dir="ltr"><<a href="mailto:rnmss.hs@gmail.com" target="_blank">rnmss.hs@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="gmail_default" style="font-family:'courier new',monospace">The class <span style="background-color:rgb(255,242,204)">Num</span> defines the method functions like <span style="background-color:rgb(255,242,204)">(+)</span>, <span style="background-color:rgb(255,242,204)">(-)</span>, <span style="background-color:rgb(255,242,204)">(*)</span>, <span style="background-color:rgb(255,242,204)">negate</span>, ...</div><div class="gmail_default" style="font-family:'courier new',monospace">But they are actually different concepts.</div><div class="gmail_default" style="font-family:'courier new',monospace"><br></div><div class="gmail_default" style="font-family:'courier new',monospace">We often meet situations that we want an addition for some type, but</div><div class="gmail_default" style="font-family:'courier new',monospace">not a multiplication. For example:</div><div class="gmail_default" style="font-family:'courier new',monospace"></div></blockquote></div><br>I think the concept you're reaching for here is Monoid. However, there is a(t least one) complication you did not consider:</div><div class="gmail_extra"><br></div><div class="gmail_extra">(+) is assuredly a monoid.</div><div class="gmail_extra">But so is (*)! (Try looking at it through logarithms.)</div><div class="gmail_extra">Unfortunately, a given type can have only a single instance of a given typeclass.<br><br>There is in fact a way to design Num "rationally", via number theory; I suggest you at least familiarize yourself with that. (This will bring you face to face with the above issue, as it turns out that Num requires two monoids.) It turns out that this is not necessarily a good idea. But see <a href="http://hackage.haskell.org/package/numeric-prelude">http://hackage.haskell.org/package/numeric-prelude</a> for an implementation of it.<br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div>brandon s allbery kf8nh                               sine nomine associates</div><div><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a>                                  <a href="mailto:ballbery@sinenomine.net" target="_blank">ballbery@sinenomine.net</a></div><div>unix, openafs, kerberos, infrastructure, xmonad        <a href="http://sinenomine.net" target="_blank">http://sinenomine.net</a></div></div></div>
</div></div>