Ticket #36 (closed bug: None)

Opened 12 years ago

Last modified 43 years ago

lazy IO

Reported by: haskeller Owned by: nobody
Priority: normal Milestone:
Component: None Version: 5.02
Keywords: Cc:
Operating System: Architecture:
Type of failure: Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

I guess you allready know it, but here it is anyway:

main :: IO()
main = do indata <- putStr "input>">>getLine 
               putStr indata


Fail to behave lazily. 

SunOS 5.6
The Glorious Glasgow Haskell Compilation System,
version 5.02.1

Change History

Changed 12 years ago by simonmar

Logged In: YES 
user_id=48280

I don't think there's a bug here: if you were expecting to 
see the prompt before the program waits for input, then 
you need to flush stdout, like so:


Changed 12 years ago by simonmar

Logged In: YES 
user_id=48280

I don't think there's a bug here: if you were expecting to 
see the prompt before the program waits for input, then 
you need to flush stdout, like so:

   main = do putStr "input"
             hFlush stdout
             indata <- getLine
             putStr indata

is this the problem?  Please follow up, so I can close the 
bug.

Changed 12 years ago by haskeller

Logged In: YES 
user_id=403140

OK, my misstake ...
But it works without flushing in other releases.


Changed 12 years ago by simonmar

  • status changed from assigned to closed
Logged In: YES 
user_id=48280

Pre-5.02 releases of GHC had some code to cause flushing 
of stdout before a read operation on stdin, but this got 
removed during the rewrite of the I/O library.

I'm in two minds as to whether this is something the I/O 
library should do or not.  C libraries implementations 
seem to vary;  eg. glibc has curious behaviour: it flushes 
all FILEs whenever you read from any one, as long as you 
don't just read from its buffer.
Note: See TracTickets for help on using tickets.