Re: [Haskell] Data.Hashtable operations in IO?

[redirecting to a more appropriate mailing list]
On 2/20/07, ROBERT DOUGLAS HOELZ
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* chevalier@alum.wellesley.edu *Often in error, never in doubt "Nuclear war can ruin your whole compile." -- Karl Lehenbauer
participants (1)
-
Kirsten Chevalier