In F# we have Computation Expressions, which can reduce boiler-plate and nesting when working in various computational contexts (async, optionals and so on).
- Does ReasonML have an equivalent of this?
- If so, what is the syntax?
In F# we have Computation Expressions, which can reduce boiler-plate and nesting when working in various computational contexts (async, optionals and so on).
By default, nope; no computation expressions. Reason is just another syntax still sharing all of the OCaml semantics, so a similar behavior is commonly achieved using modules, functors and composition.
However, Reason and OCaml have ppx rewriters, that allow extending the syntax to achieve this sort of things. There is already an open issue about a special syntax for asynchronous and awaitable computations.
Some useful ppx rewriters that are similar to computation expressions:
Show
, Eq
and Ord
© 2022 - 2024 — McMap. All rights reserved.