Abstract

Effect handlers can be composed by applying them sequentially, each handling some operations and leaving other operations uninterpreted in the syntax tree. However, the semantics of composed handlers can be subtle---it is well known that different orders of composing handlers can lead to drastically different semantics. Determining the correct order of composition is a non-trivial task. To alleviate this problem, this paper presents a systematic way of deriving sufficient conditions on handlers for their composite to correctly handle combinations, such as the sum and the tensor, of the effect theories separately handled. These conditions are solely characterised by the clauses for relevant operations of the handlers, and are derived by fusing two handlers into one using a form of fold/build fusion and continuation-passing style transformation. As case studies, the technique is applied to commutative and distributive interaction of handlers to obtain a series of results about the interaction of common handlers: (a) equations respected by each handler are preserved after handler composition; (b) handling mutable state before any handler gives rise to a semantics in which state operations are commutative with any operations from the latter handler; (c) handling the writer effect and mutable state in either order gives rise to a correct handler of the commutative combination of these two theories.

Highlights

  • Algebraic effects [Plotkin and Power 2002] and their handlers [Plotkin and Pretnar 2009, 2013] are inherently a modular approach to modelling computational effects: algebraic theories of effects specify effects and handlers implement them

  • The results developed in this paper apply to any language implementing effect handlers that has a denotational semantics based on the constructions studied in this paper

  • This paper has studied a way to reason about the semantics of sequentially composed handlers by fusing them into one, which allows us to derive relatively simple conditions for the semantics of the composite handler to agree with any combination of the effect theories separately handled

Read more

Summary

Introduction

Algebraic effects [Plotkin and Power 2002] and their handlers [Plotkin and Pretnar 2009, 2013] are inherently a modular approach to modelling computational effects: algebraic theories of effects specify effects and handlers implement them. Both algebraic theories and handlers are composable in their own right. Effect handlers are composable by running them sequentially, each handling a set of operations in the computation and forwarding other operations.

Objectives
Results
Conclusion
Full Text
Paper version not known

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call

Disclaimer: All third-party content on this website/platform is and will remain the property of their respective owners and is provided on "as is" basis without any warranties, express or implied. Use of third-party content does not indicate any affiliation, sponsorship with or endorsement by them. Any references to third-party content is to identify the corresponding services and shall be considered fair use under The CopyrightLaw.