Quick Links
  • -Overview
  • -Language Features
  • -JS Interop
  • -Build System
Documentation
Language Manual
Reference for all language features
ReScript & React
First class bindings for ReactJS
GenType
Seamless TypeScript integration
Reanalyze
Dead Code & Termination analysis
Exploration
Packages
Explore third party libraries and bindings
Syntax Lookup
Discover all syntax constructs
APIPlaygroundBlogCommunity
  • Playground
  • Blog
  • X
  • BlueSky
  • GitHub
  • Forum
Language Manual
Overview
  • Introduction
  • Installation
  • Editor Plugins
  • Migrate to ReScript Syntax
  • Try
    • Try Online
    • Quickly Evaluate Code In Terminal
    • Quickly Compile A Single File
    • Format Code
Language Features
  • Overview
  • Let Binding
  • Type
  • Primitive Types
  • Tuple
  • Record
  • Object
  • Variant
  • Polymorphic Variant
  • Null, Undefined and Option
  • Array & List
  • Function
  • If-Else & Loops
  • Pipe
  • Pattern Matching / Destructuring
  • Mutation
  • JSX
  • Exception
  • Lazy Value
  • Async & Promise
  • Module
  • Import & Export
  • Attribute (Decorator)
  • Unboxed
  • Reserved Keyword
JavaScript Interop
  • Interop Cheatsheet
  • Embed Raw JavaScript
  • Shared Data Types
  • External (Bind to Any JS Library)
  • Bind to JS Object
  • Bind to JS Function
  • Import from / Export to JS
  • Bind to Global JS Values
  • JSON
  • Inlining Constants
  • Use Illegal Identifier Names
  • Generate Converters & Helpers
  • Browser Support & Polyfills
  • Libraries & Publishing
Build System
  • Overview
  • Configuration
  • Configuration Schema
  • External Stdlib
  • Pinned Dependencies
  • Interop with JS Build Systems
  • Performance
Guides
  • Converting from JS
Extra
  • Newcomer Examples
  • Project Structure
  • FAQ
Docs / Language Manual / Try
Edit

Try Online

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

Quickly Evaluate Code In Terminal

Use bsc -e:

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

You can pipe the output to Node to run it:

SH
❯ 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:

RES
// MyFile.res let rec fib = n => { switch n { | 0 | 1 => n | n => fib(n - 1) + fib(n - 2) } } Js.log(fib(0))
SH
❯ bsc MyFile.res // Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; function fib(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

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

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

Format Code

SH
❯ 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.

Migrate to ReScript SyntaxOverview

© 2024 The ReScript Project

Software and assets distribution powered by KeyCDN.

About
  • Community
  • ReScript Association
Find us on