File tree Expand file tree Collapse file tree 3 files changed +47
-4
lines changed Expand file tree Collapse file tree 3 files changed +47
-4
lines changed Original file line number Diff line number Diff line change 1+ # readback
2+
3+ remove ` readback `
4+
15# lazy evaluation
26
37we still can bring back lazy evaluation by lazy + box,
@@ -34,7 +38,3 @@ why top level wrap need a eta?
3438```
3539
3640can adding lazy evaluation help fix this?
37-
38- # readback
39-
40- be able to readback ackermann function -- maybe use occur check for all the sub-expressions
Original file line number Diff line number Diff line change 1+ import { type Neutral , type Value } from "../value/index.ts"
2+ import { formatExp } from "./formatExp.ts"
3+
4+ export function formatValue ( value : Value ) : string {
5+ switch ( value . kind ) {
6+ case "NotYet" : {
7+ return formatNeutral ( value . neutral )
8+ }
9+
10+ case "Lambda" : {
11+ if ( value . definedName === undefined ) {
12+ return `(lambda (${ value . name } ) ${ value . ret } )`
13+ } else {
14+ return value . definedName
15+ }
16+ }
17+
18+ case "Lazy" : {
19+ return formatExp ( value . exp )
20+ }
21+
22+ case "DelayedApply" : {
23+ const target = formatValue ( value . target )
24+ const arg = formatValue ( value . arg )
25+ return `(${ target } ${ arg } )`
26+ }
27+ }
28+ }
29+
30+ function formatNeutral ( neutral : Neutral ) : string {
31+ switch ( neutral . kind ) {
32+ case "Var" : {
33+ return neutral . name
34+ }
35+
36+ case "Apply" : {
37+ const target = formatNeutral ( neutral . target )
38+ const arg = formatValue ( neutral . arg )
39+ return `(${ target } ${ arg } )`
40+ }
41+ }
42+ }
Original file line number Diff line number Diff line change 11export * from "./formatExp.ts"
2+ export * from "./formatValue.ts"
You can’t perform that action at this time.
0 commit comments