"interact" behaves oddly if used interactively

Simon Marlow simonmar at microsoft.com
Wed Oct 1 15:05:05 EDT 2003


Malcolm Wallace writes:
> 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.

This is why interact is bad, IMO: it forces you to think about the
evaluation order.  The evaluation order for Haskell is not part of the
language definition - it is normally up to the implementation to pick a
strategy.

Except when you get to lazy I/O.  The commonly accepted meaning for the
lazy I/O operations forces the implementation to adopt a lazy evaluation
strategy for values which require lazy I/O.  For example, eager
evaluation would be a completely valid implementation strategy for
Haskell if it were not for lazy I/O.

This has been swept under the carpet for far too long!

Cheers,
	Simon



More information about the Haskell mailing list