type term =
Var of string
| Lam of string * termThe relationship between the string and the term is only a convention. Renaming and capture avoidance are manual.
A language experiment from Cambridge · 2003–2005
Fresh Objective Caml extended OCaml with types of names, abstraction expressions, and pattern matching over binders—tools designed for programs that manipulate programming languages.
type var = t name;;
type term =
Var of var
| Lam of <<var>>term
| App of term * term;;
let identity =
Lam(<<x>>(Var x));;The central problem
Compilers, proof assistants, interpreters, and metaprogramming tools all manipulate syntax containing bound names. Conventional abstract syntax leaves alpha-equivalence, capture avoidance, and fresh-name generation to the programmer. Fresh OCaml moved those concerns into the type system and runtime representation.
One change in notation
type term =
Var of string
| Lam of string * termThe relationship between the string and the term is only a convention. Renaming and capture avoidance are manual.
type var = t name;;
type term =
Var of var
| Lam of <<var>>termThe abstraction is explicit. Fresh-name generation, comparison, and pattern matching can respect binding structure.
Typed object-language names instead of unstructured strings.
A direct representation of a name binding in an expression.
Create a name guaranteed to be fresh for the current computation.
Deconstruct abstraction values with ordinary functional style.
Seven recovered programs
The surviving examples cover lambda calculi, Hindley–Milner type inference, MetaML, normalization by evaluation, and the Pi-calculus.
Explore source filesThis release was based on OCaml 3.08.2 and was reported to build on Linux and Mac OS X systems of its era. Contemporary toolchains, operating systems, and OCaml packages have changed substantially.
tar fxz fresh-ocaml-3.08.2+4.tar.gz
cd fresh-ocaml-3.08.2+4
./configure
make worldDownload the recovered archive