Since BuckleScript guarantees that all OCaml functions are exported as is, no extra work is required to expose OCaml functions to JavaScript.
Caution
|
|
If users want to consume some OCaml features only available in OCaml but not in JS, we recommend users to export it as functions.
For example, data constructors are not available in JS
type t =
| Cons of int * t
| Nil
Currently, we recommend the user expose the constructor as a function so that it can be constructed from the JS side.
let cons x y = Cons (x,y)
let nil = Nil
Note
|
In the future, we will derive these functions to automate this process. |