Victoria Leshcheko
Victoria Leshcheko

Reputation: 23

Ambiguous occurrence `take`

 Ambiguous occurrence `take'
It could refer to
   either `Prelude.take',
          imported from `Prelude' at src\Main.hs:1:8-11
          (and originally defined in `GHC.List')
       or `Data.Set.take',
          imported from `Data.Set' at src\Main.hs:4:1-15
          (and originally defined in `Data.Set.Internal')
       or `Data.Map.take',
          imported from `Data.Map' at src\Main.hs:3:1-15
          (and originally defined in `Data.Map.Internal')
            |
         36 | createMines g fst = Data.Set.fromList $ take mineCount $ shuffle g $  

Please tell me how to fix this error.I use import Data.Map and import Data.Set

Upvotes: 2

Views: 505

Answers (1)

willeM_ Van Onsem
willeM_ Van Onsem

Reputation: 477607

The reason you get this error is because you imported modules that export functions with the same name. If you then use such function (like take), the compiler does not know what function you aim to use.

You can make a qualified import [Haskell-wiki], so:

import qualified Data.Set as S

You can then use a function the Data.Set module with S.take for example. If you use take, it will use the one defined in the prelude.

Upvotes: 6

Related Questions