Programming with Effect Handlers by Sudha Parimala

February 14, 2024

Sudha Parimala introduces the concept of effect handlers, a mechanism for nonlinear control flow in programs that allows for the suspension and resumption of computations. She explains that effect handlers are similar to exception handlers but can resume computation from where it was left off, and provides examples of how they can be used to build programming abstractions such as generators, asynchronous programming, and lightweight threads.

Programming with Effect Handlers: A comprehensive overview

Sudha Parimala takes us on a journey into the world of effect handlers, a mechanism for nonlinear control flow in programs, in her captivating presentation.


Introduction to effect handlers

Sudha introduces the concept of effect handlers, likening them to exception handlers but with the ability to suspend and resume computations. She demonstrates how effect handlers can be used to build powerful programming abstractions such as generators, asynchronous programming, and lightweight threads.


Practical applications

Effect handlers are not just theoretical constructs; they find practical applications in both educational and mainstream programming languages. Sudha highlights their usage in languages like Ocaml, Scala, and even in languages like C++, Python, and JavaScript through libraries.


Implementation and examples

Sudha delves into the implementation details of effect handlers, using examples to illustrate their practical usage. She walks us through a simple example, showcasing how effect declarations are made and how computations can be suspended and resumed using handlers.


Impact on concurrency

The introduction of effect handlers has had a significant impact on languages like Ocaml, shaping their concurrency story. Sudha discusses how effect handlers have addressed limitations with monadic libraries, leading to more flexible and concurrent programming paradigms.


Benefits of Effect-Based Libraries:

Sudha emphasizes the benefits of using effect-based concurrency libraries over traditional monadic ones. These libraries allow concurrent code to be written in the same style as non-concurrent code, making it easier to read and maintain.


Unified concurrency solution

Recognizing the need for a unified solution to handle concurrency across different libraries, Sudha introduces proposals like suspend and resume effects and domain-local variables. She presents EOS (Effect-Based Concurrency Library) as a refined framework for building interoperable concurrency libraries.


Future developments

Sudha discusses ongoing efforts to improve effects and peos, with plans to support FX syntax, introduce type defects, and enhance FX safety. These features aim to enable libraries to work together seamlessly and improve overall stability and reliability.


Sudha Parimala’s insightful exploration of programming with effect handlers provides a deeper understanding of nonlinear control flow mechanisms and their practical applications in building robust and scalable software systems


Additional resources

Check out more from the MeetUp Func Prog Sweden. Func Prog Sweden is the community for anyone interested in functional programming. At the MeetUps the community explore different functional languages like Erlang, Elixir, Haskell, Scala, Clojure, OCaml, F# and more.