[Haskell-cafe] preffered 'map'

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Thu Dec 8 15:35:55 EST 2005


On Fri, 2005-12-09 at 00:24 +0200, raptor wrote:
> hi,
> 
> I imported :
> 
> import Data.Map as Map
> 
> but now anywhere when I want ot use "map" it complains for 
> name clashes, so I have to specifiy Prelude.map all the time.
> Is there a way to specify that i mean Prelude not Data 'map' (but not fqn)
> I use Hugs, 'cause error messages are more understandable.

The recommended way to use Data.Map is like so:

import qualified Data.Map as Map

then ordinary "map" still refers to Prelude.map.

All Data.Map operations then need to be qualified with Map. For example:

Map.empty, Map.insert, etc.

So that you don't have to say Map.Map for the type name some people also
add:

import Data.Map (Map)

so that the type name is imported unqualified.

Duncan



More information about the Haskell-Cafe mailing list