box-0.8.1: boxes
Safe HaskellNone
LanguageHaskell2010

Box.IO

Description

IO effects

Synopsis

Documentation

fromStdin :: Emitter IO Text Source #

Emit text from stdin

λ> emit fromStdin
hello
Just "hello"

toStdout :: Committer IO Text Source #

Commit to stdout

>>> commit toStdout ("I'm committed!" :: Text)
I'm committed!
True

fromStdinN :: Int -> CoEmitter IO Text Source #

Finite console emitter

λ> toListM <$|> fromStdinN 2
hello
hello again
["hello","hello again"]

toStdoutN :: Int -> CoCommitter IO Text Source #

Finite console committer

>>> glue <$> contramap (pack . show) <$> (toStdoutN 2) <*|> qList [1..3]
1
2

readStdin :: Read a => Emitter IO a Source #

Read from console, throwing away read errors

λ> glueN 2 showStdout (readStdin :: Emitter IO Int) 1 1 hippo 2

showStdout :: Show a => Committer IO a Source #

Show to stdout

>>> glue showStdout <$|> qList [1..3]
1
2
3

handleE :: Handle -> Emitter IO Text Source #

Emits lines of Text from a handle.

handleC :: Handle -> Committer IO Text Source #

Commit lines of Text to a handle.

refCommitter :: MonadConc m => m (Committer m a, m [a]) Source #

Commit to an IORef

>>> (c1,l1) <- refCommitter :: IO (Committer IO Int, IO [Int])
>>> glue c1 <$|> qList [1..3]
>>> l1
[1,2,3]

refEmitter :: MonadConc m => [a] -> m (Emitter m a) Source #

Emit from a list IORef

>>> e <- refEmitter [1..3]
>>> toListM e
[1,2,3]

fileE :: FilePath -> CoEmitter IO Text Source #

Emit lines of Text from a file.

fileWriteC :: FilePath -> CoCommitter IO Text Source #

Commit lines of Text to a file.

fileAppendC :: FilePath -> CoCommitter IO Text Source #

Commit lines of Text, appending to a file.