[Haskell-cafe] question about STM and IO
John Lato
jwlato at gmail.com
Wed Feb 20 23:10:15 EST 2008
I take it that this follows from the lack of any mechanism to rollback
IO? If so, I think that the following guidelines suffice for when
it's acceptable to use unsafeIOtoSTM:
1. The IO action must be able to be safely repeated.
2. The IO action must be able to be safely performed with
possibly-incorrect arguments, even if it isn't supposed to be
performed.
3. Don't try to nest transactions.
If I understand it correctly, I think that covers it.
Thanks to everyone who answered; I really appreciate it.
John
On Wed, Feb 20, 2008 at 8:02 PM, Ryan Ingram <ryani.spam at gmail.com> wrote:
> On 2/20/08, Bulat Ziganshin <bulat.ziganshin at gmail.com> wrote:
> > STM operations can be repeated if first transaction was unsuccessful.
> > so, you may se here only operations that may be safely repeated - say,
> > reading/writing memory areas, or reading/writing files, or even
> > sending network message as long as its duplication is ok
>
> Actually, you have to be even more careful than that; you may only
> include not just operations that may be safely repeated, but
> operations that may be erroneously executed. Consider the following
> snippet:
More information about the Haskell-Cafe
mailing list