[Haskell-cafe] Currying confusion

Henning Thielemann iakd0 at clusterf.urz.uni-halle.de
Fri Nov 12 14:25:47 EST 2004


On Fri, 12 Nov 2004, John Goerzen wrote:

> I like the partial application feature (and used it in test1).  So, I
> thought I could use that to my advantage in test3 and test4:
> 
> test3 :: Int -> Int -> String
> test3 x f = (show x) ++ f

You mean

test3 :: Int -> (Int -> String) -> String

?

Then the implementation could be written as

test3 x f = (show x ++) . f


But I believe currying means conversion between functions of two arguments
and functions of pairs. 


pairMap :: (a -> b) -> (a,a) -> (b,b)
pairMap f (x,y) = (f x, f y)

test5 :: Int -> Int -> String
test5 = curry (uncurry (++) . pairMap show)

This is something including partial application and currying. Is this what
you are looking for? 



More information about the Haskell-Cafe mailing list