Haskell confusion (81)

27 Name: #!usr/bin/anon 2005-11-15 23:53 ID:P/Wff3Bl

Haskell doesn't forbid multiple arguments. It has two many ways to take multiple arguments. First is currying. The second is through tuples. Or you can make your own type like a tuple and have a function take that type.

(+) :: Int -> (Int -> Int)
This addition function takes an Int which returns a function which takes an Int which returns an Int. I put the brackets in for illustration.

(+) :: (Int,Int) -> Int
This addition function takes a tuple of two Ints and returns an Int.

(+) :: (Pair Int Int) -> Int
This takes a type called Pair which holds two Ints and returns an Int.

The second way is a lot like how C takes arguments. And Haskell can do what >>22 shows too, so currying is less a limitation than a feature or an integral part of the language because Haskell comes from typed lambda calculus.

This thread has been closed. You cannot post in this thread any longer.