-
Notifications
You must be signed in to change notification settings - Fork 657
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
Function returning partially applied function not compiling in correct order #1360
Comments
Another pass through the code had me notice that it is, indeed, a mutually recursive declaration because |
Mutually recursive functions are supported in Elm. What is problematic at the moment is recursive values. See #873. It's not completely straightforward where the line is drawn (what's a value, but "not a function"). Basically, it's a question of the syntactic form of the definition. One thing you could try is to reformulate your functions like feature : (String -> State -> State)
feature = block featureStr Feature to feature : (String -> State -> State)
feature string = block featureStr Feature string May look like it shouldn't make a difference, but absent a fix for #873 it actually can make a difference. In any case, I don't think what you encountered here is an issue of import Html
even x = if x == 0 then True else odd (x - 1)
odd x = if x == 0 then False else even (x - 1)
main = Html.text (toString (even 13)) |
Ah, I should have been more thorough in my testing before coming to the conclusion that mutually recursive functions are not supported. Thank you for clearing that up! I think I now have a better understanding of the difference between a function and a value in Elm. As such, the semantic difference implied by the slight syntactic modification shown in your example makes perfect sense. The behavior of Thanks for the help! |
I am working on an elm project experimenting with parsing, and I have run into an issue while attempting to take advantage of higher order functions.
After building the project and loading it up in the browser I get the following error messages:
![image](https://cloud.githubusercontent.com/assets/10535587/14893888/b998646e-0d36-11e6-8a00-22ba37fb8676.png)
The error can be traced to the following declarations in the compiled JS:
Which is being generated from this file. For some reason
feature
is being defined prior toblock
, despite the offending functions not being mutually recursive. This leads me to believe that this is potentially a bug in the compiler.I know this is a rather large chunk of code, but I was unable to quickly reproduce this in a minimal example. I'll work on getting a minimal reproduction of the error posted here within a reasonable amount of time around my finals.
The text was updated successfully, but these errors were encountered: