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, shouldn't it automatically pick the get function in Main? Why is it running into this conflict? How can I fix it?
You need to use import qualified Control.Monad.State as S. Skipping qualified keyword brings into scope both S.get and get, etc.
If the import declaration used the
qualifiedkeyword, only thequalifiedname of the entity is brought into scope. If the qualified keyword is omitted, then both the qualified and unqualified name of the entity is brought into scope.
See 5.3.2 and 5.3.4 of Haskell 2010 report.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With