Haskell: Problems with overloading: Interpreter can´t tell which + to use
- by Ben
Hi,
I want to make functions Double - Double an instance of the Num typeclass.
I want to define the sum of two functions as sum of their images.
So I wrote
instance Num Function where
f + g = (\ x - (f x) + (g x))
Here the compiler complains he can´t tell whether I´m using Prelude.+ or Module.+
in the lambda expression.
So I imported Prelude qualified as P and wrote
instance Num Function where
f + g = (\ x - (f x) P.+ (g x))
This compiles just fine, but when I try to add two functions in GHCi
the interpreter complains again he can´t tell whether I´m using Prelude.+ or
Module.+.
Is there any way I can solve this problem?