an introduction to call-by-push-value

19
An introduction to call-by-push-value calculus H Koba

Upload: k-h

Post on 13-Apr-2017

122 views

Category:

Engineering


3 download

TRANSCRIPT

Page 1: An introduction to call-by-push-value

An introduction to call-by-push-value calculus

H Koba

Page 2: An introduction to call-by-push-value

Overview of this talk• (1) Introduction• CbPV• Embedding CbV and CbN strategy in the same system

• (2) Semantics• CbV, CbN’s semantics using monads• CbPV’s semantics, using EM adjunction

Page 3: An introduction to call-by-push-value

Introduction• Types and

terms• [Levy, 2016]

(p. 3)

Page 4: An introduction to call-by-push-value

Introduction• Computations with

side effects• [Levy, 2016]

(p. 8)• Behavior of

constructs depends on the evaluation strategy• CbV, CbN, …

Page 5: An introduction to call-by-push-value

Introduction• CbV strategy

[Levy, 2016](p.7)• Arguments are

evaluated before substitution

Page 6: An introduction to call-by-push-value

Introduction• CbN strategy

[Levy, 2016](p.6)• Substitutions

occur before evaluating arguments

Page 7: An introduction to call-by-push-value

Introduction• How can we handle them in a single calculus?• Need to control evaluation order• Call-by-push-value calculus• distinction between “values” and “computations”

• Values: what do not need evaluation• Computations: what need evaluation

Page 8: An introduction to call-by-push-value

Introduction

• Call-by-push-value calculus [Levy, 2016] (p. 30)• Computation types are underlined

Page 9: An introduction to call-by-push-value

Introduction• [Levy, 2016] (p. 32)• return and to• like Haskell’s return

and >>=• thunk and force• No counterparts in

Haskell

Page 10: An introduction to call-by-push-value

Introduction• [Levy, 2016] (p. 37)• Embedding of CbV to

CbPV• In function

application, N is evaluated first

Page 11: An introduction to call-by-push-value

Introduction• [Levy, 2016] (p. 38)• Embedding of CbN to

CbPV• In function

application, evaluation of N is delayed (until the thunk is evaluated)

Page 12: An introduction to call-by-push-value

Summary• We have a calculus call-by-push-value• We have embeddings of CbV and CbN to CbPV

Page 13: An introduction to call-by-push-value

Semantics• (Denotational) semantics of pure typed lambda calculus is CCC (like

Sets)• Types -> objects, terms -> arrows

• , • Semantics of is

• What about non-pure computations?• Use monads to define denotational semantics• CbV and CbN need different categories

• CbV -> Kl(T), CbN -> EM(T)

Page 14: An introduction to call-by-push-value

Semantics• CbV’s semantics: Kl(T)• Due to Moggi (1988)

• Figure from [Levy, 2016] (p. 15)• Types -> objects in Kl(T) =

objects in C• Terms -> arrows in Kl(T) =

Kleisli arrows

Page 15: An introduction to call-by-push-value

Semantics• CbN’s semantics: EM(T)• Eilenberg-Moore category

• Figure from [Levy, 2016] (p. 29)• Types -> objects in EM(T) =

EM algebras• Terms -> An arrow (in C) for

some EM algebra

Page 16: An introduction to call-by-push-value

Semantics• CbPV’s semantics: The adjunction • Value -> object in C• Computation -> object in EM(T) (Eilenberg-Moore algebra)• Embedding of CbV and CbN preserves semantics:• Recall in CbV becomes in CbPV• This is isomorphic to !

• is a limit, so it is preserved by (right adjoint of )

Page 17: An introduction to call-by-push-value

Semantics• and are adjoint functors• Recall: ([Levy, 2016] (p. 30))

Page 18: An introduction to call-by-push-value

Summary• Embedding of CbV and CbN preserves semantics• Monad is decomposed into adjunction

Page 19: An introduction to call-by-push-value

References• [Levy, 2016] P.B.Levy, A tutorial on call-by-push-value (2016)

https://www.cs.bham.ac.uk/~pbl/papers/cbpvefftt.pdf • It describes denotational semantics of CbV and CbN first, then introduces

CbPV using them.

• [Levy, 1999] P.B.Levy. Call-By-Push-Value: A Subsuming Paradigm (Extended Abstract) (1999)• [Moggi, 1988] E. Moggi, Computational lambda-calculus and monads

(1988)