-
Notifications
You must be signed in to change notification settings - Fork 27
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
Thoughts on operators in elm-in-elm #60
Comments
Code from the elm compiler that special cases some infix operatorsThe variable Operators in
|
So the special casing of operators is more complicated. Sometimes (a vast majority of real world cases) the elm compiler special cases these operators. Othertimes it falls back to calling the kernel implementation of the arithmetic operation. Here is an image (here is it running live - but link will expire when I switch my laptop running the server off). On the left is elm code and on the right is the relevant parts of the compiled javascript. The elm compiler cannot special case the use of As a tangent this is dangerous as a bug in |
Standard elm uses a syntax borrowed from Haskell to define new operators.
I propose that elm-in-elm should hard code operators into the compiler. The main advantage of this is approach is that we avoid having to define a kernel function for each arithmetic operator: instead the compiler can generate code directly*.
Only standard packages can define operators and they do so very rarely so I think it would be feasible to handle all elm operators in the compiler.
*: The standard compiler also generates code directly as an optimsation.
The text was updated successfully, but these errors were encountered: