Compiles Haskell to WebAssembly
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
dhc Reorganize Sep 13, 2018
other Reorganize Sep 13, 2018
src Reorganize Sep 13, 2018
test Reorganize Sep 13, 2018
.gitignore Add .gitignore Aug 18, 2018
Dockerfile Update extra dependencies Jan 12, 2018
LICENSE Organize modules into library and executable. Nov 29, 2017
Makefile Add HeroIO. Aug 17, 2018
README.asciidoc Support Eq type class. May 31, 2018
default.nix Add Nix build script Apr 3, 2018
dhc.cabal Reorganize Sep 13, 2018

README.asciidoc

Dfinity Haskell Compiler

DHC is a Haskell compiler that produces WebAssembly.

It accepts only a tiny subset of the language.

Installation / Dependencies

Run nix build.

Usage / Examples

The dhc program takes Haskell source on standard input and compiles it to WebAssembly on standard output. Two IO functions are defined:

putStr :: String -> IO ()
putInt :: Int -> IO ()  -- `Int` means 64-bit integer.

which respectively call WebAssembly imports:

system.putStr (ptr : i32, len : i32)
system.putInt (lo : i32, hi : i32)

In system.putInt, we split the integer into 32-bit halves to make life easier for JavaScript.

The rundhc tool can interpret the output of dhc. It expects the input WebAssembly binary to export a function named main that takes no arguments and returns no arguments.

For example:

$ echo 'public(main) main=putStr"Hello, World!\n"' | ./dhc | ./rundhc
Hello, World!

License

All code and designs are open sourced under GPL V3.

dfinity logo