If so, then I could let people play around with a project of mine by changing its (Haskell) configuration: recompiling it in the browser, and then rerunning it in the browser. I don't care about speed. I just want to be able to demo a hard-to-setup fundamentally-desktop project in the browser. So possible new users can see if they like it, within seconds and without setup.
How cool would that be!
from what I've read, GHCJS compiles STG into JavaScript. it says it uses the GHC API, so we should be able to compile that into JavaScript too, like any other Haskell library. (right?) Is it true that, while the GHC runtime has a lot of C, the compiler itself is pure Haskell?
so:
GHCJS is a Haskell to JavaScript compiler that uses the GHC API. GHCJS contains a library, ghcjs, which contains the JavaScript code generator and a slightly customized variant of the ghc library, and several executable programs. The repository has several submodules and some files must be generated before the package can be installed.
GHCJS is a Haskell to JavaScript compiler that uses the GHC API. Quick Start - Developing GHCJS GHCJS contains a library, ghcjs, which contains the JavaScript code generator and a slightly customized variant of the ghc library, and several executable programs.
GHCJS depends on a few "local" packages in the source tree. You can use cabal-install and stack to set up a build environment that contains these packages. After the source tree has been prepared, the package can be installed. You may want ensure that binaries of earlier versions are overwritten:
The ghcjs-boot program builds the "boot" libraries, like ghc-prim, base and template-haskell with GHCJS. After booting, GHCJS can compile regular Haskell programs and packages. ghcjs-boot needs to be able to find the emscripten toolchain, a nodejs executable.
GHCJS and Haste both, to my knowledge, leverage GHC directly. GHC, though mainly haskell, is tied to a fair amount of cbits in terms of the runtime and how it operates. I am fairly certain neither can, at the moment, be compiled to run directly in browser in a "self-hosted" way.
However, Fay, which is a "Haskell-like-dialect" of JS can be compiled via GHCJS, which is pretty nifty (https://github.com/ghcjs/ghcjs-examples/tree/master/fay-hello) though perhaps not what you want.
Another alternative, if your system is simple enough, is to use emscripten to place hugs in-browser, and let your users play with that.
As you surmise, the various "try it in the browser" sites all actually use a connection to machines, typically running something like mueval
that actually execute the code given.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With