Reason
  • 문서
  • 해보기
  • API
  • 커뮤니티
  • 블로그
  • Languages icon한국어
    • 日本語
    • English
    • Deutsch
    • Español
    • Français
    • Português (Brasil)
    • Русский
    • Українська
    • 中文
    • 繁體中文
    • 번역 돕기
  • GitHub

›Setup

소개

  • What & Why

Setup

  • 설치
  • 에디터 플러그인

언어 기본

  • 개요
  • Let 바인딩
  • 원시 타입
  • 기본 자료구조
  • 타입
  • 레코드
  • Variant
  • Options and nullability
  • 함수
  • 재귀
  • 비구조화
  • 패턴 매칭
  • Mutable Bindings
  • 반복문
  • Modules

Advanced Features

  • JSX
  • 외부 접근
  • 예외
  • 오브젝트

JavaScript

  • 연동
  • 문법 치트시트
  • Pipe First
  • 프라미스
  • 라이브러리
  • JS에서 변환

추가 사항

  • 자주 물어보는 질문
  • 추가적으로 매력적인 것들
Translate

설치

Important: If you are looking for ReScript (formerly BuckleScript) installation instructions, please refer to the ReScript website.

Reason comes with its own "npm like" package manager called esy:

npm install -g esy

To create your first Reason native CLI program, run the following commands:

git clone https://github.com/esy-ocaml/hello-reason.git
cd hello-reason

# Install all dependencies (might take a while in the first run)
esy 

# Compile and run Hello.exe
esy x Hello

Reason native development is essentially OCaml development. From here on, you want to read up following websites to get to understand the ecosystem:

  • esy: The esy package manager is designed to manage your npm and opam dependencies and efficiently caches & sandboxes your project compiler and dependencies. Check out the esy website to find out how to install dependencies, setting up package resolutions, and executing compiled programs.
  • opam: The opam package index lists all available packages available in the OCaml ecosystem
  • dune: dune is the official build system in the OCaml ecosystem. Check out the manual for more details on how to set up your project.

All your packages are managed in your package.json file. Usually you will find a dune file in each source code directory (such as bin/ and lib/) for all the build system settings as well.

Some esy Tips

Adding dependencies:

To add Reason / OCaml packages that happen to be hosted on npm, run esy add npm-package-name.

esy add refmterr

Opam integration:

esy treats the npm scope @opam specially. esy will install any package name with the @opam scope directly from opam. This is the only scope with special meaning. All other package names are assumed to be hosted on npm.

esy add @opam/bos

Advanced esy configuration:

See the configuration section from the complete esy docs.

Compiling to JavaScript

Reason + OCaml both leverage the js_of_ocaml (JSOO) compiler to compile from bytecode to JavaScript.

To get started with Reason + esy + JSOO, check out this hello-jsoo-esy template:

git clone https://github.com/jchavarri/hello-jsoo-esy.git
cd hello-jsoo-esy
esy

npm install
npm run webpack

What's Next?

After you have successfully compiled your first example, it's time to set up your editor to get access to all the nice features such as auto-completion. Later on you can check out the language basics to get a basic understanding of all the Reason language constructs.

← What & Why에디터 플러그인 →
  • Compiling to JavaScript
  • What's Next?