"interact" behaves oddly if used interactively

Christian Maeder maeder at tzi.de
Wed Oct 1 14:01:55 EDT 2003

Malcolm Wallace wrote:
> Surely the name suggests that "interactive" behaviour is required, i.e.
> exactly some interleaving of input and output.  The chunk-size of the
> interleaving should depend only on the strictness of the argument to
> "interact". 

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). I'ld rather 
implement interleaving (or "interactive" behaviour) explicitely by:

interact f = do
   s <- getLine
   putStrLn (f s)
   interact f

(assuming line buffering) (Terminating with "ctrl-c")

Surely also something is needed for endless character resources as
Tom pointed out.



More information about the Haskell mailing list