This module provides an API for working with strams and pipes.
Convert bytes to utf8 string
stdInAsString : Stream Never String
stdInAsString =
stdIn
|> pipeTo utf8Decode
Convert an utf8 string to bytes.
stdOutAsString : Stream String Never
stdOutAsString =
utf8Encode
|> pipeTo stdOut
Read stream line by line, splitting on the NL char.
Uncompress stream using gzip
Compress stream using gzip
Compose Streams into pipelines.
Connect the output of one stream to the input of another.
readLineByLine : Stream Never String
readLineByLine =
stdIn
|> pipeTo gunzip
|> pipeTo utf8Decode
|> pipeTo line
Read one value from a stream. Will block until one value can be returned.
Each consecutive call to read
will return the next value
(Just value
) until the stream is exhausted (EOF) in which
case it will result in Nothing
.
These functions are convenient when you want to read all data in
a stream and process it somehow. Conceptually you can think of it
as variations of List.foldl
but for streams.
Read a stream until it is exhausted (EOF) and reduce it.
Read a stream until it is exhausted (EOF) and collect all values using an accumulator function.
toList : Stream Never value -> IO String (List value)
toList stream =
collect (::) [] stream
Read a stream until it is exhausted (EOF) and perform output on each value.
printStream : Stream Never String -> IO String ()
printStream stream =
forEach IO.printLn stream
Write data to a stream.
Stream read errors
Same as write
but with a typed error.
Stream write errors
Run a pipeline where the input and output are connected.
passthrough : IO String ()
passthrough =
stdIn
|> pipeTo stdOut
|> run