Scott Turner wrote:
> 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.

As intern behaves like id and does not have any side effects, I thought its interface should be purely functional. But I do not see any way to do it :( I'll end up with a monad, probably.

In related question: does anybody here have experience/benchmarks/tests how/if is PackedString better (uses less memory) than String in parsing tasks?


--
Gracjan

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

Reply via email to