Neon is an experimental programming language with dependent types, implementing Calculus of Constructions (CoC). It aims to provide a minimal yet expressive core language in which functions, types, and proofs can all coexist.
Neon is built with Dune. Ensure you have OCaml and Dune installed, then run:
dune buildTo run the REPL (or a .neon file), do:
dune exec neon [file.neon]- If you omit
[file.neon], Neon will start in an interactive REPL. - Type
exitto quit the REPL.
A small example of a Neon program illustrating dependent types and ADTs:
data List (A: Type) =
| Nil
| Cons (x: A) (xs: List(A))
let id (A: Type) (xs: List(A)) = xs
let nums = Cons(Int, 1, Cons(Int, 2, Nil(Int)))
let nums_id = id(Int, nums)
let x = match nums_id with
| Cons(A, x, xs) -> x
| Nil(A) -> 42Listis a simple ADT with two constructors,NilandCons.idis a polymorphic function that takes a typeAand aList(A), returning the same list.numsis aList Intwith two elements (1, 2).nums2is the result of applyingid(Int, nums).
data Sigma (A: Type) (P: (A -> Type)) =
| Pair (x: A) (y: P(x))