[Haskell-cafe] STM and unsafePerformIO/bracket
allbery.b at gmail.com
Mon Feb 3 15:15:56 UTC 2014
On Mon, Feb 3, 2014 at 5:50 AM, Rob Leslie <rob at 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
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 at gmail.com ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe