This commit is contained in:
rhiannon morris 2024-09-15 17:50:32 +02:00
parent 3f827564b4
commit 9f850de9ba
14 changed files with 325 additions and 375 deletions

View file

@ -3,6 +3,8 @@ title: a little ats program
date: 2022-09-16
tags: [computer, ATS, cool languages]
show-toc: true
summary: |
a little program in a little-known, little-documented language called ATS.
...
[ats] is a language that is a little infamous among type system likers, for its
@ -60,9 +62,7 @@ let's start by defining the syntax for types. it's going to be a single base
type, and functions.
$$
\newcommand\Typ{\mathit{typ}}
\newcommand\OR{\mathrel|}
\Typ ::= \bullet \OR \Typ_1 \to \Typ_2
A, B \operatorname{::=} \mathord• \mid A → B
$$
so obviously, my first attempt was to just write this:
@ -159,11 +159,7 @@ overload print with print_typ
types are done, now let's move on to terms. we just want names, lambdas, and
application.
$$
\newcommand\Term{\mathit{term}}
\newcommand\Var{\mathit{var}}
\Term ::= \Var \OR \lambda \Var : \Typ. \Term \OR \Term_1 \; \Term_2
$$
$$ s, t \operatorname{::=} x \mid λ x : A. s \mid s \; t $$
for the same reason as before, terms are indexed by their height, but _also_ by
the number of variables in scope, since i want de bruijn indices to be