Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
10.1145/2503778.2503791acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
research-article

Extensible effects: an alternative to monad transformers

Published: 23 September 2013 Publication History

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.

References

[1]
A. Bauer and M. Pretnar. Programming with algebraic effects and handlers. arXiv:1203.1539 {cs.PL}, 2012.
[2]
E. C. Brady. Programming and reasoning with algebraic effects and dependent types. In ICFP {11}, page To Appear.
[3]
R. Cartwright and M. Felleisen. Extensible denotational language specifications. In M. Hagiya and J. C. Mitchell, editors, Theor. Aspects of Comp. Soft., number 789 in LNCS, pages 244--272. Springer, 1994.
[4]
D. Espinosa. Modular denotational semantics. Unpublished manuscript, 1993.
[5]
D. Espinosa. Building interpreters by transforming stratified monads. Unpublished manuscript, 1994.
[6]
D. A. Espinosa. Semantic Lego. PhD thesis, Columbia University, New York, NY, USA, 1995. UMI Order No. GAX95-33546.
[7]
A. Filinski. Representing monads. Incitetpopl1994, pages 446--457.
[8]
A. Filinski. Representing layered monads. In POPL '99, pages 175--188, New York, NY, USA, 1999. ACM.
[9]
R. Hinze. Deriving backtracking monad transformers. In ICFP '00, pages 186--197. ACM Press, 2000.
[10]
J. Hughes. The design of a pretty-printing library. In First Intl. Spring School on Adv. Functional Programming Techniques, pages 53--96, London, UK, UK, 1995. Springer-Verlag.
[11]
ICFP. ICFP '13, 2013. ACM Press.
[12]
M. Jaskelioff and E. Moggi. Monad transformers as monoid transformers. Theor. Comp. Science, 411 (51/52): 4441--4466, 2010.
[13]
O. Kammar, S. Lindley, and N. Oury. Handlers in action. In ICFP {11}, page To Appear.
[14]
D. King and P. Wadler. Combining monads. In J. Launchbury and P. Sansom, editors, Functional Programming, Glasgow 1992, Workshops in Computing, pages 134--143. Springer London, 1993.
[15]
O. Kiselyov, R. Lämmel, and K. Schupke. Strongly typed heterogeneous collections. In Proc. 2004 workshop on Haskell, pages 96--107, New York, NY, USA, 2004. ACM.
[16]
O. Kiselyov, C.-c. Shan, and A. Sabry. Delimited dynamic binding. In ICFP '06, pages 26--37. ACM Press, 2006.
[17]
D. Leijen. Koka: A language with row-polymorphic effect inference. In 1st Workshop on Higher-Order Programming with Effects (HOPE 2012). ACM, September 2012.
[18]
S. Liang, P. Hudak, and M. Jones. Monad transformers and modular interpreters. In POPL '95, pages 333--343. ACM Press, 1995.
[19]
C. Lüth and N. Ghani. Composing monads using coproducts. In ICFP '02, pages 133--144. ACM Press, 2002.
[20]
S. Marlow. An extensible dynamically-typed hierarchy of exceptions. In Proc. 2006 Haskell Workshop, pages 96--106. ACM Press, 2006.
[21]
C. McBride. The Frank manual. https://personal.cis.strath.ac.uk/conor.mcbride/pub/Frank/, 2012.
[22]
E. Moggi. Computational lambda-calculus and monads. In LICS, pages 14--23, Piscataway, NJ, USA, 1989. IEEE Press.
[23]
E. Moggi. An abstract view of programming languages. Technical Report ECS-LFCS-90--113, Edinburgh Univ., 1989.
[24]
B. O'Sullivan, J. Goerzen, and D. Stewart. Real world Haskell -- code you can believe in. O'Reilly, 2008.
[25]
G. Plotkin and M. Pretnar. Handlers of algebraic effects. In ESOP '09, pages 80--94, Berlin, Heidelberg, 2009. Springer-Verlag.
[26]
POPL. POPL '94, 1994. ACM Press.
[27]
T. Schrijvers and B. C. Oliveira. Monads, zippers and views: virtualizing the monad stack. In ICFP '11, pages 32--44, New York, NY, USA, 2011. ACM.
[28]
M. Shields and E. Meijer. Type-indexed rows. In POPL '01, pages 261--275, London, United Kingdom, Jan. 17--19, 2001. ACM Press.
[29]
G. L. Steele, Jr. How to compose monads. Technical report, Thinking Machines Corporation, Cambridge, Massachusetts, July 1993.
[30]
G. L. Steele, Jr. Building interpreters by composing monads. In POPL {26}, pages 472--492.
[31]
N. Swamy, N. Guts, D. Leijen, and M. Hicks. Lightweight monadic programming in ML. In ICFP'11, pages 15--27, Sept. 2011.
[32]
W. Swierstra. Data types à la carte. J. Funct. Program., 18 (4): 423--436, July 2008.
[33]
S. Visscher. Control.effects, 2012. URL http://github.com/sjoerdvisscher/effects.
[34]
P. Wadler. The essence of functional programming. In POPL '92, pages 1--14, New York, NY, USA, 1992. ACM.

Cited By

View all
  • (2024)Parallel Algebraic Effect HandlersProceedings of the ACM on Programming Languages10.1145/36746518:ICFP(756-788)Online publication date: 15-Aug-2024
  • (2023)Gradual Typing for Effect HandlersProceedings of the ACM on Programming Languages10.1145/36228607:OOPSLA2(1758-1786)Online publication date: 16-Oct-2023
  • (2023)Grisette: Symbolic Compilation as a Functional Programming LibraryProceedings of the ACM on Programming Languages10.1145/35712097:POPL(455-487)Online publication date: 11-Jan-2023
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
Haskell '13: Proceedings of the 2013 ACM SIGPLAN symposium on Haskell
September 2013
158 pages
ISBN:9781450323833
DOI:10.1145/2503778
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 23 September 2013

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. coroutine
  2. effect handler
  3. effect interaction
  4. monad
  5. monad transformer
  6. open union
  7. type and effect system

Qualifiers

  • Research-article

Conference

ICFP'13
Sponsor:
ICFP'13: ACM SIGPLAN International Conference on Functional Programming
September 23 - 24, 2013
Massachusetts, Boston, USA

Acceptance Rates

Haskell '13 Paper Acceptance Rate 13 of 33 submissions, 39%;
Overall Acceptance Rate 57 of 143 submissions, 40%

Upcoming Conference

ICFP '25
ACM SIGPLAN International Conference on Functional Programming
October 12 - 18, 2025
Singapore , Singapore

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)41
  • Downloads (Last 6 weeks)1
Reflects downloads up to 12 Jan 2025

Other Metrics

Citations

Cited By

View all
  • (2024)Parallel Algebraic Effect HandlersProceedings of the ACM on Programming Languages10.1145/36746518:ICFP(756-788)Online publication date: 15-Aug-2024
  • (2023)Gradual Typing for Effect HandlersProceedings of the ACM on Programming Languages10.1145/36228607:OOPSLA2(1758-1786)Online publication date: 16-Oct-2023
  • (2023)Grisette: Symbolic Compilation as a Functional Programming LibraryProceedings of the ACM on Programming Languages10.1145/35712097:POPL(455-487)Online publication date: 11-Jan-2023
  • (2022)Intrinsically-typed definitional interpreters à la carteProceedings of the ACM on Programming Languages10.1145/35633556:OOPSLA2(1903-1932)Online publication date: 31-Oct-2022
  • (2022)Modular probabilistic models via algebraic effectsProceedings of the ACM on Programming Languages10.1145/35476356:ICFP(381-410)Online publication date: 31-Aug-2022
  • (2022)Formal reasoning about layered monadic interpretersProceedings of the ACM on Programming Languages10.1145/35476306:ICFP(254-282)Online publication date: 31-Aug-2022
  • (2021)Safe mutation with algebraic effectsProceedings of the 14th ACM SIGPLAN International Symposium on Haskell10.1145/3471874.3472988(122-135)Online publication date: 18-Aug-2021
  • (2021)Not by equations alone: Reasoning with extensible effectsJournal of Functional Programming10.1017/S095679682000027131Online publication date: 27-Jan-2021
  • (2020)Effect handlers, evidentlyProceedings of the ACM on Programming Languages10.1145/34089814:ICFP(1-29)Online publication date: 3-Aug-2020
  • (2020)Effect handlers in Haskell, evidentlyProceedings of the 13th ACM SIGPLAN International Symposium on Haskell10.1145/3406088.3409022(95-108)Online publication date: 27-Aug-2020
  • Show More Cited By

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media