News for hackers. Stuff that matters.

luite

Re:GHCJS - Haskell in the Browser on Thursday June 27, 2013 @03:06AM (#5951038)
You can use the Integral class (when compiling, the instance gets converted to an extra dictionary argument, if you never use the instance the dictionary will be unreachable)

But Integer is really hard to avoid in general, for example the Show instance for Double depends on it.

Re:GHCJS - Haskell in the Browser on Wednesday June 26, 2013 @07:43PM (#5949842)
If you're really careful and not use anything from base that might use an Integer ;)

Currently non-Haskell dependencies are managed per package, so if anything from integer-gmp is linked, it will include the whole JSBN.

If you want to weed out the unused JSBN part, you can use closure compiler (although the new code generator will probably still have a few incompatibilities with it).

Re:GHCJS - Haskell in the Browser on Wednesday June 26, 2013 @03:52PM (#5948550)
I want that too! Dan Frumin is working on a GSoC project that uses GHC, GHCJS and diagrams to make a "try now" pastebin site with graphics.

Unfortunately, GHCJS is not quite Safe Haskell code, so we are still working on sandboxing the compiler with SELinux.

his weblog, more updates will follow: http://parenz.wordpress.com/

Re:GHCJS - Haskell in the Browser on Wednesday June 26, 2013 @03:20PM (#5948332)
Code size is pretty big currently indeed. The highest priority is to make sure that we get all required patches to support GHCJS merged into GHC, before 7.8.1 is out. GHCJS is a standalone, cabal installable compiler (it uses the GHC API), but some features, like the "foreign import javascript" FFI need some minor changes in GHC itself.

We haven't really spent much time optimizing for code size yet, and there's still lots of low hanging fruit. We will never reach 3kB minified though, for example the JSBN library (that we use to implement Integer) alone is a lot bigger than that.

The GHCJS linker does tree shaking: Only functions that are reachable from main are included in the result. We have some plans to extend this a bit, an old version already had incremental loading, but that has not yet been implemented for the new code generator.

Re:GHCJS - Haskell in the Browser on Wednesday June 26, 2013 @03:06PM (#5948245)
The change is proposed for ECMAScript 6: http://wiki.ecmascript.org/doku.php?id=harmony:proper_tail_c...

GHCJS currently uses a trampoline, but all calls are in tail position, so when this gets implemented we can easily generate code that uses native JS tail calls.

Like GHC, GHCJS uses its own stack for non-tail calls.