Document for review: evaluation order and state tokens

As part of trac ticket 9390[1], Simon PJ recommended that we try to get a document written that clarifies some of the issues regarding evaluation order, and get it included in the GHC wiki. After a few iterations with review from Simon, I've got a first "publicly consumable" version available at: https://www.fpcomplete.com/user/snoyberg/general-haskell/advanced/evaluation... I'd appreciate any feedback on this document before I add it to the wiki. Michael [1] https://ghc.haskell.org/trac/ghc/ticket/9390

Dear Michael, Michael Snoyman wrote:
As part of trac ticket 9390[1], Simon PJ recommended that we try to get a document written that clarifies some of the issues regarding evaluation order, and get it included in the GHC wiki. After a few iterations with review from Simon, I've got a first "publicly consumable" version available at:
https://www.fpcomplete.com/user/snoyberg/general-haskell/advanced/evaluation...
Thanks for writing this, it looks very useful.
I'd appreciate any feedback on this document before I add it to the wiki.
[on unsafeDupablePerformIO] | And when the first thread completes the action, it may terminate the | execution of the other thread. I think it's worthwhile to stress that "bracket" does not help, because evaluation of the thunk in the other thread simply stops, without throwing an exception. Could you add something about unsafePerformIO inside STM? The upshot is that you get the behaviour of unsafeDupablePerformIO, except for the parallelism: When an STM transaction is interrupted to be retried, its evaluation simply stops. This is a known bug which causes real problems with FFI bindings, see https://ghc.haskell.org/trac/ghc/ticket/2401 http://www.haskell.org/pipermail/haskell-cafe/2014-February/112555.html but it has been around for a long time. Cheers, Bertram

On Mon, Aug 25, 2014 at 9:37 PM, Bertram Felgenhauer < bertram.felgenhauer@googlemail.com> wrote:
Dear Michael,
Michael Snoyman wrote:
As part of trac ticket 9390[1], Simon PJ recommended that we try to get a document written that clarifies some of the issues regarding evaluation order, and get it included in the GHC wiki. After a few iterations with review from Simon, I've got a first "publicly consumable" version available at:
https://www.fpcomplete.com/user/snoyberg/general-haskell/advanced/evaluation...
Thanks for writing this, it looks very useful.
I'd appreciate any feedback on this document before I add it to the wiki.
[on unsafeDupablePerformIO] | And when the first thread completes the action, it may terminate the | execution of the other thread.
I think it's worthwhile to stress that "bracket" does not help, because evaluation of the thunk in the other thread simply stops, without throwing an exception.
Could you add something about unsafePerformIO inside STM? The upshot is that you get the behaviour of unsafeDupablePerformIO, except for the parallelism: When an STM transaction is interrupted to be retried, its evaluation simply stops. This is a known bug which causes real problems with FFI bindings, see
https://ghc.haskell.org/trac/ghc/ticket/2401 http://www.haskell.org/pipermail/haskell-cafe/2014-February/112555.html
but it has been around for a long time.
Cheers,
Bertram
Thanks for the feedback, I've added information on both of these points to the document (STM in its own section at the bottom, as I couldn't find a good place where it fit with the existing flow). Michael
participants (2)
-
Bertram Felgenhauer
-
Michael Snoyman