Currying - Curry function
Tue, 7 Aug 2001 15:58:01 -0700
to check whether I myself understand currying correctly:
currying is not partial application (as the example below seems to
suggest), it is conversion of a function in to a form where partial
application is possible.
so we can say that
g =3D curry f
is a curried function.
: -----Original Message-----
: From: Ashley Yakeley [mailto:email@example.com]=20
: Sent: Tuesday, August 07, 2001 3:46 PM
: To: Mark Carroll; Haskell Cafe List
: Subject: Re: Currying - Curry function
: 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 =3D x + y
: > g =3D f 1
: That's not really currying, is it? This is currying:
: f :: (Integer,Integer) -> Integer
: f (x,y) =3D x + y
: g :: Integer -> Integer
: g y =3D f (1,y)
: -- g is f with the first argument curried with 1.
: h :: Integer -> Integer
: h x =3D 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 =3D f (a,b)
: uncurry :: (a -> b -> c) -> ((a,b) -> c)
: uncurry f (a,b) =3D f a b
: ... so that we can define
: g =3D curry f 1
: Ashley Yakeley, Seattle WA
: Haskell-Cafe mailing list