Open Transactional Actions: Interacting with
Non-transactional Resources in STM Haskell
Jonathas Augusto de Oliveira
Conceição
Federal University of Pelotas
Pelotas, Brazil
jadoliveira@inf.ufpel.edu.br
André Rauber Du Bois
PPGC - Federal University of Pelotas
Pelotas, Brazil
dubois@inf.ufpel.edu.br
Samuel da Silva Feitosa
Federal University of Fronteira Sul
Chapecó, Brazil
samuel.feitosa@ufs.edu.br
Gerson Geraldo Homrich
Cavalheiro
PPGC - Federal University of Pelotas
Pelotas, Brazil
gerson.cavalheiro@inf.ufpel.edu.br
Rodrigo Geraldo Ribeiro
PPGCC - Federal University of Ouro
Preto
Ouro Preto, Brazil
rodrigo.ribeiro@ufop.edu.br
Abstract
This paper addresses the problem of accessing external re-
sources from inside transactions in STM Haskell, and for that
purpose introduces a new abstraction called Open Transac-
tional Actions (OTAs) that provides a framework for wrap-
ping non-transactional resources in a transactional layer.
OTAs allow the programmer to access resources through IO
actions, from inside transactions, and also to register commit
and abort handlers: the former are used to make the accesses
to resources visible to other transactions at commit time, and
the latter to undo changes in the resource if the transaction
has to roll back. OTAs, once started, are guaranteed to be
executed completely before the hosting transaction can be
aborted, guarantying that if a resource is accessed, its respec-
tive commit and abort actions will be properly registered.
We believe that OTAs could be used by expert programmers
to implement useful system libraries and also to give a trans-
actional semantics to fast linearizable data structures, i.e.,
transactional boosting. As a proof of concept, we present
examples that use OTAs to implement transactional fle ac-
cess and transactional boosted data types that are faster than
pure STM Haskell in most cases.
CCS Concepts: · Software and its engineering → Func-
tional languages; Concurrent programming languages.
Permission to make digital or hard copies of all or part of this work for
personal or classroom use is granted without fee provided that copies
are not made or distributed for proft or commercial advantage and that
copies bear this notice and the full citation on the frst page. Copyrights
for components of this work owned by others than the author(s) must
be honored. Abstracting with credit is permitted. To copy otherwise, or
republish, to post on servers or to redistribute to lists, requires prior specifc
permission and/or a fee. Request permissions from permissions@acm.org.
Haskell ’22, September 15–16, 2022, Ljubljana, Slovenia
© 2022 Copyright held by the owner/author(s). Publication rights licensed
to ACM.
ACM ISBN 978-1-4503-9438-3/22/09. . . $15.00
htps://doi.org/10.1145/3546189.3549924
Keywords: transactional memory, functional programming,
transactional boosting, Haskell
ACM Reference Format:
Jonathas Augusto de Oliveira Conceição, André Rauber Du Bois,
Samuel da Silva Feitosa, Gerson Geraldo Homrich Cavalheiro, and Ro-
drigo Geraldo Ribeiro. 2022. Open Transactional Actions: Interact-
ing with Non-transactional Resources in STM Haskell. In Proceed-
ings of the 15th ACM SIGPLAN International Haskell Symposium
(Haskell ’22), September 15–16, 2022, Ljubljana, Slovenia. ACM, New
York, NY, USA, 12 pages. htps://doi.org/10.1145/3546189.3549924
1 Introduction
Transactional Memory (TM) is an abstraction that provides
a higher-level abstraction for concurrent/parallel program-
ming: critical sections of the code are accessed through trans-
actions, similar to data-base transactions, that appear to the
programmer to be executed atomically with respect to other
concurrently executed transactions. The underlying trans-
actional system must guarantee atomicity, consistency and
isolation, when transactions concurrently access shared data.
Many important aspects of software development are im-
proved, such as composability, robustness, and correctness.
STM Haskell is a mature and widely used extension of
Haskell for transactional memory that was frst introduced
in 2005 [18]. In STM Haskell, transactions operate on transac-
tional variables (also called TVars) which are special shared
memory variables that can only be accessed by transactions.
The type system guarantees that the only operations allowed
to occur inside transactions are the ones related to creating,
writing and reading transactional variables, pure computa-
tions, and also operations to compose transactions into new
ones. Confict detection between transactions is done in a
fne grain level, based on reads and writes to TVars. Such
confict detection scheme, which is used in most TM sys-
tems, has its disadvantages as it might limit concurrency
for certain objects specially if they are the source of high-
contention [20]. Furthermore, as the type system guarantees
that only TVars operations are allowed in transactions the
54