[Haskell-beginners] IO question
Ertugrul Soeylemez
es at ertes.de
Fri Oct 28 17:01:40 CEST 2011
Brandon Allbery <allbery.b at gmail.com> wrote:
> On Thu, Oct 27, 2011 at 10:48, Rustom Mody <rustompmody at gmail.com> wrote:
>
> > Can someone explain what is happening here?
> > *Main> getTwoChars
> > ab
> > ('a','b')
> > *Main> getTwoChars
> > a
> > ('\n','a')
>
> The code is doing exactly what it says. getTwoChars reads two
> characters --- *not* a line. So the next character waiting to be read
> is the newline, which is returned by the next getTwoChars.
>
> This may depend to some extent on the platform, as Unix defaults to a
> line-oriented input interface (at the OS level) but Windows to
> character-oriented input.
I can't confirm that. This is true for compiled programs, but when
running
liftA2 (,) getChar getChar
on the GHCi command line, it seems to use NoBuffering.
Greets,
Ertugrul
--
nightmare = unsafePerformIO (getWrongWife >>= sex)
http://ertes.de/
More information about the Beginners
mailing list