NixLabConnectionconnecting
ProjectsProject
horizon /

dependent-nixlab-examples

publicguest

Worked examples of where dependent types help NixLab.

git clone git@nixlab.openfp.net:horizon/dependent-nixlab-examples.git
571e42096581aca5754d235d36ad79f1f629eb05/README.md

dependent-nixlab-examples

Worked examples of where dependent types help NixLab, written in Dependent Haskell and type-checked by the TharkunAB GHC 10.1 fork.

ModuleWhat the types guarantee
NixLab.Dependent.SchemaA schema is an ordinary value, and interp :: Ty -> Type computes the Haskell type of each field, so one decoder serves every schema.
NixLab.Dependent.Commandsargs and reply compute a host command's payload and reply types from the command.
NixLab.Dependent.ReviewA report holds exactly one verdict per rule of its edition, and merge needs evidence that every verdict passes.
NixLab.Dependent.LifecycleA merge request's state is in its type: only an open one is approved, and only an approved one is merged.
NixLab.Dependent.FuelA 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.RoundTripReading back what the printer wrote returns the expression and exactly the tokens after it, for every expression.
NixLab.Dependent.LawsFour 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.