chenglou changed the topic of #reasonml to: https://reasonml.github.io. Channel logs at https://irclog.whitequark.org/reasonml. Discord: https://discord.gg/reasonml
_whitelogger has joined #reasonml
`slikts has quit [Quit: No Ping reply in 180 seconds.]
<cods> Hi. Any idea how to obtain a Javascript value of this shape: [{"type": "X", "title": "foo"}, {"type": "Y", "value": 123}]? I'm using Js.Array and bs.deriving abstract to build the final value, built from a Reason list and matching records, but at best I end up with [[{"type": "X", ...}], [{"type": "Y", ...}]] (1-element array because of the tagged representation).
<cods> I can't use Js.Dict because the value can be of different types (number, string) as shown.
<cods> here is the simplified code: https://eden.tuxee.net/rejs.html
<cods> For those wondering, the answer I got on SO: Use Obj.magic instead (and type it with an abstract type).
<reynir> Urgh, that's not a good answer IMO
<cods> I'm interested by anything better :)
<reynir> cods: Obj.magic is basically unsafe cast. All sorts of "interesting" behavior could happen when you use that. I would think you should rather do some manual runtime checking of the shape of the object, but I don't know what BS offers for this