Syntax Lookup

Enter some language construct you want to know more about.
This is the pipe operator.

The -> operator passes a value into the first argument position of a function. Typically it's used to chain multiple function calls together in a "pipeline like" fashion.

Example

ReScriptJS Output
let dieRoll = size => {
  Math.Int.random(1, size)
}

let dieRollMessage = (value, name) => {
  "Hi " ++ name ++ ", you rolled a " ++ Int.toString(value)
}

let message = dieRoll(6)->dieRollMessage("Marshall")

Which produces a message such as Hello Marshall, you rolled a 3.

You can also explicitly define the argument position of a piped value by using the _ placeholder:

ReScriptJS Output
let logMsg = (user: string, datestr: string, msg: string): unit => {
  Console.log(`${user}|${datestr}|${msg}`)
}

let datestr = "01-01-2021"
let user = "admin"

// Here, we put the result of toUpperCase into the last position
// denoted with an _
String.toUpperCase("example message")->logMsg(user, datestr, _)

References