I got it. Thanks a lot. By the way, can you provide with example of using resultFun or secondFun.<br>I did search on Hyahoo and Hoogle for names and signatures and I didn't see any.<br><br>Thanks,<br><br>Malik<br><br><div class="gmail_quote">
On Thu, Nov 18, 2010 at 1:29 PM, Daniel Fischer <span dir="ltr"><<a href="mailto:daniel.is.fischer@web.de">daniel.is.fischer@web.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">On Thursday 18 November 2010 18:51:32, MH wrote:<br>
> Oh, so this signature is really a partial application that expects<br>
> another parameter to be executed.<br>
<br>
</div>Depends on how you look at it.<br>
Strictly speaking, there is no such thing as partial application. Every<br>
function takes exactly one argument, so it's either not applied to any<br>
argument at all yet or it's fully applied. But the result of a function<br>
application can be another function, so it may take another argument ...<br>
<br>
However, always talking about functions taking an argument of type a and<br>
returning a function taking an argument of type b and returning a function<br>
taking an argument of type c ...<br>
is terribly cumbersome, so we speak of functions taking several arguments.<br>
<br>
But note that the number of arguments a function takes until the final<br>
result is no longer a function is not always fixed. For example,<br>
id :: a -> a takes one argument, obviously, doesn't it?<br>
But if that argument is a function, it takes one more argument, so id can<br>
take two arguments, or three, or however many you want, it depends on which<br>
arguments you pass.<br>
<br>
So when you have a value of type a -> b -> c (which is the same as<br>
a -> (b -> c), since the function arrow is right-associative), and apply it<br>
to a value of type a, sometimes it is more appropriate to think of that as<br>
a partial application, sometimes as a complete application resulting in a<br>
function.<br>
<div class="im"><br>
> So<br>
> resultFun :: (h b -> h b') -> (h (a->b) -> h (a->b'))<br>
<br>
</div>which is<br>
<div class="im"><br>
resultFun :: (h b -> h b') -> h (a -> b) -> h (a -> b')<br>
<br>
> is<br>
> foo :: h b -> h b'<br>
<br>
</div>Yes<br>
<div class="im"><br>
> bar :: h (a->b) -> h (a->b')<br>
<br>
</div>No. bar :: h (a -> b)<br>
<br>
resultFun foo :: h (a -> b) -> h (a -> b')<br>
<br>
so it takes an argument of type h (a -> b) and its result has type<br>
h (a -> b')<br>
(which may be another function type, if h x = e -> x).<br>
<div class="im"><br>
><br>
> firstFunction = resultFun foo<br>
> result = firstFunction bar<br>
<br>
</div>Yep<br>
<br>
><br>
> Is this correct?<br>
</blockquote></div><br>