DEV Community


Discussion on: Optional chaining in Reason

hoichi profile image
Sergey Samokhov

Nice writeup! If I were to nitpick, I’d add that:

  1. Jane Street Base uses >>| for map, so maybe it’s slightly more idiomatic in OCaml/Reason (then again, not a lot of programming fonts have ligatures for >>| 😅).
  2. Nested optional values can be a code smell the same way optics are: they can help you to be lax with abstraction boundaries.
johnridesabike profile image
John Jackson Author

Good points. As far as >>= goes, I picked it as my example because it’s used by bs-abstract and Relude (which uses bs-abstract).

Although, if you bind them to Belt’s functions, this may still feel “wrong” to people used to data-last infixes. There are tradeoffs no matter what infix you choose.

hoichi profile image
Sergey Samokhov • Edited

I’ve also heard (actually, read) Cheng Lou say they’d like to avoid infix operators in general, so probably monadic let is the way to go.