hFlush doesn't seem to work under GHCi/Solaris
Hi folks,
executing "hFlush stdout" doesn't seem to have any
effect when working under GHCi on Solaris (at least for
me ...). Consider the following toy program:
----------------------------
module Main where
import IO
main :: IO ()
main =
do n <- askQuestion "How many numbers would you like
to sum up? "
is <- mapM askNumber [1..n]
let s = sum is
putStrLn $ "The total sum is " ++ (show s) ++ "."
askQuestion :: String -> IO Int
askQuestion s =
do putStr s
hFlush stdout
fmap read getLine
askNumber :: Int -> IO Int
askNumber i = askQuestion $ "Please input number " ++
(show i) ++ ": "
-------------------------------
While everything looks fine under Linux (or when
executing the program after compiling it with GHC) the
output under Solaris looks rather messed up:
---------------------
> ghci-5.04.2 ex2-1.hs
___ ___ _
/ _ \ /\ /\/ __(_)
/ /_\// /_/ / / | | GHC Interactive, version
5.04.2, for Haskell 98.
/ /_\\/ __ / /___| | http://www.haskell.org/ghc/
\____/\/ /_/\____/|_| Type :? for help.
Loading package base ... linking ... done.
Loading package haskell98 ... linking ... done.
Compiling Main ( ex2-1.hs, interpreted )
Ok, modules loaded: Main.
*Main> main
How many numbers would you like to sum up? 4
1
Please input number 1: Please input number 2: 2
3
Please input number 3: Please input number 4: 4
The total sum is 10.
*Main>
-----------------------
This is a GHCi-5.04.2 built from the source
distribution under Sparc/Solaris by the way.
Cheers,
Matthias Neubauer
neubauer@informatik.uni-freiburg.de
Trac metadata
Trac field |
Value |
Version |
5.04.2 |
Type |
Bug |
TypeOfFailure |
OtherFailure |
Priority |
normal |
Resolution |
ResolvedFixed |
Component |
None |
Test case |
|
Differential revisions |
|
BlockedBy |
|
Related |
|
Blocking |
|
CC |
|
Operating system |
|
Architecture |
|