55 research outputs found
Space-Efficient Gradual Typing in Coercion-Passing Style
Herman et al. pointed out that the insertion of run-time checks into a gradually typed program could hamper tail-call optimization and, as a result, worsen the space complexity of the program. To address the problem, they proposed a space-efficient coercion calculus, which was subsequently improved by Siek et al. The semantics of these calculi involves eager composition of run-time checks expressed by coercions to prevent the size of a term from growing. However, it relies also on a nonstandard reduction rule, which does not seem easy to implement. In fact, no compiler implementation of gradually typed languages fully supports the space-efficient semantics faithfully.
In this paper, we study coercion-passing style, which Herman et al. have already mentioned, as a technique for straightforward space-efficient implementation of gradually typed languages. A program in coercion-passing style passes "the rest of the run-time checks" around - just like continuation-passing style (CPS), in which "the rest of the computation" is passed around - and (unlike CPS) composes coercions eagerly. We give a formal coercion-passing translation from ?S by Siek et al. to ?S?, which is a new calculus of first-class coercions tailored for coercion-passing style, and prove correctness of the translation. We also implement our coercion-passing style transformation for the Grift compiler developed by Kuhlenschmidt et al. An experimental result shows stack overflow can be prevented properly at the cost of up to 3 times slower execution for most partially typed practical programs
Diamonds are not forever: Liveness in reactive programming with guarded recursion
When designing languages for functional reactive programming (FRP) the main
challenge is to provide the user with a simple, flexible interface for writing
programs on a high level of abstraction while ensuring that all programs can be
implemented efficiently in a low-level language. To meet this challenge, a new
family of modal FRP languages has been proposed, in which variants of Nakano's
guarded fixed point operator are used for writing recursive programs
guaranteeing properties such as causality and productivity. As an apparent
extension to this it has also been suggested to use Linear Temporal Logic (LTL)
as a language for reactive programming through the Curry-Howard isomorphism,
allowing properties such as termination, liveness and fairness to be encoded in
types. However, these two ideas are in conflict with each other, since the
fixed point operator introduces non-termination into the inductive types that
are supposed to provide termination guarantees.
In this paper we show that by regarding the modal time step operator of LTL a
submodality of the one used for guarded recursion (rather than equating them),
one can obtain a modal type system capable of expressing liveness properties
while retaining the power of the guarded fixed point operator. We introduce the
language Lively RaTT, a modal FRP language with a guarded fixed point operator
and an `until' type constructor as in LTL, and show how to program with events
and fair streams. Using a step-indexed Kripke logical relation we prove
operational properties of Lively RaTT including productivity and causality as
well as the termination and liveness properties expected of types from LTL.
Finally, we prove that the type system of Lively RaTT guarantees the absence of
implicit space leaks
- …