Abstract

AbstractWe explore the design and implementation of Frank, a strict functional programming language with a bidirectional effect type system designed from the ground up around a novel variant of Plotkin and Pretnar’s effect handler abstraction. Effect handlers provide an abstraction for modular effectful programming: a handler acts as an interpreter for a collection of commands whose interfaces are statically tracked by the type system. However, Frank eliminates the need for an additional effect handling construct by generalising the basic mechanism of functional abstraction itself. A function is but the special case of a Frankoperatorthat interprets no commands. Moreover, Frank’s operators can bemultihandlerswhich simultaneously interpret commands from several sources at once, without disturbing the direct style of functional programming with values. Effect typing in Frank employs a novel form of effect polymorphism which avoids mentioning effect variables in source code. This is achieved by propagating anambient abilityinwards, rather than accumulating unions of potential effects outwards. With the ambient ability describing the effects that are available at a certain point in the code, it can become necessary to reconfigure access to the ambient ability. A primary goal is to be able to encapsulate internal effects, eliminating a phenomenon we calleffect pollution. Moreover, it is sometimes desirable to rewire the effect flow between effectful library components. We propose adaptors as a means for supporting both effect encapsulation and more general rewiring. Programming with effects and handlers is in its infancy. We contribute an exploration of future possibilities, particularly in combination with other forms of rich type systems.

Highlights

  • IntroductionWe say “Yes”: purity is a choice to make locally. We introduce Frank, an applicative language where the meaning of “impure” computations is open to negotiation, based on Plotkin and Pretnar’s effect handlers (Plotkin & Pretnar, 2013)—a rich foundation for effectful programming

  • Shall I be pure or impure?—Philip Wadler (1992)We say “Yes”: purity is a choice to make locally

  • We introduce Frank, an applicative language where the meaning of “impure” computations is open to negotiation, based on Plotkin and Pretnar’s effect handlers (Plotkin & Pretnar, 2013)—a rich foundation for effectful programming

Read more

Summary

Introduction

We say “Yes”: purity is a choice to make locally. We introduce Frank, an applicative language where the meaning of “impure” computations is open to negotiation, based on Plotkin and Pretnar’s effect handlers (Plotkin & Pretnar, 2013)—a rich foundation for effectful programming. There have been several efforts to build object-oriented effect handler libraries in Scala (Brachthäuser et al, to appear; Brachthäuser & Schuster, 2017) and Java (Brachthäuser et al, 2018; Inostroza & van der Storm, 2018) These incorporate effect type systems not dissimilar to those of Kammar et al.’s Haskell library, encoded via Java classes in place of type classes. The primary new contributions in this paper are a direct semantics (previously the semantics was given by translation to a core language) and extensions to Frank with polymorphic commands and adaptors to support effect encapsulation and enable the rewiring of effect flow. Frank is a functional programming language with effects and handlers in the spirit of Eff (Bauer & Pretnar, 2015), controlled by a type system inspired by Levy’s call-bypush-value (CBPV) (Levy, 2004). Doing and Being are clearly separated and managed by distinguished notions of computation and value types

Data types and first-order functions
Effect polymorphism in ambient silence
Controlling evaluation
Polymorphic commands
Direct style for monadic programming
Handling by application
Handling multiple arguments at once
The catch question
2.10 The disappearance of control
Adapting effects
Typing rules
Operational semantics
Computations as data
Concurrency in Frank
Implementation
Adaptor variations and extensions
Related work
11 Conclusion

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.