Inline newtype constructor applications with ($)#4205
Inline newtype constructor applications with ($)#4205rhendric merged 13 commits intopurescript:masterfrom
Conversation
Feel free to extract and introduce the |
|
I haven't the time right this moment to consider a constructive alternative, but as initial feedback I think it's a little unfortunate to duplicate the So, for example, one thing I almost proposed to you now was to replace newtype constructors here with The reason I'm not proposing precisely that is that it introduces a dependency on As I said, I'd need more time than I have right this moment to come up with a better version of that idea, but maybe this inspires a good idea in you or someone else, or a counterargument to one of my thoughts. |
I agree. I had not considered the CoreImp inliner ahead of time because I'm still not really familiar with that part of the code base. Though I figured the CoreFn would be another likely candidate to put this optimization into, it wouldn't really be the best move to make considering the reasons you've pointed out. Thanks a lot, I'll take those pointers in mind. |
|
With CoreImp though, I'm not sure if there's a simple way of determining whether or not some I've tested out this approach on another branch PureFunctor@c828d35f0eb935b9b10d6567c90e909a0b59ca0e and it passes all tests, which at least gives me a bit more confidence with manually checking newtypes like this, but I still think something better could be done. In particular, I sort of propose parameterizing the |
|
I didn't see mention of the fact that non-newtype constructors are also compiled differently with testNonNt1 = NonNT 42
testNonNt2 = NonNT $ 42var testNonNt2 = NonNT.create(42);
var testNonNt1 = new NonNT(42);As the inlining of |
|
Yeah, I think I agree with you. Most of the stuff being inlined in |
|
I think it'd be best to write up a proposal if we ought to move some Likewise, I think this is one of the first few steps in creating a general optimization API for the compiler that isn't backend/codegen-specific, which would prove to be pretty helpful considering that the |
|
I'm not sure what to do with the weeder errors here. |
Co-authored-by: Ryan Hendrickson <ryan.hendrickson@alum.mit.edu>
|
Anything else we want to do before merging this? |
Description of the change
This change makes it so that newtype application using the
($)operator is inlined, which fixes #2866.I'm not entirely sure how to add tests for this though, or for codegen code in general.
Checklist:
[ ] Added myself to CONTRIBUTORS.md (if this is my first contribution)[ ] Updated or added relevant documentation