aljones15 / asterius

A Haskell to WebAssembly compiler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Asterius: A Haskell to WebAssembly compiler

CircleCI AppVeyor

A Haskell to WebAssembly compiler. Project status: alpha, in active development, some simple examples already work.

See the documentation for further instructions. Or check our blog posts:

Quick start

We provide pre-built Docker images. Put the input .hs program in a directory and map the directory to a Docker volume:

terrorjack@ubuntu:~$ docker run -it -v ~/mirror:/mirror terrorjack/asterius
root@76bcb511663d:~# cd /mirror
root@76bcb511663d:/mirror# ahc-link --help
...

See the help text of ahc-link for further instructions.

What works currently:

  • All GHC language features except Template Haskell.
  • Non-IO parts in ghc-prim/integer-simple/base/array/deepseq/containers/transformers/mtl/pretty. IO is achieved via rts primitives like print_i64 or JavaScript FFI.
  • Importing JavaScript expressions via the foreign import javascript syntax. First-class JSRef type in Haskell land.
  • Calling Haskell functions from JavaScript via the foreign export javascript syntax. Haskell closures can be passed between Haskell/JavaScript boundary via StablePtr.
  • Invoking RTS API on the JavaScript side to manipulate Haskell closures and trigger evaluation.
  • A linker which performs aggressive dead-code elimination, producing as small WebAssembly binary as possible.
  • A debugger which outputs memory loads/stores and control flow transfers.
  • Complete binaryen raw bindings, plus a monadic EDSL to construct WebAssembly code directly in Haskell.
  • A Haskell library to handle WebAssembly code, which already powers binary code generation.
  • Unit tests implementing stochastic fuzzer/shrinker for WebAssembly, in order to produce minimal repro in case something goes wrong in generated code.
  • Besides WebAssembly MVP, no special requirements on the underlying JavaScript engine at the moment.

Better check the fib, jsffi, array and rtsapi test suites first to get some idea on current capabilities of asterius.

Sponsors

Asterius is maintained by Tweag I/O.

Have questions? Need help? Tweet at @tweagio.

About

A Haskell to WebAssembly compiler


Languages

Language:WebAssembly 36.5%Language:Haskell 28.6%Language:JavaScript 15.9%Language:C++ 15.0%Language:C 2.5%Language:Python 0.7%Language:Shell 0.3%Language:Terra 0.1%Language:CMake 0.1%Language:M4 0.1%Language:HTML 0.0%Language:Makefile 0.0%Language:Objective-C 0.0%Language:Perl 6 0.0%Language:Dockerfile 0.0%Language:Batchfile 0.0%Language:Perl 0.0%