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

2013-07-03 Thread Daniel Frumin


On Jul 3, 2013, at 5:13 PM, B B  wrote:

>> 
>> I think GHCJS should be able to compile all Haskell code in GHC, but we 
>> haven't tested this yet. The tricky bit is probably getting foreign code 
>> work, and creating a working installation that includes all other things, 
>> like libraries and a package database. Usually, GHCi loads object files for 
>> the libraries when running Haskell code. Obviously you can't run machine 
>> code with JavaScript, so you'd have to find a way around it. GHCJS includes 
>> an IO layer, which can be used to set up a virtual filesystem [2], but the 
>> API is far from finished.
> Nice to hear that - we are concidering using GHCJS heavly in our project. We 
> dont have many people and this is free-time "driven" project for now, but we 
> would love to cooperate with you - help with GHCJS development and work 
> together to make it suitable for the project we are working on.
> 
>  
>> Ah it's much easier if the code can be compiled on the server. This is more 
>> or less what Daniil Frumin is doing for his Google Summer of Code project 
>> [3]. We are using GHC on the server for non-interactive things, and GHCJS to 
>> compile interactive code that is run on the client. Our main goal is to get 
>> interactive graphics with the diagrams [4] library working.
>> Currently he is working on building a good sandbox for the compiler on the 
>> server (With SELinux, rlimits and cgroups) so that we can compile code, and 
>> run Template Haskell safely. I'm working on improving the GHCJS linker, so 
>> that we can support incremental code loading more easily (so users can 
>> download just the code for the new function they wrote, instead of the whole 
>> program every time)
> 
> That's very interesting. We want to use GHCJS EXACTLY for this - we want to 
> compile the code on the server and run it in the users browesr BUT we dont 
> want to load the whole program everytime a function is changed - only this 
> particular function. 
> Additional (which is NOT the same) - while writing a function - we want to 
> interactively execute it's "body" on the client side - but this requires 
> something like interpreter on the user client (please see below for 
> explanation). But we are thinking right now about it and its architecture, so 
> we will be in touch in this topic with you :)
>  
> 
>> I have a very crude example of this type here:
>> 
>> http://hdiff.luite.com/reduce/
> 
> This is not exactly the kind of thing I'm talking about. 
> Think about something like matlab simulink or labview - functions are 
> representaed by "nodes" (rectangles) connected with other functions by lines. 
> Lines are "sending data" between these nodes. 
> So user is connecting these blocks - each block is like a function 
> application on data - so adding a block is like adding a new line in Haskell 
> .hs file. We want user to be able to interactively add such nodes (apply 
> further functions on already processed and cached data - every "node" caches 
> processed data) and process the data further - If I didn't explained this 
> simple enought, I will try harder. Such thing needs something like client 
> side interpreter I think ...
>  
>> When we have the SELinux sandbox working, I plan to work on this again, so 
>> that users can enter/compile their own code.
> 
> When do you plan roughtly to release it? We are strongly interested in 
> testing and using it :) 

As Luite has pointed out we plan on releasing the first public beta within a 
month and we are hoping to ship full-featured easily extensible documented 
version by the end of the summer. 


> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2013-07-03 Thread Luite Stegeman
> Similarly I would expect that generating any sort of sensible Javascript
> would require something fairly tightly tied to GHC; otherwise the output's
> going to have horrible performance because it's not going to understand the
> input and will fall back to the slowest but most general translation. (If
> it even has such a fallback, instead of simply failing on code that it
> doesn't recognize.)
>
>
Emscripten produces a limited subset of JavaScript (asm.js), and Firefox
has an optimizer specifically for that. It could result in good
performance, but the CPS transformed code is still a problem indeed, so
it's unclear if GHC generated code would work at all.

Asm.js is really limited, it's like a far less convenient LLVM without
modern instructions in JavaScript syntax. You can't use objects, everything
is stored in a global heap array.

Interestingly, Firefox performs far worse than Chrome and Safari on the
current GHCJS code, probably because their garbage collector is rather poor
(non-generational), and Haskell code produces lots of short-lived immutable
objects.

luite
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2013-07-03 Thread Luite Stegeman
On Wed, Jul 3, 2013 at 3:13 PM, B B  wrote:

>
>>> I think GHCJS should be able to compile all Haskell code in GHC, but we
>> haven't tested this yet. The tricky bit is probably getting foreign code
>> work, and creating a working installation that includes all other things,
>> like libraries and a package database. Usually, GHCi loads object files for
>> the libraries when running Haskell code. Obviously you can't run machine
>> code with JavaScript, so you'd have to find a way around it. GHCJS includes
>> an IO layer, which can be used to set up a virtual filesystem [2], but the
>> API is far from finished.
>>
> Nice to hear that - we are concidering using GHCJS heavly in our project.
> We dont have many people and this is free-time "driven" project for now,
> but we would love to cooperate with you - help with GHCJS development and
> work together to make it suitable for the project we are working on.
>

Great, if you want to help or discuss, you can come to #ghcjs on freenode.


>
>
This is not exactly the kind of thing I'm talking about.
> Think about something like matlab simulink or labview - functions are
> representaed by "nodes" (rectangles) connected with other functions by
> lines. Lines are "sending data" between these nodes.
>

I think it's possible to "trap" function application and show inputs and
outputs that way, but it might be tricky (maybe some patching required).
Also the generated optimized code can be quite different from the original
Haskell. There is lots of inlining, let floating and specialization, and
all functions that use typeclasses get extra parameters for the
dictionaries for example, so i guess trying to visualize everything
automatically will not give you the results you're after.

So user is connecting these blocks - each block is like a function
> application on data - so adding a block is like adding a new line in
> Haskell .hs file. We want user to be able to interactively add such nodes
> (apply further functions on already processed and cached data - every
> "node" caches processed data) and process the data further - If I didn't
> explained this simple enought, I will try harder. Such thing needs
> something like client side interpreter I think ...
>

You could let the user edit functions, then call back to the server and get
back graph nodes (and the code to run them of course), which could show the
name and the correct number of inputs. Actually connecting them would
require a typechecker though (and changing one connection can of course
make other connections invalid), perhaps through a server callback.

If you want to work with cached data, you probably want to use some special
thing to connect the functions, since Haskell code generally does not do
that. Perhaps FRP can be an inspiration here, where your graph editor wraps
pure Haskell functions (written by the user) in behaviours, and changing
values or behaviours propagates changes through the FRP network.


>
>> When we have the SELinux sandbox working, I plan to work on this again,
>> so that users can enter/compile their own code.
>>
>>
> When do you plan roughtly to release it? We are strongly interested in
> testing and using it :)
>

The current code is already on github, but it does not quite work yet (and
using it is not recommended until we are confident in the security of the
sandbox). Daniil will probably blog about it soon, and we should have a
public beta within a month.

luite
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2013-07-03 Thread Brandon Allbery
On Wed, Jul 3, 2013 at 6:26 AM, B B  wrote:

> 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?
>

I'd like to point out that the LLVM code from GHC is CPS-transformed, and
this makes it a nightmare to work with. Already the LLVM optimizer pretty
much fails to do anything: optimizing CPS-transformed code is well-nigh
impossible without knowing what the pre-transformation code was, which
means a GHC-specific optimizer is necessary, or some way to communicate the
code's structure (LLVM actually supports annotations for this, but current
GHC doesn't generate them; I also would expect those annotations to go only
so far without GHC-specific tweaks to LLVM, and in fact I am under the
impression such tweaks have been proposed for inclusion in LLVM).

Similarly I would expect that generating any sort of sensible Javascript
would require something fairly tightly tied to GHC; otherwise the output's
going to have horrible performance because it's not going to understand the
input and will fall back to the slowest but most general translation. (If
it even has such a fallback, instead of simply failing on code that it
doesn't recognize.)

-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2013-07-03 Thread B B
>
>
>> I think GHCJS should be able to compile all Haskell code in GHC, but we
> haven't tested this yet. The tricky bit is probably getting foreign code
> work, and creating a working installation that includes all other things,
> like libraries and a package database. Usually, GHCi loads object files for
> the libraries when running Haskell code. Obviously you can't run machine
> code with JavaScript, so you'd have to find a way around it. GHCJS includes
> an IO layer, which can be used to set up a virtual filesystem [2], but the
> API is far from finished.
>
Nice to hear that - we are concidering using GHCJS heavly in our project.
We dont have many people and this is free-time "driven" project for now,
but we would love to cooperate with you - help with GHCJS development and
work together to make it suitable for the project we are working on.



> Ah it's much easier if the code can be compiled on the server. This is
> more or less what Daniil Frumin is doing for his Google Summer of Code
> project [3]. We are using GHC on the server for non-interactive things, and
> GHCJS to compile interactive code that is run on the client. Our main goal
> is to get interactive graphics with the diagrams [4] library working.
>
Currently he is working on building a good sandbox for the compiler on the
> server (With SELinux, rlimits and cgroups) so that we can compile code, and
> run Template Haskell safely. I'm working on improving the GHCJS linker, so
> that we can support incremental code loading more easily (so users can
> download just the code for the new function they wrote, instead of the
> whole program every time)
>

That's very interesting. We want to use GHCJS EXACTLY for this - we want to
compile the code on the server and run it in the users browesr BUT we dont
want to load the whole program everytime a function is changed - only this
particular function.
Additional (which is NOT the same) - while writing a function - we want to
interactively execute it's "body" on the client side - but this requires
something like interpreter on the user client (please see below for
explanation). But we are thinking right now about it and its architecture,
so we will be in touch in this topic with you :)


I have a very crude example of this type here:
>
> http://hdiff.luite.com/reduce/
>

This is not exactly the kind of thing I'm talking about.
Think about something like matlab simulink or labview - functions are
representaed by "nodes" (rectangles) connected with other functions by
lines. Lines are "sending data" between these nodes.
So user is connecting these blocks - each block is like a function
application on data - so adding a block is like adding a new line in
Haskell .hs file. We want user to be able to interactively add such nodes
(apply further functions on already processed and cached data - every
"node" caches processed data) and process the data further - If I didn't
explained this simple enought, I will try harder. Such thing needs
something like client side interpreter I think ...


> When we have the SELinux sandbox working, I plan to work on this again, so
> that users can enter/compile their own code.
>
>
When do you plan roughtly to release it? We are strongly interested in
testing and using it :)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2013-07-03 Thread Luite Stegeman
On Wed, Jul 3, 2013 at 12:26 PM, B B  wrote:

> 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?
>

I didn't know a good way to get the tail calling to work, and also it
looked like it would be hard to make it as convenient to use as higher
level JavaScript (we can just wrap JS objects in Haskell thunks, insert
foreign imports directly in the functions (example: [1] ).

That said, asm.js/emscripten have progressed a lot since I started working
on this (I started on the 'gen2' code generator in August last year).
Perhaps when JS gets native tail calls, it might be time to give
LLVM/emscripten another look.


> Is GHCJS "production ready"? Also - Can I use GHCJS to compile big
> projects (like GHC or GHCI) to Javascript?
>
>
I think GHCJS should be able to compile all Haskell code in GHC, but we
haven't tested this yet. The tricky bit is probably getting foreign code
work, and creating a working installation that includes all other things,
like libraries and a package database. Usually, GHCi loads object files for
the libraries when running Haskell code. Obviously you can't run machine
code with JavaScript, so you'd have to find a way around it. GHCJS includes
an IO layer, which can be used to set up a virtual filesystem [2], but the
API is far from finished.


> 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
> results.
>

Ah it's much easier if the code can be compiled on the server. This is more
or less what Daniil Frumin is doing for his Google Summer of Code project
[3]. We are using GHC on the server for non-interactive things, and GHCJS
to compile interactive code that is run on the client. Our main goal is to
get interactive graphics with the diagrams [4] library working.

Currently he is working on building a good sandbox for the compiler on the
server (With SELinux, rlimits and cgroups) so that we can compile code, and
run Template Haskell safely. I'm working on improving the GHCJS linker, so
that we can support incremental code loading more easily (so users can
download just the code for the new function they wrote, instead of the
whole program every time)


> 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.
>

I have a very crude example of this type here:

http://hdiff.luite.com/reduce/

It's hacked together in one day, replacing the GHCJS main loop with one
that draws a graph of the stack and heap every reduction step. It could be
much better obviously, with better forward backward stepping/tracing and
more information about the objects, and of course improved presentation.

When we have the SELinux sandbox working, I plan to work on this again, so
that users can enter/compile their own code.

luite

[1] Foreign import javascript example:
https://github.com/ghcjs/ghcjs-jquery/blob/03b71effaeb059c9847306c93d69839588354134/JavaScript/JQuery/Internal.hs#L119
[2] GHCJS IO Layer: https://github.com/ghcjs/shims/blob/master/src/io.js
[3] Daniil Frumin's GSoC project:
https://github.com/co-dan/interactive-diagrams
[4] Diagrams library: http://projects.haskell.org/diagrams/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2013-07-03 Thread B B
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
results.
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 

> On Wed, Jul 3, 2013 at 11:06 AM, B B  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
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2013-07-03 Thread Luite Stegeman
On Wed, Jul 3, 2013 at 11:06 AM, B B  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
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2013-07-03 Thread B B
Emscripten is meant to translate ANY LLVM IR code to javascript and it
should work (as I belive).
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 want to simply try emscripten and see how it performs on such GHC
generater LLVM IRs.


2013/7/2 Luite Stegeman 

> On Tue, Jul 2, 2013 at 4:38 PM, B B  wrote:
>
>> Thank you for all the replies.
>> Luite Stegeman - I was thinking that the LLVM IR code is optimized
>> already or you can run LLVM IR optimization passes to get rid of such
>> things. I think compiling with ghc -fllvm generates LLVM bitcode and then
>> you can simply run emscripten on it to get Javascript - and it should work
>> as expected.
>>
>
> Most of the optimizations that GHC does are on Core, so you also get those
> if you use Core or STG as the source. You do miss out on the later
> optimization passes (GHC optimizes Cmm with Hoopl, and LLVM optimizes
> again). We implement this in GHCJS ourselves, optimizing the generated
> JavaScript.
>
> Since GHC itself is written in Haskell, it would be a good goal to compile
> simple Haskell programs first and make sure that the RTS is working (you'll
> need to compile the Cmm and C RTS files to LLVM). You can try to get the
> GHC Testsuite [1] running. The GHCJS testsuite [2] might also be useful, it
> contains much of the GHC Testsuite and a runner program that checks the
> JavaScript results against native Haskell.
>
> Like i said in the previous post, the generated code is a bit weird:
> stacks are allocated dynamically, functions never return, there are only
> tail calls. Emscripten might have a hard time with this.
>
> [1] https://github.com/ghc/testsuite
> [2] https://github.com/ghcjs/ghcjs/tree/master/test
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2013-07-02 Thread Luite Stegeman
On Tue, Jul 2, 2013 at 4:38 PM, B B  wrote:

> Thank you for all the replies.
> Luite Stegeman - I was thinking that the LLVM IR code is optimized already
> or you can run LLVM IR optimization passes to get rid of such things. I
> think compiling with ghc -fllvm generates LLVM bitcode and then you can
> simply run emscripten on it to get Javascript - and it should work as
> expected.
>

Most of the optimizations that GHC does are on Core, so you also get those
if you use Core or STG as the source. You do miss out on the later
optimization passes (GHC optimizes Cmm with Hoopl, and LLVM optimizes
again). We implement this in GHCJS ourselves, optimizing the generated
JavaScript.

Since GHC itself is written in Haskell, it would be a good goal to compile
simple Haskell programs first and make sure that the RTS is working (you'll
need to compile the Cmm and C RTS files to LLVM). You can try to get the
GHC Testsuite [1] running. The GHCJS testsuite [2] might also be useful, it
contains much of the GHC Testsuite and a runner program that checks the
JavaScript results against native Haskell.

Like i said in the previous post, the generated code is a bit weird: stacks
are allocated dynamically, functions never return, there are only tail
calls. Emscripten might have a hard time with this.

[1] https://github.com/ghc/testsuite
[2] https://github.com/ghcjs/ghcjs/tree/master/test
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2013-07-02 Thread B B
Thank you for all the replies.
Luite Stegeman - I was thinking that the LLVM IR code is optimized already
or you can run LLVM IR optimization passes to get rid of such things. I
think compiling with ghc -fllvm generates LLVM bitcode and then you can
simply run emscripten on it to get Javascript - and it should work as
expected.


We are creating an online graphics (HTML5 canvas, webgl) processing tool -
we want to use Haskell as our processing language and we want allow users
to interactively process graphics in a functional, lazy manner. We want
GHCI to be run inside browser, to allow for smooth work.
So what about compiling GHC to JS - please look at: http://repl.it/languages

There are a lot of interpreters (like python or ruby) compiled to
javascript using emscripten.

Would it be possible to compile the GHCI (written in haskell?) with GHC
-fllvm to IR bitcode and then to javascript to get the online GHCI
interpreter? (not such "online" tools like "Try Haskell", which under the
hood compute everything on server)


2013/6/28 Tikhon Jelvis 

> My understanding is that Try Haskell actually runs the submitted code on a
> server with mueval rather than compiling it to JavaScript and running it in
> the client. This is different from some of the other "try" websites (like
> try.ocamlpro.com), so it's easy to get confused.
>
>
> On Fri, Jun 28, 2013 at 11:24 AM, Henk-Jan van Tuyl wrote:
>
>> On Fri, 28 Jun 2013 15:25:59 +0200, B B 
>> wrote:
>>
>>  Hi!
>>> Does anybody tried, or is there anywhere a project, of online ghc or ghci
>>> (compiled to JavaScript with Emscripten)?
>>>
>>
>> There is Try Haskell![0], source code can be found on GitHub[1]
>>
>> Regards,
>> Henk-Jan van Tuyl
>>
>>
>> [0] http://tryhaskell.org/
>> [1] 
>> https://github.com/chrisdone/**tryhaskell
>>
>>
>> --
>> Folding@home
>> What if you could share your unused computer power to help find a cure?
>> In just 5 minutes you can join the world's biggest networked computer and
>> get us closer sooner. Watch the video.
>> http://folding.stanford.edu/
>>
>>
>> http://Van.Tuyl.eu/
>> http://members.chello.nl/**hjgtuyl/tourdemonad.html
>> Haskell programming
>> --
>>
>>
>> __**_
>> Haskell-Cafe mailing list
>> Haskell-Cafe@haskell.org
>> http://www.haskell.org/**mailman/listinfo/haskell-cafe
>>
>
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2013-06-28 Thread Tikhon Jelvis
My understanding is that Try Haskell actually runs the submitted code on a
server with mueval rather than compiling it to JavaScript and running it in
the client. This is different from some of the other "try" websites (like
try.ocamlpro.com), so it's easy to get confused.


On Fri, Jun 28, 2013 at 11:24 AM, Henk-Jan van Tuyl wrote:

> On Fri, 28 Jun 2013 15:25:59 +0200, B B  wrote:
>
>  Hi!
>> Does anybody tried, or is there anywhere a project, of online ghc or ghci
>> (compiled to JavaScript with Emscripten)?
>>
>
> There is Try Haskell![0], source code can be found on GitHub[1]
>
> Regards,
> Henk-Jan van Tuyl
>
>
> [0] http://tryhaskell.org/
> [1] 
> https://github.com/chrisdone/**tryhaskell
>
>
> --
> Folding@home
> What if you could share your unused computer power to help find a cure? In
> just 5 minutes you can join the world's biggest networked computer and get
> us closer sooner. Watch the video.
> http://folding.stanford.edu/
>
>
> http://Van.Tuyl.eu/
> http://members.chello.nl/**hjgtuyl/tourdemonad.html
> Haskell programming
> --
>
>
> __**_
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/**mailman/listinfo/haskell-cafe
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2013-06-28 Thread Henk-Jan van Tuyl

On Fri, 28 Jun 2013 15:25:59 +0200, B B  wrote:


Hi!
Does anybody tried, or is there anywhere a project, of online ghc or ghci
(compiled to JavaScript with Emscripten)?


There is Try Haskell![0], source code can be found on GitHub[1]

Regards,
Henk-Jan van Tuyl


[0] http://tryhaskell.org/
[1] https://github.com/chrisdone/tryhaskell


--
Folding@home
What if you could share your unused computer power to help find a cure? In  
just 5 minutes you can join the world's biggest networked computer and get  
us closer sooner. Watch the video.

http://folding.stanford.edu/


http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
Haskell programming
--

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2013-06-28 Thread Luite Stegeman
I don't know of any complete implementation. The LLVM code produced by GHC
might be hard to compile to JavaScript, since JS does not have tail call
optimization. You would also need to get the RTS working, including the
garbage collector. It's written in C and Cmm, both of which can be compiled
to LLVM, but often in practice it's not that easy to get it working
properly.

We do have a working Haskell compiler based on GHC with GHCJS [1], which
uses the GHC API to translate STG code to JavaScript. We do a fairly
high-level translation, compiling Haskell closures to JavaScript objects,
so that we use as much of the JS runtime, like the garbage collector, as
possible. I have spent some time optimizing the performance, making sure
that the code is reasonably optimizable by the JS JIT compilers, makes
effective use of the inline caches etc, but it's quite possible that a
lower level LLVM/asm.js would give us better performance.

For the moment though, we want to concentrate on other things, like getting
a release ready before GHC 7.8.1 is out (and getting the patches to support
GHCJS merged in GHC), building more libraries, and reducing the size of the
generated code.

Dan Frumin [2] is working for his Google Summer of Code project on an
pastebin that uses GHCJS and the diagrams [3] library that lets the user
run the code directly. Generated code supports graphics, functional
reactive programming etc, and can be included on other pages. Code is
compiled on the server, since GHC itself is a bit too big to compile to
JavaScript.

For more information on GHCJS, see my weblog [4] [5]. In the past we have
already had multiple code generators, if you want to work on one that uses
LLVM as the source language we would be happy to add it, and you can use
the GHCJS Cabal support, testsuite etc. If it's clearly better than the
existing one, it can replace it one day as the default generator.

luite

[1] GHCJS: https://github.com/ghcjs
[2] Dan Frumin's weblog: http://parenz.wordpress.com/
[3] Diagrams library: http://hackage.haskell.org/package/diagrams
[4] GHCJS introduction: http://weblog.luite.com/wordpress/?p=14
[5] Functional Reactive Programming with GHCJS and sodium:
http://weblog.luite.com/wordpress/?p=127


On Fri, Jun 28, 2013 at 3:25 PM, B B  wrote:

> Hi!
> Does anybody tried, or is there anywhere a project, of online ghc or ghci
> (compiled to JavaScript with Emscripten)?
>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2013-06-28 Thread B B
Hi!
Does anybody tried, or is there anywhere a project, of online ghc or ghci
(compiled to JavaScript with Emscripten)?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe