On Mon, Feb 3, 2014 at 5:50 AM, Rob Leslie <rob@mars.org> wrote:
I’ve run into a difficulty I’d appreciate some advice to solve.

I am trying to make a call to C (through the FFI) within an STM transaction to compute what is effectively a pure result. By itself this doesn’t seem to be a problem, except that the C function depends on some global state in a way that compromises thread safety, and so I would like to

This does not sound particularly pure to me, from a Haskell standpoint.

>  unsafePerformIO $ bracket (takeMVar lock) (putMVar lock) $ \_ -> do

And this looks to me like completely undefined behavior. I suspect bracket *can't* work in unsafePerformIO.

--
brandon s allbery kf8nh                               sine nomine associates
allbery.b@gmail.com                                  ballbery@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net