Giter Club home page Giter Club logo

hazel's Introduction

Hazel

Hazel is a live functional programming environment rooted in the principles of type theory. You can find the relevant papers and more motivation at the Hazel website.

Building Hazel

You can build Hazel using the following instructions.

Prerequisites

Hazel is implemented in Coq and Reason/OCaml, and is compiled to Javascript for the web browser via the js_of_ocaml compiler. 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:

  • Make sure opam is updated:

    > opam update
  • You need a version 4.05.0+ of the OCaml compiler. First check the current version used by opam:

    > opam switch
    --     -- 3.11.2  Official 3.11.2 release
    --     -- 3.12.1  Official 3.12.1 release
    --     -- 4.00.0  Official 4.00.0 release
    --     -- 4.00.1  Official 4.00.1 release
    --     -- 4.01.0  Official 4.01.0 release
    --     -- 4.02.0  Official 4.02.0 release
    --     -- 4.02.1  Official 4.02.1 release
    --     -- 4.02.2  Official 4.02.2 release
    --     -- 4.02.3  Official 4.02.3 release
    --     -- 4.03.0  Official 4.03.0 release
    	--     -- 4.04.0  Official 4.04.0 release
    --     -- 4.04.1  Official 4.04.1 release
    --     -- 4.04.2  Official 4.04.2 release
    --     -- 4.05.0  Official 4.05.0 release
    --     -- 4.06.0  Official 4.06.0 release
    --     -- 4.06.1  Official 4.06.1 release
    system  C system  System compiler (4.02.1)

    The C marks the current compiler. Here version 4.02.1 is installed. We can see that a more recent version is available (4.06.1). So we will install it as follows:

    > opam switch 4.06.1
    > eval `opam config env`

    This won't remove the system compiler as opam will install the files in your .opam directory.

  • We also need Coq:

    > opam install coq
  • Finally, we can now install the necessary OCaml dependencies:

    > opam install reason js_of_ocaml tyxml deriving ppx_deriving reactiveData js_of_ocaml-tyxml camomile menhir oUnit

Compilation

We can now build the application.

> cd src
> dune build --auto-promote

From a fresh checkout, dune build --auto-promote does four things:

  1. Extracts the semantics from the Coq file, Semantics.v.
  2. Generates some parsers using menhir.
  3. Auto-formats all reason code, using refmt (this is why we need auto-promote).
  4. Compiles the reason code to src/_build/default/www/hazel.js.

If writing dune build --auto-promote is annoying, we put that command into the Makefile, so you can also just run make.

If something weird is going on, it sometimes helps to do a dune clean to delete the various files being generated.

Debugging

You can use dune build --profile debug --auto-promote instead of dune build --auto-promote. This differs only in that we pass the --debuginfo flag to js_of_ocaml, which causes the insertion of comments mapping locations in the generated JS to locations in the source files. This is useful for debugging purposes, but causes a substantial increase in compilation time and file size, so it is disabled by default.

Results

You can now open src/_build/default/www/hazel.html in a browser to see Hazel in action.

hazel's People

Contributors

cyrus- avatar dm0n3y avatar nickcollins avatar bkase avatar michaelhilton avatar asolove avatar yairchu avatar

Watchers

James Cloos avatar Julia Katheder 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.