If I use the + operator, Haskell automatically infers the type class Num:
> let add x y = x + y
> :t add
add :: Num a => a -> a -> a
Does this mean I cannot have multiple type classes with a + operator?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t have multiple type classes defining
+in the same module (the same applies to any other function name of course – not just+).And if you import multiple modules which define
+(whether it be as part of a typeclass or not), you either need to hide+when importing all but one of them, import all but one of them as qualified or always refer to+qualified.