I feel like for is already an odd construct, because it behaves like a Enum.map (with nesting and filtering). Ideally I think you’d want generators to be more integrated with the standard library, but that’s hard to do right now.
To avoid confusion, I would let the for contruct mirror the functions we know as much as possible, instead of making up new terms for the same functions we already have in Enum.
Something like this (map can be the default unless specified):
for map x <- [1,2,3], y <- [4,5,6] do
{x, y}
end
for map_reduce acc = 0, x <- [1,2,3], y <- [4,5,6] do
{{x, y}, acc + x + y}
end
for reduce acc = 0, x <- [1,2,3], y <- [4,5,6] do
acc + x + y
end
This will also leave some room for possible future expansion for any other enumerable functions.






















