[Haskell-beginners] Simple IO problem

Ali Razavi ali.razavi at gmail.com
Thu Mar 4 13:21:58 EST 2010


I am using windows XP, and both in cygwin and cmd, it first pauses to get
the input, and then displays the prompt and the hello message in the same
line.


c:\haskell>runghc Test.hs
test
Please Enter Your Name: Hello test

Ali
On Thu, Mar 4, 2010 at 1:13 PM, Deniz Dogan <deniz.a.m.dogan at gmail.com>wrote:

> 2010/3/4 Ali Razavi <ali.razavi at gmail.com>:
> > Why doesn't this work the way it's supposed to, or the way it's
> intuitively
> > apparent from the code, that is, showing the prompt first, getting the
> line
> > next, and printing the result finally?
> >
> > main = do
> >         putStr "Please Enter Your Name: "
> >         name <- getLine
> >         putStrLn ("Hello " ++ name)
> >
> >
> > changing putStr with putStrLn rectifies it to the expected behavior, but
> I
> > wonder why this version misbehaves. FWIW, I use ghc in cygwin.
> >
> > Ali
> >
>
> FWIW using GHCi in standard Windows Vista, this works like it should.
>
> --
> Deniz Dogan
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20100304/0556095b/attachment.html


More information about the Beginners mailing list