How to hide the operator during import?

Here is my code trying to override * . This can only be achieved when * previously hiding:

 import Prelude hiding (*) (*) :: Int -> Int -> Int x * 0 = 0 x * y = x + x*(y-1) 

But this does not work:

 $ ghci test.hs 

GHCi version 8.0.1: http://www.haskell.org/ghc/ :? for reference

test.hs: 1: 24: error: input parsing error '*

Failure, modules loaded: none.

Prelude>

I could hide another function like:

 import Prelude hiding (read) import Prelude hiding (show) 

until it works for an operator like * , + , - .

How to hide them?

+7
haskell
source share
1 answer

Recall how you request ghci for a function type:

 :t read :t show 

About the operator:

You enter :t + ?

No, you get a parsing error.

You do :t (+) .

As for your case, you will hide it with extra brackets: ((*))

 import Prelude hiding ((*)) (*) :: Int -> Int -> Int x * 0 = 0 x * y = x + x*(y-1) 
+16
source share

All Articles