01 02 03 04 05 06 01 02 03 04 05 06 07 08 ← →
module Main where
We have been writing functions which take multiple arguments. We can also write functions which take a tuple of arguments.
one ∷ Int → Int → Int one x y = x + y + 2 two ∷ (Int, Int) → Int two (x,y) = x + y + 2
curry
and uncurry
convert between these forms, for a pair of arguments.
curry ∷ ((a, b) → c) → a → b → c uncurry ∷ (a → b → c) → ((a, b) → c)
main ∷ IO () main = do print $ one 1 2 print $ two (1,2) print $ uncurry one (1,2) print $ curry two 1 2
5 5 5 5