The code is available on github.
Note: JavaScript code generation (used to evaluate results) is not prefect yet and has rough edges.
| Feature | Type syntax | Term syntax |
|---|---|---|
| Basic Terms & Types | ||
| literals |
true,
false,
0,
1,
"",
"a",
etc.
|
(same syntax) |
| intersection | S & T |
|
| union | S | T |
if ... then s else t |
| negation | ~T |
|
| nominal tag | #C |
|
| record | { x: int; y: bool } |
{ x = 0; y = false } |
| selection | t.a |
|
| array of known size (tuple) | (), (int,), (int, int) etc. |
(), (0,), (0, 1) etc. |
| array of unknown size | Array[int] |
if ... then (0, 1) else (0, 1, 2) |
| function | int -> int |
fun x -> x + 1 |
| application | F[A] |
f a |
| variable | 'a |
x |
| let binding | let x = s in t |
|
| pattern matching 1 | case t of C1 -> t1, C2 -> t2 |
|
| pattern matching 2 | case t of C1 -> t1, C2 -> t2, _ -> t3 |
|
| Top-Level Declarations | ||
| definition | def foo: T |
def foo = t or just foo = t |
| class, trait, method |
trait MyBase[T]: { fld1: T }
|
mc = MyClass { fld1 = 0; fld2 = "ok" } |
| type alias | type Foo[T] = |
|
| Miscellaneous | ||
| type ascription | t: T |
|
| array indexing | a[i] |
|
| multi-parameter function | (int, int) -> int |
fun (x, y) -> x + y |
| multi-argument application | F[S, T] |
f(s, t) |
| tuple-parameter function | ((int, int)) -> int |
fun ((x, y)) -> x + y
|
| tuple-argument application | F[(S, T)] |
f((s, t)) |