Interoperating with Data Types
In the preceding examples, you saw a little bit of JavaScript and ReasonML data type interaction. ReasonML shares certain data types with JavaScript. The ReasonML string, bool, and array types correspond directly to JavaScript string, boolean, and array types. Tuples are compiled to JavaScript arrays, which is very handy if you ever need to process a non-homogeneous array from JavaScript—treat it as a tuple on the ReasonML side. You may depend upon these shared data types. The BuckleScript site has a handy cheat sheet for you.[33]
For all other data types, ReasonML compiles to a JavaScript representation that can vary depending on the version of the compiler. For example, as of this writing, a ReasonML char
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access