Hey folks! Looking for an assist with some functors. I want to create a module that fetches data from a server as JSON but returns it as a Reason record type. I’m doing that by creating a definition module that defines the record type (
data) and provides a function for decoding the JSON into that type. Then my functor uses that to return the fetching module. I’m also using Belt’s Result.t to handle errors, and wrapping that in a state variant type to indicate loading. My problem is: once I do the data fetch and get back a result, it seems that the underlying definition of
data (that is, that it’s a Reason record) has been obfuscated away by the functor somehow. No matter how I annotate it, if I try to access one of its fields I get an error. I’ve mocked up a stripped down, contrived example to show all of this:
Anyone have any idea how to do this properly so that I can access the record’s fields when I get it back as a result? Seems like it ought to be possible but I just haven’t been able to figure out how to do it. Thanks!