When you return :halt you can only update the accumulator, not the resulting stream of elements. You have to have at least one instance when you don’t return :halt.
Take you for taking time to answer my question. However I do not understand your explanation. Could you perhaps share with me how you would do this if you wanted to see ["foo"] in the final result
The accumulator is only used as internal state for next_fun and after_fun, and it’s not part of the output or directly visible to the caller of Stream.transform. When your next_fun returns {:halt, next_acc}, the stream ends and the output elements must have already been produced by previous calls to next_fun that returned {[elements], next_acc}, otherwise the output stream will be empty, which is what is going on in your example.
In other words: the accumulator has nothing to do with the elements, elements and accumulator are distinct entities.