Abstract

AbstractEffect handlers are a promising way to structure effectful programs in a modular way. We present the Scala libraryEffekt, which is centered around capability passing and implemented in terms of a monad for multi-prompt delimited continuations.Effektis the first library implementation of effect handlers that supports effect safety and effect polymorphism without resorting to type-level programming. We describe a novel way of achieving effect safety using intersection types and path-dependent types. The effect system of our library design fits well into the programming paradigm of capability passing and is inspired by the effect system of Zhang & Myers (2019,Proc. ACM Program. Lang.3(POPL), 5:1-5:29). Capabilities carry an abstract type member, which represents an individual effect type and reflects the use of the capability on the type level. We represent effect rows as the contravariant intersection of effect types. Handlers introduce capabilities and remove components of the intersection type. Reusing the existing type system of Scala, we get effect subtyping and effect polymorphism for free.

Highlights

  • To get a first impression of Effekt, consider the following piece of code written in Scala and using our library

  • We describe a novel way of achieving effect safety in a library embedding using intersection types and path-dependent types

  • While we aim to achieve an effect-safe implementation of effect handlers, as an intermediate step, we present a monadic implementation of delimited control (Section 3) to show how to restrict it to an effect-safe, yet useful subset (Section 4)

Read more

Summary

Introduction

To get a first impression of Effekt, consider the following piece of code written in Scala and using our library. It models a coin toss, but with a twist: the gambler might be too drunk and lose the coin (Kammar et al, 2013). The program uses two effect operations: flip and raise. The effect operation flip is used to nondeterministically decide whether the gambler is too drunk to catch the coin. We use the effect operation raise to signal an exception. We return the result of a second coin toss as a string

Objectives
Discussion
Conclusion
Full Text
Published version (Free)

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