Twilight STM for Haskell

The Twilight STM enhances a transaction with twilight code that executes between the preparation to commit the transaction and its actual commit or abort. Twilight code runs irrevocably and concurrently with the rest of the program. It can detect and repair potential read inconsistencies in the state of its transaction and may thus turn a failing transaction into a successful one. Moreover, twilight code can safely use I/O operations while modifying the transactionally managed memory. We developed a Twilight library for Haskell. It employs Haskell's type system to restrict operations to the atomic or the twilight phase, depending on where they are safe to use.

It features:

  • an-easy to-use API with powerful primitives,
  • application specific conflict detection,
  • and usage of I/O operations within transactions!


A full formalization of Twilight STM with proofs for several semantics are available here: The semantics of Twilight Transactions.

Further details on Twilight STM can be found in the technical report:

  • Annette Bieniusa, Arie Middelkoop and Peter Thiemann.

    Actions in the Twilight: Concurrent irrevocable transactions and Inconsistency repair.

    Technical Report 257, Insitut für Informatik, Universität Freiburg, 2010.


The implementation is released under the GPL.


For further information, bug reports, etc. please contact: Annette Bieniusa.