Skip to content

Latest commit

 

History

History
93 lines (69 loc) · 1.56 KB

File metadata and controls

93 lines (69 loc) · 1.56 KB
titledescriptioncanonical
Try
Try ReScript via Command Line
/docs/manual/latest/try

Try Online

Our Playground lets you try ReScript online, and comes with ReScript-React preinstalled.

Quickly Evaluate Code In Terminal

Use bsc -e:

❯ bsc -e 'let add = (x, y) => x + y' // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict';functionadd(x, y) { return x + y | 0; } exports.add = add; /* No side effect */

You can pipe the output to Node to run it:

❯ bsc -e 'let add = (x, y) => x + y; Js.log(add(1, 2))'| node 3

Quickly Compile A Single File

You can compile a file directly via bsc MyFile.res:

// MyFile.resletrecfib=n=> { switchn { | 0 | 1=>n | n=>fib(n-1) +fib(n-2) } } Js.log(fib(0))
❯ bsc MyFile.res // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict';functionfib(n) { if (n === 0 || n === 1) { return n; } 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 type signatures directly via bsc -i MyFile.res

❯ bsc -i MyFile.res let fib: int => int

Note that this is for quick tests. For real projects, use our build system.

Format Code

❯ bsc -format MyFile.res let rec fib = n => { switch n { | 0 | 1 => n | n => fib(n - 1) + fib(n - 2) } } Js.log(fib(0))

Our editor plugins come with formatting by default.

close