12 ms·
> it's more confusing (and less expressive) than full-on do-notation (or F#-like "computation expressions"). It's strictly more expressive than do-notation. An
by lpil 3y ago
> it's more confusing (and less expressive) than full-on do-notation (or F#-like "computation expressions").
It's strictly more expressive than do-notation. Anything that Haskell's `do` can do Gleam's `use` can do, but not everything that Gleam's `use` can do Haskell's `do` can do.
I don't think the clarity argument holds true, I think rather this is about what you're familiar with rather than an actual property of the syntax. Both are rather opaque.
Given there's a few languages with `use` now I think that familiarity problem will lessen too.
- tome 3y agoCan it be nested? Haskell's do can be used like do r <- do foo bar quux r But I don't see (from https://gleam.run/news/v0.25-introducing-use-expressions/ https://gleam.run/news/v0.25-introducing-use-expressions/) any obvious way of nesting like that in Gleam.
- lpil 3y agoUnlike in Haskell `{}` are not optional in Gleam, so that would be written like so: use a <- one({ use b <- two // etc })
- tome 3y agoThanks. I don't fully grasp what `one` is, but do notation has the nice property that do r <- do foo bar quux r is the same as do foo r <- bar quux r It doesn't look like that holds for use. Specifically one({ use b <- two foo }) baz is not the same as use b <- two foo baz right?
- lpil 3y agoCorrect, it’s not.