Extensible effects: An alternative to monad transformers

Oleg Kiselyov, Amr Sabry, Cameron Swords

Research output: Chapter in Book/Report/Conference proceedingConference contribution

46 Citations (Scopus)

Abstract

We design and implement a library that solves the long-standing problem of combining effects without imposing restrictions on their interactions (such as static ordering). Effects arise from interactions between a client and an effect handler (interpreter); interactions may vary throughout the program and dynamically adapt to execution conditions. Existing code that relies on monad transformers may be used with our library with minor changes, gaining efficiency over long monad stacks. In addition, our library has greater expressiveness, allowing for practical idioms that are inefficient, cumbersome, or outright impossible with monad transformers. Our alternative to a monad transformer stack is a single monad, for the coroutine-like communication of a client with its handler. Its type reflects possible requests, i.e., possible effects of a computation. To support arbitrary effects and their combinations, requests are values of an extensible union type, which allows adding and, notably, subtracting summands. Extending and, upon handling, shrinking of the union of possible requests is reflected in its type, yielding a type-and-effect system for Haskell. The library is lightweight, generalizing the extensible exception handling to other effects and accurately tracking them in types.

Original languageEnglish
Title of host publicationHaskell 2013 - Proceedings of the 2013 ACM SIGPLAN Haskell Symposium, Co-located with ICFP 2013
Pages59-70
Number of pages12
DOIs
Publication statusPublished - 2013
Event2013 ACM SIGPLAN Haskell Symposium, Haskell 2013 - Co-located with the 18th ACM SIGPLAN International Conference on Functional Programming, ICFP 2013 - Boston, MA, United States
Duration: 2013 Sept 232013 Sept 24

Publication series

NameProceedings of the ACM SIGPLAN International Conference on Functional Programming, ICFP

Other

Other2013 ACM SIGPLAN Haskell Symposium, Haskell 2013 - Co-located with the 18th ACM SIGPLAN International Conference on Functional Programming, ICFP 2013
Country/TerritoryUnited States
CityBoston, MA
Period13/9/2313/9/24

Keywords

  • Coroutine
  • Effect handler
  • Effect interaction
  • Monad
  • Monad transformer
  • Open union
  • Type and effect system

ASJC Scopus subject areas

  • Software

Fingerprint

Dive into the research topics of 'Extensible effects: An alternative to monad transformers'. Together they form a unique fingerprint.

Cite this