Coder Social home page Coder Social logo

ajchapman / agda-frp Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 61 KB

Functional Reactive Programming in Agda, adapting [Conal Elliott's Push-Pull Functional Reactive Programming](http://conal.net/papers/push-pull-frp/push-pull-frp.pdf).

Agda 100.00%
agda dependent-types functional-reactive-programming

agda-frp's Introduction

Work In Progress -- Agda Functional Reactive Programming (FRP)

This is my attempt at porting the system described in Conal Elliot's Push-Pull Functional Reactive Programming to Agda.

The aim is to:

  1. Describe a specification of FRP -- a simple and precise semantics for programming with:
    • Time-varying values (Behaviors),
    • Events, and
    • The interactions between Behaviors and Events.
  2. Define an efficient implementation of this, and
  3. Prove that the implementation is faithful to the specification by defining homomorphisms from implementation to specification.

Dependencies

To check that everything works, run agda index.agda. If it gives no output then all is well!

Reading the Code

The Agda source code is in ./src/FRP.

Time

First we define time. We don't choose a concrete underlying type for time, but we do define constraints on it -- it must be decidably totally ordered, and it must be a group (i.e. informally, it must have +, - and 0). Most modules are parameterised by this type, so a user of agda-frp as a library would need to define this, and create an object of type DecOrderedGroup.

We extend the underlying type by adding -∞ and so that we can have time values which occur before or after any others, e.g. Events that are guaranteed to already have occurred. This is done in Time/T+.agda.

It is all tied together in Time.agda. After importing this you will have the type T available as the underlying time type, with the convention of a (subscript 't') suffix on operators and properties, etc. E.g. compare values of type T with ≤ₜ. You will also have the type , which extends T with -∞ and . This uses a (superscript t) suffix.

Semantics

The semantics, or specification, is in ./src/FRP/Semantics. Here we have:

Implementation

The implementation implements the specification in a more efficient way, or at least will one day. At this stage the implementation is identical to the specification, but also has functions to map to the specification and proofs that these mappings are homomorphisms.

Work in Progress

Things I haven't figured out yet:

  • Should Future be under Time rather than under Semantics?
  • Is there any point using Felix, e.g. I have defined a Category instance for Behavior, and it's lawful, but is it any use?
  • Should we use absolute or relative semantics for Event times? Conal's paper uses absolute, but mentions the possibility of relative in a couple of places. Relative may make some things simpler, such as the pure Event simply having time 0, instead of -∞, and join not needing to change the times of sub-events.

Still to do:

  • Efficient implementations as per the paper. They are currently simply copies of the specification.

agda-frp's People

Contributors

ajchapman avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.