[Haskell-cafe] question about STM and IO
lrpalmer at gmail.com
Tue Feb 12 13:33:45 EST 2008
On Feb 12, 2008 6:28 PM, John Lato <jwlato at gmail.com> wrote:
> I was recently looking at the STM library, and I have a question about
> the function "unsafeIOToSTM". Can anyone explain to me what is unsafe
> about it, and what sort of use would be considered "safe"?
A few things. First, this will crash:
> atomically $ unsafeIOToStm $ atomically $ return ()
The implementation requires that transactions must not be nested, and
this function allows you to nest transactions.
Also, it's unclear what "retry" means in the context of arbitrary IO
actions. A memory transaction is really only defined for exactly
that: memory stuff. When you start talking about user I/O, network,
etc. the transactional idea breaks down.
So mostly the way I think of it is that it's semantically nonsense.
More information about the Haskell-Cafe