[Haskell-beginners] different getChar behaviour in interpeter and compiled program

Motiejus Jakštys desired.mta at gmail.com
Sun Oct 14 18:00:42 CEST 2012


On Sun, Oct 14, 2012 at 11:31:58AM -0400, Brandon Allbery wrote:
> On Sun, Oct 14, 2012 at 11:14 AM, Motiejus Jakštys <desired.mta at gmail.com>wrote:
> 
> > The behaviour is fine: right after entering a character, I get echo
> > back.
> >
> > However, when started with runhaskell (or compiled ./getchar):
> >
> >     motiejus at precise> runhaskell getchar.hs
> >     la<CR>
> >     Entered: l
> >     Entered: a
> >     Entered:
> >
> 
> http://www.haskell.org/ghc/docs/latest/html/users_guide/ghci-faq.htmlscroll
> to the bottom.
> 

Thanks.

Not exactly like in the FAQ, but it lead me to the right direction. In
my case stdin in ghci is not buffered, whereas in ghc it is line
buffered. Turning stdin buffering off before getChar (hSetBuffering
stdin NoBuffering) made it work.

Regards,
Motiejus



More information about the Beginners mailing list