Skip to content
Compiler for Grain, the functional programming language. A modern web staple. 🌾
Branch: master
Clone or download
Latest commit 1595b53 Mar 3, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
grainc Enable malloc() and fix runtime errors Aug 1, 2018
runtime Update runtime dependencies Mar 2, 2019
script Upgrade script dependencies Mar 2, 2019
src Address PR issues Jan 27, 2019
test Address PR issues Jan 27, 2019
.merlin fixed merlin Apr 18, 2017
.travis.yml Un-screw up the tests Dec 8, 2018
LICENSE Fix license. Jul 16, 2018
Makefile Fix Makefile for macOS Jun 15, 2018 Add note about 'opam switch' and clean up bash snippets Aug 4, 2018
dune-project Bump dune-project to support latest jbuilder/dune release Jul 31, 2018
grain-favicon.svg Add favicon Apr 28, 2018
grain.opam Add core as a dependency Jan 27, 2019
grain_utils.opam Bump jbuilder dependency May 8, 2018
grainc.opam Add workspace file (to make sure build environment is consistent) Jan 19, 2018

License: LGPL v3 GitHub version

The Grain Compiler

Grain is a strongly-typed functional programming language built for the modern web by leveraging the brilliant work done by the WebAssembly project.

This language is still a work in progress, but be sure to stay tuned, or even contribute!

For more information about the language, visit



To build the compiler, have ocaml (version = 4.05) and opam (version >= 2.0) installed and on your path. Then,

# If needed, make sure you have OCaml 4.05 enabled
$ opam switch 4.05.0
# Then install dependencies and build
$ opam install . --deps-only
$ make

Running make install will symlink grainc onto your PATH.

You can run the tests with make tests.


To build the runtime, have node (version >= 9) and npm (version >= 5) installed. Then,

$ cd runtime
$ npm install
$ npm run build


To make the CLI available on your path, have node (version >= 9) and npm (version >= 5) installed. Then,

$ cd cli
$ npm install
$ npm link --global


To create a .wasm file, run the following:

$ grainc /path/to/ -o /path/to/output.wasm

For an example of how to run the file in JavaScript, look at the files under script. You'll need to create a symlink from script/public/javascripts/grain-runtime.js to the built file in runtime/dist/grain-runtime.js, or you'll have to just copy it over to run the example.

Alternatively, you can use the CLI to run your program on Node:

$ grain

Copyright ©️ 2017-2018 Philip Blair and Oscar Spencer.

You can’t perform that action at this time.