[Haskell-cafe] ghci & ghc -> JS (Emscripten)

B B blackbox.dev.ml at gmail.com
Wed Jul 3 12:26:26 CEST 2013

Thank you for your response :)
Could you please answer one additional question - why you, while creating
GHCJS didn't base on emscripten? Why haven't you patched it and created
custom solution?
Is GHCJS "production ready"? Also - Can I use GHCJS to compile big projects
(like GHC or GHCI) to Javascript?

When you mentioned the file sizes I thought it would be good to further
introduce what we are trying to do.
We want to be able to send a haskell code to a server to compile it and
return the resulted JS to user as a compiled library. We want users to be
able to connect these compiled functions together to get some interactive
for example: user is creating 2 functions (pseudocode): a(x) and b(x). They
are send to server and compiled to JS. Then in an online tool user is
connecting (visually with lines) a data (lets say a list of ints) [] -> a
-> b. While connecting it we want this tool to "interpret" such connections
and visualise the data on each step - so we want to have some kind of
"runtime" or "interpreter" on client side.

2013/7/3 Luite Stegeman <stegeman at gmail.com>

> On Wed, Jul 3, 2013 at 11:06 AM, B B <blackbox.dev.ml at gmail.com> wrote:
>> Emscripten is meant to translate ANY LLVM IR code to javascript and it
>> should work (as I belive).
> It cannot compile ANY LLVM code: It's heavily geared towards porting C and
> C++ code to JavaScript, and still there are some limitatons, see:
> https://github.com/kripken/emscripten/wiki/CodeGuidelinesAndLimitations
> Also the FAQ mentions how event loops should be converted to something
> that emscripten can deal with:
> https://github.com/kripken/emscripten/wiki/FAQ
> Since the GHC runtime never returns, you'd probably have to do something
> similar.
> I've tried to compile 'hello wrold' Haskell program to JS using Emscripten
>> but I faced a problem, that in generated LLVM IR code there is no C-like
>> main function (https://github.com/kripken/emscripten/issues/500) so
>> there has to be a runtime library that has to be linked and will run the
>> code - is this "RTS" or something else?
>> If its RTS I understeand I should compile it to javascript and then
>> provide it as a library to emscripten? Do you have a working RTS js version?
> I don't have a working version. The files you need are probably mostly in
> the rts directory of the GHC repository:
> https://github.com/ghc/ghc/tree/master/rts , but you might need a bit
> more, like libffi and gmp (unless you use integer-simple).
>> I want to simply try emscripten and see how it performs on such GHC
>> generater LLVM IRs.
> I don't think it's that easy... I'd expect a few weeks of work minimum to
> get very simple examples like "Hello, world" working. And a few months for
> something big like GHC.
> Also keep in mind that the code will probably be pretty big, GHC (and
> GHCi, which is the same file) is ~65MB on my linux system, so getting well
> over 100MB of JavaScript wouldn't be terribly surprising.
>  luite
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130703/a30e4191/attachment.htm>

More information about the Haskell-Cafe mailing list