
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 l1 = "abc" l2 = [1,2,3] ==========Here's my error: Prelude> :l maptest [1 of 1] Compiling Main ( maptest.hs, interpreted ) Ok, modules loaded: Main. *Main> l1 Loading package syb ... linking ... done. Loading package array-0.2.0.0 ... linking ... done. Loading package containers-0.2.0.0 ... linking ... done. "abc" *Main> l2 [1,2,3] *Main> zip l1 l2 [('a',1),('b',2),('c',3)] *Main> fromList $ zip l1 l2 <interactive>:1:0: Not in scope: `fromList' *Main> =========== Why isn't this working? Michael

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
participants (2)
-
Jochem Berndsen
-
michael rice