[Haskell-cafe] Trouble with currying and uncurrying...
Angel de Vicente
angelv at iac.es
Mon Apr 25 15:11:52 CEST 2011
Hi,
I'm reading "The Craft of Functional Programming" and I found something
I don't understand in page 185.
It says:
"Suppose first that we want to write a curried version of a function g,
which is itself uncurried and of type (a,b) -> c.
curry g
This funtion expects its arguments as a pair, but its curried version,
curry g, will take them separately - we therefore have to form them into
a pair before applying g to them:
curry :: ((a,b) -> c) -> (a -> b -> c)
curry g x y = g (x,y)
curry multiplyUC will be exactly the same function as multiply."
OK, I have tried it and it works, but I don't understand the syntax for
curry. Until now I have encountered only functions that take the same
number of arguments as the function definition or less (partial
application), but this syntax looks a bit new to me. curry is supposed
to have as its argument one function of type (a,b) -> c and produce
another function, but then the second line gives three arguments to
curry, the function itself and the variables x and y.
What I'm missing here?
Thanks a lot,
Ángel de Vicente
--
http://www.iac.es/galeria/angelv/
High Performance Computing Support PostDoc
Instituto de Astrofísica de Canarias
---------------------------------------------------------------------------------------------
ADVERTENCIA: Sobre la privacidad y cumplimiento de la Ley de Protección de Datos, acceda a http://www.iac.es/disclaimer.php
WARNING: For more information on privacy and fulfilment of the Law concerning the Protection of Data, consult http://www.iac.es/disclaimer.php?lang=en
More information about the Haskell-Cafe
mailing list