GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — New command: purs codegen by colinwahl · Pull Request #4092 · purescript/purescript Conversation
Contributor
Description of the change Implements a new command:
This command allows for CoreFn transformations to be written outside of the compiler (even in PureScript!) without having to worry about using PureScript as a library. Example usage of this would be: This intends to close #3339 Checklist:
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
colinwahl
commented
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If there is an appropriate place to move this then I will update all 3 of those modules.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds like a good idea. Create a
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
colinwahl
commented
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When performing
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it would be better to factor
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea - I can go ahead and do that now
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsUh oh!
There was an error while loading. Please reload this page.
rhendric
reviewed
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it would be better to factor
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds like a good idea. Create a
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While you're messing around with this, you can import
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, it is, great call
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
rhendric
reviewed
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking good! I have one outstanding question about the
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the normal compilation path, the codegen supply monad is initialized with the next unused number from previous parts of the compilation. Using 0 here raises the question of whether this reuse is necessary. If so, using 0 here might cause problems. If not (I suspect not), we should probably be consistent so that the produced code isn't different when generated just by So assuming it's safe to do so, I think we should remove the
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a great point. I tried reading through the usages of the supply monad in the codegen code and it looks like it's just for generating fresh variable names - it doesn't seem to me that it'd require we start off from where we left off in say typechecking - but I don't have enough experience to say for sure. At work we've been using If it is the case that it doesn't matter, then I'll remove the
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I spent some time going through the I went ahead and made the change you suggested, and all tests are passing. If anyone knows more than I do and thinks that we should undo the change, I can do that too!
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Comment on lines
+73
to
+74
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
rhendric
reviewed
Uh oh!
There was an error while loading. Please reload this page.
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
|
| (makeResult, makeWarnings) <- | ||
| P.runMake purescriptOptions | ||
| $ traverse (P.codegenJS (makeActions foreigns filePathMap) codegenSourceMaps . snd) | ||
| $ rights mods |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Here's a second rights mods. Perhaps that should also be moved to a let binding so more things can reuse it?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@colinwahl do you have bandwidth to finish this off? Can I help? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I've rebased on current master here. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@MaybeJustJames would you like to take this over from me? My bandwidth for compiler work is pretty low these days. The big open question is that I'm still not sure if #4092 (comment) could lead to any problems. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
As the question is over a year old, I'm inclined to say let's ship it and find out. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Happy to take over. How would you like to do it? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
However you'd like to do it is fine with me - you could continue off this PR, or make a new branch and cherry-pick my changes, or just close it and start again from scratch. Let me know what you decide and if I should close this PR! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
IMHO it would be a shame to lose the context here. Could I get write permission to your branch so I can pick up from here? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I was wondering - is this work necessary at all now that we have the backend optimizer? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Supporting an optimizer was certainly my main goal for this - now that we've got |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
It does strike me as a loss if the best general-purpose JavaScript backend for PureScript remains in a third-party project in the long term. I'm not sure how exactly this happened—I suspect the friction to contributing to PureScript is just too high for this level of innovation—but with enough time I would hope it can be mostly unforked. At that point, exposing the backend used by |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@rhendric I agree with you - my point here is that the new backend has shuffled the landscape quite a bit: it shows not only that it's possible to aggressively optimise the CoreFn, but also that it's possible to emit more performant JS outside of the compiler, and all of this while the implementation is in PureScript. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Okay yeah, I agree with looking at Is In the meantime, as long as there's some value in having a built-in JS backend (regardless of the language in which the backend is written or the repo in which it lives), I think there's still a case for exposing it, so users can benefit from custom optimizations and rewrites without needing to also use a third-party backend. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
purs-backend-es does not subsume compiler functionality.
So, I do not see any near term future where the current JS backend is rendered obsolete, though I would like a near term future where something like purs-backend-es can be used in a first-class way. That being said, if there are currently no pending users of this feature, I'm not sure what the point is. I think the fresh name issue seems like it can clearly cause a problem, however unlikely, and I'm not sure how you'd fix it. I don't know how I feel about merging a feature with a uncertain prospects and potentially buggy behavior. I'm happy to talk about |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I agree. I wanted to get this through for zephyr specifically. There is potential for other optimization tools to make use of this interface even if an improved backend is eventually merged. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Also expose the new codegenJS action for use in purs codegen
Always initialize supply with 0 as codegenJS implementation detail in order to get deterministic variable naming while doing a normal purs compile vs purs compile; purs codegen
Co-authored-by: Ryan Hendrickson <[email protected]>
cb5920a to
231ed9e
Compare
|
I think this PR can be closed, right? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I would still vote to merge for the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Is the vision for purescript to have multiple codegen backends? If non-javascript backends are always going to be separate projects then maybe to makes sense for JavaScript codegen to be separate too? In which case this PR should be closed. If the vision for the compiler is to include multiple backends then I think a |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
At least 1 approving review is required to merge this pull request.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Considerpurs codegen command
There was an error while loading. Please reload this page.