Affiliation:
1. Imperial College London, UK
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.
Funder
Engineering and Physical Sciences Research Council
Publisher
Association for Computing Machinery (ACM)
Subject
Safety, Risk, Reliability and Quality,Software
Reference46 articles.
1. Handling fibred algebraic effects
2. Andrej Bauer. 2018. What is algebraic about algebraic effects and handlers? arxiv:1807.05923. arxiv:1807.05923 Andrej Bauer. 2018. What is algebraic about algebraic effects and handlers? arxiv:1807.05923. arxiv:1807.05923
3. An Effect System for Algebraic Effects and Handlers
4. Programming with algebraic effects and handlers
5. Handle with care: relational interpretation of algebraic effects and handlers
Cited by
7 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献
1. Making a Curry Interpreter using Effects and Handlers;Proceedings of the 17th ACM SIGPLAN International Haskell Symposium;2024-08-28
2. A framework for higher-order effects & handlers;Science of Computer Programming;2024-05
3. Modular Denotational Semantics for Effects with Guarded Interaction Trees;Proceedings of the ACM on Programming Languages;2024-01-05
4. Modular Models of Monoids with Operations;Proceedings of the ACM on Programming Languages;2023-08-30
5. Reasoning about MLIR Semantics through Effects and Handlers;Proceedings of the 32nd ACM SIGSOFT International Symposium on Software Testing and Analysis;2023-07-12