-
Notifications
You must be signed in to change notification settings - Fork 50
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
Inefficient categorical IR? #52
Comments
Thanks for the question. After writing the paper, I introduced a class for monoidal categories with products as a superclass of cartesian categories. (My non-cartesian, monoidal, motivating example was a category of isomorphisms---really a category transformer.) Such a monoidal category has |
Thank you! It would be interesting to have a list of "requirements" or "overarching issues" that are essential for the approach to be viable when IR optimizations matter. This is related to a recent remark by David Spivak where he mentions that "isomorphisms are free [in mathematics] but expensive [in computer science]". All this seems to put rewrite systems in the spotlight, and it would be interesting to know from a research perspective what the key problems are in practice. |
I realize there isn't an easy answer, and I'd like to give an example to illustrate what I mean in case others stumble across our conversation in the future. Re-consider the function Setting The question is whether it is feasible to get such a categorical form (or maybe something simpler) without relying on the λ-calculus. Put differently, can we simplify
The rationale behind such calculation using a "categorical IR" is that there may be theorem(s) that we can exploit to optimize the code. The purpose of this Github issue is to find out whether you think such an approach is viable. I suspect there may be a good reason why something like CAM has never caught on in the larger community around functional programming compilers. |
This is not so much a bug report but a technical question:
In your papers, an expression such as
x + (x * y)
would be encoded asadd ○ (exl △ mul)
. However, your compiler extension usesdup
instead. This seems to lead to inefficiencies.I am therefore wondering: what is the reason for the difference between the categorical operators in your papers and the implementation? Is it due to the way GHC works? Or does it solve some other issues? Could the above inefficiencies be avoided by using the more "rudimentary" categorical operators that you use in your papers?
Many thanks in advance for your time!
The text was updated successfully, but these errors were encountered: