Skip to content

Instantly share code, notes, and snippets.

@eterps
Created Jan 16, 2020
Embed
What would you like to do?
Run a ReasonML file
#!/bin/bash
set -e
realpath() {
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
}
SRC=$(realpath "$1")
if ! [ -e bsconfig.json ]; then
TMPDIR=$(mktemp -d)
cd $TMPDIR
bsb -init tempproject -theme basic-reason >/dev/null
cd tempproject
cp "$SRC" src/
fi
bsb -make-world |awk '!/no work to do|Building/'
NAME=${SRC##*/}
TARGET=${NAME/.re/.bs}
node src/${TARGET}.js
@eterps

This comment has been minimized.

Copy link
Owner Author

@eterps eterps commented Jan 16, 2020

Usage:

$ echo 'Js.log("Hello world!");' >hello.re
$ reasonml hello.re
Hello world!
@eterps

This comment has been minimized.

Copy link
Owner Author

@eterps eterps commented Jan 16, 2020

In my .vimrc I added:

autocmd BufRead,BufNewFile *.re map <buffer> <leader>r :w<CR>:!reasonml %<CR>
@eterps

This comment has been minimized.

Copy link
Owner Author

@eterps eterps commented Jan 16, 2020

Apparently this can be done much easier:

$ bsc hello.re |node
Hello world!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment