Christian Maeder <[EMAIL PROTECTED]> writes: > I'm not happy that interleaving depends on the strictness. Lazy or > strict evaluation should only change the behaviour of overall > termination (lazy evaluation should terminate more often).
But the whole purpose of 'interact' is to use its argument as the demanding function which drives lazy consumption of the input. It is *designed* to reveal the evaluation behaviour, by hoisting it into the I/O monad. (AFAIK, 'interact' was explicitly designed for beginners, as an easy way to turn a pure computation into one which will actually run, before they learn about the I/O monad. Anyone from the original Haskell committee should feel free to correct me at this point, but interact was never intended for "serious" users.) > I'ld rather > implement interleaving (or "interactive" behaviour) explicitely by: > > interact f = do > s <- getLine > putStrLn (f s) > interact f Your suggested implementation does not have anything like the same semantics as the current 'interact'. For instance, consider the following program to number the lines of its input: main = interact (unlines . zipWith lineno [0..] . lines) where lineno n s = shows n (" "++s) Your version of interact behaves very unintuitively here! Regards, Malcolm _______________________________________________ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell