O N THE EXPRESSIVENESS OF EFFECT HANDLERS AND MONADIC REFLECTION Yannick Forster supvervised by Ohad Kammar and Marcelo Fiore
Introduction Approach Expressiveness Conclusion A LITTLE SURVEY ◮ Who has ever tried to prove a functional program correct? ◮ Who has ever tried for a program involving reference cells or exceptions? ◮ Who has succeeded? ◮ Who thought it was fun? 2
Introduction Approach Expressiveness Conclusion H OW TO INCORPORATE EFFECTS ? Effects are . . . ◮ global store (i.e. references), ◮ exceptions, ◮ I/O, ◮ random, ◮ nondeterminism, ◮ or concurrency 3
Introduction Approach Expressiveness Conclusion A N EXAMPLE exception Error val r = ref 0 fun error () = raise Error fun test () = (r := 5; error() handle Error => !r) test() evaluates to? Why not to 0 ? 4
Introduction Approach Expressiveness Conclusion W OULD BE COOL : User definable effects on top of a functional language There is more than one solution available! 5
Introduction Approach Expressiveness Conclusion G OAL Compare two existing approaches in their expressiveness A bit like “Compare expressiveness of recursion and for-loops” 6
Introduction Approach Expressiveness Conclusion A PPROACH ◮ take a base language (functional, typed, no recursion) ◮ add each concept to the language ◮ define denotational semantics to each resulting calculus ◮ prove denotational semantics to be adequate ◮ use this to compare expressiveness 7
Introduction Approach Expressiveness Conclusion T AKE A BASE LANGUAGE Call-by-push-value lambda-calculus from Levy Distinguishes between values and computations Levy (1999), Levy (2004) 8
Introduction Approach Expressiveness Conclusion ADD EACH CONCEPT ◮ Effects and handler calculus λ eff ◮ Monadic reflection calculus λ mon Kammar, Lindley, and Oury (2013), Filinski (2010) 9
Introduction Approach Expressiveness Conclusion E FFECT HANDLERS 10
Introduction Approach Expressiveness Conclusion M ONADIC REFLECTION 11
Introduction Approach Expressiveness Conclusion D ENOTATIONAL SEMANTICS ◮ Define what types “mean” in pure set theory ◮ Define what terms “mean” in pure set theory 12
Introduction Approach Expressiveness Conclusion A DEQUACY AND S OUNDNESS 13
Introduction Approach Expressiveness Conclusion T YPED MACRO EXPRESSABILITY One concept can express another if there is a local translation function that: ◮ is homomorphic on the base calculus ◮ replaces new syntactic constructs without rearranging the whole program ◮ translates terms ∅ ⊢ M : X to terms ∅ ⊢ M : X Felleisen (1990) 14
Introduction Approach Expressiveness Conclusion F OCUS IN THIS THESIS Produce negative results: Prove that no translation exists with the help of denotational semantics 15
Introduction Approach Expressiveness Conclusion λ mon CAN NOT TYPED MACRO EXPRESS λ eff ◮ There are only finitely many terms for every type in λ mon ◮ Some types in λ eff have countably many observationally distinguishable terms ◮ Given a translation λ eff → λ mon , take the type F 1 ◮ F 1 has k terms ◮ F 1 has more than k observationally distinguishable terms ◮ Derive a contradiction 16
Introduction Approach Expressiveness Conclusion T HE BIG PICTURE 17
Introduction Approach Expressiveness Conclusion C ONTRIBUTION ◮ Adequacy proof for the set theoretic model for calculus of effect handlers λ eff ◮ Adequate denotational semantics for calculus of monadic reflection λ mon ◮ Definition of (typed) macro expressability ◮ Proof that λ mon is macro expressible in λ eff ◮ Proof that λ eff is not macro typed expressible in λ mon 18
Introduction Approach Expressiveness Conclusion F UTURE WORK ◮ Show that λ mon is not typed macro expressible in λ eff ; ◮ extend the type system of λ eff to typed macro express λ mon ; ◮ do similar comparison for calculus of delimited control. 19
Introduction Approach Expressiveness Conclusion R ELATED WORK / B IBLIOGRAPHY ◮ Paul Blain Levy. Call-By-Push-Value: A Functional/Imperative Synthesis, volume 2 of Semantics Structures in Computation. Springer, 2004. ◮ Ohad Kammar, Sam Lindley, and Nicolas Oury. Handlers in action. SIGPLAN Not. 48(9):145–158, September 2013. ◮ Andrzej Filinski. Monads in action. SIGPLAN Not., 45(1):483–494, January 2010. ◮ Matthias Felleisen. On the expressive power of programming languages. In Science of Computer Programming, pages 134–151. Springer-Verlag, 1990. 20
21
22
Recommend
More recommend