DiffArray Performance
Simon Marlow
simonmar at microsoft.com
Fri Nov 7 11:45:48 EST 2003
> >This is one good reason they have to be protected by MVars
>
> Forgive my stupidity, but arn't the MVar operations
> (takeMVar, putMVar)
> IO operation, therefore the locks must be in the IO monad, therefore
> the code acting on the DiffArray should be in the IO monad...
> otherwise they can't use the MVar calls?
DiffArray is an example of a good use for unsafePerformIO: it uses
imperative operations to implement a pure API. The DiffArray is made of
mutable objects under the hood, but as far as the programmer is
concerned it behaves just like a pure Array.
Cheers,
Simon
More information about the Glasgow-haskell-users
mailing list