Seeing this now after https://github.com/whatyouhide/stream_data/pull/104 has been opened. Just wanted to mention here too that I also think that a generic way to convert streams to generators would be nice but there is a big limitation: generators are stateless while streams aren’t. Streams are enumerated in order and there is no way for generators to know at which index in the stream it’s at.
@ericmj also your solution can be even simpler as bind
+ constant
is just map
:
def repeatedly(fun) do
StreamData.map(StreamData.constant(nil), fn _ -> fun.() end)
end