SlideShare a Scribd company logo
@rizafahmi
@rizafahmi22
REASONML
About
NEW SYNTAX & TOOLCHAIN FOR OCAML
LOOKS AND FEELS LIKE
(* ocaml *)
let x y = y + 2
type 'a mytype
type listOfString = string list
let run () =
let nothing = None in
let something = Some 10 in
Js.log3 "a" 2 something;
let count = match nothing with
| None !=> "10"
| Some _ !=> "20"
in
if x 2 = 4 then
Js.log "Good"
else
Js.log "panic!"
.
!/* old reason !*/
let x y !=> y + 2;
type mytype 'a;
type listOfString = list string;
let run () !=> {
let nothing = None;
let something = Some 10;
Js.log3 "a" 2 something;
let count = switch nothing {
| None !=> "10"
| Some _ !=> "20"
};
if (x 2 !== 4) {
Js.log "Good"
} else {
Js.log "panic!"
}
};
!/* new reason !*/
let x(y) !=> y + 2;
type mytype('a);
type listOfString = list(string);
let run () !=> {
let nothing = None();
let something = Some(10);
Js.log3("a", 2, something);
let count = switch nothing {
| None !=> "10"
| Some _ !=> "20"
};
if (x(2) !== 4) {
Js.log("Good");
} else {
Js.log("panic!");
}
};
YARN/NPM BASED WORKFLOW
Introduction to ReasonML
FULL REBUILD IS 2S, INCREMENTAL BUILD IS <100MS ON AVERAGE.
USED TO RECEIVE BUGS REPORTS ON A DAILY BASIS; THERE HAVE BEEN A
TOTAL OF 10 BUGS DURING THE WHOLE YEAR!
REFACTORING SPEED WENT FROM DAYS TO DOZENS OF MINUTES.
OCAML
About
GENERAL PURPUSE SYSTEM
LANGUAGE
STABLE, MATURE, 20 YEARS
OLD
STATIC TYPES AND TYPE
INFERENCE
BUCKLESCRIPT BRINGS
OCAML TO THE WEB
Introduction to ReasonML
Introduction to ReasonML
Introduction to ReasonML
WHY
The
FREAKIN‘ FAST!
TYPE IS COOL
TYPE INFERENCE IS EVEN MORE COOLER!
FUNCTIONAL BUT PERMISSIVE
VARIANT AND PATTERN MATCHING
CAN TARGET JS AND NATIVE
HUMAN READABLE ERROR MESSAGE
Introduction to ReasonML
Introduction to ReasonML
COMPLETE TOOLS
Package Management
Bundler
UI Library
Forma9er
Linter
Transpiler
Boilerplate
yarn/npm
webpack
React
Pre0er
ESLint
Babel
create-react-app
ReasonReact
🎉
🎉
Refmt
🎉
🎉
🎉
EASE OF ADOPTION AND EASE OF
MAINTENANCE
Ease of Adop+on
EaseofMaintenance
Low High
High
JS Interop
FAR CLOSE
“THE COMMUNITY IS SMALL BUT VERY
FOCUSED ON DELIVERING A BETTER
EXPERIENCE FOR DEVELOPERS.”
Wojciech Bilicki
BUCKLESCRIPT
Now
BRINGS OCAML TO THE WEB
COMPILES OCAML/REASON TO JS
OCaml
OCaml Semantic
Bytecode Native
Reason
OCaml
OCaml Semantic
Reason
BuckleScript
JavaScript
Bytecode Native
SUPER READABLE OUTPUT
'use strict';
var Http = require("http");
var Http$1 = /* module */[];
Http.createServer((function (_, res) {
return res.end("Hello Bali");
})).listen(3333);
exports.Http = Http$1;
'use strict';
function add(a, b) {
return a + b | 0;
}
exports.add = add;
GREAT INTEROP WITH JS
10X FASTER THAN
Introduction to ReasonML
REASONMLRecap
MODERN SYNTAX AND TOOLCHAIN FOR OCAML
STATIC TYPE AND TYPE INFERENCE
CAN TARGET AND INTEROP WITH JS
COMPILE TO NATIVE AND BYTECODE
FAST, READABLE OUTPUT, READABLE ERROR MESSAGE
“TALK IS CHEAP. SHOW ME CODE.”
Linus Torvalds
Install and Setups
$ yarn global add bs-platform
$ yarn global add reason-cli
$ rtop
Syntax 101
let two = 1 + 1;
print_int(42);
print_endline("Hello Bali");
let float_addition = 1.1 +. 2.2;
Js.log(2 > 3);
Js.log(2 > 3.1);
Js.log(float_of_int(2) > 3.1);
print_endline("Hello" ++ "Bali");
let age = 32;
let age: int = 32;
let colors = ["red", "green", "blue"];
Records 101
type person = {
age: int,
name: string,
};
type nonPerson = {
age: int,
name: string,
species: string,
};
let kuririn: person = {age: 31, name: "Kuririn"};
let chiChi = {age: 21, name: "Chi-chi"};
let piccolo = {age: 103, name: "Piccolo", species: “Namek”};
print_endline(piccolo.species);
Reason Project
$ bsb -init reason-demo -theme basic-reason
$ cd reason-demo
.
!"" README.md
!"" bsconfig.json
!"" node_modules
#   %"" bs-platform
!"" package.json
%"" src
%"" Demo.re
package.json
{
"name": "reason-demo-1",
"version": "0.1.0",
"scripts": {
"build": "bsb -make-world",
"start": "bsb -make-world -w",
"clean": "bsb -clean-world"
},
"keywords": [
"BuckleScript"
],
"author": "",
"license": "MIT",
"devDependencies": {
"bs-platform": "^4.0.6"
}
}
bsconfig.json{
"name": "reason-demo-1",
"version": "0.1.0",
"sources": {
"dir" : "src",
"subdirs" : true
},
"package-specs": {
"module": "commonjs",
"in-source": true
},
"suffix": ".bs.js",
"bs-dependencies": [
// add your dependencies here.
],
"warnings": {
"error" : "+101"
},
"namespace": true,
"refmt": 3
}
src/Demo.re
Js.log("Hello, BuckleScript and Reason!");
$ node src/Demo.bs.js
Hello, BuckleScript and Reason!
Try it out!
$ yarn start
.
%"" src
!"" Demo.bs.js
%"" Demo.re
Variants 101
type species =
| Saiyan
| Namekian
| Human
| Majin
| Other;
type characters = {
age: int,
name: string,
species,
};
let bejita = {age: 42, name: "Vegeta", species: Saiyan};
Pattern Matching 101
let reply =
switch (message) {
| "Reason's pretty cool" => "Yep"
| "good night" => "See ya!"
| “hello" | “hi" | “heya" | "hey" => "hello to you too!"
| _ => "Nice to meet you!"
};
Pattern Matching and Variant
let hear =
switch (bejita.species) {
| Saiyan => "This is too easy for me!!"
| Namekian => “…”
| Other => “Let’s try one more time"
};
Binding and Interop
[%bs.raw {|
console.log("here is some js for you!")
|}];
Js.log("this is reason");
let x = [%bs.raw {| 'here is a string from javascript' |}];
Js.log(x ++ " back in reason land");
[@bs.val] external pi: float = "Math.PI";
let volume_cylinder = (diameter, height) => pi *. diameter *. height;
DEMO CODERecap
FAMILIAR SYNTAX
TYPE AND TYPE INFERENCE
VARIANTS
PATTERN MATCHING
BINDING AND INTEROP
REACT
Wait, what about
+ =
NPM/Yarn
React Router
Flow
Pre@er
EsLint JS Console
PropTypes
Redux
NPM/Yarn
React Router
Flow
Pre@er
EsLint JS Console
NPM/Yarn
Reason Router
StaLc

Typing
Refmt
Rtop
PropTypes PropTypes
Redux Redux
NPM/Yarn
Deps
Deps
Deps
Deps
Included in

Browser
NPM/Yarn
Included
Language
feature
Included Included in
Toolchain
Deps Language

feature
Deps Included
Component Lifecycle
componentDidMount()
componentWillReceiveProps()
shouldComponentUpdate()
componentWillUpdate()
componentDidUpdate()
componentWillUnmount()
didMount
willReceiveProps
shouldUpdate
willUpdate
didUpdate
willUnmount
Props
{this.props.someProp}
<Example someProp=“Hello!” />
let make(~someProp, _children) {
…component,
render /* etc */
}
<Example someProp=“Hello!” />
ReasonReact.statelessComponent
ReasonReact.reducerComponent
Component
type state = {count: int};
/* the actions */
type action =
| Increment
| Decrement;
let component = ReasonReact.reducerComponent("Counter");
let make = (_children) => {
...component,
/* the state */
initialState: () => {count: 0},
/* the reducer */
reducer: (action, state) =>
switch action {
| Increment => ReasonReact.Update({count: state.count + 1})
| Decrement => ReasonReact.Update({count: state.count - 1})
},
render: ({ state, send }) =>
<div>
<h1> {ReasonReact.string(string_of_int(state.count))} </h1>
<button onClick=((_e) => send(Increment))> {ReasonReact.string(“+”)} </button>
<button onClick=((_e) => send(Decrement))> {ReasonReact.string(“-“)} </button>
</div>
};
type state = {count: int};
/* the actions */
type action =
| Increment
| Decrement;
let component = ReasonReact.reducerComponent("Counter");
let make = (_children) => {
...component,
/* the state */
initialState: () => {count: 0},
/* … */
};
/* the reducer */
reducer: (action, state) =>
switch action {
| Increment => ReasonReact.Update({count: state.count + 1})
| Decrement => ReasonReact.Update({count: state.count - 1})
},
render: ({ state, send }) =>
<div>
<h1> {ReasonReact.string(string_of_int(state.count))} </h1>
<button onClick=((_e) => send(Increment))> {ReasonReact.string(“+”)} </button>
<button onClick=((_e) => send(Decrement))> {ReasonReact.string(“-“)} </button>
</div>
REASONREACTRecap
“At the language level, it has features that we’v previously had to
Bolt on top of the JavaScript such as alloca+on-less named
arguments, prop types and more. In short, it is the best way to
take React to the next level — unlocking far beGer user
experience and fast-loading applica+ons.”
Jordan Walke
Creator React and Reason
JavaScript and HTML — I can build things!
React — I can reuse my things!
ReasonReact — I can reuse my React things more safely!
All FuncLonal Programming
Some Additional Resources
DISCORD.GG/REASONML
ZAISTE.NET/REASON_IN_NUTSHELL_GETTING_STARTED_GUIDE
JAREDFORSYTH.COM/POSTS/A-REASON-REACT-TUTORIAL
MARMELAB.COM/BLOG/2018/04/09/ENJOY-PAINLESS-TYPING-WITH-REASON.HTML
CROWDIN.COM/PROJECT/REASON
Introduction to ReasonML
Introduction to ReasonML
github.com/rizafahmi
slideshare.net/rizafahmi
twiDer.com/rizafahmi22
facebook.com/rizafahmi
riza@hackGv8.com
ceritanyadeveloper.com

More Related Content

What's hot (20)

PPTX
Taming that client side mess with Backbone.js
Jarod Ferguson
 
PDF
History of jQuery
jeresig
 
KEY
Fatc
Wade Arnold
 
PDF
Drupal, meet Assetic
Kris Wallsmith
 
PDF
Testing Backbone applications with Jasmine
Leon van der Grient
 
PDF
JavaScript Promise
Joseph Chiang
 
PDF
Web Crawling with NodeJS
Sylvain Zimmer
 
PDF
How Kris Writes Symfony Apps
Kris Wallsmith
 
KEY
Backbone js
rstankov
 
PPTX
Venturing Into The Wild: A .NET Developer's Experience As A Ruby Developer
Jon Kruger
 
KEY
Why ruby
rstankov
 
PDF
Building Go Web Apps
Mark
 
KEY
Ruby/Rails
rstankov
 
PDF
¿Cómo de sexy puede hacer Backbone mi código?
jaespinmora
 
PDF
The Open Web and what it means
Robert Nyman
 
PDF
The Beauty Of Java Script V5a
rajivmordani
 
PDF
Rails 3: Dashing to the Finish
Yehuda Katz
 
PPTX
Testable, Object-Oriented JavaScript
Jon Kruger
 
PDF
The Beauty of Java Script
Michael Girouard
 
PDF
A Gentle Introduction to Event Loops
deepfountainconsulting
 
Taming that client side mess with Backbone.js
Jarod Ferguson
 
History of jQuery
jeresig
 
Drupal, meet Assetic
Kris Wallsmith
 
Testing Backbone applications with Jasmine
Leon van der Grient
 
JavaScript Promise
Joseph Chiang
 
Web Crawling with NodeJS
Sylvain Zimmer
 
How Kris Writes Symfony Apps
Kris Wallsmith
 
Backbone js
rstankov
 
Venturing Into The Wild: A .NET Developer's Experience As A Ruby Developer
Jon Kruger
 
Why ruby
rstankov
 
Building Go Web Apps
Mark
 
Ruby/Rails
rstankov
 
¿Cómo de sexy puede hacer Backbone mi código?
jaespinmora
 
The Open Web and what it means
Robert Nyman
 
The Beauty Of Java Script V5a
rajivmordani
 
Rails 3: Dashing to the Finish
Yehuda Katz
 
Testable, Object-Oriented JavaScript
Jon Kruger
 
The Beauty of Java Script
Michael Girouard
 
A Gentle Introduction to Event Loops
deepfountainconsulting
 

Similar to Introduction to ReasonML (20)

PDF
Reason - introduction to language and its ecosystem | Łukasz Strączyński
Grand Parade Poland
 
PDF
NodeJS The edge of Reason - Lille fp#6
Thomas Haessle
 
PDF
Nik Graf - Get started with Reason and ReasonReact
OdessaJS Conf
 
PDF
Get started with Reason
Nikolaus Graf
 
PDF
Linux conf-2018-fp-miniconf-slideshare
Keira Hodgkison (she-her)
 
PDF
Reason React
Arnar Þór Sveinsson
 
PDF
Roman Schejbal: From Madness To Reason
Develcz
 
PDF
Elm: give it a try
Eugene Zharkov
 
PDF
Hey! There's OCaml in my Rust!
Kel Cecil
 
PDF
React meets o OCalm
Michał Załęcki
 
PDF
Intro to React
Troy Miles
 
PDF
React Development with the MERN Stack
Troy Miles
 
PDF
Documenting with xcode
Goran Blazic
 
PDF
ES6: The Awesome Parts
Domenic Denicola
 
PDF
Workshop 10: ECMAScript 6
Visual Engineering
 
PDF
The Future of JavaScript (Ajax Exp '07)
jeresig
 
PDF
ReasonML: Strict, Powerful, and Forgiving
hari
 
PDF
Angular Weekend
Troy Miles
 
PDF
I don't know what I'm Doing: A newbie guide for Golang for DevOps
Peter Souter
 
PDF
Functional Programming in F#
Dmitri Nesteruk
 
Reason - introduction to language and its ecosystem | Łukasz Strączyński
Grand Parade Poland
 
NodeJS The edge of Reason - Lille fp#6
Thomas Haessle
 
Nik Graf - Get started with Reason and ReasonReact
OdessaJS Conf
 
Get started with Reason
Nikolaus Graf
 
Linux conf-2018-fp-miniconf-slideshare
Keira Hodgkison (she-her)
 
Reason React
Arnar Þór Sveinsson
 
Roman Schejbal: From Madness To Reason
Develcz
 
Elm: give it a try
Eugene Zharkov
 
Hey! There's OCaml in my Rust!
Kel Cecil
 
React meets o OCalm
Michał Załęcki
 
Intro to React
Troy Miles
 
React Development with the MERN Stack
Troy Miles
 
Documenting with xcode
Goran Blazic
 
ES6: The Awesome Parts
Domenic Denicola
 
Workshop 10: ECMAScript 6
Visual Engineering
 
The Future of JavaScript (Ajax Exp '07)
jeresig
 
ReasonML: Strict, Powerful, and Forgiving
hari
 
Angular Weekend
Troy Miles
 
I don't know what I'm Doing: A newbie guide for Golang for DevOps
Peter Souter
 
Functional Programming in F#
Dmitri Nesteruk
 
Ad

More from Riza Fahmi (20)

PDF
Membangun Aplikasi Web dengan Elixir dan Phoenix
Riza Fahmi
 
PDF
Berbagai Pilihan Karir Developer
Riza Fahmi
 
PDF
Web dan Progressive Web Apps di 2020
Riza Fahmi
 
PDF
Remote Working/Learning
Riza Fahmi
 
PDF
How to learn programming
Riza Fahmi
 
PDF
Rapid App Development with AWS Amplify
Riza Fahmi
 
PDF
Menguak Misteri Module Bundler
Riza Fahmi
 
PDF
Beberapa Web API Menarik
Riza Fahmi
 
PDF
MVP development from software developer perspective
Riza Fahmi
 
PDF
Ekosistem JavaScript di Indonesia
Riza Fahmi
 
PDF
How I Generate Idea
Riza Fahmi
 
PDF
Strategi Presentasi Untuk Developer Workshop Slide
Riza Fahmi
 
PDF
Lesson Learned from Prolific Developers
Riza Fahmi
 
PDF
Clean Code JavaScript
Riza Fahmi
 
PDF
The Future of AI
Riza Fahmi
 
PDF
Chrome Dev Summit 2018 - Personal Take Aways
Riza Fahmi
 
PDF
Essentials and Impactful Features of ES6
Riza Fahmi
 
PDF
Modern Static Site with GatsbyJS
Riza Fahmi
 
PDF
Machine learning with py torch
Riza Fahmi
 
PDF
Introduction to Tensorflow.js
Riza Fahmi
 
Membangun Aplikasi Web dengan Elixir dan Phoenix
Riza Fahmi
 
Berbagai Pilihan Karir Developer
Riza Fahmi
 
Web dan Progressive Web Apps di 2020
Riza Fahmi
 
Remote Working/Learning
Riza Fahmi
 
How to learn programming
Riza Fahmi
 
Rapid App Development with AWS Amplify
Riza Fahmi
 
Menguak Misteri Module Bundler
Riza Fahmi
 
Beberapa Web API Menarik
Riza Fahmi
 
MVP development from software developer perspective
Riza Fahmi
 
Ekosistem JavaScript di Indonesia
Riza Fahmi
 
How I Generate Idea
Riza Fahmi
 
Strategi Presentasi Untuk Developer Workshop Slide
Riza Fahmi
 
Lesson Learned from Prolific Developers
Riza Fahmi
 
Clean Code JavaScript
Riza Fahmi
 
The Future of AI
Riza Fahmi
 
Chrome Dev Summit 2018 - Personal Take Aways
Riza Fahmi
 
Essentials and Impactful Features of ES6
Riza Fahmi
 
Modern Static Site with GatsbyJS
Riza Fahmi
 
Machine learning with py torch
Riza Fahmi
 
Introduction to Tensorflow.js
Riza Fahmi
 
Ad

Recently uploaded (20)

PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 

Introduction to ReasonML