[Haskell-cafe] Simple hash table creation

2009-11-17 Thread michael rice
I'm trying to create a hash table. Yeah, I know, don't use hash tables, but I need to create something I'm familiar with, not something I've never worked with before. What's wrong with this code? Michael import Prelude hiding (lookup) import Data.HashTable data

Re: [Haskell-cafe] Simple hash table creation

2009-11-17 Thread Bulat Ziganshin
Hello michael, Tuesday, November 17, 2009, 10:16:50 PM, you wrote: I'm trying to create a hash table. Yeah, I know, don't use hash tables, but I need to create something I'm familiar with, not something I've never worked with before. What's wrong with this code? ht = MyHashTable.new (==)

Re: [Haskell-cafe] Simple hash table creation

2009-11-17 Thread Daniel Fischer
Am Dienstag 17 November 2009 20:16:50 schrieb michael rice: I'm trying to create a hash table. Yeah, I know, don't use hash tables, but I need to create something I'm familiar with, not something I've never worked with before. What's wrong with this code? Michael

Re: [Haskell-cafe] Simple hash table creation

2009-11-17 Thread Daniel Fischer
Am Dienstag 17 November 2009 20:36:46 schrieb Daniel Fischer: What you probably wanted was type MyHashTable = HashTable String Int -- not data MyHashTable Just in case it's not clear: ht - new (==) dummy :: IO MyHashTable only works at the prompt or in an IO do-block, not at the top level

Re: [Haskell-cafe] Simple hash table creation

2009-11-17 Thread michael rice
...@web.de Subject: Re: [Haskell-cafe] Simple hash table creation To: haskell-cafe@haskell.org Date: Tuesday, November 17, 2009, 2:36 PM Am Dienstag 17 November 2009 20:16:50 schrieb michael rice: I'm trying to create a hash table. Yeah, I know, don't use hash tables, but I need to create something I'm

Re: [Haskell-cafe] Simple hash table creation

2009-11-17 Thread michael rice
Subject: Re: [Haskell-cafe] Simple hash table creation To: haskell-cafe@haskell.org Date: Tuesday, November 17, 2009, 2:45 PM Am Dienstag 17 November 2009 20:36:46 schrieb Daniel Fischer: What you probably wanted was type MyHashTable = HashTable String Int -- not data MyHashTable Just in case it's

Re: [Haskell-cafe] Simple hash table creation

2009-11-17 Thread Gregory Crosswhite
You don't need to create a new type for a String - Int hashtable, you already get it for free because HashTable is a parameterized type. Also, although you are apparently trying to make life simpler for yourself using a HashTable, you are actually making like more complicated because the

Re: [Haskell-cafe] Simple hash table creation

2009-11-17 Thread Daniel Fischer
Am Dienstag 17 November 2009 21:09:26 schrieb michael rice: What is GHC.Int.Int32? Can't find it on Hoogle. Int32 is the guaranteed-to-be-32-bits integer type, it's defined in the module GHC.Int, typically it's imported via Data.Int (because, naturally, using GHC's own modules isn't

Re: [Haskell-cafe] Simple hash table creation

2009-11-17 Thread Gregory Crosswhite
`dummy' In a stmt of a 'do' expression: ht - new (==) dummy :: IO MyHashTable *Main :t dummy dummy :: String - Int *Main --- On Tue, 11/17/09, Daniel Fischer daniel.is.fisc...@web.de wrote: From: Daniel Fischer daniel.is.fisc...@web.de Subject: Re: [Haskell-cafe] Simple hash table

Re[2]: [Haskell-cafe] Simple hash table creation

2009-11-17 Thread Bulat Ziganshin
Hello Daniel, Tuesday, November 17, 2009, 11:21:18 PM, you wrote: The hash function must have a return type of fixed and specified width, or porting the app between 32-bit and 64-bit platforms could have enormous performance impact, so it can't be plain Int. i think that the problem with

Re: [Haskell-cafe] Simple hash table creation

2009-11-17 Thread michael rice
I've looked at in a long time. Thanks for your input. Michael --- On Tue, 11/17/09, Gregory Crosswhite gcr...@phys.washington.edu wrote: From: Gregory Crosswhite gcr...@phys.washington.edu Subject: Re: [Haskell-cafe] Simple hash table creation To: michael rice nowg...@yahoo.com Cc

Re: [Haskell-cafe] Simple hash table creation

2009-11-17 Thread Brad Larsen
On Tue, Nov 17, 2009 at 4:00 PM, michael rice nowg...@yahoo.com wrote: Hi Gregory, I was wondering about that, because of the following: [1 of 1] Compiling Main ( hash1.hs, interpreted ) Ok, modules loaded: Main. *Main ht - new (==) dummy :: IO MyHashTable *Main dummy mike 7

Re: [Haskell-cafe] Simple hash table creation

2009-11-17 Thread michael rice
So, what you're telling me is, my dummy hash function IS being used, and because of collisions the other values are placed in different locations? Michael --- On Tue, 11/17/09, Brad Larsen brad.lar...@gmail.com wrote: From: Brad Larsen brad.lar...@gmail.com Subject: Re: [Haskell-cafe] Simple

Re: [Haskell-cafe] Simple hash table creation

2009-11-17 Thread Brad Larsen
On Tue, Nov 17, 2009 at 4:22 PM, michael rice nowg...@yahoo.com wrote: So, what you're telling me is, my dummy hash function IS being used, and because of collisions the other values are placed in different locations? Michael [...] If Data.HashTable is implemented using separate chaining,

Re[2]: [Haskell-cafe] Simple hash table creation

2009-11-17 Thread Bulat Ziganshin
Hello michael, Wednesday, November 18, 2009, 12:00:58 AM, you wrote: *Main toList ht [(miguel,3),(michael,2),(mike,1)] It seems my dummy function is being ignored. i wonder why you think so? your ht has all 3 pairs you ever inserted inside, they all are inside the same bucket since hash

Re: Re[2]: [Haskell-cafe] Simple hash table creation

2009-11-17 Thread michael rice
with data structures other than lists, so I needed to see how things work. Thanks, everyone, for the help. Michael --- On Tue, 11/17/09, Bulat Ziganshin bulat.zigans...@gmail.com wrote: From: Bulat Ziganshin bulat.zigans...@gmail.com Subject: Re[2]: [Haskell-cafe] Simple hash table creation