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

Simon Marlow marlowsd at gmail.com
Thu Apr 8 04:23:09 EDT 2010


On 07/04/2010 18:54, Isaac Dupree wrote:
> On 04/07/10 11:12, Simon Marlow wrote:
>> It's possible to mis-use the API, e.g.
>>
>> getUnmask = mask return
>
> ...incidentally,
> unmask a = mask (\restore -> return restore) >>= (\restore -> restore a)

That doesn't work, as in it can't be used to unmask exceptions when they 
are masked.  The 'restore' you get just restores the state to its 
current, i.e. masked, state.

>> 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.)

Sigh, yes I suppose that's true, but I've never encountered a case where 
I needed to call unmask more than once, let alone at different types, 
within the scope of a mask.  Anyone else?

Cheers,
	Simon


More information about the Haskell-Cafe mailing list