> > :l IO
> > openFile "thefile" WriteMode >>= \ hdl -> hPutStrLn hdl "hi" >> hClose hdl
> >
> > yields a file "thefile" containing a single newline, but not the text
> > "hi". [...]
>
> I can reproduce this with an even shorter example:
>
> :l IO
> hPutStr stdout ":-P"
>
> There's no output at all and using hPutStrLn instead only outputs a
> newline. Buffering bug?
Some inspection reveals that since May, two extra lines have crept into
primHPutStr in iomonad.c:
primFun(primHPutStr) { /* print string on handle */
Int h;
HandleArg(h,4);
drop();
push(primArg(4)); /* duplicate the handle before */
/* possible GC inside String eval */
push(primArg(2)); /* and copy the String back onto */
/* the top of the stack */
[...]
The extra lines are the two pushes. Deleting these restores the
original behaviour (ie, hPutStr puts the str).
HTH.
--KW 8-)
--
: Keith Wansbrough, MSc, BSc(Hons) (Auckland) ------------------------:
: PhD Student, Computer Laboratory, University of Cambridge, England. :
: (and recently of the University of Glasgow, Scotland. [><] ) :
: Native of Antipodean Auckland, New Zealand: 174d47' E, 36d55' S. :
: http://www.cl.cam.ac.uk/users/kw217/ mailto:[EMAIL PROTECTED] :
:---------------------------------------------------------------------: