gregvaughn

gregvaughn

Supercharging for comprehensions

José, I just watched your Twitch stream of day 10 of Advent of Code and, as a fan of for comprehensions, I enjoyed the time you spent discussing potential extensions of them. I recall learning about the reduce option the last time you streamed AoC. I’d like to start a thread to discuss some of those things you discussed. Twitch

I have found myself treating for more like with and sometimes using = in the clauses. My initial thoughts are that it is not a big problem to expect that level of understanding in order to use a group_by or sort_by option. However, I might also be convinced of group_by and sort_by options being a function if they could receive a binding.

I also am intrigued by your suggestion of with. My first thought went to let (allowing multiple of those) in which case they are mutable and the for comprehension can return them as a second binding param.

More thoughts and discussion?

Most Liked

josevalim

josevalim

Creator of Elixir

Oh, I missed this thread. Yeah, I should submit a proposal by today for for-let. It no longer has let! but retains the rest of the proposal. :slight_smile: thanks for the feedback!

gregvaughn

gregvaughn

I hesitate to ping you directly because I know you are busy @josevalim but from your day 13 Twitch livestream (Twitch) I see this is still on your mind.

I am in favor of how you have developed the let idea within a for comprehension (and how it can let us deprecate the :reduce option). Like the live chatters in the livestream, I too have a concern about let!/1 so I would prefer that a for that uses let return a 2 element tuple. Is there a benefit of the 2nd element of that tuple being a binding rather than a tuple of the let vars?

Where Next?

Popular in Discussions Top

Jayshua
I recently came across the javascript library htmx. It reminded me a lot of liveview so I thought the community here might be interested....
New
mikl
I wanted to capitalize a string, and tried using String.capitalize(). That generally works well, until you try to capitalize a word like...
New
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
WolfDan
After doing a port from a c++ library to my project in phoenix I’ve seen that I need a faster way to run this algorithm and I found this ...
New
chuck
Let me start by stating an assumption: Phoenix is a great approach to building REST APIs. There are many reasons for this, but I will ass...
New
New
rms.mrcs
A couple of days ago I was discussing with a friend about different approaches to write microservices. He said that if he was going to w...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New
Markusxmr
Since Drab has been developed for a while in the open, introducing the Liveview functionality in a way it happend appears to undermine th...
New

Other popular topics Top

9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 43657 311
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31194 112
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52774 488
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
jaysoifer
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)? Would mix ecto.rollback -v 200809061...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New

We're in Beta

About us Mission Statement