<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><BR><DIV><DIV>On 4 May 2007, at 08:43, Adrian Neumann wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite"><P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica">However I</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica">don't understand the type signatures for bind and fmap. I'd say (and</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica">ghci's type inference agrees) that bind and fmap have the type</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px"><BR></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica">bind:: (a-&gt;W b) -&gt; W a -&gt; W b</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica">fmap:: (a-&gt;b) -&gt; W a -&gt; W b</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px"><BR></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica">They take a function f and something and return what f does to that. I</FONT></P> <P style="margin: 0.0px 0.0px 0.0px 0.0px"><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica">don't see why they should return a function.</FONT></P> </BLOCKQUOTE></DIV><BR><DIV>I suggest you look up currying.  In the mean time, I shall attempt an explanation.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>In Haskell (as in many other functional languages), function types appear as if the function were curried.  This means that a function accepts one single argument, and returns one single result.  The important thing to realise though is that the result (or less importantly the argument) may be a function.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Let's study a (slightly over constrained) variant on the (+) function, with type (+) :: Int -&gt; Int -&gt; Int.  This type signature should be read to mean:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>(+) takes an Int, and returns a new function of type (Int -&gt; Int).  We can see an example of this (+ 5) -- (+) is given an argument (5), and returns a function (that adds 5 to integers).</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Another way to think about it is that the (-&gt;) type constructor is right associative, so any type written as a -&gt; b -&gt; c -&gt; d -&gt; e, can also be written as a -&gt; (b -&gt; (c -&gt; (d -&gt; e))).</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>I hope that helped a bit, and if it didn't I suggest going and looking up currying in as many places as you can.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Bob</DIV></BODY></HTML>