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

Long load time #384

Closed christianpbrink closed 10 years ago

christianpbrink commented 10 years ago

I've Fay-compiled a Haskell module to a standalone JS module. When I included it on a web page, however, the Strict export didn't appear to be in scope in the Javascript console. I waited a few minutes (in case it needed time to execute) and still nothing.

I also tried it on a page where I load JS modules asynchronously using require.js (simply added it as a dependency for another module used on the page). The result was that the page never loaded fully and in fact began to freeze up after a few seconds (console wouldn't open, etc.). Seems like require.js was waiting for my module to finish loading before proceeding to load the rest of the page, and it just never finished.

Does this sound like evidence of a bug, or are some fay-compiled JS files just very slow to load?

bergmark commented 10 years ago

Fay files should not take long to load, there is nothing special that happens during startup.

It might be a problem with the strictness wrapper being too eager in evaluating something. Can you make a reproduction out of it?

christianpbrink commented 10 years ago

I cleared out code to find a minimal working example, then re-added bits until I ran into the bit that was giving me trouble. It was the use of ellipsis to denote lists. None of my lists was infinite -- think ['A'..'B'] -- but apparently the ellipsis isn't Fay-friendly at all? I don't know enough about Haskell's list implementation to know whether the use of any ellipsis, even if bounded at both ends, is shot through with laziness.

Anyway, I've now replaced my ellipses with the full list literals, and it compiles just fine to a JS file that exports Static.MyModule.

Side note: I also noticed that some uses of $ seem to throw Fay off. It compiles without an issue, but at runtime the invocation of a function whose Haskell source uses $ sometimes blows up, reporting on that "undefined is not a function". I replaced most (not all) of my $s with parentheses and the problem went away.

Thanks for all your work on this.

christianpbrink commented 10 years ago

That is: thanks a ton for all your work on this. I got my Haskell module compiled to JS, it works, and I couldn't be happier.

bergmark commented 10 years ago

For enums, see #364. Fay warns when it can about these things but can't always figure it out. It's fine to use with numbers though.

If you can give me a reproduction $ failing i'd be happy to take a look, it sounds like a bug.

bergmark commented 10 years ago

I'll close this, please open a new ticket if you find a reproduction.

christianpbrink commented 10 years ago

Will do, although it might be a couple days. Thanks again.

On Fri, Jan 17, 2014 at 9:50 AM, Adam Bergmark notifications@github.comwrote:

I'll close this, please open a new ticket if you find a reproduction.

— Reply to this email directly or view it on GitHubhttps://github.com/faylang/fay/issues/384#issuecomment-32611532 .