"interact" behaves oddly if used interactively
Tomasz Zielonka
t.zielonka at students.mimuw.edu.pl
Wed Oct 1 18:01:43 EDT 2003
On Wed, Oct 01, 2003 at 04:42:51PM +0200, Christian Maeder wrote:
> Can actually someone supply an implementation of something like interact
> that does no pipelining for the argument "id"? Simply doing "putStr !$ f
> !$ s" was not enough!
The simplest working but not necessarily correct solution could be:
interact f = do
s <- getContents
length s `seq` putStr (f s)
This one is probably better:
interact f = do
s <- getContents
foldr seq () s `seq` putStr (f s)
And this is more fun ;) :
interact f = do
s <- getContents
foldr seq (putStr (f s)) s
> Thanks, Christian
Best regards,
Tom
--
.signature: Too many levels of symbolic links
More information about the Haskell
mailing list