r/functionalprogramming • u/kinow mod • Sep 14 '25
Gleam My First Impressions of Gleam
https://mtlynch.io/notes/gleam-first-impressions/
21
Upvotes
r/functionalprogramming • u/kinow mod • Sep 14 '25
2
u/kinow mod Sep 14 '25
Hacker News thread: https://news.ycombinator.com/item?id=45231852
11
u/rlDruDo Sep 14 '25
Neat!
A few thoughts I had:
Yes, but you can use all of Erlang and JS using the FFI, giving you a much bigger ecosystem.
Error handling:
I think you can use
usefor error handling (usingmapandflat_map(the name might be different). You can also use this keyword for writing something similar to for loops, especially if you run it in a block. It’s kind of a weird keyword though.Since gleam has multiple targets (JS and Erlang), these functions are platform specific and might not even available (the web). At least I think that’s the reasoning.
I think the killer feature is, that it’s compiling to Erlang / the BEAM, which enables you to use the BEAM patterns, managers, actors etc (that’s what they use right?!). Maybe that’s something unique and worth exploring?
4
u/codeconscious Sep 14 '25
I'm still new to functional programming and don't know Gleam, so this might be a silly question.
This pseudo-code example in the "Dislike: Error handling" section got me thinking a bit:
This would return a
Result<string, 'a>, if I understand the author's intent correctly.However, it appears that Gleam's standard library has a
Result.mapfunction. Would using it basically allow the type of code that the author desires?For example, if the example above is rewritten in pseudo-F#, it might look as below. (I say "pseudo" because
Splitin F# actually returns astring, not aResult.)This returns a
Result<string, 'a>.Thus, I wondered if Gleam, via its own
mapfunction, might already be able to do something like this.