ListT package:list-transformer

This is like a list except that you can interleave effects between each list element. For example:
stdin :: ListT IO String
stdin = ListT (do
eof <- System.IO.isEOF
if eof
then return Nil
else do
line <- getLine
return (Cons line stdin) )
The mnemonic is "List Transformer" because this type takes a base Monad, 'm', and returns a new transformed Monad that adds support for list comprehensions
Similar to ZipList in base: a newtype wrapper over ListT that overrides its normal Applicative instance (combine every combination) with one that "zips" outputs together one at a time.
>>> let xs = do x <- select [1,2,3,4]; liftIO (print x)

>>> let ys = do y <- select [5,6]; liftIO (print y)

>>> runListT (xs *> ys)
1
5
6
2
5
6
3
5
6
4
5
6

>>> runListT (getZipListT (ZipListT xs *> ZipListT ys))
1
5
2
6
3
Note that the final "3" is printed even though it isn't paired with anything. While this can be used to do zipping, it is usually more convenient to just use zip. This is more useful if you are working with a function that expects "an Applicative instance", written to be polymorphic over all Applicatives.
Use this to drain a ListT, running it to completion and discarding all values. For example:
stdout :: ListT IO String -> IO ()
stdout l = runListT (do
str <- l
liftIO (putStrLn str) )
The most common specialized type for runListT will be:
runListT :: ListT IO a -> IO ()