-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogram.js
112 lines (93 loc) · 1.6 KB
/
program.js
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
export class Pair {
state;
value;
constructor(state, value) {
this.state = state;
this.value = value;
}
};
export class Program {
bind(f) {
return new Bind(this, f);
}
step(y) {
return new Step(this, y);
}
apply(x) {
return new Apply(this, x);
}
map(f) {
return new Map(this, f);
}
}
export class Bind extends Program {
x;
f;
constructor(x, f) {
super();
this.x = x;
this.f = f;
}
}
export class Map extends Program {
x;
f;
constructor(x, f) {
super();
this.x = x;
this.f = f;
}
}
export class Apply extends Program {
f;
x;
constructor(f, x) {
super();
this.f = f;
this.x = x;
}
}
export class Step extends Program {
x;
y;
constructor(x, y) {
super();
this.x = x;
this.y = y;
}
}
export class Pure extends Program {
value;
constructor(value) {
super();
this.value = value;
}
}
export const pure = v => new Pure(v);
export class Put extends Program {
s;
constructor(s) {
super();
this.s = s;
}
}
export class Get extends Program {
}
export class Modify extends Program {
f;
constructor(f) {
super();
this.f = f;
}
}
export class Fragment extends Program {
f;
constructor(f) {
super();
this.f = f;
}
}
export const get = new Get();
export const put = s => new Put(s);
export const modify = f => new Modify(f);
export const fragment = f => new Fragment(f);