In type theory and functional programming, a stream is a potentially infinite analog of a list, given by the coinductive definition:
Generating and computing with streams requires lazy evaluation, either implicitly in a lazily evaluated language or by creating and forcing thunks in an eager language. In total languages they must be defined as codata and can be iterated over using (guarded) corecursion.
Java provides the java.util.stream.Stream interface. JavaScript provides the ReadableStream, WritableStream and TransformStream interfaces. Python have the asyncio.StreamReader and asyncio.StreamWriter classes in the asyncio module. .NET provides the abstract class System.IO.Stream which is implemented by classes such as System.IO.FileStream and System.IO.MemoryStream. In Rust a struct can implement the std::io::Read trait. There is also the std::io::Cursor struct wraps an in-memory buffer. In C++, the std::ranges::views library (also abbreviated in the standard library as std::views) provides lazily evaluated range adaptors for ranges.
See also Coinduction
References