[][src]Crate voile

Voile is a dependently-typed programming language evolved from Mini-TT.

Design

Goal

The focus of Voile is extensible algebraic data types on top of dependent types. It can solve the expression problem without using any design patterns (like visitor or object-algebra in Java, or finally-tagless or DTALC in Haskell).

We're pretty much inspired by the coexistence of guarded recursion, coinductive data types, and inductive types in Agda, which does not work very well according to a discussion here. We can observe that Sums, Records, and (Dependent) Pattern matching in Agda only work well when being top-level bindings.

Features

Voile is supporting Sum-types (coproduct), Record-types (product) as first-class language components.

First-class record support is known as Record Calculus, or Row Polymorphism, or Extensible Records, or "first-class labels". The idea of "Extensible Record" is that the creation, manipulation and destruction of "Records" can be done locally -- without the need of declaring a record type globally. In other words, the "Record type" itself is a kind of expression.

The study on extensible records has a long history.

TODO Something needs to be written here.

However, there isn't much research and implementations on extensible Sums yet. Extensible Sums are quite complicated because it probably requires:

  • First-class pattern matching
  • Subtyping on Sums

While currently, I can only find one programming language, MLPolyR (language spec, papers: first-class cases, type-safe extensible programming), whose pattern matching is first-class (in the papers it's called "first-class cases").

Implementation

Voile's implementation is inspired from Agda, mlang and its prototype, minitt.

TODO Something needs to be written here.

Bottlenecks

Recursion on sum types is a huge problem against the design of first-class sum types.

In the cliché programming languages with non-first-class Sums (where the sum types need to be declared globally before usage), type-checking against recursive Sums can be easily supported because the types are known to the type-checker -- there's no need of reduction on an already-resolved sum type. Once a term is known to be some sum type, it becomes a canonical value.

For Voile, arbitrary expressions can appear inside of a sum type term, which means reduction is still needed before checking some other terms against this sum-type-term. If there's recursion on a sum-type-term, like the Natural number definition:

This example is not tested
Nat = 'Zero | 'Suc Nat

The type-checker will infinitely loop on its reduction.

The above definition will actually be rejected by the termination checker, but recursion on Sum-types have to be supported because we have been using it for a long time -- we shouldn't sacrifice this fundamental language feature.

TODO Something needs to be written here.


About the name, Voile This name is inspired from a friend whose username is Voile (or Voileexperiments). However, this is also the name of a library in the Scarlet Devil Mansion.

The librarian of Voile, the Magic Library

Modules

check

Type-Checking module.

syntax

Abstract syntax, surface syntax, parser and well-typed terms (core language).