-
Notifications
You must be signed in to change notification settings - Fork 0
/
io.rkt
47 lines (46 loc) · 1.36 KB
/
io.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#lang plait
(define-type-alias Id Symbol)
(define-type Constant
(c-void)
(c-str [it : String])
(c-num [it : Number])
(c-bool [it : Boolean])
(c-vec [it : (Listof Constant)])
(c-list [it : (Listof Constant)]))
(define-type-alias Program ((Listof Def) * (Listof Expr)))
(define (program d* e*) (pair d* e*))
(define-type Def
[d-fun [fun : Id] [arg* : (Listof Id)]
[def* : (Listof Def)]
[prelude* : (Listof Expr)]
[result : Expr]]
[d-var [var : Id] [val : Expr]])
(define-type Expr
(e-con [c : Constant])
(e-var [x : Id])
(e-fun [arg* : (Listof Id)]
[def* : (Listof Def)]
[prelude* : (Listof Expr)]
[result : Expr])
(e-let [bind* : (Listof Bind)]
[def* : (Listof Def)]
[prelude* : (Listof Expr)]
[result : Expr])
(e-if [cnd : Expr] [thn : Expr] [els : Expr])
(e-begin [prelude* : (Listof Expr)] [result : Expr])
(e-set! [var : Id] [val : Expr])
(e-app [fun : Expr] [arg* : (Listof Expr)])
)
(define (bind x e) (values x e))
(define-type-alias Bind (Id * Expr))
(define (var-of-bind bind) (fst bind))
(define (val-of-bind bind) (snd bind))
(define-type Obs
(o-void)
(o-con [it : Constant])
(o-vec [it : (Vectorof Obs)])
(o-list [it : (Listof Obs)])
(o-fun [it : (Optionof String)])
(o-rec [id : Number] [content : Obs])
(o-var [id : Number])
(o-exn [it : String]))