a minimal implementation of simply-typed lambda calculus in racket
Racket 98.8%
Just 1.2%
2 1 0

Clone this repository

https://tangled.org/luthenwald.tngl.sh/stlc https://tangled.org/did:plc:7qgbtwkpsxbeang4z3ecvtuq/stlc
git@knot.tangled.wizardry.systems:luthenwald.tngl.sh/stlc git@knot.tangled.wizardry.systems:did:plc:7qgbtwkpsxbeang4z3ecvtuq/stlc

For self-hosted knots, clone URLs may differ based on your setup.

Download tar.gz
readme.md

syntax#

type ::= Int
      |  Bool
      |  (-> type type)
      |  (* type type)

term ::= (λ (var type) term)
      |  ($ term term)
      |  (if term term term)
      |  (let (var term) term)
      |  (pair term term)
      |  (fst term)
      |  (snd term)
      |  var
      |  int
      |  bool
      |  (op term term)

var  ::= <symbol>
int  ::= <integer>
bool ::= true | false
op   ::= + | - | * | / | = | < | > | <= | >=

setup#

run commands with just:

# link local packages into your racket installation
install:
   raco pkg install --auto --skip-installed --link ./stlc-lib ./stlc-test ./stlc-doc ./stlc

# compile the linked packages
setup:
   raco setup --pkgs stlc-lib stlc-test

# run the test suite
test:
   raco test stlc-test/tests/stlc/

# build documentation as single-page HTML
doc:
   raco scribble --html --dest doc --dest-name stlc stlc-doc/scribblings/stlc/main.scrbl

# open the documentation page
preview:
   open ./doc/stlc.html

examples#

#lang stlc

;; type checking
(typeof (λ (x Int) x))
;; -> (-> Int Int)

;; evaluation
(eval ($ (λ (x Int) (+ x 1)) 10))
;; -> 11

references#