Hey,
If you’re looking to try multicore with Reason, try this esy project template I created.
It’s an esy
project with the multicore compiler, no-effect-syntax
branch, with Dune 1.9.1 and Sudha Parimala’s fork of Lwt. Sudha’s lwt fork lets one use Lwt_preemptive.detach
over real system cores (more correctly called domains). There’s a great blog post about it here.
How to get started?
You’ll need
-
esy
- you can install it withnpm i -g esy
oryarn global add esy
-
Clone the repo:
git clone https://github.com/ManasJayanth/reason-on-multicore
-
Run
make deps
to install the dependencies -
Run
make
to compileApp.re
and run it.
Writing multicore programs
Domains is the recommended way to write multicore programs. But, since we’re familiar with promises, Sudha’s Lwt
, is really convenient. If you have a computation heavy problem to try Reason with, they’re looking for sandmark benchmarks.
What about Effects?
This branch of the multicore compiler does not have effects. Effects and multicore has being decoupled. Multicore will be available via Domains.
How does this template work? What do we need for Multicore to work on Reason?
Multicore compiler doesn’t work with the central opam repository. The multicore team maintains it’s own fork of the opam repository with only packages that work with multicore. I had to fork it and add packages needed to build Reason. Great news - we dont need any patches or overrides, but we need Reason from master
branch.
Because we need more packages from multicore opam, my fork has to be specified to esy and some packages (even on upstream opam) need overrides - unrelated to multicore afaik. Hence, the command looks like this,
esy --opam-repository-remote https://github.com/ManasJayanth/multicore-opam \
--opam-override-repository-remote https://github.com/ManasJayanth/multicore-esy-opam-overrides
Editor support
Unfortunately, there is not merlin/lsp support as of now.
Happy hacking!