faylang / fay

A proper subset of Haskell that compiles to JavaScript
https://github.com/faylang/fay/wiki
BSD 3-Clause "New" or "Revised" License
1.29k stars 86 forks source link

The runtime makes use of Fay.FFI.* functions that are defined in the application code. #405

Closed cies closed 10 years ago

cies commented 10 years ago

Somehow it feels weird that a runtime needs particular application code to run. This prevents (in some cases) the runtime from being in a separate JS file from the application code.

When wrongly separating the runtime from the application code I got the following JS error in my Chrome browser:

Uncaught ReferenceError: Fay is not defined

Find more info about this issue here:

https://github.com/fpco/yesod-fay/issues/12

bergmark commented 10 years ago

The runtime should always be printed before application code. It references the Defined and Nullable types inside functions that are only invoked through application code. I don't see how this could go wrong... Is this reproducible without yesod-fay if you use fay --no-rts and include the runtime separately?

cies commented 10 years ago

I just tried, but could not reproduce it in a minimal Fay-only example. As you said I used --no-rts and included the runtime separately, after that it still works like a charm.

I'll look deeper into what Yesod-Fay does differently.

bergmark commented 10 years ago

I'll close this in favor of fpco/yesod-fay#12. Please re-open if it turns out to be a fay problem.