What I've Learned Writing Gleam

33 points by briankung


alurm

The use construct is still so interesting to me.

https://tour.gleam.run/advanced-features/use/

I first thought it was like "do notation" in Haskell, but it actually has quite a different desugaring. Also, I think it's not as "generic" semantically (please correct me if I'm wrong).

Here's how I understood the two desugar:

Haskell:

do { x <- a ; b x }
a >>= \x -> b x

Gleam:

x <- use a; b(x)
a(fn(x) { b(x) })

So it's actually inverted in a way!