[Haskell-cafe] ghc 6.4 import problem

Fergus Henderson fjh-mailbox-24 at galois.com
Tue May 31 14:24:41 EDT 2005


On 31-May-2005, Daniel Fischer <daniel.is.fischer at web.de> wrote:
> 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.


More information about the Haskell-Cafe mailing list