CSCI 1730 · Fall 2026

Code🔗

To aid you in the migration from Plait to Shplait, here are some of the programs from the lectures, rewritten in Shplait. You are welcome (indeed, encouraged!) to download and run these and play along.

A key detail: The tests in these files are deliberately sparse. That is an expository choice, not something you should emulate! Your homeworks are required to have extensive testing. They’re just left out here to reduce clutter (and to avoid doing your homework for you!).

  • calc.rhm: The smallest possible language: numbers, +, and *. No parser yet. Write abstract syntax trees by hand!

  • calc-with-parse.rhm: Adds a parse function that turns text of type Syntax into the corresponding syntax tree, so you can write much more convenient programs. Observe that single-quotes create values of type Syntax, which is what parse consumes.

  • calc-parse-cond.rhm: Adds booleans and if to the language. The result of evaluation now needs its own datatype.

  • interp-let.rhm: Adds variables and let. Evaluation now needs an environment.

  • interp-lam-dynamic.rhm: Adds functions (lam) and application. A function value records only its parameter and body, and is applied in the environment of the call. This is dynamic scope; the tests at the end show the resulting behavior, which is not what we want.

  • interp-lam-static.rhm: Fixes the above: a function value is now a closure that also records the environment where the lam was evaluated, and the body is evaluated in that environment. The argument, however, must still be evaluated in the caller’s environment; the last test checks this.

  • interp-sugar.rhm: Adds syntactic sugars: subtraction, unary negation, and, and cond. Now features a new datatype to represent surface terms. The key is a desugar function that turns surface programs into core ones. A critical detail is that the interpreter is imported: there is no definition in this file. This shows that we could grow the language without modifying the interpreter at all.

The descriptions above are not substitutes for the lecture/book, nor are they meant to make sense in their absence.