Asterius: A Haskell to WebAssembly compiler
Asterius is a Haskell to WebAssembly compiler based on GHC. It compiles
which can be run in Node.js or browsers.
(lightweight Async FFI with
Promise support) and small output code (~600KB
hello.wasm for a Hello
World). A lot of common
Haskell packages like
lens are already supported. The project is actively
maintained by Tweag I/O.
Demos of popular Haskell apps, running in your browser:
Quickstart using the prebuilt container image
We host a prebuilt container image on Docker Hub. The image also ships ~2k prebuilt packages from a recent Stackage snapshot for convenience of testing simple programs without needing to set up a Cabal project.
To use the image, mount the working directory containing the source code as a
shared volume, then use the
terrorjack@hostname:/project$ podman run -it --rm -v $(pwd):/workspace -w /workspace terrorjack/asterius root@hostname:/workspace#
There are a lot of link-time options available to
ahc-link, e.g. targeting
the browser platform instead of
node, adding extra GHC options or setting
runtime parameters. Check the documentation for
It's also possible to use
ahc-cabal as a drop-in replacement of
build a Cabal project. Use
--input-exe on the output
post for an
Check the documentation section
about the prebuilt image for more information, e.g. versioning policy, how to
Building and using
See the Building guide in the documentation for details.
Hacking on Asterius
We have documentation and blog posts:
- Fibonacci compiles end-to-end: Haskell to WebAssembly via GHC
- Asterius GHC WebAssembly backend reaches TodoMVC
- Haskell art in your browser with Asterius
- Edge computing with Servant on Cloudflare
Note that they may be slightly out-of-date as the project evolves. Whenever you find something in the docs of blog posts which doesn't reflect the status quo, it's a bug and don't hesitate to open a ticket :)
Project status & roadmap
See the roadmap section in the documentation for details.
Asterius is maintained by Tweag I/O.
Have questions? Need help? Tweet at @tweagio.