約從http://www.seas.upenn.edu/~cis194/lectures/02-lists.html咖喱/ uncurry(schönfinkel/unschönfinkel)的定義,如何理解咖喱的函數定義/ uncurry
schönfinkel :: ((a,b) -> c) -> a -> b -> c
schönfinkel f x y = f (x,y)
unschönfinkel :: (a -> b -> c) -> (a,b) -> c
unschönfinkel f (x,y) = f x y
但我覺得上面這些函數的定義應該是:
schönfinkel :: ((a,b) -> c) -> a -> b -> c
schönfinkel f (x,y) = f x y
-- schönfinkel(curry) converts an uncurried function
-- (f (x,y), its type signature is (a,b) -> c)
-- to a curried function
-- (f x y, its type signature is a -> b -> c)
unschönfinkel :: (a -> b -> c) -> (a,b) -> c
unschönfinkel f x y = f (x,y)
-- unschönfinkel(uncurry) converts a curried function
-- (f x y , its type signature is a -> b -> c)
-- to an uncurried function
-- (f (x,y), its type signature is (a,b) -> c)
請有人給我一個簡單的解釋?
在'schönfinkel'中,如果'f'具有類型'(a,b) - > c'then然後你不能像你所做的那樣將它應用於2個參數。你在一個元組上匹配模式,但是類型表示還有兩個參數,它們都不是元組。 – user2407038 2015-03-03 05:40:56