Haskell - Redefining (hiding) arithmetic operators
functional-programming, haskell, notation, syntax
Solution
Answering the edited question:
You can do
import Prelude hiding ((*))
import qualified Prelude as P
to gain access to all Prelude functions except `(*)` in the usual way and to `(*)` via the `P` prefix:
x = 5 + 3 -- works
y = 5 P.* 3 -- works
z = 5 * 3 -- complains about * not being in scope
Problem
I want to redefine several arithmetic operators in Haskell in order to make them more extensible and generic. E.g. ``` class Mul a b c | a b -> c where (*) :: a -> b -> c ``` This seems to work in combination with ``` import Prelude hiding ((*)) ``` hiding the standard `*` operator. But of course all usual multiplications have to work as well, so I'd have to define something like ``` instance (Num t) => Mul t t t where (*) = ?? ``` How can I access the original `*` operator (`Prelude.(*)` doesn't work) here and how do I have to define the instance type such that `1 * 1` doesn't conflict with the Monomorpism Restriction? Edit - ``` import qualified ``` is a good tip, thanks. But unfortunately this forced me to bring all standard methods into scope explicitly. I just want to have the possibility of redefining certain bindings leaving the rest unchanged. So is there a combination of both? Something like ``` import Prelude qualified ((*)) ```