Mistake error even after qualified import

Here is a snippet of my code:

import Control.Monad.State as S get x = x + 1 

Now, if I try to use get , I get the following error:

 Ambiguous occurrence `get' It could refer to either `Main.get', defined at twitter.hs:59:1 or `S.get', imported from Control.Monad.State at twitter.hs:15:1-31 

Since I imported Control.Monad.State as a qualified module, should I not automatically select the get function in Main ? Why is he facing this conflict? How can i fix this?

+4
source share
1 answer

You need to use import qualified Control.Monad.State as S Skipping the qualified keyword introduces both S.get and get , etc.

If the qualified keyword is used in the import declaration, only the qualified name of the object is visible in the area. If the keyword "qualified" is omitted, then both the full and unqualified name of the object is entered into the scope.

See 5.3.2 and 5.3.4 Haskell 2010 Report .

+11
source

All Articles