View min.re
let rec min node =>
switch node {
| Empty => Empty
| Node {value, left, right} =>
if (left == Empty) {
node
} else {
min left
}
};
View remove.re
let rec remove tree compare v =>
switch tree {
| Empty => Empty
| Node {value, left: Empty, right: Empty} => compare v value == 0 ? Empty : tree
| Node {value, left: Node _ as left, right: Empty as right} =>
compare v value == 0 ? left : Node {value, left: remove left compare v, right}
| Node {value, left: Empty as left, right: Node _ as right} =>
compare v value == 0 ? right : Node {value, left, right: remove right compare v}
| Node {value, left: Node _ as left, right: Node _ as right} =>
if (compare v value == (-1)) {
View compare.re
let compare f s => {
if (f < s) {
-1
} else if (f > s) {
1
} else {
0
}
};
View functions.re
/* Anonymous Functions*/
fun x => x * x;
/* Named Functions*/
let square x => x * x;
View insert.re
let rec insert tree compare v =>
switch tree {
| Empty => Node {value: v, left: Empty, right: Empty}
| Node {value, left, right} =>
if (compare v value == (-1)) {
Node {value, left: insert left compare v, right}
} else if (
compare v value == 1
) {
Node {value, left, right: insert right compare v}
View samples.re
/* type constructor/alias for the type int. Types like
* this can be useful so that error messages reference
* centimeters instead of int. Giving more context.
*/
type centimeters = int;
let deskWidth: centimeters = 20;
/* type constructor/aliases are required for records. You cannot use a
* record before creating a type for that record. Think typed
View bst.re
type binarySearchTree 'a =
| Empty
| Node (node 'a)
and node 'a = {
value: 'a,
left: binarySearchTree 'a,
right: binarySearchTree 'a
};
let empty = Empty;
View bst.js
class Node {
constructor (value) {
this.value = value;
this.left = null;
this.right = null;
}
}
class BinarySearchTree {
constructor (root = null) {
View Migrating.md

First couple things I thought about when migrating after reading the docs

So migrating my existing app wasn't as troublesome as I originally thought. First thing I did was take a look at my router and routes and figure try to make a mental model of all the files where I had nested routes in the existing app because those components/containers will contain {this.props.children}. So I need to replace those with the nested <Match /> components.

So just to give an example:

In v2:

<Router history={history}>
  <Route path="/" component={App}>