Worked examples of where dependent types help NixLab.
git clone git@nixlab.openfp.net:horizon/dependent-nixlab-examples.gitdependent-nixlab-examples
Worked examples of where dependent types help NixLab, written in Dependent Haskell and type-checked by the TharkunAB GHC 10.1 fork.
| Module | What the types guarantee |
|---|---|
NixLab.Dependent.Schema | A schema is an ordinary value, and interp :: Ty -> Type computes the Haskell type of each field, so one decoder serves every schema. |
NixLab.Dependent.Commands | args and reply compute a host command's payload and reply types from the command. |
NixLab.Dependent.Review | A report holds exactly one verdict per rule of its edition, and merge needs evidence that every verdict passes. |
NixLab.Dependent.Lifecycle | A merge request's state is in its type: only an open one is approved, and only an approved one is merged. |
NixLab.Dependent.Fuel | A program's cost is computed from the program; the evaluator takes a proof that the budget covers it and has no out-of-fuel case. |
NixLab.Dependent.RoundTrip | Reading back what the printer wrote returns the expression and exactly the tokens after it, for every expression. |
NixLab.Dependent.Laws | Four horizon-dsl law-kit laws hold for every starting state and every continuation, not just sampled ones. |
The library only has to compile: each guarantee is checked by the type checker.