Syntax Lookup

Enter some language construct you want to know more about.
This is the @deriving decorator.

When the @deriving decorator is applied to a record type, it expands the type into a factory function plus a set of getter/setter functions for its fields.

Note that this is an outdated decorator and you may no longer need to use it. See Convert Record Type to Abstract Record for more details.

Example

ReScriptJS Output
@deriving(abstract)
type person = {
  name: string,
  age: int,
  job: string,
}

let joe = person(~name="Joe", ~age=20, ~job="teacher")

let joeName = nameGet(joe)
let joeAge = ageGet(joe)
let joeJob = jobGet(joe)

References