<div dir="ltr"><div class="gmail_default"><font face="monospace, monospace"><span style="font-size:14px">No, I didn't know there such wiki page. Thank you.</span></font></div><div class="gmail_extra"><br><div class="gmail_quote">2015-09-08 4:05 GMT+08:00 Alexey Muranov <span dir="ltr"><<a href="mailto:alexey.muranov@gmail.com" target="_blank">alexey.muranov@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">You saw this, right?<div><br></div><div><a href="https://wiki.haskell.org/Nitpicks#Base-related_nitpicks" target="_blank">https://wiki.haskell.org/Nitpicks#Base-related_nitpicks</a></div><div><br></div><div>(Just in case, maybe it was you who included this topic.)</div><span class="HOEnZb"><font color="#888888"><div><br></div></font></span><div><span class="HOEnZb"><font color="#888888">Alexey.</font></span><div><div class="h5"><br><br>On Monday, September 7, 2015 at 4:08:54 PM UTC+2, DreamApart AtHaskells wrote:<blockquote class="gmail_quote" style="margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div 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 style="font-family:'courier new',monospace">But they are actually different concepts.</div><div style="font-family:'courier new',monospace"><br></div><div style="font-family:'courier new',monospace">We often meet situations that we want an addition for some type, but</div><div style="font-family:'courier new',monospace">not a multiplication. For example:</div><div style="font-family:'courier new',monospace"><br></div><div style="font-family:'courier new',monospace"> <b><font color="#000000">data</font></b> <font color="#6aa84f">Vec3</font> = <font color="#bf9000">Vec3</font> <font color="#6aa84f">Float Float Float</font></div><div style="font-family:'courier new',monospace"><br></div><div style="font-family:'courier new',monospace">The additive (and subtractive) operation is obvious, but not for a</div><div style="font-family:'courier new',monospace">multiplication.</div><div style="font-family:'courier new',monospace"><br></div><div style="font-family:'courier new',monospace"><font color="#999999"><i> Note</i></font></div><div style="font-family:'courier new',monospace"><span style="background-color:rgb(255,255,255)"><br></span></div><div style="font-family:'courier new',monospace"><span style="background-color:rgb(255,255,255)"> </span><font style="background-color:rgb(255,255,255)" color="#bf9000">(*)</font><span style="background-color:rgb(255,255,255)"> :: <font color="#6aa84f">a</font> -> </span><span style="color:rgb(106,168,79)">a</span><span style="background-color:rgb(255,255,255)"> -> </span><span style="color:rgb(106,168,79)">a</span><span style="background-color:rgb(255,255,255)"> </span><font style="background-color:rgb(255,255,255)" color="#990000">-- not avaliable for a Vec3</font><br></div><div style="font-family:'courier new',monospace"><span style="background-color:rgb(255,255,255)"><br></span></div><div style="font-family:'courier new',monospace"> <font color="#bf9000">scale</font> :: <font color="#6aa84f">Float</font> -> <font color="#6aa84f">Vec3</font> -> <span style="color:rgb(106,168,79)">Vec3</span></div><div style="font-family:'courier new',monospace"> <font color="#bf9000">dot</font> :: <span style="color:rgb(106,168,79)">Vec3</span> -> <span style="color:rgb(106,168,79)">Vec3</span> -> <span style="color:rgb(106,168,79)">Float</span></div><div style="font-family:'courier new',monospace"><br></div><div style="font-family:'courier new',monospace">We cannot define a <span style="background-color:rgb(255,242,204)">(+)</span> alone for a type, so we got many different functions</div><div style="font-family:'courier new',monospace">from different libs, like <span style="background-color:rgb(255,242,204)">mappend</span>, <span style="background-color:rgb(255,242,204)">mplus</span>, <span style="background-color:rgb(255,242,204)">plus</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)">(+.)</span>, which all reads</div><div style="font-family:'courier new',monospace">"plus".</div><div style="font-family:'courier new',monospace"><br></div><div style="font-family:'courier new',monospace">My opinion is that the methods of <span style="background-color:rgb(255,242,204)">Num</span> should be seperated into different type</div><div style="font-family:'courier new',monospace">classes, so we don't need to invent a new symbol for a new lib.</div><div style="font-family:'courier new',monospace"><br></div><div><font face="courier new, monospace">A feasible design is:</font></div><div style="font-family:'courier new',monospace"><br></div><div><div><font face="courier new, monospace"> <b>import</b> <font color="#c27ba0">Prelude</font> <b>hiding</b> ( <font color="#6aa84f">Num</font> (..), <font color="#38761d">Monoid</font> (..), sum )</font></div><div><br></div><div><font face="courier new, monospace"> <b>class</b> <font color="#3d85c6">SemiGroup</font> </font><span style="color:rgb(56,118,29);font-family:'courier new',monospace">a</span><font face="courier new, monospace"> <b>where</b></font></div><div><font face="courier new, monospace"> <font color="#bf9000">(+)</font> :: <font color="#38761d">a</font> -> </font><span style="color:rgb(56,118,29);font-family:'courier new',monospace">a</span><font face="courier new, monospace"> -> </font><span style="color:rgb(56,118,29);font-family:'courier new',monospace">a</span></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"> <b>class</b> </font><span style="color:rgb(61,133,198);font-family:'courier new',monospace">SemiGroup</span><font face="courier new, monospace"> </font><span style="color:rgb(56,118,29);font-family:'courier new',monospace">a</span><font face="courier new, monospace"> => <font color="#3d85c6">Monoid</font> </font><span style="color:rgb(56,118,29);font-family:'courier new',monospace">a</span><font face="courier new, monospace"> </font><b style="font-family:'courier new',monospace">where</b></div><div><font face="courier new, monospace"> <font color="#bf9000">zero</font> :: </font><span style="color:rgb(56,118,29);font-family:'courier new',monospace">a</span></div><div><span style="color:rgb(56,118,29);font-family:'courier new',monospace"> </span></div><div><font face="courier new, monospace"> <b>class</b> </font><span style="color:rgb(61,133,198);font-family:'courier new',monospace">Monoid</span><font face="courier new, monospace"> </font><span style="color:rgb(56,118,29);font-family:'courier new',monospace">a</span><font face="courier new, monospace"> => <font color="#3d85c6">Group</font> </font><span style="color:rgb(56,118,29);font-family:'courier new',monospace">a</span><font face="courier new, monospace"> </font><b style="font-family:'courier new',monospace">where</b></div><div><font face="courier new, monospace"> <font color="#bf9000">negate</font> :: </font><font face="courier new, monospace"><font color="#38761d">a</font> -> </font><span style="color:rgb(56,118,29);font-family:'courier new',monospace">a</span></div><div><font face="courier new, monospace"> <font color="#bf9000">(-)</font> :: </font><font face="courier new, monospace"><font color="#38761d">a</font> -> </font><span style="color:rgb(56,118,29);font-family:'courier new',monospace">a</span><font face="courier new, monospace"> -> </font><span style="color:rgb(56,118,29);font-family:'courier new',monospace">a</span></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"> x <font color="#bf9000">-</font> y = x + negate y</font></div><div><font face="courier new, monospace"> <font color="#bf9000">negate</font> x = zero - x </font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"> </font><b style="font-family:'courier new',monospace">class</b><font face="courier new, monospace"> </font><span style="color:rgb(61,133,198);font-family:'courier new',monospace">Group</span><font face="courier new, monospace"> </font><span style="color:rgb(56,118,29);font-family:'courier new',monospace">a</span><font face="courier new, monospace"> => <font color="#3d85c6">Ring</font> </font><span style="color:rgb(56,118,29);font-family:'courier new',monospace">a</span><font face="courier new, monospace"> </font><b style="font-family:'courier new',monospace">where </b><span style="font-family:'courier new',monospace"><font color="#990000">-- not sure about the name ...</font></span></div><div><font face="courier new, monospace"> <font color="#bf9000">(*)</font> :: </font><font face="courier new, monospace"><font color="#38761d">a</font> -> </font><span style="color:rgb(56,118,29);font-family:'courier new',monospace">a</span><font face="courier new, monospace"> -> </font><span style="color:rgb(56,118,29);font-family:'courier new',monospace">a</span></div><div><span style="color:rgb(56,118,29);font-family:'courier new',monospace"> </span></div><div><font face="courier new, monospace"> </font><b style="font-family:'courier new',monospace">class</b><font face="courier new, monospace"> </font><span style="color:rgb(61,133,198);font-family:'courier new',monospace">Ring</span><font face="courier new, monospace"> </font><span style="color:rgb(56,118,29);font-family:'courier new',monospace">a</span><font face="courier new, monospace"> => <font color="#3d85c6">Num</font> a <b>where</b></font></div><div><font face="courier new, monospace"> <font color="#bf9000">abs</font> :: </font><font face="courier new, monospace"><font color="#38761d">a</font> -> </font><span style="color:rgb(56,118,29);font-family:'courier new',monospace">a</span></div><div><font face="courier new, monospace"> <font color="#bf9000">signum</font> :: </font><font face="courier new, monospace"><font color="#38761d">a</font> -> </font><span style="color:rgb(56,118,29);font-family:'courier new',monospace">a</span></div><div><font face="courier new, monospace"> <font color="#bf9000">fromInteger</font> :: <font color="#38761d">Integer</font> -> </font><span style="color:rgb(56,118,29);font-family:'courier new',monospace">a</span></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"> </font><span style="font-family:'courier new',monospace"><font color="#bf9000">sum</font> :: (</span><span style="font-family:'courier new',monospace">Foldable t, </span><span style="font-family:'courier new',monospace">Monoid a) => t a -> a</span></div><div><span style="font-family:'courier new',monospace"> <font color="#bf9000">sum</font> = foldl' (+) zero</span></div><div><br></div><div><font face="courier new, monospace"> <font color="#990000">-- for compatibility </font></font></div><div><font face="courier new, monospace"> <font color="#bf9000">mempty</font> = <font color="#000000">zero</font></font></div><div><font face="courier new, monospace"> <font color="#bf9000">mappend</font> = <font color="#000000">(+)<br></font></font></div><div><font face="courier new, monospace"><font color="#000000"> </font></font><span style="color:rgb(191,144,0);font-family:'courier new',monospace">mconcat</span><span style="font-family:'courier new',monospace"><font color="#000000"> = sum</font></span></div><div><font face="courier new, monospace"><font color="#000000"><br></font></font></div></div></div>
</blockquote></div></div></div></div></blockquote></div><br></div></div>