Effect systems (aka algebraic effects), IMHO, are a pretty powerful construct that can be used to model various kinds of patterns which traditionally require "dedicated" features to express, such as error handling, asynchronous programming (through, e.g., async/await), etc.

However, what is the cost of implementing such a feature? What are the main problems with the current implementations of effect systems?

  • 1
    $\begingroup$ There aren't many languages that implement effects, and those that do aren't remotely mainstream. Like, why aren't GADT more common? $\endgroup$ Commented May 18, 2023 at 0:21
  • 1
    $\begingroup$ I see your argument. Maybe my actual question was not properly worded. I'd like to know the main drawbacks of current implementations of effect systems. Can they be efficiently compiled? Etc. $\endgroup$ Commented May 18, 2023 at 0:28
  • 1
    $\begingroup$ They're very tough to implement. Multicore OCaml added effects, but they're not checked in the type system itself. I suspect it might be a little cumbersome to start including effects in the type system without a lot of sugar. Java's checked exceptions are somewhat similar in that method signatures need to include them and you need to catch them, and they're very unpopular because of the added verbosity (although I personally like the bit of safety they give you, even if they're misused/overused sometimes) $\endgroup$
    – user
    Commented May 18, 2023 at 1:26

1 Answer 1


Efficient implementation techniques

Effect systems have been studied in the literature to explore implementation techniques, but their maturity varies across programming languages. Compared to established features like async/await or coroutines, research on effect systems is relatively limited, there is still scope for improvement.

Multiple effect instances

Managing multiple effect instances and preserving the integrity of linear resources is a challenge. When effectful operations have multiple resumptions, it's important to handle them properly alongside linear resources while maintaining modularity and composability. Avoiding accidental mix-up of effects is another challenge, especially when using state cells simultaneously or with higher-order functions.

The implementation issues will be very language dependent, for example, for the previous issue related to managing multiple effect instances, Idris handles this using Labelled Effects, by associating unique labels to each effect instance, the labeling effects help to disambiguate between different effects.

The current problems are normally related to:

  • Efficient implementation techniques
  • Composition and modularity
  • Tooling and Development Support
  • Static analysis and verification of programs using algebraic effects
  • Minimize the performance overhead associated with effects
  • Interacting with a language's FFI
  • Implementation without penalizing legacy programs

They are complicated

Besides some technical details, there's a huge problem that's often ignored: they are complicated. It is a bit like thinking about async/await in 2000, algebraic effects are a fairly complex abstraction. An abstaction over exceptions, coroutines, error handling, state, sometimes subtyping, and other things? It's a little too much for most people, and without clear guidelines or community consensus, different languages or frameworks may implement their own variations of effect systems.

While progress has been made in the implementation of effect systems, there is still ongoing research and exploration to address these challenges. Researchers are actively studying efficient implementation techniques for effect handlers, aiming to improve their performance and usability. As an example, see the OCaml library eio, which makes crucial use of effect handlers to implement efficient I/O in direct-style. We have only begun to scratch the surface here. It will be exciting to see what kind of applications people come up with.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .