1
1
mirror of https://github.com/tweag/asterius.git synced 2024-11-11 03:07:47 +03:00
A Haskell to WebAssembly compiler
Go to file
2019-06-20 18:30:08 +02:00
.circleci Add circleCI config 2019-06-20 18:30:08 +02:00
.github Update to ghc-8.7.20181027 (+13 squashed commit) 2018-10-29 16:38:28 +08:00
asterius Asyncify the rts api (#190) 2019-06-20 18:30:08 +02:00
binaryen Change binaryen link from terrorJack/binaryen to tweag/binaryen 2019-05-20 18:23:52 +02:00
docs Asyncify the rts api (#190) 2019-06-20 18:30:08 +02:00
ghc-toolkit foo 2019-06-20 18:30:08 +02:00
inline-js@fcd6c7821d Basic exception handling support (#128) 2019-05-20 14:12:16 +08:00
npm-utils Finalize the modularized rts work #50 (+53 squashed commit) 2019-01-08 03:36:09 +08:00
utils Change Cmm function sigs to [] -> [] and implement tail call opcodes (#95) 2019-03-21 22:05:00 +08:00
wabt Update wabt (#120) 2019-05-15 12:36:44 +08:00
wasm-toolkit Change Cmm function sigs to [] -> [] and implement tail call opcodes (#95) 2019-03-21 22:05:00 +08:00
.dockerignore bytestring support & numerous bugfixes and impovements 2018-12-09 10:19:01 +08:00
.ghcid Update the example .ghcid file 2019-05-14 20:47:38 +08:00
.gitignore Fix test failure due to stack major upgrade (#184) 2019-06-17 00:26:56 +03:00
.gitmodules bytestring support & numerous bugfixes and impovements 2018-12-09 10:19:01 +08:00
clean.sh Update binaryen (#121) 2019-05-15 16:07:02 +08:00
Dockerfile Update wabt (#120) 2019-05-15 12:36:44 +08:00
mkdocs.yml Add a hacking guide 2019-05-14 20:45:02 +08:00
README.md Add link to docs/hacking.md from README.md 2019-05-14 17:21:29 +02:00
stack.yaml Fix deps from head.hackage 2019-06-18 10:18:27 +02:00

Asterius: A Haskell to WebAssembly compiler

CircleCI Docker Pulls Gitter chat

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:

Also, we've added Weekly Status Reports in case you're interested where the bleeding edge has reached.

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 --input-hs xxx.hs
...

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/bytestring/binary/xhtml. IO is achieved via rts primitives like print_i64 or JavaScript FFI.
  • Fast arbitrary-precision Integer operations backed by BigInts.
  • Preliminary copying GC, managing both Haskell heap objects and JavaScript references.
  • Preliminary Cabal support.
  • Importing JavaScript expressions via the foreign import javascript syntax. First-class JSVal type in Haskell land.
  • Fast conversion between Haskell/JavaScript types (strings, arrays and ArrayBuffers at the moment)
  • 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 checks invalid memory access and outputs memory loads/stores and control flow transfers.
  • Complete binaryen/wabt 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 and BigInt, no special requirements on the underlying JavaScript engine at the moment. Optionally, we emit binaries using the experimental tail call opcodes; see the ahc-link documentation page for details.

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

Building from source

install the following:

and then follow the commands in the Dockerfile.

For hacking instructions, there is a docs/hacking.md which has advice and common commands

Sponsors

Asterius is maintained by Tweag I/O.

Have questions? Need help? Tweet at @tweagio.