Skip to content

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).

Notifications You must be signed in to change notification settings

AJChapman/agda-frp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages