<div dir="ltr">Dear Haskellers,<br><div class="gmail_quote"><div dir="ltr"><br>I'm trying to define a polymorphic "add" function which takes a variable number of arguments (instance of Num) and returns their sum. I don't want to specify the types of the arguments while calling the function, I just want to , at most, specify the return type (<b>it should infer that the return type is the type of the arguments</b>).<br>
<br>class Add a b where<br> add :: a -> b<br><br>instance Num a => Add a a where<br> add = id<br><br>instance (Num a, Add a b) => Add (a -> b) where<br> add x y = add (x + y)<br><br>Can someone tell me why this is not working and propose a fix for this, if possible?<br>
<br>Thanks in advance<br></div>
</div></div>