hazelgrove / HZ

Simple reference implementation of Hazelnut using js_of_ocaml and OCaml React. (frozen -- ongoing development in the hazel repo)
http://hazel.org/HZ/hz.html
MIT License
29 stars 3 forks source link

HZ

HZ is a reference implementation of Hazelnut, a bidirectionally typed structure editor calculus. A release of this repo was submitted to POPL 2017 for artifact evaluation.

Running HZ

You can run HZ without installing any dependencies by opening /src/www/hz.html in a browser. We also have a hosted version available at http://hazelgrove.org/HZ/hz.html.

Building HZ

You can build HZ using the following instructions.

Prerequisites

An easy way to install both OCaml and the necessary libraries is to install opam. After having installed opam using the instructions on their website, follow these steps:

Compilation

You can execute build.sh to compile hz.ml.

> cd src/
> ./build.sh

It consists of two steps:

  1. Compile the hz.ml file to OCaml bytecode with the ocamlbuild command.
  2. Build the Javascript file from the hz.byte file with the js_of_ocaml command.

Results

You can now open hz.html in a browser to see HZ in action.

Implementation Details

The file hz_semantics.ml implements the syntax and semantics from the paper in a pure functional style, independent of any details of the user interface. NOTE: We use positive OCaml integers for the Hazelnut num type.

The file hz_model.ml gives the signature of the reactive signal that models edit states, which consist of a Z-expression paired with an H-type.

The file hz_view.ml transforms Z-expressions to HTML trees. These are styled by the style.css file in the www directory.

The file hz.ml (which should be read roughly from the bottom up) is the top-level file. It sets up the reactive signals and constructs the UI. The main logic of interest has to do with the action palette, which controls updates to the model and therefore the view.