1,883 research outputs found

    Synthesizing Functional Reactive Programs

    Get PDF
    Functional Reactive Programming (FRP) is a paradigm that has simplified the construction of reactive programs. There are many libraries that implement incarnations of FRP, using abstractions such as Applicative, Monads, and Arrows. However, finding a good control flow, that correctly manages state and switches behaviors at the right times, still poses a major challenge to developers. An attractive alternative is specifying the behavior instead of programming it, as made possible by the recently developed logic: Temporal Stream Logic (TSL). However, it has not been explored so far how Control Flow Models (CFMs), as synthesized from TSL specifications, can be turned into executable code that is compatible with libraries building on FRP. We bridge this gap, by showing that CFMs are indeed a suitable formalism to be turned into Applicative, Monadic, and Arrowized FRP. We demonstrate the effectiveness of our translations on a real-world kitchen timer application, which we translate to a desktop application using the Arrowized FRP library Yampa, a web application using the Monadic threepenny-gui library, and to hardware using the Applicative hardware description language ClaSH.Comment: arXiv admin note: text overlap with arXiv:1712.0024

    Smoothly Navigating between Functional Reactive Programming and Actors

    Full text link
    We formally define an elegant multi-paradigm unification of Functional Reactive Programming, Actor Systems, and Object-Oriented Programming. This enables an intuitive form of declarative programming, harvesting the power of concurrency while maintaining safety. We use object and reference capabilities to highlight and tame imperative features: reference capabilities track aliasing and mutability, and object capabilities track I/O. Formally, our type system limits the scope, impact and interactions of impure code. - Scope: Expressions whose input is pure will behave deterministically. - Impact: Data-races and synchronisation issues are avoided. The only way for an actor to behave nondeterministically, is by mutating its state based on message delivery order. - Interactions: Signals provide a functional boundary between imperative and functional code, preventing impure code from invalidating functional assumptions.Comment: Part of WFLP 2020 pre-proceedings (updated post-comments

    Semantics of RxJS

    Get PDF
    RxJS is a popular JavaScript library for reactive programming in Web applications. It provides numerous operators to create, combine, transform, and filter discrete events and to handle errors. These operators may be stateful and have side effects, which makes it difficult to understand the precise meaning of the resulting computation. In this paper, we define a formal model for RxJS programs by formalizing a selected subset of RxJS operators using a small-step operational semantics. We present several debugging related applications using the semantics as a model. We also implemented a subset of RxJS based on this semantics, which provides convenient access to the runtime representation of the RxJS program to help debugging

    Injecting Abstract Interpretations into Linear Cost Models

    Full text link
    We present a semantics based framework for analysing the quantitative behaviour of programs with regard to resource usage. We start from an operational semantics equipped with costs. The dioid structure of the set of costs allows for defining the quantitative semantics as a linear operator. We then present an abstraction technique inspired from abstract interpretation in order to effectively compute global cost information from the program. Abstraction has to take two distinct notions of order into account: the order on costs and the order on states. We show that our abstraction technique provides a correct approximation of the concrete cost computations

    Compressive sensing adaptation for polynomial chaos expansions

    Full text link
    Basis adaptation in Homogeneous Chaos spaces rely on a suitable rotation of the underlying Gaussian germ. Several rotations have been proposed in the literature resulting in adaptations with different convergence properties. In this paper we present a new adaptation mechanism that builds on compressive sensing algorithms, resulting in a reduced polynomial chaos approximation with optimal sparsity. The developed adaptation algorithm consists of a two-step optimization procedure that computes the optimal coefficients and the input projection matrix of a low dimensional chaos expansion with respect to an optimally rotated basis. We demonstrate the attractive features of our algorithm through several numerical examples including the application on Large-Eddy Simulation (LES) calculations of turbulent combustion in a HIFiRE scramjet engine.Comment: Submitted to Journal of Computational Physic

    Timeflies: Push-pull signal-function functional reactive programming

    Get PDF
    Functional Reactive Programming (FRP) is a promising class of abstractions for interactive programs. FRP systems provide values defined at all points in time (behaviors or signals) and values defined at countably many points in time (events) as abstractions. Signal-function FRP is a subclass of FRP which does not provide direct access to time-varying values to the programmer, but instead provides signal functions, which are reactive transformers of signals and events, as first-class objects in the program. All signal-function implementations of FRP to date have utilized demand-driven or pull-based evaluation for both events and signals, producing output from the FRP system whenever the consumer of the output is ready. This greatly simplifies the implementation of signal-function FRP systems, but leads to inefficient and wasteful evaluation of the FRP system when this strategy is employed to evaluate events, because the components of the signal function which process events must be computed whether or not there is an event occurrence. In contrast, an input-driven or push-based system evaluates the network whenever new input is available. This frees the system from evaluating the network when nothing has changed, and then only the components necessary to react to the input are re-evaluated. This form of evaluation has been applied to events in standard FRP systems but not in signal-function FRP systems. I describe the design and implementation of a signal-function FRP system which applies pull-based evaluation to signals and push-based evaluation to events (a push-pull system). The semantics of the system are discussed, and its performance and expressiveness for practical examples of interactive programs are compared to existing signal-function FRP systems through the implementation of a networking application

    Extending Rebeca with synchronous messages and reusable components

    Get PDF
    In this paper, we propose extended Rebeca as a tool-supported actor-based language for modeling and verifying of concurrent and distributed systems. We enrich Rebeca with a formal concept of components which integrates the message-driven computational model of actor-based languages with synchronous message passing. Components are used to encapsulate a set of internal active objects which react asynchronously to messages by means of methods and which additionally interact via a synchronous message passing mechanism. Components themselves interact only via asynchronous and anonymous messages. We present our compositional verification approach and abstraction techniques, and the theory corresponding to it, based on formal semantics of Rebeca. These techniques are exploited to overcome state explosion problem in model checkin

    Asynchronous Monad for Reactive IoT Programming

    Get PDF
    The widespread adoption of Internet of Things (IoT) has given rise to systems which must reactively process signal data, while maintaining latency and throughput constraints. While the reactive programming paradigm partially addresses this problem, it does not offer a complete solution. We propose a design for a monad, AsyncM, and apply it to implement push-pull functional reactive programming (FRP) where side-effect bound events are performed in low-latency push streams, and time-series computations are performed in demand-driven pull streams. The design uses implicitly threaded cancellation tokens and continuation passing style to allow for implementations in languages which have single-threaded event-loops as well as languages which have multi-threading. We present our abstractions Stream, Signal, and Behavior and their functor, applicative, and (when applicable) monadic instances. We demonstrate how push streams (Stream) can be converted to pull streams (Signal) (and visa versa) to apply our model to practical use cases. We give a use case of a real-time IoT data analytics platform to demonstrate our design\u27s industrial significance where signal sample rates can change dynamically based on unknown factors such as network speed and processor resources. Application of the design to dynamic languages is shown throughout the paper in a reference JavaScript implementation
    • …
    corecore