Trying to use decode from rescript-json-combinators library, it is mentionned that Decoders have been made abstract and they have to be run via Decode.decode
let targetValue: JsonCombinators.Json.Decode.decode<Web.Json.t, string>
Trying to use this way raises this error:
This type constructor, JsonCombinators.Json.Decode.decode, can't be found.
Is this the correct way to use it? if not any idea on how this error can be fixed?
I'm not entirely sure what you are trying to do with
targetValuehere, but the type constructor for a decoder isJson.Decode.t, and only takes one argument, the type it will produce. Then there's a functionJson.Decode.decode, which is also available throughJson.decode, that takes a decoder and aJs.Json.tvalue, and runs the decoder on that value to produce aresultthat, if successful, will contain the decoded value.Here's an abbreviated version of the README example with some type annotations to hopefully illustrate it better: