[Haskell-cafe] Re: Asynchronous exception wormholes kill modularity

Isaac Dupree ml at isaac.cedarswampstudios.org
Wed Apr 7 13:54:51 EDT 2010

On 04/07/10 11:12, Simon Marlow wrote:
> It's possible to mis-use the API, e.g.
> getUnmask = mask return

unmask a = mask (\restore -> return restore) >>= (\restore -> restore a)

> mask :: ((IO a -> IO a) -> IO b) -> IO b

It needs to be :: ((forall a. IO a -> IO a) -> IO b) -> IO b
so that you can use 'restore' on two different pieces of IO if you need 
to. (alas, this requires not just Rank2Types but RankNTypes. Also, it 
doesn't cure the loophole. But I think it's still essential.)

> nonInterruptibleMask :: ((IO a -> IO a) -> IO b) -> IO b
> nonInterruptibleMask_ :: IO a -> IO a
> which is just like mask/mask_, except that blocking operations (e.g.
> takeMVar) are not interruptible.

What would be an appropriate use of this?


More information about the Haskell-Cafe mailing list