Re: [Haskell-cafe] Problem with Data.Map

Thanks, guys.
Sounds like Lisp packages. Now I see the functionality of the A or B, etc.: Fewer keystrokes.
Michael
--- On Mon, 6/8/09, minh thu
import Blurp bring every thing defined in the Blurp module in scope. So if blah is defined in blurp, blah will work as expected.
import qualified Blurp as B does the same thing but everything defined in Blurp should be qualified (i.e. prefixed) with B. B.blah will work, not blah
So your import statement is right but you should write Map.fromList instead of just fromList. The goal is to have multiple identical names from different modules and still be able to use them at the same time, but qualified, for instance lookup is defined in both Data.List and Data.Map.
import qualified Data.List as L import qualified Data.Map as M L.lookup M.lookup The two last lines are unambiguous.
Cheers,
Thu
2009/6/8 michael rice
I don't understand your response. I copied the imports from Hoogles Data.Map page. What should the imports be?
Michael
--- On Mon, 6/8/09, Jochem Berndsen
wrote: From: Jochem Berndsen
Subject: Re: [Haskell-cafe] Problem with Data.Map To: "michael rice" Cc: haskell-cafe@haskell.org Date: Monday, June 8, 2009, 12:45 PM michael rice wrote:
I'm trying to understand Map type for possible use in another problem I'm working on, but am stymied right off the bat.
==========Here's my source:
import Data.Map (Map) import qualified Data.Map as Map
*Main> fromList $ zip l1 l2
<interactive>:1:0: Not in scope: `fromList'
You imported map "qualified as Map", that means that only 'Map.fromList' and 'Data.Map.fromList' are in scope, and not 'fromList'. The reason one normally does it like this is that a lot of function names clash with the Prelude (on purpose). Normally one uses "qualified as M" or "qualified as Map" to shorten the notation.
HTH,
-- Jochem Berndsen | jochem@functor.nl GPG: 0xE6FABFAB
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (1)
-
michael rice