
On 2009 Mar 20, at 7:05, 7stud wrote:
func2 x y = x + y
func3 x y z = x + y + z
Here are the results:
*Main> func2 10 20 30 *Main> 10 `func2` 20 30 *Main> func3 10 20 30 60 *Main> 10 `func3` 20 30
<interactive>:1:11: No instance for (Num (t1 -> t)) arising from the literal `20' at <interactive>:1:11-15
Keep in mind that any function taking multiple arguments is indistinguishable from a function taking a single argument and returning a function that takes more arguments. So we have in this case "10 `func3` 20" which requires another argument. But because of Haskell evaluation rules, writing "10 `func3` 20 30" causes Haskell to try to evaluate "20 30" as a function (i.e. Haskell infers "10 `func3` (20 30)". We need to tell Haskell not to do this: (10 `func3` 20) 30 It can easily be seen that "(10 `func3` 20)" returns a function which is applied to "30", as we intended. (hm, I'm starting to sound like Oleg. not necessarily a good thing... this is not a research paper :) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH