Skip to content

Interactive I/O with ghc doesn't prompt until after reading

My students complained that the interactive program they were to write using Haskell would not issue its first prompt until after the first line of input had been entered. I enclose a tiny Haskell program that exhibits this behaviour in 6.2 (SPARC Solaris) and 6.4 (Intel Linux) and am told that it also happens in 6.6. I also show that it works fine in Hugs, HBC, and NCH98. Script started on Tue 15 May 2007 02:11:26 PM NZST f% cat -n kcl.hs

1 main =

2 putStr "Enter a line:" >>

3 putChar ' ' >>

4 getLine >>= \a ->

5 putStrLn a >>

6 putStrLn a

f% uname -a SunOS frege 5.9 Generic_112233-04 sun4u sparc SUNW,Sun-Blade-100

f% hugs98 [snip]

|| || Version: February 2001 _________________________________________ Haskell 98 mode: Restart with command line option -98 to enable extensions Reading file "/home/users/okeefe_r/quasar/hugs98/shared/hugs/lib/Prelude.hs": [snip] Prelude> :load kcl Reading file "kcl.hs":

[snip] kcl.hs Main> main Enter a line: Foo! Foo! Foo!

Main> [Leaving Hugs]

f% rm a.out f% nhc98 -o a.out kcl.hs f% a.out Enter a line: Foo! Foo! Foo!

f% rm a.out f% hbc -o a.out kcl.hs f% a.out Enter a line: Foo! Foo! Foo!

f% rm a.out f% ghc --version The Glorious Glasgow Haskell Compilation System, version 6.2 f% ghc kcl.hs f% a.out Foo! Enter a line: Foo! Foo!

f% [[ftp kcl.hs to bling]] f% ssh bling [snip] b% uname -a Linux oucs816.otago.ac.nz 2.6.19-1.2911.fc6 #1 (closed) SMP Sat Feb 10 15:51:47 EST 2007 i686 i686 i386 GNU/Linux b% hugs b% hugs [snip]

|| || Version: November 2002 _________________________________________ [snip] Prelude> :load kcl Reading file "kcl.hs":

Hugs session for: /usr/local/lib/hugs/lib/Prelude.hs kcl.hs Main> main Enter a line: Bar! Bar! Bar!

Main> [Leaving Hugs]

b% rm a.out b% ghc --version The Glorious Glasgow Haskell Compilation System, version 6.4 b% ghc kcl.hs b% ./a.out Bar! Enter a line: Bar! Bar!

Trac metadata
Trac field Value
Version 6.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Prelude
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system Multiple
Architecture Multiple
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information