<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Thanks all,<br><br>Got it! type rather than data and &lt;- rather than = (should have remembered this from monad stuff). Also, don't need the qualification.<br><br>Onward and upward.<br><br>Thanks,<br><br>Michael<br><br>--- On <b>Tue, 11/17/09, Daniel Fischer <i>&lt;daniel.is.fischer@web.de&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Daniel Fischer &lt;daniel.is.fischer@web.de&gt;<br>Subject: Re: [Haskell-cafe] Simple hash table creation<br>To: haskell-cafe@haskell.org<br>Date: Tuesday, November 17, 2009, 2:36 PM<br><br><div class="plainMail">Am Dienstag 17 November 2009 20:16:50 schrieb michael rice:<br>&gt; I'm trying to create a hash table. Yeah, I know, don't use hash tables, but<br>&gt; I need to create something I'm familiar with, not something I've never<br>&gt; worked
 with before. What's wrong with this code?<br>&gt;<br>&gt; Michael<br>&gt;<br>&gt; ====================<br>&gt;<br>&gt; import Prelude hiding (lookup)<br>&gt; import Data.HashTable<br>&gt;<br>&gt; data MyHashTable = HashTable String Int<br>&gt;<br>&gt; dummy:: String -&gt; Int<br>&gt; dummy s = 7<br>&gt;<br>&gt; ht = MyHashTable.new (==) dummy<br>&gt;<br>&gt; ====================<br><br> MyHashTable.new is parsed as a qualified function, 'new' from the module MyHashTable. But <br>there's no module MyHashTable imported, hence there's no function 'new' from that module <br>in scope.<br><br>&gt;<br>&gt; [michael@localhost ~]$ ghci hash1<br>&gt; GHCi, version 6.10.3: <a href="http://www.haskell.org/ghc/%C2%A0" target="_blank">http://www.haskell.org/ghc/&nbsp;</a> :? for help<br>&gt; Loading package ghc-prim ... linking ... done.<br>&gt; Loading package integer ... linking ... done.<br>&gt; Loading package base ... linking ... done.<br>&gt; [1 of 1] Compiling
 Main&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ( hash1.hs, interpreted )<br>&gt;<br>&gt; hash1.hs:9:5: Not in scope: `MyHashTable.new'<br>&gt; Failed, modules loaded: none.<br>&gt; Prelude&gt;<br><br>If we look at the type of Data.HashTable.new:<br><br>new ::&nbsp; (key -&gt; key -&gt; Bool)&nbsp; -&gt; (key -&gt; GHC.Int.Int32)&nbsp; -&gt; IO (HashTable key val)<br><br>we see that<br><br>new (==) dummy<br><br>(or Data.HashTable.new (==) dummy, but we don't need to qualify new)<br>has type<br><br>IO (HashTable String val), so is an IO-action returning a hashtable.<br><br>What you probably wanted was<br><br>type MyHashTable = HashTable String Int -- not data MyHashTable<br><br>ht &lt;- new (==) dummy :: IO MyHashTable<br><br>then ht is a hashtable of type MyHashTable.<br>_______________________________________________<br>Haskell-Cafe mailing list<br><a ymailto="mailto:Haskell-Cafe@haskell.org"
 href="/mc/compose?to=Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br><a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br></div></blockquote></td></tr></table><br>