https://github.com/brendanzab/elm-stlc
Bidirectional type checker for the simply typed lambda calculus
https://github.com/brendanzab/elm-stlc
bidirectional-typechecking elm lambda-calculus simply-typed-lambda-calculus type-checking
Last synced: 11 months ago
JSON representation
Bidirectional type checker for the simply typed lambda calculus
- Host: GitHub
- URL: https://github.com/brendanzab/elm-stlc
- Owner: brendanzab
- License: mit
- Created: 2018-11-15T12:54:53.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-02-04T04:41:13.000Z (about 6 years ago)
- Last Synced: 2025-03-23T23:27:01.092Z (12 months ago)
- Topics: bidirectional-typechecking, elm, lambda-calculus, simply-typed-lambda-calculus, type-checking
- Language: Elm
- Homepage: https://ellie-app.com/3Wq9nP4zcCva1
- Size: 15.6 KB
- Stars: 14
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# elm-stlc
A type checker for the simply typed lambda calculus, implemented in a
bidirectional style.
The point of this is to show that type checking is actually quite simple if
you follow a bidirectional approach! Hopefully this whets your appetite for
playing around with your own type checkers!
The idea behind bidirectional type checking is that you split up your syntax
into terms that are:
- easy to infer the type of
- need additional type annotations to check them
For example:
- `'foo` is easy to infer - it's an `Atom`
- `\x => x` can't have its type inferred - it needs an annotation
This split is reflected in the type checker, which has two mutually defined functions:
```elm
infer : Context -> Term -> Result String Type
check : Context -> Term -> Type -> Result String ()
```
## Running the app
To play with this, install Elm 0.19, clone the repository, and run the Elm
Reactor:
```
elm reactor
```
Then open `src/Main.elm` in the file navigator
## Further reading
- http://www.davidchristiansen.dk/tutorials/bidirectional.pdf
- http://davidchristiansen.dk/tutorials/nbe/
- https://www.andres-loeh.de/LambdaPi/