Oh man, I came late to this party.<br><br>I&#39;ll throw what little weight I have here behind Jerry&#39;s argument.  Yes, this change to base is not Haskell2010 compatible, but it&#39;s still a good change and I hope that Haskell2012 or 2013 or whatever the next version of the standard that comes out incorporates it.<br>
<br>As to why it&#39;s a good change:<br><br>(1) People were doing it anyways with bogus Eq instances; the syntactic benefit of being able to use integer literals is huge; using the standard +/-/* etc functions is a nice bonus.  For an example, see <a href="http://twanvl.nl/blog/haskell/simple-reflection-of-expressions">http://twanvl.nl/blog/haskell/simple-reflection-of-expressions</a><br>
(2) Pattern matching on numeric literals is what requires Eq, and combined with (1) leads to fragile code.  Now, for example,<br><br>    fac 0 = 1<br>    fac n = n * fac (n-1)<br><br>Now the type of fac explicitly states that it requires Eq to work; with the &#39;hack&#39; version of Eq in the expressions above, &quot;fac x&quot; doesn&#39;t terminate and instead gives x * (x-1) * (x-1-1) * ... forever.  Other versions (like the version in this thread with Num (e -&gt; a)) turn fac into a function that always returns bottom.<br>
<br>  -- ryan<br><br><div class="gmail_quote">On Tue, Mar 20, 2012 at 12:02 PM, Ryan Ingram <span dir="ltr">&lt;<a href="mailto:ryani.spam@gmail.com">ryani.spam@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This instance can be made more general without changing the code; change the first line to<br><br>instance Num a =&gt; Num (e -&gt; a) where<br><br>I think this version doesn&#39;t even require FlexibleInstances.<br><br>This lets you do<br>

<br>f x = if x then 2 else 3<br>g x = if x then 5 else 10<br><br>-- f + g = \x -&gt; if x then 7 else 13<span class="HOEnZb"><font color="#888888"><br><br>  -- ryan<br><br></font></span><div class="gmail_quote"><div><div class="h5">
On Mon, Mar 19, 2012 at 10:38 AM, Ozgur Akgun <span dir="ltr">&lt;<a href="mailto:ozgurakgun@gmail.com" target="_blank">ozgurakgun@gmail.com</a>&gt;</span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">Hi,<div><br></div><div>If you are feeling adventurous enough, you can define a num instance for functions:<div>
<br></div>
<div><font face="&#39;courier new&#39;, monospace">{-# LANGUAGE FlexibleInstances #-}</font></div><div>

<font face="&#39;courier new&#39;, monospace"><br></font></div><div><font face="&#39;courier new&#39;, monospace">instance Num a =&gt; Num (a -&gt; a) where</font></div><div><font face="&#39;courier new&#39;, monospace">    f + g = \ x -&gt; f x + g x</font></div>



<div><font face="&#39;courier new&#39;, monospace">    f - g = \ x -&gt; f x - g x</font></div><div><font face="&#39;courier new&#39;, monospace">    f * g = \ x -&gt; f x * g x</font></div><div><font face="&#39;courier new&#39;, monospace">    abs f = abs . f</font></div>



<div><font face="&#39;courier new&#39;, monospace">    signum f = signum . f</font></div><div><div><font face="&#39;courier new&#39;, monospace">    fromInteger = const . fromInteger</font></div><div><font face="&#39;courier new&#39;, monospace"><br>



</font></div></div><div><font face="&#39;courier new&#39;, monospace">ghci&gt; let f x = x * 2</font></div><div><font face="&#39;courier new&#39;, monospace">ghci&gt; let g x = x * 3</font></div><div><font face="&#39;courier new&#39;, monospace">ghci&gt; (f + g) 3</font></div>



<div><font face="&#39;courier new&#39;, monospace">15</font></div><div><font face="&#39;courier new&#39;, monospace">ghci&gt; (f+g+2) 2</font></div><div><font face="&#39;courier new&#39;, monospace">17</font></div><div><br>



</div><div>HTH,</div><div>Ozgur <div><br><br><div class="gmail_quote">On 19 March 2012 16:57,  <span dir="ltr">&lt;<a href="mailto:sdiyazg@sjtu.edu.cn" target="_blank">sdiyazg@sjtu.edu.cn</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

By arithmetic I mean the everyday arithmetic operations used in engineering.<br>
In signal processing for example, we write a lot of expressions like f(t)=g(t)+h(t)+g&#39;(t) or f(t)=g(t)*h(t).<br>
I feel it would be very natural to have in haskell something like<br>
   g::Float-&gt;Float<br>
   --define g here<br>
   h::Float-&gt;Float<br>
   --define h here<br>
   f::Float-&gt;Float<br>
   f = g+h --instead of f t = g t+h t<br>
   --Of course, f = g+h is defined as f t = g t+h t<br>
</blockquote></div><br>
</div></div></div>
<br></div></div><div class="im">_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></div></blockquote></div><br>
</blockquote></div><br>