Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ziman/ttstar
Dependently typed core calculus with erasure
https://github.com/ziman/ttstar
dependent-types erasure functional-programming type-system typechecker
Last synced: about 2 months ago
JSON representation
Dependently typed core calculus with erasure
- Host: GitHub
- URL: https://github.com/ziman/ttstar
- Owner: ziman
- License: bsd-3-clause
- Created: 2015-05-16T11:58:56.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2021-08-31T19:09:48.000Z (over 3 years ago)
- Last Synced: 2024-10-16T13:25:32.600Z (3 months ago)
- Topics: dependent-types, erasure, functional-programming, type-system, typechecker
- Language: Idris
- Homepage:
- Size: 3.25 MB
- Stars: 18
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TTstar
Dependently typed core calculus with erasure inference.
## Examples from the dissertation
* Palindrome ([source](https://github.com/ziman/ttstar/blob/master/examples/palindrome.tt),
[erased](https://github.com/ziman/ttstar/blob/master/examples/outputs/palindrome/erased.tt))
* Binary adder ([source](https://github.com/ziman/ttstar/blob/master/examples/bin.tt),
[erased](https://github.com/ziman/ttstar/blob/master/examples/outputs/bin/erased.tt))
* RLE ([source](https://github.com/ziman/ttstar/blob/master/examples/rle.tt),
[erased](https://github.com/ziman/ttstar/blob/master/examples/outputs/rle/erased.tt))
* Scope-indexed lambda calculus ([source](https://github.com/ziman/ttstar/blob/master/examples/tt.tt),
[erased](https://github.com/ziman/ttstar/blob/master/examples/outputs/tt/erased.tt))
* [Other example programs](https://github.com/ziman/ttstar/tree/master/examples)
and [their outputs](https://github.com/ziman/ttstar/tree/master/examples/outputs)## Features
### Erasure
* erasure inference (fills in erasure annotations)
* separate erasure checker (verifies consistency of inferred annotations)
* erasure from higher-order functions
* complete removal of unused arguments (rather than passing in `NULL`)
* erasure polymorphism for functions
* four constraint solvers
* simple and straightforward O(n²) solver
* graph-based constraint solver
* indexing solver (fastest, default)
* LMS solver
* "last man standing"
* Adapted from "Chaff: Engineering an efficient SAT solver"
by Moskewicz et al., 2001.
* theoretically faster than the indexer, my implementation is slower
* a tentative implementation of irrelevance ([example](https://github.com/ziman/ttstar/blob/master/examples/irrelevance.tt))### Language
* full dependent pattern matching clauses
* pattern matching local `let` definitions are useful for emulating
* `case` expressions
* `with` clauses
* mutual recursion
* rudimentary term/type inference via first order unification### Practicalities
* type errors come with backtraces
* rudimentary FFI via `foreign` postulates
* a simplified intermediate representation for backends (`IR`)
* translation from `TT` to `IR` compiles patterns into case trees
* native code generators
* a codegen from `TT`: via Scheme (Chicken Scheme or Racket)
* uses the `matchable` extension
* a codegen from `IR`: produces standard Scheme
* mostly R5RS-compliant
* except that some programs redefine the same name repeatedly in `let*`
* when interpreted with `csi`, the `IR`-generated code runs much (~3x) faster than the `TT`-generated code
* only about 10% faster than `TT`-generated code when compiled using `csc`
* a codegen via [Malfunction](https://github.com/stedolan/malfunction), using `IR`
* produces fast native code## Other stuff
* dependent erasure (if `x == 3` then `erased` else `not_erased`)
* unused functions are removed entirely
* `Refl` is always erased
* `Maybe` sometimes becomes Boolean after erasure## Does not feature
* totality checking
* mutual recursion
* a restricted form is easy to achieve using local let bindings
* sufficient in all cases I've come across
* much syntax sugar