[Haskell-cafe] Tracking characters and a timestamp ?

Matthew Brecknell haskell at brecknell.org
Wed Apr 4 18:00:03 EDT 2007


Marc Weber:
> main = do
>   hSetBuffering stdin NoBuffering
>   hGetContents stdin >>= mapM addTimeCode >>= mapM_ handleChar
> 
> It seems to wait till the end of the infinite list. Why?

The sequencing imposed by the IO monad means that the first mapM must
complete before the second can start. To see this, you can try the
following:

> main = do
>   hSetBuffering stdin NoBuffering
>   hGetContents stdin >>= mapM_ (\c -> addTimeCode c >>= handleChar)



More information about the Haskell-Cafe mailing list