[Haskell-cafe] Hash table constructors return table in IO Monad. Why?

2011-05-12 Thread michael rice
Is there some reason why ALL the ways to create a hash table return one in the 
IO Monad, but all the functions for retrieving a value from a hash table take 
as an argument a hash table NOT in the IO Monad?
Michael
 =
Prelude Data.HashTable let ht = fromList id [(5,'a'),(6,'b')]Prelude 
Data.HashTable fmap ((flip Data.HashTable.lookup) 6) htPrelude Data.HashTable
Prelude Data.HashTable :t fmap ((flip Data.HashTable.lookup) 6) htfmap ((flip 
Data.HashTable.lookup) 6) ht :: IO (IO (Maybe Char))
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Hash table constructors return table in IO Monad. Why?

2011-05-12 Thread Stephen Tetley
The hashtable needs to be been created in IO, after that, think of the
'hashtable' as a analogous to a file handle. You have to pass it
around to do anything with it - but the only things you can do with it
are in IO.

(That's why no-one really likes it, of course...)

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Hash table constructors return table in IO Monad. Why?

2011-05-12 Thread Bryan O'Sullivan
On Thu, May 12, 2011 at 9:22 AM, Stephen Tetley stephen.tet...@gmail.comwrote:

 The hashtable needs to be been created in IO, after that, think of the
 'hashtable' as a analogous to a file handle. You have to pass it
 around to do anything with it - but the only things you can do with it
 are in IO.


The appropriate pure package to be using instead is unordered-containers.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Hash table constructors return table in IO Monad. Why?

2011-05-12 Thread michael rice
Thanks, Bryan and Stephan.
I seem to remember playing around with a data structure that accumulates (in a 
list) different values associated with an identical key, i.e.,
insert data-structure abc 5insert data-structure abc 6
retrieve data-structure abc - [5,6]
HashTable doesn't do it. Neither does Map. Was I dreaming?
Michael

--- On Thu, 5/12/11, Bryan O'Sullivan b...@serpentine.com wrote:

From: Bryan O'Sullivan b...@serpentine.com
Subject: Re: [Haskell-cafe] Hash table constructors return table in IO Monad. 
Why?
To: Stephen Tetley stephen.tet...@gmail.com
Cc: haskell-cafe@haskell.org
Date: Thursday, May 12, 2011, 2:22 PM

On Thu, May 12, 2011 at 9:22 AM, Stephen Tetley stephen.tet...@gmail.com 
wrote:

The hashtable needs to be been created in IO, after that, think of the

'hashtable' as a analogous to a file handle. You have to pass it

around to do anything with it - but the only things you can do with it

are in IO.

The appropriate pure package to be using instead is unordered-containers.

-Inline Attachment Follows-

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Hash table constructors return table in IO Monad. Why?

2011-05-12 Thread Ozgur Akgun
On 12 May 2011 20:59, michael rice nowg...@yahoo.com wrote:

 HashTable doesn't do it. Neither does Map. Was I dreaming?


I suppose you could implement this functionality on top of either.

HTH,
Ozgur
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Hash table constructors return table in IO Monad. Why?

2011-05-12 Thread Bryan O'Sullivan
On Thu, May 12, 2011 at 12:59 PM, michael rice nowg...@yahoo.com wrote:


 HashTable doesn't do it. Neither does Map. Was I dreaming?


multiInsert k v m = insertWith' (++) k [v] m
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Hash table constructors return table in IO Monad. Why?

2011-05-12 Thread michael rice
I guess everyone has weighed in. I must have been hallucinating.
Yes, this will work.
Thanks,
Michael

--- On Thu, 5/12/11, Bryan O'Sullivan b...@serpentine.com wrote:

From: Bryan O'Sullivan b...@serpentine.com
Subject: Re: [Haskell-cafe] Hash table constructors return table in IO Monad. 
Why?
To: michael rice nowg...@yahoo.com
Cc: Stephen Tetley stephen.tet...@gmail.com, haskell-cafe@haskell.org
Date: Thursday, May 12, 2011, 6:04 PM

On Thu, May 12, 2011 at 12:59 PM, michael rice nowg...@yahoo.com wrote:


HashTable doesn't do it. Neither does Map. Was I dreaming?

multiInsert k v m = insertWith' (++) k [v] m
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe