Dependent types
A vector carries its length in its type. A connection carries its schema. Functions can require evidence about the values they accept and preserve those relationships in their results.
Values and dependent types↗Dependent types.
Explicit effects. Resource control.
Cinch is a strict functional language for programs with contracts about their data, resources, and runtime behavior.
The length fits n + 1. The first element can be borrowed.
A function’s type can describe the length of its result, the effects it performs, and the resources it borrows.
Cinch uses algebraic data types, pattern matching, and higher-order functions. Dependent types and ownership extend that foundation so you can specify properties of your code and check the evidence for them.
Core language specification ↗The input has length n + 1. An empty vector has length 0, so it cannot be passed to this function.
Pattern matching leaves one constructor to handle. The returned reference borrows from the input and cannot outlive it.
Read the example in context ↗-- Borrow the first element of a nonempty vector.
first :: forall a n region.
Ref region (Vec (n + 1) a)
-> Ref region a
first xs = case xs of
Cons x rest -> xWhy there is no Nil branchNil has length 0. This input requires n + 1.
Ref region
(Vec (n + 1) a)n elements
Ref region aA vector carries its length in its type. A connection carries its schema. Functions can require evidence about the values they accept and preserve those relationships in their results.
Values and dependent types↗Resource ownership determines who can use a value and when it must be released. Effect signatures describe what a computation can do, including I/O, suspension, and divergence.
Ownership and effects tutorial↗Replacing a running module requires a compatibility check and a plan for its state. An upgrade package describes the migration, ownership transfer, and obligations to existing clients.
Compatible hot upgrades tutorial↗The tutorials introduce the notation.
The specifications define the contracts.