<font face="verdana,sans-serif">Compile with -Wall and the flaw becomes obvious:</font><div><font face="verdana,sans-serif"><br></font></div><div><font face="verdana,sans-serif"><div><interactive>:2:5:</div><div> Warning: This binding for `+' shadows the existing binding</div>
<div> imported from `Prelude' (and originally defined in `GHC.Num')</div><div><br></div><div><interactive>:2:9:</div><div> Warning: This binding for `*' shadows the existing binding</div>
<div> imported from `Prelude' (and originally defined in `GHC.Num')</div><div><br></div><div><interactive>:2:16:</div><div> Warning: Defaulting the following constraint(s) to type `Integer'</div>
<div> (Num a0) arising from the literal `1'</div><div> In the first argument of `(+)', namely `1'</div><div> In the first argument of `(*)', namely `1 + 2'</div><div> In the expression: 1 + 2 * 3</div>
<div><br></div><div><interactive>:2:16:</div><div> Warning: Defaulting the following constraint(s) to type `Integer'</div><div> (Num a0) arising from the literal `1' at <interactive>:2:16</div>
<div> (Show a0) arising from a use of `print' at <interactive>:2:1-34</div><div> In the first argument of `(+)', namely `1'</div><div> In the first argument of `(*)', namely `1 + 2'</div>
<div> In the expression: 1 + 2 * 3</div><div><br></div><div>Shadowing is bad, and tends (as in this case) to be confusing.</div><div><br></div><div> - Clark</div></font><br><div class="gmail_quote">On Fri, Oct 5, 2012 at 7:22 AM, Roman Cheplyaka <span dir="ltr"><<a href="mailto:roma@ro-che.info" target="_blank">roma@ro-che.info</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">* Johannes Waldmann <<a href="mailto:waldmann@imn.htwk-leipzig.de">waldmann@imn.htwk-leipzig.de</a>> [2012-10-05 11:11:48+0000]<br>
<div class="im">> I was really surprised at the following:<br>
><br>
> *Main> 1 + 2 * 3<br>
> 7<br>
><br>
> *Main> ( \ (+) (*) -> 1 + 2 * 3 ) (+) (*)<br>
> 9<br>
><br>
> because I was somehow assuming that either<br>
><br>
> a) the Prelude fixities of the operators are kept<br>
> b) or they are undefined, so the parser rejects.<br>
><br>
> but the Haskell standard says "Any operator lacking a fixity declaration<br>
> is assumed to be infixl 9". This really should be "infix 9"?<br>
<br>
</div>This behaviour is really handy when you use functions as operators<br>
(using backticks notation). They typically lack infix annotations, but<br>
having to put parentheses would be very annoying.<br>
<span class="HOEnZb"><font color="#888888"><br>
Roman<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">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>
</div></div></blockquote></div><br></div>