3 ms·
>It is also interesting to look at what javascript was generated by ReasonML ``` function updateName(product, name) { return [name, product[1]] } ``` Records
by Illniyar 7y ago
>It is also interesting to look at what javascript was generated by ReasonML
```
function updateName(product, name) {
return [name, product[1]]
}
```
Records in ReasonML are represented as arrays. And generated code looks like a human wrote it if humans could remember indices of every property of every type like a compiler does.
This seems like a massive headache, what about JSON? or accessing dictionaries? Do you need to parse every js datastructure to a ReasonML record?
- pkilgore 7y agoNo. Reason (bucklescript really) maps to the full range of a data structures. So use a dict as a dict, a record as a record, an array as an array...etc. It will map back to what makes the most sense in the JS world. As opposed to JS, where really all these things are overloaded onto the same data structure ( object ).
- pkilgore 7y agoBut to be clear, yes, interop with regular JavaScript and JSON is a bit of a pain in the butt. Bucklescript has lots of helpers but it's definitely the place where the soundness of the type system has broken down for me in the past.