-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathval.rkt
94 lines (64 loc) · 1.57 KB
/
val.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#lang typed/racket
(provide (all-defined-out))
(require "expr.rkt")
(define-type Val (U vlam vpair vcon vunit vset
vone vpi vsigma vfun vsum vnt))
(struct vlam
([clos : Clos]) #:transparent)
(struct vpair
([lhs : Val]
[rhs : Val]) #:transparent)
(struct vcon
([name : Symbol]
[val : Val]) #:transparent)
(struct vunit () #:transparent)
(struct vset () #:transparent)
(struct vone () #:transparent)
(struct vpi
([val : Val]
[clos : Clos]) #:transparent)
(struct vsigma
([val : Val]
[clos : Clos]) #:transparent)
(struct vfun
([clos : SClos]) #:transparent)
(struct vsum
([clos : SClos]) #:transparent)
(struct vnt
([nt : Neut]) #:transparent)
(define-type Neut (U ntgen ntapp ntfst ntsnd ntfun))
(struct ntgen
([n : Integer]) #:transparent)
(struct ntapp
([rator : Neut]
[rand : Val]) #:transparent)
(struct ntfst
([nt : Neut]) #:transparent)
(struct ntsnd
([nt : Neut]) #:transparent)
(struct ntfun
([clos : SClos]
[nt : Neut]) #:transparent)
(define-type Clos (U cls cmp cval))
(struct cls
([patt : Patt]
[exp : Expr]
[rho : Telescope]) #:transparent)
(struct cmp
([clos : Clos]
[name : Symbol]) #:transparent)
(struct cval
([val : Val]) #:transparent)
(define-type Telescope (U tnil tupvar tupdec))
(define-type SClos sclos)
(struct sclos
([branch : Branch]
[rho : Telescope]) #:transparent)
(struct tnil () #:transparent)
(struct tupvar
([rho : Telescope]
[patt : Patt]
[val : Val]) #:transparent)
(struct tupdec
([rho : Telescope]
[decl : Decl]) #:transparent)