In many other languages one can make a generic asynchronous iterable type, like Observable<T>
in Rx variants, chan T
in Go.
Julia's coroutine abstraction Task
is a comparable construct which can pass objects between (lightweight) threads. Does Julia have a method to annotate the type of those objects?
I would like to make a function that accepts a Task
as its parameter and be able to express the type of objects that the task emits. For example, if Task
were a generic type, I would imagine:
function foo(socket::Task{String})
for word in socket
println(word)
end
end
More generally, is there an abstract type for objects that are iterable using for
(or other methods using start
/next
/done
) so that I can annotate in function signatures?