ABSTRACT
Algebraic effect handlers are a powerful means for describing effectful computations. They provide a lightweight and orthogonal technique to define and compose the syntax and semantics of different effects. The semantics is captured by handlers, which are functions that transform syntax trees.
Unfortunately, the approach does not support syntax for scoping constructs, which arise in a number of scenarios. While handlers can be used to provide a limited form of scope, we demonstrate that this approach constrains the possible interactions of effects and rules out some desired semantics.
This paper presents two different ways to capture scoped constructs in syntax, and shows how to achieve different semantics by reordering handlers. The first approach expresses scopes using the existing algebraic handlers framework, but has some limitations. The problem is fully solved in the second approach where we introduce higher-order syntax.
- A. Bauer and M. Pretnar. Programming with algebraic effects and handlers, 2012.Google Scholar
- E. Brady. Programming and reasoning with algebraic effects and dependent types. In Proceedings of the 18th ACM SIGPLAN International Conference on Functional programming, pages 133--144. ACM, 2013. Google ScholarDigital Library
- R. Hinze. Deriving backtracking monad transformers. In Proceedings of the Fifth ACM SIGPLAN International Conference on Functional Programming, pages 186--197. ACM, 2000. ISBN 1-58113-202-6. Google ScholarDigital Library
- M. Hyland, G. D. Plotkin, and J. Power. Combining effects: Sum and tensor. Theor. Comput. Sci., 357 (1--3): 70--99, 2006. Google ScholarDigital Library
- M. Jaskelioff. Monatron: An extensible monad transformer library. In S.-B. Scholz and O. Chitil, editors, Implementation and Application of Functional Languages - Revised Selected Papers, volume 5836 of Lecture Notes in Computer Science, pages 233--248. Springer, 2008. Google ScholarDigital Library
- M. Jaskelioff and E. Moggi. Monad transformers as monoid transformers. Theor. Comput. Sci., 411 (51--52): 4441--4466, Dec. 2010. Google ScholarDigital Library
- O. Kammar, S. Lindley, and N. Oury. Handlers in action. In Proceedings of the 18th ACM SIGPLAN International Conference on Functional programming, pages 145--158. ACM, 2013. Google ScholarDigital Library
- O. Kiselyov, A. Sabry, and C. Swords. Extensible effects: an alternative to monad transformers. In Proceedings of the 2013 ACM SIGPLAN symposium on Haskell, Haskell '13, pages 59--70. ACM, 2013. Google ScholarDigital Library
- S. Liang, P. Hudak, and M. Jones. Monad transformers and modular interpreters. In POPL'95, 1995. Google ScholarDigital Library
- kC. McBride. The Frank manual, May 2012. https://personal.cis.strath.ac.uk/conor.mcbride/pub/Frank/TFM.pdf.Google Scholar
- G. D. Plotkin and J. Power. Notions of computation determine monads. In M. Nielsen and U. Engberg, editors, Foundations of Software Science and Computation Structures, volume 2303 of Lecture Notes in Computer Science, pages 342--356. Springer, 2002. Google ScholarDigital Library
- G. D. Plotkin and J. Power. Algebraic operations and generic effects. Applied Categorical Structures, 11 (1): 69--94, 2003.Google ScholarCross Ref
- G. D. Plotkin and M. Pretnar. Handlers of algebraic effects. In ESOP, volume 5502 of Lecture Notes in Computer Science, pages 80--94. Springer, 2009. Google ScholarDigital Library
- W. Swierstra. Data types à la carte. J. Funct. Program., 18 (4): 423--436, 2008. Google ScholarDigital Library
Index Terms
- Effect handlers in scope
Recommendations
Effects as capabilities: effect handlers and lightweight effect polymorphism
Effect handlers have recently gained popularity amongst programming language researchers. Existing type- and effect systems for effect handlers are often complicated and potentially hinder a wide-spread adoption.
We present the language Effekt with the ...
Liberating effects with rows and handlers
TyDe 2016: Proceedings of the 1st International Workshop on Type-Driven DevelopmentAlgebraic effects and effect handlers provide a modular abstraction for effectful programming. They support user-defined effects, as in Haskell, in conjunction with direct-style effectful programming, as in ML. They also present a structured interface ...
Effect handlers in scope
Haskell '14Algebraic effect handlers are a powerful means for describing effectful computations. They provide a lightweight and orthogonal technique to define and compose the syntax and semantics of different effects. The semantics is captured by handlers, which ...
Comments