[redirecting to a more appropriate mailing list]

On 2/20/07, ROBERT DOUGLAS HOELZ <[EMAIL PROTECTED]> wrote:
I was reading the docs for Data.Hashtable, and quickly noticed that operations 
on a hashtable are of the IO monad.  Why is this?  I should think that the 
operations would look like this:

insert :: Hashtable -> key -> val -> Hashtable
lookup :: Hashtable -> key -> a

If you read the source for Data.HashTable, you'll notice that the
HashTable type is defined in terms of mutable arrays, which must be in
the IO monad since side effects are involved. This is purely for
performance reasons. If you want an analogous type whose operations
are pure, look at Data.Map:
http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data-Map.html

Cheers,
Kirsten

--
Kirsten Chevalier* [EMAIL PROTECTED] *Often in error, never in doubt
"Nuclear war can ruin your whole compile." -- Karl Lehenbauer
_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to