On 2005 June 02 Thursday 04:38, Gracjan Polak wrote:
>  >>iorefset :: Ord a => IORef(Map.Map a a)
>  >>iorefset = unsafePerformIO $ do
>  >>     newIORef $ Map.empty

> I could have as many dictionaries as there are types. The problem is I
> get one dictionary for each object which defeats the idea.

To avoid unsafe operations and get control over the dictionaries that are 
created, I would put the desired dictionaries into a state monad.  The type 
of 'intern' becomes
    Ord a => a -> DictionaryState a
All the code that uses 'intern' would need some modification to deal more 
directly with the dictionary state. It may be more complex, but it's also 
more solid.
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to