"interact" behaves oddly if used interactively

Christian Maeder maeder at tzi.de
Wed Oct 1 15:32:17 EDT 2003

Colin Runciman wrote:
> Let not the eager imperative tail wag the lazy functional dog!

Ideally functional programs should be independent of evaluation strategy 
  and I assume that this is the case for about 90% of all Haskell 
programs. This leaves maybe the head or only the nose for laziness of 
the "functional dog".

But looking at the two actions of interact:

interact f = do
    s <- getContents
    putStr (f s)

I would expect the first action to be finished before the second, (and I 
would not call it "interact" anymore after this discussion).

Therefore, the "primitives" (getContents, putStr) behave "incorrect" to 
my taste, (although the actual behaviour may be more desirable for 
special other purposes.)


More information about the Haskell mailing list