# Currying - Curry function

**Ashley Yakeley
**
ashley@semantic.org

*Tue, 7 Aug 2001 15:46:20 -0700*

At 2001-08-07 14:20, Mark Carroll wrote:
>>* Is there an exemple of such a function in the Haskell language ?
*>*
*>*Most certainly. For instance, we can define:
*>*
*>* f :: Integer -> Integer -> Integer
*>* f x y = x + y
*>*
*>* g = f 1
*
That's not really currying, is it? This is currying:
f :: (Integer,Integer) -> Integer
f (x,y) = x + y
g :: Integer -> Integer
g y = f (1,y)
-- g is f with the first argument curried with 1.
h :: Integer -> Integer
h x = f (x,1)
-- h is f with the second argument curried with 1.
And these are the functions for the first of two arguments:
curry :: ((a,b) -> c) -> (a -> b -> c)
curry f a b = f (a,b)
uncurry :: (a -> b -> c) -> ((a,b) -> c)
uncurry f (a,b) = f a b
... so that we can define
g = curry f 1
--
Ashley Yakeley, Seattle WA