<div class="gmail_quote">2008/12/26 Oscar Picasso <span dir="ltr">&lt;<a href="mailto:oscarpicasso@gmail.com">oscarpicasso@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi,<br><br>I can write:<br>*Main&gt; let yes = not . not<br>*Main&gt; :t yes<br>yes :: Bool -&gt; Bool<br><br>But not:<br>*Main&gt; let isNotEqual = not . (==)</blockquote><div><br></div><div>The definition of (.):</div><div>
<br></div><div>f . g = \x -&gt; f (g x)</div><div><br></div><div>So:</div><div><br></div><div>not . (==) = \x -&gt; not ((==) x)</div><div><br></div><div>But (==) x is a function (of type a -&gt; Bool, which returns whether its argument is equal to x), not a Bool as not is expecting.</div>
<div><br></div><div>Composition like that usually only works for single argument functions. &nbsp;It gets uglier quickly for multi arg functions:</div><div><br></div><div>isNotEqual = &nbsp;(not .) . (==)</div><div><br></div><div>You can define your own operator to help:</div>
<div><br></div><div>(.:) = (.) . (.)</div><div><br></div><div>Which is a bit of silly definition. &nbsp;I typically don&#39;t like pointfree style for any but the most transparent of uses, so in real life (tm), I&#39;d probably write:</div>
<div><br></div><div>(f .: g) x y = f (g x y)</div><div><br></div><div>But be prepared for others to disagree with me.</div><div><br></div><div>Luke</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br><br>&lt;interactive&gt;:1:23:<br>&nbsp;&nbsp;&nbsp; Couldn&#39;t match expected type `Bool&#39;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; against inferred type `a -&gt; Bool&#39;<br>&nbsp;&nbsp;&nbsp; Probable cause: `==&#39; is applied to too few arguments<br>&nbsp;&nbsp;&nbsp; In the second argument of `(.)&#39;, namely `(==)&#39;<br>&nbsp;&nbsp;&nbsp; In the expression: not . (==)<br><br>

Why?<br><font color="#888888"><br>Oscar<br><br>
</font><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>
<br></blockquote></div><br>