HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleio-streams-1.5.2.2Haskell2010

System.IO.Streams.List

List conversions and utilities.

  • 8 values

List conversions

4 declarations
valuetoList :: InputStream a -> IO [a]
#

Drains an InputStream, converting it to a list. N.B. 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.fromList [1, 2]
ghci> Streams.toList is
[1, 2]

Utility

4 declarations
valuelistOutputStream :: IO (OutputStream c, IO [c])
#

listOutputStream returns an OutputStream which stores values fed into it and an action which flushes all stored values to a list.

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.listOutputStream :: IO (OutputStream Int, IO [Int])
ghci> Streams.writeList [1, 2] os
ghci> flush
[1, 2]
ghci> Streams.writeList [3, 4] os
ghci> flush
[3, 4]