## Linearly-used state in models of call-by-value

Citations: | 5 - 5 self |

### BibTeX

@MISC{Møgelberg_linearly-usedstate,

author = {Rasmus Ejlers Møgelberg and Sam Staton},

title = {Linearly-used state in models of call-by-value},

year = {}

}

### OpenURL

### Abstract

Abstract. We investigate the phenomenon that every monad is a linear state monad. We do this by studying a fully-complete state-passing translation from an impure call-by-value language to a new linear type theory: the enriched call-by-value calculus. The results are not specific to store, but can be applied to any computational effect expressible using algebraic operations, even to effects that are not usually thought of as stateful. There is a bijective correspondence between generic effects in the source language and state access operations in the enriched call-byvalue calculus. From the perspective of categorical models, the enriched call-by-value calculus suggests a refinement of the traditional Kleisli models of effectful call-by-value languages. The new models can be understood as enriched adjunctions. 1

### Citations

733 | Notions of Computation and Monads
- Moggi
- 1991
(Show Context)
Citation Context ... and functional programming languages exhibiting such behaviour are thought of as “impure”. However, computational effects can be encapsulated within a purely functional language by the use of monads =-=[12]-=-. The central idea behind this is to distinguish between a type of values such as (nat), and a type of computations T (nat) that may return a value of type nat but can also do other things along the w... |

377 | Basic concepts of enriched category theory, volume 64
- Kelly
- 1982
(Show Context)
Citation Context ... which is initial (with respect to an appropriate notion of morphism). 5.2 Enriched call-by-value models The categorical notion of model for ECBV involves basic concepts from enriched category theory =-=[9]-=-. Let us recall some rudiments. Following [7, 6], we begin with actions of categories. Let V be a category with finite products. Recall that an action of V on a category C is a functor ·: V × C → C to... |

125 |
The formal theory of monads
- Street
- 1972
(Show Context)
Citation Context ... be the 2-category whose objects are monad models (V, T ). A 1-cell (V, T ) → (V ′ , T ′ ) is a functor F : V → V ′ together with a natural isomorphism φ: T ′ F ∼ = F T making (F, φ) a monad morphism =-=[26]-=-, and such that F preserves products and coproducts, strengths and Kleisli exponentials. The 2-cells are natural coherent isomorphisms. These definitions can be extended to 2-categories ENRE, MNDE who... |

99 | Premonoidal categories and notions of computation
- Power, Robinson
- 1997
(Show Context)
Citation Context ...s a coreflection. 5.4 Remark: Closed Freyd categories Closed Freyd categories [20] are an alternative way of presenting monad models. Freyd categories are usually defined using premonoidal categories =-=[23]-=-, but we will use the following equivalent definition using actions (following [10, App. B]). A distributive closed Freyd category [22] can be described as an enriched model (V, C) together with an id... |

97 |
On closed categories of functors
- Day
- 1974
(Show Context)
Citation Context ...eserve them. Since V is distributive, FP(Vop , Set) is cartesian closed (see [5]). We now show that FP(Cop , Set) is enriched in FP(Vop , Set) with powers and copowers. Recall the construction of Day =-=[1]-=-, which induces a monoidal biclosed structure on Â (= [Aop, Set]) for every monoidal structure on any category A. We develop this in two ways. First, the monoidal action of V on C induces a monoidal a... |

55 | From Algol to polymorphic linear lambda-calculus
- O’Hearn, Reynolds
(Show Context)
Citation Context ...r later, nor can they discard the state and insert a new one instead. This special status of the state was already noted by Strachey [25] and Scott [24] and has been developed by O’Hearn and Reynolds =-=[13]-=-. Linear usage of state can be expressed syntactically using a linear state passing style, in which a stateful computation of type A → B is considered as a linear map of type !A ⊗ S ⊸ !B ⊗ S. The type... |

55 | Notions of computation determine monads
- Plotkin, Power
- 2002
(Show Context)
Citation Context ...ignl with typing judgements Γ ⊢p derefl : Val and Γ ⊢p assignl (V ): 1 if Γ ⊢v V : Val. We add to the theory of equality in Figure 1 the seven equations for global store proposed by Plotkin and Power =-=[18]-=-, for example the two equations derefl to x. assign l (x) = return (⋆) (3) assign l (V ) to x. assign l (W ) = assign l (W ) (4)Linearly-used state in models of call-by-value 5 which state that readi... |

33 | Power.Algebraic Operations and Generic Effects
- Plotkin, John
- 2003
(Show Context)
Citation Context ...f computations T (nat) that may return a value of type nat but can also do other things along the way. Imperative behaviour can then be encoded using generic effects in the sense of Plotkin and Power =-=[19]-=-. For example, one can add global store by adding a pair of terms, assign l : Val → T (1) and derefl : T (Val), for each cell l in the store, or one can add nondeterminism by adding a constant random:... |

30 |
call-by-value and the λ-calculus. Theoret
- Plotkin
- 1975
(Show Context)
Citation Context ...ns. 2 Source calculus: Fine-Grained Call-by-Value Our source language is a call-by-value language equipped with an equational theory to be thought of as generated by some operational semantics, as in =-=[14]-=-. We use a variant of fine-grained call-by-value [11], because the explicit separation of judgements into value and producer judgements fits well with a similar division in the target language. We use... |

27 |
The varieties of programming language
- Strachey
- 1972
(Show Context)
Citation Context ... of linear usage: computations cannot copy the state and save it for later, nor can they discard the state and insert a new one instead. This special status of the state was already noted by Strachey =-=[25]-=- and Scott [24] and has been developed by O’Hearn and Reynolds [13]. Linear usage of state can be expressed syntactically using a linear state passing style, in which a stateful computation of type A ... |

14 | Modelling environments in call-by-value programming languages
- Levy, Power, et al.
(Show Context)
Citation Context ...we introduce the enriched call-by-value calculus (ECBV). We show that a special state type in ECBV gives rise to a language that is equivalent to a fine-grained monadic call-by-value calculus (FGCBV) =-=[11]-=-. On the semantic side we introduce a notion of enriched call-by-value model which generalises monad models. Central to our treatment of state is the idea of linear usage: computations cannot copy the... |

11 |
A.: Enrichment through variation
- Gordon, Power
- 1997
(Show Context)
Citation Context ...iate notion of morphism). 5.2 Enriched call-by-value models The categorical notion of model for ECBV involves basic concepts from enriched category theory [9]. Let us recall some rudiments. Following =-=[7, 6]-=-, we begin with actions of categories. Let V be a category with finite products. Recall that an action of V on a category C is a functor ·: V × C → C together with coherent natural unit and associativ... |

9 | A note on actions of a monoidal category
- Janelidze, Kelly
(Show Context)
Citation Context ...iate notion of morphism). 5.2 Enriched call-by-value models The categorical notion of model for ECBV involves basic concepts from enriched category theory [9]. Let us recall some rudiments. Following =-=[7, 6]-=-, we begin with actions of categories. Let V be a category with finite products. Recall that an action of V on a category C is a functor ·: V × C → C together with coherent natural unit and associativ... |

8 | Enriching an effect calculus with linear types
- Egger, Møgelberg, et al.
- 2009
(Show Context)
Citation Context ...ic that is expressive enough to describe the linear usage of state. Earlier metalanguages for effects, such as the monadic metalanguage [12], call-by-push-value [10], and the enriched effect calculus =-=[2]-=- have an explicit monadic type constructor. There is no monadic type constructor in ECBV: there is a state type S instead. Still, in this fragment one can express all algebraic notions of effects, eve... |

7 | Enrichment and representation theorems for categories of domains and continuous functions
- Fiore
- 1996
(Show Context)
Citation Context ...(Aop , Set) be the category of finite product preserving functors Aop → Set and natural transformations between them. This category is the cocompletion of A as a category with finite coproducts (e.g. =-=[5]-=-, [23], [9, Thms 5.86, 6.11]). We will show that (FP(Vop, Set), FP(Cop , Set)) is an EEC model, and that (V, C) embeds in it as an enriched model. For general reasons, FP(Vop , Set) and FP(Cop , Set) ... |

7 |
From comodels to coalgebras: State and arrays
- Power, Shkaravska
(Show Context)
Citation Context ...hed in itself with copowers given by products, and indeed S is a comodel for the theory for global store in the enriched model (Set, Set). The induced monad on Set is ((−)×S) S . Power and Shkaravska =-=[21]-=- showed that S is the final comodel of global store.Linearly-used state in models of call-by-value 13 7 Categories of models and full completeness We sketch how the constructions of Propositions 7 an... |

6 | Linearly-used continuations in the enriched effect calculus
- Egger, Møgelberg, et al.
(Show Context)
Citation Context ... =) ∼ = V(−, U(=)) (see e.g. [8]). The choice of S in ECBV S models gives an enriched adjunction, since (− · S) is left adjoint to C(S, −): C → V. The following proposition (first noted noted for EEC =-=[3]-=-, though it does not appear explicitly there) shows that every enriched adjunction arises in this way: Proposition 8 ([3]). Let (V, C) be an enriched model. If F ⊣ U : C → V is an enriched adjunction ... |

6 |
Adjunction for enriched categories
- Kelly
- 1969
(Show Context)
Citation Context ...if there is a natural coherent isomorphism F (A×B) ∼ = A·F (B). When V is cartesian closed, this is equivalent to the usual definition, i.e. a natural isomorphism C(F (−), =) ∼ = V(−, U(=)) (see e.g. =-=[8]-=-). The choice of S in ECBV S models gives an enriched adjunction, since (− · S) is left adjoint to C(S, −): C → V. The following proposition (first noted noted for EEC [3], though it does not appear e... |

5 | Generic models for computational effects
- Power
- 2006
(Show Context)
Citation Context ...reyd categories are usually defined using premonoidal categories [23], but we will use the following equivalent definition using actions (following [10, App. B]). A distributive closed Freyd category =-=[22]-=- can be described as an enriched model (V, C) together with an identity on objects functor J : V → C that preserves the action (i.e. J(A × B) = A · J(B)). If (V, T ) is a monad model the inclusion V →... |

5 |
Mathematical concepts in programming language semantics
- Scott
- 1972
(Show Context)
Citation Context ...e: computations cannot copy the state and save it for later, nor can they discard the state and insert a new one instead. This special status of the state was already noted by Strachey [25] and Scott =-=[24]-=- and has been developed by O’Hearn and Reynolds [13]. Linear usage of state can be expressed syntactically using a linear state passing style, in which a stateful computation of type A → B is consider... |

4 | Tensors of comodels and models for operational semantics
- Plotkin, Power
(Show Context)
Citation Context ... but in this paper we shall see that all algebraic effects can be viewed in this way. 3 The notion of state plays an important role in operational semantics and Hoare logic. Indeed, Plotkin and Power =-=[15]-=- have suggested that configurations, i.e. pairs 〈M, s〉 consisting of a term M to be evaluated and the current state s of the machine, might form a basis for defining general operational semantics. In ... |

2 |
and Hayo Thielecke. Closed Freyd- and κ-categories
- Power
- 1999
(Show Context)
Citation Context ...linear state monad. We shall prove later that this connection between monad models and enriched models can be understood as a coreflection. 5.4 Remark: Closed Freyd categories Closed Freyd categories =-=[20]-=- are an alternative way of presenting monad models. Freyd categories are usually defined using premonoidal categories [23], but we will use the following equivalent definition using actions (following... |

1 |
A.: The enriched effect calculus
- Egger, Møgelberg, et al.
(Show Context)
Citation Context ... this translation. Further type constants can be added to ECBV S E without changing the result; this can be proved via a normalization theorem for ECBV S E which follows the one for EEC (to appear in =-=[4]-=-). In Section 7.1 we sketch a semantic proof of Theorems 3 and 4. 5 Categorical models By studying categorical models, we are able to give a canonical, universal status to the two calculi that we have... |

1 |
Call By Push Value
- Levy
- 2003
(Show Context)
Citation Context ...as a kind of non-commutative linear logic that is expressive enough to describe the linear usage of state. Earlier metalanguages for effects, such as the monadic metalanguage [12], call-by-push-value =-=[10]-=-, and the enriched effect calculus [2] have an explicit monadic type constructor. There is no monadic type constructor in ECBV: there is a state type S instead. Still, in this fragment one can express... |

1 |
M.: A logic for algebraic effects. In: LICS’08
- Plotkin, Pretnar
- 2008
(Show Context)
Citation Context ... ⊸ !(1 + 1) ⊗ S . (1) The equivalence of FGCBV and ECBV is proved for extensions of the two calculi along any algebraic effect theory. The generalisation is formulated using a notion of effect theory =-=[16]-=- which captures notions of algebraic effects. The categorical models of ECBV provide a new general notion of model for call-by-value languages. In brief, an enriched model consists of two categories V... |

1 | M.: Handlers of algebraic effects. In: ESOP’09 - Plotkin, Pretnar - 2009 |