Try via CLI
You can compile a file directly via bsc MyFile.res
:
RES// MyFile.res
let rec fib = n => {
switch n {
| 0 | 1 => 1
| n => fib(n -1) + fib(n-2)
}
}
Js.log(fib(0))
SH❯ bsc MyFile.res
// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE
'use strict';
function fib(n) {
if (n === 0 || n === 1) {
return 1;
} else {
return fib(n - 1 | 0) + fib(n - 2 | 0) | 0;
}
}
console.log(fib(0));
exports.fib = fib;
/* Not a pure module */
You can also get the inferred signature directly via bsc -i MyFile.res
let fib: int => int