
Hi, I tried to port some code from ghc 6.2 to ghc 6.4, but I got the following error PrelExts.lhs:41:25: Ambiguous occurrence `map' It could refer to either `GHC.Base.map', imported from Data.List at PrelExts.lhs:11:0-15 or `Data.Set.map', imported from Data.Set at PrelExts.lhs:10:0-14 The following is the first part of the code module PrelExts where import Data.FiniteMap import Data.Set import Data.List import IO There is no problem under ghc 6.2. What should I do? Shiqi Cao

On Thu, 26 May 2005, Shiqi Cao wrote:
Hi,
I tried to port some code from ghc 6.2 to ghc 6.4, but I got the following error
PrelExts.lhs:41:25: Ambiguous occurrence `map' It could refer to either `GHC.Base.map', imported from Data.List at PrelExts.lhs:11:0-15 or `Data.Set.map', imported from Data.Set at PrelExts.lhs:10:0-14
This means that there is a 'map' for lists (Data.List.map) and one for sets (Data.Set). You should import them qualified.
The following is the first part of the code
module PrelExts where
import Data.FiniteMap import Data.Set import Data.List import IO
There is no problem under ghc 6.2. What should I do?
import qualified Data.Set as Set import qualified Data.List as List and call Set.map and List.map

Am Freitag, 27. Mai 2005 02:06 schrieb Shiqi Cao:
Hi,
I tried to port some code from ghc 6.2 to ghc 6.4, but I got the following error
PrelExts.lhs:41:25: Ambiguous occurrence `map' It could refer to either `GHC.Base.map', imported from Data.List at PrelExts.lhs:11:0-15 or `Data.Set.map', imported from Data.Set at PrelExts.lhs:10:0-14
The following is the first part of the code
module PrelExts where
import Data.FiniteMap import Data.Set import Data.List import IO
There is no problem under ghc 6.2. What should I do?
Shiqi Cao
The module Set has undergone major changes - look at the code and admire, if you have it. Formerly sets were implemented as 'FiniteMap's, now as size-balanced trees. Formerly there was a function called 'mapSet', now there's 'map'. To solve your problem, use import controls, for example import Data.Set hiding (map) import qualified Data.Set as Set will do fine. BTW, module FiniteMap is deprecated (I don't know why). Cheers, Daniel

On Tue, 31 May 2005, Daniel Fischer wrote: (snip)
The module Set has undergone major changes - look at the code and admire, if you have it. Formerly sets were implemented as 'FiniteMap's, now as size-balanced trees. Formerly there was a function called 'mapSet', now (snip)
I'm puzzled: wasn't the FiniteMap version also some form of size-balanced tree? -- Mark

Am Dienstag, 31. Mai 2005 14:05 schrieben Sie:
On Tue, 31 May 2005, Daniel Fischer wrote: (snip)
The module Set has undergone major changes - look at the code and admire, if you have it. Formerly sets were implemented as 'FiniteMap's, now as size-balanced trees. Formerly there was a function called 'mapSet', now
(snip)
I'm puzzled: wasn't the FiniteMap version also some form of size-balanced tree?
-- Mark
Indeed, I have looked at the sources and found out that now the implementations of 'Set' and 'Map' are basically the same. Presumably the new implementation of size-balanced trees is (much?) more efficient than the old one from 'FiniteMap'. Cheers, Daniel

Daniel Fischer wrote:
Indeed, I have looked at the sources and found out that now the implementations of 'Set' and 'Map' are basically the same.
The major achievement of (the new) Data.Set and Data.Map are canonical names that should be used in conjunction with qualified imports: import qualified Data.Set as Set import qualified Data.Map as Map import Data.List as List
Presumably the new implementation of size-balanced trees is (much?) more efficient than the old one from 'FiniteMap'.
There is no difference in efficiency, Data.Map is not slower than the old FiniteMap. Cheers Christian

On 31-May-2005, Daniel Fischer
Am Freitag, 27. Mai 2005 02:06 schrieb Shiqi Cao:
I tried to port some code from ghc 6.2 to ghc 6.4, but I got the following error
PrelExts.lhs:41:25: Ambiguous occurrence `map' It could refer to either `GHC.Base.map', imported from Data.List at PrelExts.lhs:11:0-15 or `Data.Set.map', imported from Data.Set at PrelExts.lhs:10:0-14
The following is the first part of the code
module PrelExts where
import Data.FiniteMap import Data.Set import Data.List import IO
There is no problem under ghc 6.2. What should I do? ... To solve your problem, use import controls, for example
import Data.Set hiding (map) import qualified Data.Set as Set
will do fine.
That code only compiles with ghc 6.4, and won't compile with ghc 6.2: you'll get an error for the "hiding (map)" part, because in 6.2 Data.Set does not contain a "map" function. If you want code that compiles with both 6.2 and 6.4 and does not give any warnings with "ghc -Wall", then I think you'll need to use qualified imports, i.e. just the second line above. -- Fergus J. Henderson | "I have always known that the pursuit Galois Connections, Inc. | of excellence is a lethal habit" Phone: +1 503 626 6616 | -- the last words of T. S. Garp.

Hello Fergus, Tuesday, May 31, 2005, 10:24:41 PM, you wrote:
import Data.Set hiding (map) import qualified Data.Set as Set
will do fine.
FH> That code only compiles with ghc 6.4, and won't compile with ghc 6.2: FH> you'll get an error for the "hiding (map)" part, because in 6.2 FH> Data.Set does not contain a "map" function. btw, question to Simon Marlow and Simon PJ - how about disabling this error message? -- Best regards, Bulat mailto:bulatz@HotPOP.com
participants (7)
-
Bulat Ziganshin
-
Christian Maeder
-
Daniel Fischer
-
Fergus Henderson
-
Henning Thielemann
-
Mark Carroll
-
Shiqi Cao