Bidirectional Hazel to OCaml programming
This is an idea proposed in 2025 as a good starter project, and is under discussion with a student but not yet confirmed. It may be co-supervised with Patrick Ferris and Cyrus Omar.
Hazel is a pure subset of OCaml with a live functional programming environment that is able to typecheck, manipulate, and even run incomplete programs. As a pure language with no effects, Hazel is a great choice for domains such as configuration languages where some control flow is needed, but not the full power of a general purpose programming language. On the other hand, Hazel only currently has an interpreter and so is fairly slow to evaluate compared to a full programming language such as OCaml.
This summer project aims to do two things:
- Build a simple Hazel -> OCaml transpiler that will directly evaluate a Hazel program with no typed holes as OCaml. If there is a typed hole, then an exception can be raised. With some creative thinking, we may be able to raise an OCaml effect instead and do something useful to continue the execution of the program.
- Build on Patrick Ferris's OCaml to Hazel transpiler which goes from a subset of OCaml code to Hazel.
Once we can go back and forth, we can explore some interesting domains where this is useful. For example, can we build a configuration language frontend in Hazel, and then directly convert that into OCaml code for embedding into an application? Could we build a simple blog/wiki frontend where layout is expressed in livelit Hazel, and then when ready is converted to OCaml for publishing on the web?
We don't know if any of this will work, but we'd like to explore this "context switching" between languages of different expressivity in order to explore the divide between interactive, exploratory programming, and high performance and more static published code.
Related News
- Planetary Computing / Jan 2022