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

Luite Stegeman stegeman at gmail.com
Wed Jul 3 17:03:36 CEST 2013

On Wed, Jul 3, 2013 at 3:13 PM, B B <blackbox.dev.ml at gmail.com> 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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130703/fb8cfd1e/attachment.htm>

More information about the Haskell-Cafe mailing list