forever

Repeat an action indefinitely.

Examples

A common use of forever is to process input from network sockets, Handles, and channels (e.g. MVar and Chan). For example, here is how we might implement an echo server, using forever both to listen for client connections on a network socket and to echo client input on client connection handles:
echoServer :: Socket -> IO ()
echoServer socket = forever $ do
client <- accept socket
forkFinally (echo client) (\_ -> hClose client)
where
echo :: Handle -> IO ()
echo client = forever $
hGetLine client >>= hPutStrLn client
Note that "forever" isn't necessarily non-terminating. If the action is in a MonadPlus and short-circuits after some number of iterations. then forever actually returns mzero, effectively short-circuiting its caller.
Repeat an action indefinitely. Using ApplicativeDo: 'forever as' can be understood as the pseudo-do expression
do as
as
..
with as repeating.

Examples

A common use of forever is to process input from network sockets, Handles, and channels (e.g. MVar and Chan). For example, here is how we might implement an echo server, using forever both to listen for client connections on a network socket and to echo client input on client connection handles:
echoServer :: Socket -> IO ()
echoServer socket = forever $ do
client <- accept socket
forkFinally (echo client) (\_ -> hClose client)
where
echo :: Handle -> IO ()
echo client = forever $
hGetLine client >>= hPutStrLn client
forever act repeats the action infinitely.
A shorthand for looping a Chunk forever.
Like forever but sans space leak
Run a LiveProgramExcept in a loop, discarding the exception.
Run a LiveProgramExcept in a loop. In the additional 'ReaderT e' context, you can read the last thrown exception. (For the first iteration, e is set to the first argument to foreverELiveProgram.) This way, you can create an infinite loop, with the exception as the loop variable.
Execute the stream until it throws an exception, then restart it. One might be tempted to define this function recursively with applyExcept, but this would result in a runtime error, trying to define an infinite state.
"for every"
Run a consuming conduit repeatedly, only stopping when there is no more data available from upstream.
Run a consuming conduit repeatedly, only stopping when there is no more data available from upstream. In contrast to peekForever, this function will ignore empty chunks of data. So for example, if a stream of data contains an empty ByteString, it is still treated as empty, and the consuming function is not called.
Wait for input forever, calling the given inner component for each piece of new input. This function is provided as a convenience for the common pattern of awaiting input, checking if it's Just and then looping. Since 0.5.0