Concurrent System Programming with Effect Handlers

Algebraic effects and their handlers have been steadily gaining attention as a programming language feature for composably expressing user-defined computational effects. While several prototype implementations of languages incorporating algebraic effects exist, Multicore OCaml incorporates effect handlers as the primary means of expressing concurrency in the language. In this paper, we make the observation that effect handlers can elegantly express particularly difficult programs that combine system programming and concurrency without compromising performance. Our experimental results on a highly concurrent and scalable web server demonstrate that effect handlers perform on par with highly optimised monadic concurrency libraries, while retaining the simplicity of direct-style code.

[1]  J. Winter,et al.  What the “F”? , 2018, The American journal of bioethics : AJOB.

[2]  Oleg Kiselyov,et al.  Eff Directly in OCaml , 2016, ML/OCAML.

[3]  Robert Hieb,et al.  Revised 5 Report on the Algorithmic Language , 1999 .

[4]  Daan Leijen Structured asynchrony with algebraic effects , 2017, TyDe@ICFP.

[5]  Don Syme,et al.  The F# Asynchronous Programming Model , 2011, PADL.

[6]  Daniel P. Friedman,et al.  Constraining control , 1985, POPL.

[7]  Simon L. Peyton Jones,et al.  Extending the Haskell foreign function interface with concurrency , 2004, Haskell '04.

[8]  Philip Wadler,et al.  The essence of functional programming , 1992, POPL '92.

[9]  Jonathan Rees,et al.  Revised3 report on the algorithmic language scheme , 1986, SIGP.

[10]  Philip Wadler,et al.  Links: Web Programming Without Tiers , 2006, FMCO.

[11]  Gordon D. Plotkin,et al.  Adequacy for Algebraic Effects , 2001, FoSSaCS.

[12]  Oleg Kiselyov,et al.  Freer monads, more extensible effects , 2015, Haskell.

[13]  Tom Schrijvers,et al.  Effect handlers in scope , 2014, Haskell 2014.

[14]  Yaron Minsky,et al.  Real world OCaml , 2013 .

[15]  Edwin Brady,et al.  Programming and reasoning with algebraic effects and dependent types , 2013, ICFP.

[16]  Kent M. Pitman Condition Handling in the Lisp Language Family , 2000, Advances in Exception Handling Techniques.

[17]  R. Kent Dybvig,et al.  Revised5 Report on the Algorithmic Language Scheme , 1986, SIGP.

[18]  BradyEdwin Programming and reasoning with algebraic effects and dependent types , 2013 .

[19]  Robert Atkey,et al.  Continuation Passing Style for Effect Handlers , 2017, FSCD.

[20]  Andrej Bauer,et al.  Programming with algebraic effects and handlers , 2012, J. Log. Algebraic Methods Program..

[21]  Ohad Kammar,et al.  On the expressive power of user-defined effects: effect handlers, monadic reflection, delimited control , 2016, Journal of Functional Programming.

[22]  Tom Schrijvers,et al.  Efficient algebraic effect handlers for Prolog , 2016, Theory Pract. Log. Program..

[23]  R. Kent Dybvig,et al.  Representing control in the presence of one-shot continuations , 1996, PLDI '96.

[24]  David A. Patterson,et al.  Attack of the killer microseconds , 2017, Commun. ACM.

[25]  Conor McBride,et al.  Do be do be do , 2017, POPL.

[26]  Sam Lindley,et al.  Compiling Links Effect Handlers to the OCaml Backend , 2016 .

[27]  Amr Sabry,et al.  Extensible effects: an alternative to monad transformers , 2013, Haskell '13.

[28]  Joe Armstrong,et al.  Concurrent programming in ERLANG , 1993 .

[29]  Ohad Kammar,et al.  Handlers in action , 2013, ICFP.

[30]  Simon L. Peyton Jones,et al.  Asynchronous exceptions in Haskell , 2001, PLDI '01.

[31]  Daan Leijen,et al.  Type directed compilation of row-typed algebraic effects , 2017, POPL.

[32]  Jérôme Vouillon,et al.  Lwt: a cooperative thread library , 2008, ML '08.

[33]  Sam Lindley,et al.  Liberating effects with rows and handlers , 2016, TyDe@ICFP.

[34]  Simon L. Peyton Jones,et al.  Composable scheduler activations for Haskell , 2016, Journal of Functional Programming.

[35]  Claes Wikström,et al.  Concurrent programming in ERLANG (2nd ed.) , 1996 .

[36]  Eugenio Moggi,et al.  Notions of Computation and Monads , 1991, Inf. Comput..

[37]  Gordon D. Plotkin,et al.  Handling Algebraic Effects , 2013, Log. Methods Comput. Sci..