There is a runtime error when composing 2 functions. The same code works fine when composition operator is avoided (e.g. let foo = squarePromise 4 |> createPromise)
open Fable.Core
let squarePromise a resolve reject =
resolve (a*a)
[<Emit("new Promise($0)")>]
let createPromise (f: ('a -> unit) -> (System.Exception -> unit) -> unit): Fable.Import.JS.Promise<'a> = jsNative
let foo =
(squarePromise >> createPromise) 4
Expected: foo should contain a promise that is resolved to 16
Actual: Uncaught TypeError: Promise resolver undefined is not a function
dotnet fable --version): 1.3.10Thanks for the report @durkiewicz and sorry for replying late. This seems due to the current way in Fable 1 to "uncurry" lambdas which relies mainly in runtime checks and it fails in some cases. I've tested with Fable 2 (dev2.0 branch) and the error is not happening. I am trying to release the next version soon, would it be possible for you to use the work around (|> operator) until the next version is ready? If necessary, I can also try to fix it for the current version.
Hi Alfonso, thanks for replying. It's nice to hear that the bug is going to be fixed in Fable 2. I'm fine with using the workaround - I just need to be careful.
BTW, the fable.io page should have a donation button!
Great, thanks for your understanding! For me personally, the best donation is you keep using Fable, post about it and help make it better everyday, so companies trust the tool I (and others) can get professional projects using Fable :)
Fixed in Fable 2 so we can close this :)
Most helpful comment
Great, thanks for your understanding! For me personally, the best donation is you keep using Fable, post about it and help make it better everyday, so companies trust the tool I (and others) can get professional projects using Fable :)