Effect system explained

In computing, an effect system is a formal system that describes the computational effects of computer programs, such as side effects. An effect system can be used to provide a compile-time check of the possible effects of the program.

The effect system extends the notion of type to have an "effect" component, which comprises an effect kind and a region. The effect kind describes what is being done, and the region describes with what (parameters) it is being done.

An effect system is typically an extension of a type system. The term "type and effect system" is sometimes used in this case. Often, a type of a value is denoted together with its effect as type ! effect, where both the type component and the effect component mention certain regions (for example, a type of a mutable memory cell is parameterized by the label of the memory region in which the cell resides). The term "algebraic effect" follows from the type system.

Effect systems may be used to prove the external purity of certain internally impure definitions: for example, if a function internally allocates and modifies a region of memory, but the function's type does not mention the region, then the corresponding effect may be erased from the function's effect.[1]

Examples

Some examples of the behaviors that can be described by effect systems include:

From a programmer's point of view, effects are useful as it allows for separating the implementation (how) of specific actions from the specification of what actions to perform. For example, an ask name effect can read from either the console, pop a window, or just return a default value. The control flow can be described as a blend of yield (in that the execution continues) and throw (in that an unhandled effect propagates down until handled).[2]

Implementations

Core feature

Full support

Partial support and prototypes

References

Textbook chapters

Overview papers

Further reading

Notes and References

  1. Book: Turbak . Franklyn Albin . Gifford . David K. . Sheldon . Mark A. . 2010 . Design concepts in programming languages . PHI Learning . 978-81-203-3996-5 . 1261053520 .
  2. Web site: Abramov . Dan . 21 July 2019 . Algebraic Effects for the Rest of Us . overreacted.io . 20 August 2025 . en .
  3. Web site: Leijen . Daan . 22 July 2025 . The Koka Programming Language . koka-lang.github.io . live . https://web.archive.org/web/20250726021620/https://koka-lang.github.io/koka/doc/book.html . 26 July 2025 . 20 August 2025 .
  4. Web site: Eff programming language . eff-lang.org . 20 August 2025 .
  5. Web site: The Unison language . www.unisonweb.org . deviated . https://web.archive.org/web/20211205232903/https://www.unisonweb.org/ . 5 December 2021 . 7 December 2021 .
  6. Web site: The Effekt research team. Effekt Language: Concepts and Features . 13 June 2023 . Effekt Language.
  7. Web site: Vera . Josh . freemonad benchmark . GitHub . 18 April 2020 . A benchmark comparing the performance of different free monad implementations..
  8. Moggi . E. . Sabry . Amr . November 2001 . Monadic encapsulation of effects: a revised approach (extended version) . Journal of Functional Programming . en . 11 . 6 . 591–627 . 10.1017/S0956796801004154 . 0956-7968.
  9. Web site: Chapter 12 Language extensions . v2.ocaml.org . live . https://web.archive.org/web/20230613204206/https://v2.ocaml.org/manual/effects.html . 13 June 2023 . 13 June 2023.
  10. Web site: CanThrow Abilities. 7 December 2021. Scala Documentation.
  11. Web site: Pulley . Rocky . 12 August 2013 . Java 8 Lambda function that throws exception? . Stack Overflow . 25 December 2021 .