2018-03-05 14:34:45 +03:00
# Asterius: A Haskell to WebAssembly compiler
2017-11-20 17:00:14 +03:00
2017-11-20 17:15:25 +03:00
[![CircleCI ](https://circleci.com/gh/tweag/asterius/tree/master.svg?style=shield )](https://circleci.com/gh/tweag/asterius/tree/master)
2018-05-21 22:57:52 +03:00
[![AppVeyor ](https://ci.appveyor.com/api/projects/status/github/tweag/asterius?branch=master&svg=true )](https://ci.appveyor.com/project/GHCAppveyor/asterius?branch=master)
2017-11-20 17:15:25 +03:00
2018-07-12 12:43:27 +03:00
A Haskell to WebAssembly compiler. Project status: **alpha** , in active development, some simple examples already work.
2017-11-20 17:15:25 +03:00
2018-04-05 10:25:24 +03:00
See the [documentation ](https://tweag.github.io/asterius ) for further instructions.
2018-03-05 14:34:45 +03:00
2018-07-12 12:43:27 +03:00
## 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.
2018-08-02 12:56:38 +03:00
What works currently:
* All GHC language features except Template Haskell.
2018-08-07 09:37:32 +03:00
* 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.
2018-08-02 12:56:38 +03:00
* Importing JavaScript expressions via the `foreign import javascript` syntax. First-class `JSRef` type in Haskell land.
2018-08-19 07:47:22 +03:00
* Calling Haskell functions from JavaScript via the `foreign export javascript` syntax. Haskell closures can be passed between Haskell/JavaScript boundary via `StablePtr` .
2018-08-02 12:56:38 +03:00
* Invoking RTS API on the JavaScript side to manipulate Haskell closures and trigger evaluation.
2018-08-19 07:47:22 +03:00
* A linker which performs aggressive dead-code elimination, producing as small WebAssembly binary as possible.
2018-08-02 12:56:38 +03:00
* A debugger which outputs memory loads/stores and control flow transfers.
2018-08-19 07:47:22 +03:00
* Complete `binaryen` raw bindings, plus a monadic EDSL to construct WebAssembly code directly in Haskell.
2018-08-02 12:56:38 +03:00
* Besides WebAssembly MVP & the experimental BigInt support, no special requirements on the underlying JavaScript engine.
2018-07-12 12:43:27 +03:00
2018-08-10 09:54:31 +03:00
Better check the [`fib` ](asterius/test/fib/fib.hs ), [`jsffi` ](asterius/test/jsffi/jsffi.hs ), [`array` ](asterius/test/array/array.hs ) and [`rtsapi` ](asterius/test/rtsapi.hs ) test suites first to get some idea on current capabilities of `asterius` .
2018-07-12 12:43:27 +03:00
2018-03-05 14:34:45 +03:00
## Sponsors
2018-05-28 12:22:06 +03:00
[<img src="https://www.tweag.io/img/tweag-med.png" height="65"> ](https://tweag.io )
2018-03-05 14:34:45 +03:00
2018-04-05 10:25:24 +03:00
Asterius is maintained by [Tweag I/O ](https://tweag.io/ ).
2018-03-05 14:34:45 +03:00
2018-04-05 10:25:24 +03:00
Have questions? Need help? Tweet at [@tweagio ](https://twitter.com/tweagio ).