agda/agda-frp-js

Name: agda-frp-js

Owner: Agda Github Community

Description: ECMAScript back end for Functional Reactive Programming in Agda

Created: 2011-09-12 22:17:06.0

Updated: 2018-01-04 22:16:51.0

Pushed: 2017-10-19 12:27:03.0

Homepage:

Size: 215

Language: Agda

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

An implementation of Functional Reactive Programming for building HTML applications in Agda.

To build and application, start with an HTML file:

tml>
<head>
  <title>Hello World</title>
  <script data-main="agda.frp.main" src="require.js"></script>
</head>
<body> 
  <h1>A greeting</h1>
  <p class="agda" data-agda="Demo.Hello"></p>
</body>
html>

This is just a regular old HTML file, which loads the agda.frp.main JavaScript module (using require.js, but any AMD-compliant JavaScript module loader should work). The important part is:

 class="agda" data-agda="Demo.Hello"></p>

The “agda” class and data-agda attribute indicates that an Agda program should be executed inside the annotated node.

Now write an Agda program:

en import FRP.JS.Behaviour using ( Beh ; [_] )
en import FRP.JS.DOM using ( DOM ; text )
en import FRP.JS.RSet using ( ?_? )

dule Demo.Hello where

in : ? {w} ? ? Beh (DOM w) ?
in = text ["Hello, world."]

This program creates a text node whose content is always “Hello, World.”

Compile (using the darcs snapshot of Agda 2.2.11):

da --js Demo/Hello.agda

this will create a bunch of js files such as jAgda.Demo.Hello.js.

Put all the .js files (including require.js and the agda.frp.*.js files) in the same directory as hello.html.

Load hello.html in a browser, and enjoy.

There are unit tests in FRP.JS.Test, which link against John Resig's QUnit (http://docs.jquery.com/QUnit). To run the tests, first “make tests”, then load build/tests.html in a browser.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.