HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

Moduleio-streams-1.5.2.2Haskell2010

System.IO.Streams.List

List conversions and utilities.

Contents
  1. List conversions
  2. Utility
Synopsis

List conversions

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

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]