-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathideas.txt
155 lines (119 loc) Β· 1.86 KB
/
ideas.txt
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
> The sound(ness) of one hand typing
- sound (audio)
- soundness (correctness)
- one hand (literally one hand)
- one hand (one side)
- typing (writing)
- typing (type system)
right
v
(a b)
^
left
one hand
(not sound?)
v
(a)
no hand
(sound?)
v
()
(left (a b)) = a
(right (a b)) = b
((lambda (f) (f (a b))) left) = a
expr = left | right | (lambda (arg...) body) | (f x)
```haskell
data Hand a b = Left a | Right b -- Either
swap :: Hand a b -> Hand b a
swap = \case
Left x -> Right x
Right x -> Left x
```
```haskell
data Hand a = Left a | Null -- Maybe
```
left
(right a)
(= or-default
(lambda (x default)
((default <-> y y) x)))
```
((x <x y> y) x) = x
((x <x y> y) y) = y
((x <x y> y) 'x) = x
((x <x y> y) y') = y
((x <x y> y) 'x') = x, y
```
not:
```
r
r <-> l
```
=
```
l
```
two-handed type:
a => b : x -> y
takes a, returns b
one-handed type:
a : x -> y
takes whatever, returns a
no hands: ()
one hand: (a)
two hands: (a b)
(a (b c))
((a b) c)
(left (left ((a b) c))) = a
(): ()
Nothing: ()
Just a: (a)
[]: ()
[a]: (a)
[a b c]: (a (b c))
Left a: (a ())
Right a: (() a)
\x -> x: (x x)
((\x -> x) ()): (apply (x x) ())
(apply (x (y x)) a) = (y a)
(apply (apply (x (y x)) a) b) = a
(apply (x ()) a) = ()
(left (x ())) = x
(right (x ())) = ()
[(a b) c] = b where a=c
(a b) = (a b)
Two-handed expressions are sound:
(a b) = (a b)
[(x x) a] = (a a)
One-handed expressions are not:
[a]
^
error: no right hand
[(a) b]
^
error: no right hand
No-handed expressions:
[]
^
error: no hands
Need literals?
:a
symbol = :a
(symbol symbol) = (:a :b)
(a a) = (x x)
(a (b a)) = (x (y x))
[(x x) :a]
^^ ^
|| |
|| symbol
|(symbol symbol)
symbol
Need functions instead of applications
[x x] = [x x]
([x x] [x x]) = [x x]
program = def...
def = {var exp}
exp = fun | app | var
fun = [arg exp]
app = (exp exp)
var = x, where x is in scope