Not at my computer right now but the last part looks problematic. You’ve got an option that could be None and are trying to apply it to the hello text. Maybe just getElement → option.forEach( elem => sethtml to hello on the element )
Thank you for a very quick reply! The actual error is at setInnerHTML part (sorry the wrong place) saying This has type: (Webapi.Dom.Element.t, string) => unit, Somewhere wanted: option<'a>.
However, I am wondering if it could be a little shorter, hopefully without pattern matching. (For me as a OCaml programmer, this is usual, but I’d like to know if there is a nicer way in the current ReScript ecosystem.)
Thank you so much! I realised that something like optional chaining ?. in JavaScript, binding operator let* in OCaml, or point-free style, … is what I anticipated. For future reference, the following link would also be useful:
Have you seen Belt.Option.flatMap?
I have it aliased to bind in our codebase for haskell familiarity.
I wonder if an operator would make it more familiar to js coders