You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This happened again :) As I can see that biggest pain in Fable is dealing with F# curried functions and Javascript. I've found one more issue with it, tests included : #1071
I've found workaround, but want to know is it neccessary, and if so - how to automate if somehow (having one single curry function to call. Maybe it'd be better to write in JS?)
Related information
Fable version (dotnet fable --version): Strangely I have clitool dotnet-fable 1.1.11, but dotnet fable --version returns 1.1.10. Nevertheless tests included are failing with latest Fable's sources.
You're right, @irium. I'm always hoping we've covered all the issues with curried application, but it seems new cases always pop out from time to time... Sometimes I wonder if the uncurrying optimization was a good idea after all 😕
The safest solution would be to make all lambdas dynamically curried but I'm not sure what would be the performance impact of this. Anyways, I'll try to fix this and let's pray the next case takes much longer to appear 😉 Thanks a lot for the tests! This is always the hardest part.
Ok, so the ad-hoc currying was working... but not for option function types, so I just added an extra check. Hopefully it should be fine now. I will publish the fix right away as version 1.1.12.
BTW, about the version, there was an issue with the dependencies for 1.1.10 so I republished again manually and forgot to update the version literal (that's a task for the build script) 😅
Thanks a lot! For now I've workarounded it by included in my sort of Prelude file the manual currying function and using it where appropriate.
I agree that total auto-currying maybe not the best solution for all, so maybe just to expose mentioned to Fable.JS.Interop so everybody could use it to make curried functions? Such universal function is impossible to write in pure Fable F#.
Hmm, users shouldn't need to convert lambdas into dynamically curried functions by themselves (or even know that such a wrapper exists) Fable should do it automatically when needed. But it's true that maybe the only way to workaround an issue until a proper fix comes to Fable.
Maybe the best solution is to add an importFromFableCore function as I've thinking so advanced users can import functions directly from fable-core JS files (assuming the risks those functions can change in future versions).
I saw code of your fix and it looks smart enough to be automatic in processing f option.
But Option is just one of many monads. For example - Promise<'a> from Fable.PowerPack ;)
Or async from FSharp itself. Someday somebody will get it, and the story will continue... :)
Good point! The main difference with of Option with other monads is options are erased in Fable, that's why we need to deal with functions and function options in the same way. For Promise and other monads the add-hoc currying should happen when the function is actually unwrapped.
However, if you've time, it'd be very nice if you could PR a test for other monad types to check that this is actually working 👍
Activity
alfonsogarciacaro commentedon Jul 16, 2017
You're right, @irium. I'm always hoping we've covered all the issues with curried application, but it seems new cases always pop out from time to time... Sometimes I wonder if the uncurrying optimization was a good idea after all 😕
The safest solution would be to make all lambdas dynamically curried but I'm not sure what would be the performance impact of this. Anyways, I'll try to fix this and let's pray the next case takes much longer to appear 😉 Thanks a lot for the tests! This is always the hardest part.
alfonsogarciacaro commentedon Jul 17, 2017
Ok, so the ad-hoc currying was working... but not for option function types, so I just added an extra check. Hopefully it should be fine now. I will publish the fix right away as version 1.1.12.
BTW, about the version, there was an issue with the dependencies for 1.1.10 so I republished again manually and forgot to update the version literal (that's a task for the build script) 😅
Fix #1072: Curried application with option type
irium commentedon Jul 17, 2017
Thanks a lot! For now I've workarounded it by included in my sort of
Preludefile the manual currying function and using it where appropriate.I agree that total auto-currying maybe not the best solution for all, so maybe just to expose mentioned to
Fable.JS.Interopso everybody could use it to make curried functions? Such universal function is impossible to write in pure Fable F#.alfonsogarciacaro commentedon Jul 17, 2017
Hmm, users shouldn't need to convert lambdas into dynamically curried functions by themselves (or even know that such a wrapper exists) Fable should do it automatically when needed. But it's true that maybe the only way to workaround an issue until a proper fix comes to Fable.
Maybe the best solution is to add an
importFromFableCorefunction as I've thinking so advanced users can import functions directly fromfable-coreJS files (assuming the risks those functions can change in future versions).irium commentedon Jul 21, 2017
I saw code of your fix and it looks smart enough to be automatic in processing
f option.But
Optionis just one of many monads. For example -Promise<'a>fromFable.PowerPack;)Or
asyncfrom FSharp itself. Someday somebody will get it, and the story will continue... :)alfonsogarciacaro commentedon Jul 21, 2017
Good point! The main difference with of
Optionwith other monads is options are erased in Fable, that's why we need to deal with functions and function options in the same way. ForPromiseand other monads the add-hoc currying should happen when the function is actually unwrapped.However, if you've time, it'd be very nice if you could PR a test for other monad types to check that this is actually working 👍
irium commentedon Jul 21, 2017
Good point too about special meaning of
Optionmonad.As for writing more tests - I'll do, but somewhat later, when there will be time for it.
style: use struct partial active patterns and postfix array syntax