[Haskell-beginners] infix functions with 3 args

7stud bbxx789_05ss at yahoo.com
Fri Mar 20 07:05:49 EDT 2009


On p. 76 of RWH, it says:

"If a function or constructor takes two or more arguments, we have 
the option of using it in infix 
form, where we place it between its first and second arguments."

Here is my code:

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
    Possible fix: add an instance declaration for (Num (t1 -> t))
    In the second argument of `func3', namely `20 30'
    In the expression: 10 `func3` 20 30
    In the definition of `it': it = 10 `func3` 20 30

How do you get a function to work using infix notation when it has
3 arguments?






More information about the Beginners mailing list