-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Floats let bindings #76
Open
mikesol
wants to merge
24
commits into
aristanetworks:main
Choose a base branch
from
mikesol:float-lets
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
1c73c42
Floats let bindings
40f04ae
Adds recursive evalAssocLet
1697a2d
Updates branch
22cbff5
Merge branch 'main' into float-lets
5f977b5
Updates
87ff495
Fixes stuff
7f1c4a1
Small changes
28e35f8
Removes free encoding
f29c375
Fails for the wrong reasons
881cdc4
Uses stringly typed programing to get the PR over the net
77d15b9
Improves sorting
9cf5e36
Adds some comments
7d90243
uses original ordering
2a0f5e3
Fixes ordering for more complex bindings
d27a7fc
Fixes snapshot
ee67991
Removes extraneous guard
3224524
Adds smart constructors
017d2cd
Takes care of special top-level letrec
ccdc1fa
Adds test for top-level letrec
9b8478e
Fixes logic bug
186a986
Removes traces
d7bbffb
Simplifies boolean
5bfac3e
Uses Nate's eval strategy
b912546
Adds back test
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
import * as Effect$dConsole from "../Effect.Console/index.js"; | ||
const test1 = /* #__PURE__ */ (() => { | ||
const $0 = Effect$dConsole.log("1"); | ||
return () => { | ||
$0(); | ||
const value = Effect$dConsole.log("2")(); | ||
Effect$dConsole.log("3")(); | ||
return value; | ||
}; | ||
})(); | ||
export {test1}; | ||
const test1$0 = /* #__PURE__ */ Effect$dConsole.log("1"); | ||
const test1 = () => { | ||
test1$0(); | ||
const value = Effect$dConsole.log("2")(); | ||
Effect$dConsole.log("3")(); | ||
return value; | ||
}; | ||
export {test1, test1$0}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import * as $runtime from "../runtime.js"; | ||
import * as Data$dEither from "../Data.Either/index.js"; | ||
import * as Data$dFoldable from "../Data.Foldable/index.js"; | ||
import * as Data$dTuple from "../Data.Tuple/index.js"; | ||
import * as Effect$dConsole from "../Effect.Console/index.js"; | ||
const test1$0$b = /* #__PURE__ */ Effect$dConsole.log("foo"); | ||
const test1$1$a = /* #__PURE__ */ Data$dFoldable.foldlArray(a => b => { | ||
if (a.tag === "Left") { return Data$dEither.$Either("Left", a._1); } | ||
if (a.tag === "Right") { | ||
if (b.tag === "Left") { return Data$dEither.$Either("Left", b._1); } | ||
if (b.tag === "Right") { return Data$dEither.$Either("Right", a._1 + b._1 | 0); } | ||
} | ||
$runtime.fail(); | ||
})(/* #__PURE__ */ Data$dEither.$Either("Right", 3))([ | ||
/* #__PURE__ */ Data$dEither.$Either("Left", test1$0$b), | ||
/* #__PURE__ */ Data$dEither.$Either("Right", 4), | ||
/* #__PURE__ */ Data$dEither.$Either("Left", test1$0$b) | ||
]); | ||
const test1 = /* #__PURE__ */ Data$dTuple.$Tuple( | ||
1, | ||
/* #__PURE__ */ Data$dTuple.$Tuple( | ||
test1$1$a, | ||
/* #__PURE__ */ (() => { | ||
if (test1$1$a.tag === "Left") { return Data$dEither.$Either("Left", test1$1$a._1); } | ||
if (test1$1$a.tag === "Right") { return Data$dEither.$Either("Right", test1$1$a._1 + 1 | 0); } | ||
$runtime.fail(); | ||
})() | ||
) | ||
); | ||
export {test1, test1$0$b, test1$1$a}; |
37 changes: 37 additions & 0 deletions
37
backend-es/test/snapshots-out/Snapshot.FloatLetFromArray.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import * as $runtime from "../runtime.js"; | ||
import * as Data$dEither from "../Data.Either/index.js"; | ||
import * as Effect$dConsole from "../Effect.Console/index.js"; | ||
const snd = a => a[1]; | ||
const right = x => { | ||
if (x.tag === "Right") { return x._1; } | ||
$runtime.fail(); | ||
}; | ||
const left = x => { | ||
if (x.tag === "Left") { return x._1; } | ||
$runtime.fail(); | ||
}; | ||
const fst = a => a[0]; | ||
const test1$0$b = /* #__PURE__ */ Effect$dConsole.log("foo"); | ||
const test1 = [ | ||
/* #__PURE__ */ Data$dEither.$Either("Left", 5), | ||
/* #__PURE__ */ Data$dEither.$Either( | ||
"Right", | ||
[ | ||
/* #__PURE__ */ Data$dEither.$Either( | ||
"Left", | ||
[ | ||
/* #__PURE__ */ Data$dEither.$Either("Left", 1), | ||
/* #__PURE__ */ Data$dEither.$Either( | ||
"Right", | ||
[ | ||
/* #__PURE__ */ Data$dEither.$Either("Left", test1$0$b), | ||
/* #__PURE__ */ Data$dEither.$Either("Right", [/* #__PURE__ */ Data$dEither.$Either("Left", 5), /* #__PURE__ */ Data$dEither.$Either("Right", test1$0$b)]) | ||
] | ||
) | ||
] | ||
), | ||
/* #__PURE__ */ Data$dEither.$Either("Right", 6) | ||
] | ||
) | ||
]; | ||
export {fst, left, right, snd, test1, test1$0$b}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import * as Data$dTuple from "../Data.Tuple/index.js"; | ||
import * as Effect$dConsole from "../Effect.Console/index.js"; | ||
const test1$0$b = /* #__PURE__ */ Effect$dConsole.log("foo"); | ||
const test1 = /* #__PURE__ */ Data$dTuple.$Tuple( | ||
5, | ||
/* #__PURE__ */ Data$dTuple.$Tuple(/* #__PURE__ */ Data$dTuple.$Tuple(1, /* #__PURE__ */ Data$dTuple.$Tuple(test1$0$b, /* #__PURE__ */ Data$dTuple.$Tuple(5, test1$0$b))), 6) | ||
); | ||
export {test1, test1$0$b}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import * as Effect$dConsole from "../Effect.Console/index.js"; | ||
const test1$0$b = /* #__PURE__ */ Effect$dConsole.log("foo"); | ||
const test1 = {l: 5, r: {l: {l: 1, r: {l: test1$0$b, r: {l: 5, r: test1$0$b}}}, r: 6}}; | ||
export {test1, test1$0$b}; |
18 changes: 9 additions & 9 deletions
18
backend-es/test/snapshots-out/Snapshot.FunctionCompose03.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,13 @@ | ||
const $Html = (tag, _1, _2) => ({tag, _1, _2}); | ||
const Elem = value0 => value1 => $Html("Elem", value0, value1); | ||
const Text = value0 => $Html("Text", value0); | ||
const h11 = /* #__PURE__ */ (() => { | ||
const $0 = Elem("h1"); | ||
return x => $0([x]); | ||
})(); | ||
const h21 = /* #__PURE__ */ (() => { | ||
const $0 = Elem("h2"); | ||
return x => $0([x]); | ||
})(); | ||
const h11$0 = /* #__PURE__ */ Elem("h1"); | ||
const h21$0 = /* #__PURE__ */ Elem("h2"); | ||
const p1 = /* #__PURE__ */ Elem("p"); | ||
const section1 = /* #__PURE__ */ Elem("section"); | ||
const article1 = /* #__PURE__ */ Elem("article"); | ||
const test = user => section1([ | ||
h11($Html("Text", "Posts for " + user)), | ||
article1([h21($Html("Text", "The first post")), p1([$Html("Text", "This is the first post."), $Html("Text", "Not much else to say.")])]) | ||
h11$0([$Html("Text", "Posts for " + user)]), | ||
article1([h21$0([$Html("Text", "The first post")]), p1([$Html("Text", "This is the first post."), $Html("Text", "Not much else to say.")])]) | ||
]); | ||
export {$Html, Elem, Text, article1, h11, h21, p1, section1, test}; | ||
export {$Html, Elem, Text, article1, h11$0, h21$0, p1, section1, test}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 10 additions & 12 deletions
22
backend-es/test/snapshots-out/Snapshot.RecursiveBindingGroup02.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
// @fails Binding demanded before initialized | ||
import * as $runtime from "../runtime.js"; | ||
const test = /* #__PURE__ */ (() => { | ||
const test3 = n => { | ||
if (n < 100) { return n; } | ||
return test1$lazy().bar; | ||
}; | ||
const test2$lazy = $runtime.binding(() => ({baz: test1$lazy().bar})); | ||
const test1$lazy = $runtime.binding(() => ({foo: test2$lazy().baz, bar: test3(42)})); | ||
const test2 = test2$lazy(); | ||
const test1 = test1$lazy(); | ||
return test1.bar; | ||
})(); | ||
export {test}; | ||
const test$0$test3$$rec = n => { | ||
if (n < 100) { return n; } | ||
return test$0$test1$$rec$lazy().bar; | ||
}; | ||
const test$0$test2$$rec$lazy = /* #__PURE__ */ $runtime.binding(() => ({baz: test$0$test1$$rec$lazy().bar})); | ||
const test$0$test1$$rec$lazy = /* #__PURE__ */ $runtime.binding(() => ({foo: test$0$test2$$rec$lazy().baz, bar: test$0$test3$$rec(42)})); | ||
const test$0$test2$$rec = /* #__PURE__ */ test$0$test2$$rec$lazy(); | ||
const test$0$test1$$rec = /* #__PURE__ */ test$0$test1$$rec$lazy(); | ||
const test = /* #__PURE__ */ (() => test$0$test1$$rec.bar)(); | ||
export {test, test$0$test1$$rec, test$0$test2$$rec, test$0$test3$$rec}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,24 @@ | ||
const test = /* #__PURE__ */ (() => { | ||
const go = go$a0$copy => { | ||
let go$a0 = go$a0$copy, go$c = true, go$r; | ||
while (go$c) { | ||
const n = go$a0; | ||
const k = k$a0$copy => { | ||
let k$a0 = k$a0$copy, k$c = true, k$r; | ||
while (k$c) { | ||
const m = k$a0; | ||
if (m === 100) { | ||
k$c = false; | ||
go$a0 = m - 1 | 0; | ||
continue; | ||
} | ||
if (m === 900) { | ||
go$c = k$c = false; | ||
go$r = 42; | ||
continue; | ||
} | ||
k$a0 = m - 1 | 0; | ||
} | ||
return k$r; | ||
}; | ||
if (n === 0) { | ||
go$c = false; | ||
go$r = n; | ||
const test = n => { | ||
const k = k$a0$copy => { | ||
let k$a0 = k$a0$copy, k$c = true, k$r; | ||
while (k$c) { | ||
const m = k$a0; | ||
if (m === 100) { | ||
k$c = false; | ||
k$r = test(m - 1 | 0); | ||
continue; | ||
} | ||
if (n <= 100) { | ||
go$a0 = n - 1 | 0; | ||
if (m === 900) { | ||
k$c = false; | ||
k$r = 42; | ||
continue; | ||
} | ||
k(n - 1 | 0); | ||
k$a0 = m - 1 | 0; | ||
} | ||
return go$r; | ||
return k$r; | ||
}; | ||
return go; | ||
})(); | ||
if (n === 0) { return n; } | ||
if (n <= 100) { return test(n - 1 | 0); } | ||
return k(n - 1 | 0); | ||
}; | ||
export {test}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still find this odd that these definitions are being swapped around. I'm not sure if that's incorrect, it just seems like a strange artifact. Do you have any idea what is happening here? It may be easier to tell if all the invocations were different functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just making sure things are correct & then I'll respond to the point about why this is happening:
In the old one, 0 == g, 1 == f, 2 == g, 3 == f, 4 == g, so the final result of 0,1,2,3,4 was g,f,g,f,g.
In the current one, 0 == g, 1 == f, 2 == f, 3 == g, 4 == f, so the final result of 0,2,3,1,4 is g, f, g, f, g.
So it's correct, but as to why it's happening, I don't know.
Here's the trace from the new one:
and here's the old one:
Just reading through those, I can't figure out exactly what's going on yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's odd to me that in Step 2 there are a bunch of left-associative binds (level 6). I wouldn't expect that to happen since
eval
should be reassociating all binds. It looks like this is happening in the second case as well though.