class FunAble h => FunDble h where
resultFun :: (h b -> h b') -> (h (a->b) -> h (a->b'))
class FunAble h where
secondFun :: (h b -> h b') -> (h (a,b) -> h (a,b')) -- for 'second'
in the signatures:
resultFun :: (h b -> h b') -> (h (a->b) -> h (a->b'))
secondFun :: (h b -> h b') -> (h (a,b) -> h (a,b'))
if (h b -> h b') is the input of these functions where does 'a' comes from
in the output?
Thanks,
'a' is arbitrary, so it works for all 'a'. The result of resultFun foo,
resp. secondFun foo is a function of type
h (a -> b) -> h (a -> b')
resp.
h (a,b) -> h (a,b')
where the types b and b' have been determined by foo (not necessarily
completely, if foo is id, all that has been determined is that b' = b) and
'a' is still arbitrary. The type variable 'a' is fixed or restricted when
xxxFun gets its second argument, bar in
resultFun foo bar
resp.
secondFun foo bar.
>
> Thanks,
HTH,
Daniel
_______________________________________________
Beginners mailing list
Begi...@haskell.org
http://www.haskell.org/mailman/listinfo/beginners
firstFunction = resultFun foo
result = firstFunction bar
Is this correct?
On Thu, Nov 18, 2010 at 10:52 AM, Daniel Fischer
<daniel.i...@web.de>wrote:
Depends on how you look at it.
Strictly speaking, there is no such thing as partial application. Every
function takes exactly one argument, so it's either not applied to any
argument at all yet or it's fully applied. But the result of a function
application can be another function, so it may take another argument ...
However, always talking about functions taking an argument of type a and
returning a function taking an argument of type b and returning a function
taking an argument of type c ...
is terribly cumbersome, so we speak of functions taking several arguments.
But note that the number of arguments a function takes until the final
result is no longer a function is not always fixed. For example,
id :: a -> a takes one argument, obviously, doesn't it?
But if that argument is a function, it takes one more argument, so id can
take two arguments, or three, or however many you want, it depends on which
arguments you pass.
So when you have a value of type a -> b -> c (which is the same as
a -> (b -> c), since the function arrow is right-associative), and apply it
to a value of type a, sometimes it is more appropriate to think of that as
a partial application, sometimes as a complete application resulting in a
function.
> So
> resultFun :: (h b -> h b') -> (h (a->b) -> h (a->b'))
which is
resultFun :: (h b -> h b') -> h (a -> b) -> h (a -> b')
> is
> foo :: h b -> h b'
Yes
> bar :: h (a->b) -> h (a->b')
No. bar :: h (a -> b)
resultFun foo :: h (a -> b) -> h (a -> b')
so it takes an argument of type h (a -> b) and its result has type
h (a -> b')
(which may be another function type, if h x = e -> x).
>
> firstFunction = resultFun foo
> result = firstFunction bar
Yep
>
> Is this correct?
Thanks,
Malik
Great.
> Thanks a lot.
'twas a pleasure.
> By the way, can you provide with example of using resultFun or secondFun.
No, sorry, I've never used them myself nor came across code using them.
> I did search on Hyahoo and Hoogle for names and signatures and I didn't
> see any.
>
> Thanks,
>
> Malik
_______________________________________________