Closed LaylBongers closed 7 years ago
You can compile your program with the --onexec
flag. This launches appends a call to hasteMain
to the program output.
I've never heard of Screeps, but if your code involves any kind of file manipulation or other OS calls, readFile
and the other usual suspects from base
won't work. The reasoning is that if you want to run your code on some platform where manipulating files, creating threads, etc. makes sense, it'd very likely be both easier and faster to just use vanilla GHC. Seems like games such as this might be an exception to that rule. Of course, you can wrap the native node.js facilities for this functionality using the FFI.
How would I add the --onexec flag when building my project with cabal? Screeps doesn't have files anyways, so that's no problem.
For other people who come past this, add this to your executable bit in the cabal file:
ghc-options: "--onexec"
I'm trying to use Haste to compile Haskell for the node.js-based MMORTS programming game Screeps. Code produced by haste runs pretty much out of the box, with one exception. To make it run properly, I have to add the following to the end of the file:
This is because main is triggered using
window.onload
, which is never called in node.js. Other than that it seems to work fine. Is there a more elegant solution that could be done for this?