
I'm trying to do something -- I think it's called uncurrying. I've boiled up a little test case to show what I mean: test1 :: Int -> String test1 = show test2 :: Int -> Int -> String test2 x y = (show x) ++ (show y) OK, that works OK. Now let's say I want to provide a function that generates the string to use in place of (show y) -- perhaps, test1. 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 test4 :: Int -> (Int -> String) test4 x f = (show x) ++ f Of course, I could say test3 x f y = (show x) ++ (f y) but for various reasons that's not the most useful in my program. Thoughts?

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?

On 2004-11-12, Henning Thielemann
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
?
Yes.
Then the implementation could be written as
test3 x f = (show x ++) . f
Tried that, but: test.hs:13: Couldn't match `String' against `Int -> [Char]' Expected type: String Inferred type: Int -> [Char] In the expression: (((show x) ++)) . f In the definition of `test3': 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?
-- John Goerzen Author, Foundations of Python Network Programming http://www.amazon.com/exec/obidos/tg/detail/-/1590593715

On Fri, 12 Nov 2004, John Goerzen wrote:
On 2004-11-12, Henning Thielemann
wrote: test3 :: Int -> (Int -> String) -> String
?
Yes.
Then the implementation could be written as
test3 x f = (show x ++) . f
Tried that, but:
Sorry, it must be: test3 :: Int -> (Int -> String) -> Int -> String
participants (2)
-
Henning Thielemann
-
John Goerzen