Drains an InputStream, converting it to a vector. Note that this
function reads the entire InputStream strictly into memory and as such is
not recommended for streaming applications or where the size of the input is
not bounded or known.
ghci> is <- Streams.System.IO.Streams.fromList [(1::Int)..4]
ghci> Streams.toVector is :: IO (V.Vector Int)
fromList [1,2,3,4]
Drains an InputStream, converting it to a mutable vector. Note that this
function reads the entire InputStream strictly into memory and as such is
not recommended for streaming applications or where the size of the input is
not bounded or known.
vectorOutputStream returns an OutputStream which stores values fed
into it and an action which flushes all stored values to a vector.
The flush action resets the store.
Note that this function will buffer any input sent to it on the heap.
Please don't use this unless you're sure that the amount of input provided
is bounded and will fit in memory without issues.
ghci> (os, flush) <- Streams.vectorOutputStream :: IO (OutputStream Int, IO (V.Vector Int))
ghci> Streams.System.IO.Streams.write (Just 1) os
ghci> Streams.System.IO.Streams.write (Just 2) os
ghci> flush
fromList [1,2]
ghci> Streams.System.IO.Streams.write (Just 3) os
ghci> Streams.System.IO.Streams.write Nothing os
ghci> Streams.System.IO.Streams.write (Just 4) os
ghci> flush
fromList [3]
Note that this function will buffer any input sent to it on the heap.
Please don't use this unless you're sure that the amount of input provided
is bounded and will fit in memory without issues.