> >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 _______________________________________________ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users