[Haskell-cafe] classes question
paul.tokarev at rwth-aachen.de
Mon Nov 9 17:09:48 EST 2009
Thanks, that works. But how sould I change my class definition, so that it
works without (2::Int), but just with 2?
Ross Mellgren wrote:
> You did not specify what type of number it is -- in Haskell numeric
> constants like "1" are actually typed as forall a. Num a -- that is,
> can be any type of Num.
> Try: plus (2::Int) 3
> On Nov 9, 2009, at 1:44 PM, Paul Tokarev wrote:
>> I am using Hugs 98
>> I have that piece of code:
>> class PlusTimes a where
>> plus :: a -> a -> a
>> instance PlusTimes Int where
>> plus x y = x + y
>> when I run : "plus 2 3" I get this error:
>> ERROR - Unresolved overloading
>> *** Type : (Num a, PlusTimes a) => a
>> *** Expression : plus 2 3
>> What am I doing wrong?
>> View this message in context:
>> Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
View this message in context: http://old.nabble.com/classes-question-tp26271257p26274624.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
More information about the Haskell-Cafe