The selection monad as a CPS transformation
نویسنده
چکیده
A computation in the continuation monad returns a final result given a continuation, ie. it is a function with type (X → R) → R. If we instead return the intermediate result at X then our computation is called a selection function. Selection functions appear in diverse areas of mathematics and computer science (especially game theory, proof theory and topology) but the existing literature does not heavily emphasise the fact that the selection monad is a CPS translation. In particular it has so far gone unnoticed that the selection monad has a call/cc-like operator with interesting similarities and differences to the usual call/cc, which we explore experimentally using Haskell. Selection functions can be used whenever we find the intermediate result more interesting than the final result. For example a SAT solver computes an assignment to a boolean function, and then its continuation decides whether it is a satisfying assignment, and we find the assignment itself more interesting than the fact that it is or is not satisfying. In game theory we find the move chosen by a player more interesting than the outcome that results from that move. The author and collaborators are developing a theory of games in which selection functions are viewed as generalised notions of rationality, used to model players. By realising that strategic contexts in game theory are examples of continuations we can see that classical game theory narrowly misses being in CPS, and that a small change of viewpoint yields a theory of games that is better behaved, and especially more compositional.
منابع مشابه
How to CPS Transform a Monad
CPS transformation is an important tool in the compilation of functional programming languages. For strict languages, such as our web programming language “Rinso” or Microsoft’s F#, monadic expressions can help with structuring and composing computations. To apply a CPS transformation in the compilation process of such a language, we integrate explicit monadic abstraction in a call-by-value sou...
متن کاملValue Transforming Style
A new program transformation is presented that allows to remove control operators related to partial continuations. The basis for the transformation is to adopt an improved representation for continuations that makes frames apparent. Various examples of control operators with or without dynamic extent stress are presented. Scheme IEE91], ooers rst-class continuations with indeenite extent. Pion...
متن کاملAn Initial Model for the Monadic Calculus
When it comes to compiler design, there has been a dispute as to whether it is useful to transform the source code using the continuation passing style (CPS) transform first. Some have observed that it is easier to optimize CPS transformed code, while others maintain that direct style compilation is better. Sabry and Felleisen resolve the dispute by showing how get the benefits of CPS without t...
متن کاملMonad Translating Inductive and Coinductive Types
We show that the call-by-name monad translation of simply typed lambda calculus extended with sum and product types extends to special and general inductive and coinductive types so that its crucial property of preserving typings and βand commuting reductions is maintained. Specific similar-purpose translations such as CPS translations follow from the general monad translations by specializatio...
متن کاملCPS transformation of flow information , Part II : administrative reductions ∗ DANIEL
We characterize the impact of a linear β-reduction on the result of a control-flow analysis. (By ‘a linear β-reduction’ we mean the β-reduction of a linear λ-abstraction, i.e., of a λabstraction whose parameter occurs exactly once in its body.) As a corollary, we consider the administrative reductions of a Plotkin-style transformation into Continuation-Passing Style (CPS), and how they affect t...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید
ثبت ناماگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید
ورودعنوان ژورنال:
- CoRR
دوره abs/1503.06061 شماره
صفحات -
تاریخ انتشار 2015