## ReasonML an introduction @_bogthe [|]() bogthe.me [|]() github.com/bogthe by Bogdan Stolojan
A note on statistics
“There are 3 types of lies: lies, damn lies and statistics“
Benjamin Disraeli
## How does Reason look like? ```js let add = (x, y) => x + y; let result = add(1, 2); // result = 3; // currying for free! let succ = add(1); let four = succ(3); // four = 4; // be a FP hipster with pipe operator; let five = four |> succ; // same as succ(4); ```
```js let someString = "Hello world!"; // someString = "No can do"; !all variables are immutable by default; let changeMe = ref("I change a lot"); changeMe := "yes you do…"; let namedArgs = (~greeting) => greeting ++ " Joe!"; namedArgs(~greeting = "Ola"); // Ola Joe! ```
## LIVE DEMO! ```js type bevarage = | Beer | Tea | Cocktail(string); let customerOrder = Cocktail("mojito"); let toPay = switch(customerOrder) { | Beer => 3.2 | Tea => 2.2 | Cocktail(selection) => selection == "mojito" ? 1.0 : 5.0; } // toPay = 1. ```
```js let someList = [1, 2, 3]; let first = switch(someList) { | [head, ..._tail] => head | [] => 0 } // first = 1; ```
```js type livingStatus = | Alive | Dead; type person = { name: string, age: int, status: livingStatus, }; let joe = { name: "Joe", age: 35, status: Alive, }; // joe is infered to be a person, amazing *__* ```
## Real world examples This is where I open my editor up…
## Thank you /reasonml.github.io/ @_bogthe [|]() bogthe.me [|]() github.com/bogthe