Open cognivore opened 2 years ago
There's this one defined in Lean:
structure FS.Stream where
isEof : IO Bool
flush : IO Unit
read : USize → IO ByteArray
write : ByteArray → IO Unit
getLine : IO String
putStr : String → IO Unit
deriving Inhabited
Why?
In lazy languages, it's trivial to build infinite Streams. Lean would require plumbing around it to allow for infinite data structures. It's not acceptable, because we would like to parse stuff we get down the wire, signals coming from a signal generator, multipart form data.
The most practical use case is processing streams of data that are exceeding memory capabilities, such as huge JSON or XML files.
What?