The Gleam hype started and I was curious about some language goodies.
While reading the language tour (a lot of similar stuff to Rescript), I stopped at the use expression.
Use what? The use expression is just some syntactic sugar for (nested) callbacks.
There are already many discussions (some are a bit older) and I don’t want to bother anyone, but well …
- F# with
computation expressions(I hate to implement them, but I like to use them) - Scala with
for comprehensions - Haskell with
monad comprehensions - OCaml with
let op
And now Gleam with use.
All of these languages offer some kind of syntactic sugar for combining multiple results, options, etc.
Some are builtin, some have to be implemented by yourself and can be extended immeasurably.
I think overriding the let binding (OCaml version) or implementing custom computation expressions (F#) could “destory” the simplicity of Rescript and could confuse other devs while reading your code, but the use expression looks like a simple and generic way to hide callback hells.
What do you think?