Hi, just starting out with ReasonML. I’m trying to model a JS class (from the Firebase API) as follows:
type dataSnapshot('k, 'v) = {
.
"key": 'k,
[@bs.meth] "val": unit => Js.Nullable.t('v),
[@bs.meth] "exists": unit => bool,
[@bs.meth] "numChildren": unit => int,
};
open ReasonMaybe;
let snapValMaybe = (snapshot: option(dataSnapshot('k, 'v))) =>
Maybe.from(snapshot)
|> Maybe.chain(snap => Maybe.from(Js.Nullable.toOption(snap##val())));
But snap##val()
is a syntax error, presumably because val
is a reserved word. I can’t use [@bs.as]
for some reason – perhaps because I am already using the quoted object keys syntax?
Any help or insight would be hugely appreciated. Thanks!