Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Simple IO problem (Ali Razavi)
2. Re: Simple IO problem (Deniz Dogan)
3. Re: Simple IO problem (Ali Razavi)
4. Re: Simple IO problem (Brent Yorgey)
5. Re: Simple IO problem (Johan Tibell)
6. Re: Simple IO problem (Daniel Fischer)
7. Re: Simple IO problem (Gabr?el A. P?tursson)
8. Call for papers: MULTICONF-10, USA, July 2010 (John Edward)
----------------------------------------------------------------------
Message: 1
Date: Thu, 4 Mar 2010 13:06:42 -0500
From: Ali Razavi <[email protected]>
Subject: [Haskell-beginners] Simple IO problem
To: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20100304/d610a776/attachment-0001.html
------------------------------
Message: 2
Date: Thu, 4 Mar 2010 19:13:12 +0100
From: Deniz Dogan <[email protected]>
Subject: Re: [Haskell-beginners] Simple IO problem
To: Ali Razavi <[email protected]>
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
2010/3/4 Ali Razavi <[email protected]>:
> 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
------------------------------
Message: 3
Date: Thu, 4 Mar 2010 13:21:58 -0500
From: Ali Razavi <[email protected]>
Subject: Re: [Haskell-beginners] Simple IO problem
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
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 <[email protected]>wrote:
> 2010/3/4 Ali Razavi <[email protected]>:
> > 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-0001.html
------------------------------
Message: 4
Date: Thu, 4 Mar 2010 13:30:17 -0500
From: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] Simple IO problem
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
On Thu, Mar 04, 2010 at 01:06:42PM -0500, Ali Razavi wrote:
> 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
This is because of output buffering. By default, LineBuffering is
used, which means that the runtime will collect output in a buffer
until seeing a newline, at which point it will actually print the
buffer contents on the screen. This is why changing the putStr to
putStrLn makes it work. You can turn off output buffering like so:
import System.IO
main = do hSetBuffering stdout NoBuffering
putStr "Please Enter Your Name: "
... etc.
-Brent
------------------------------
Message: 5
Date: Thu, 4 Mar 2010 19:44:00 +0100
From: Johan Tibell <[email protected]>
Subject: Re: [Haskell-beginners] Simple IO problem
To: [email protected]
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
On Thu, Mar 4, 2010 at 7:30 PM, Brent Yorgey <[email protected]> wrote:
> On Thu, Mar 04, 2010 at 01:06:42PM -0500, Ali Razavi wrote:
> > 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
>
> This is because of output buffering. By default, LineBuffering is
> used, which means that the runtime will collect output in a buffer
> until seeing a newline, at which point it will actually print the
> buffer contents on the screen. This is why changing the putStr to
> putStrLn makes it work. You can turn off output buffering like so:
>
> import System.IO
>
> main = do hSetBuffering stdout NoBuffering
> putStr "Please Enter Your Name: "
> ... etc.
If you don't want a newline after the prompt you can use `hFlush stdout` to
manually flush the buffer.
Cheers,
Johan
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20100304/a34c828d/attachment-0001.html
------------------------------
Message: 6
Date: Thu, 4 Mar 2010 19:44:40 +0100
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] Simple IO problem
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
Am Donnerstag 04 März 2010 19:30:17 schrieb Brent Yorgey:
> On Thu, Mar 04, 2010 at 01:06:42PM -0500, Ali Razavi wrote:
> > 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
>
> This is because of output buffering. By default, LineBuffering is
> used, which means that the runtime will collect output in a buffer
> until seeing a newline, at which point it will actually print the
> buffer contents on the screen. This is why changing the putStr to
> putStrLn makes it work. You can turn off output buffering like so:
>
> import System.IO
>
> main = do hSetBuffering stdout NoBuffering
> putStr "Please Enter Your Name: "
> ... etc.
>
> -Brent
Another option is to explicitly flush stdout:
import System.IO
main = do
putStr "Please enter your name: "
hFlush stdout
name <- getLine
putStrLn $ "Hello " ++ name
Whether globally setting the buffering to NoBuffering is better or manually
flushing the handle in a couple of places depends of course on the
programme flow (lots of output with few prompts in between, flush manually;
lots of prompts and little other output, set buffering).
------------------------------
Message: 7
Date: Fri, 05 Mar 2010 13:37:20 +0000
From: Gabr?el "A." P?tursson <[email protected]>
Subject: Re: [Haskell-beginners] Simple IO problem
To: [email protected]
Message-ID: <1267796240.18006.2.ca...@polarina-desktop>
Content-Type: text/plain; charset="UTF-8"
On Thu, 2010-03-04 at 13:30 -0500, Brent Yorgey wrote:
> On Thu, Mar 04, 2010 at 01:06:42PM -0500, Ali Razavi wrote:
> > 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
>
> This is because of output buffering. By default, LineBuffering is
> used, which means that the runtime will collect output in a buffer
> until seeing a newline, at which point it will actually print the
> buffer contents on the screen. This is why changing the putStr to
> putStrLn makes it work. You can turn off output buffering like so:
>
> import System.IO
>
> main = do hSetBuffering stdout NoBuffering
> putStr "Please Enter Your Name: "
> ... etc.
>
> -Brent
It is also possible to use hFlush from System.IO to force a flush on
stdout.
main = do
putStr "Hi, "
hFlush stdout
name <- getLine
putStrLn ("You really do like flowers, miss " ++ name)
------------------------------
Message: 8
Date: Fri, 5 Mar 2010 07:42:14 -0800 (PST)
From: John Edward <[email protected]>
Subject: [Haskell-beginners] Call for papers: MULTICONF-10, USA, July
2010
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"
It
would be highly appreciated if you could share this announcement with your
colleagues, students and individuals whose research is in computer science,
computer engineering, information science and related areas.
Call
for papers: MULTICONF-10, USA, July 2010
The
2010 multi-conference (MULTICONF-10) (website: http://www.PromoteResearch.org )
will
be held during July 12-14, 2010 in Orlando, Florida, USA. The primary goal of
MULTICONF is to promote research and developmental activities in computer
science, information technology, control engineering, and related fields.
Another goal is to promote the dissemination of research to a multidisciplinary
audience and to facilitate communication among researchers, developers,
practitioners in different fields. The following conferences are planned to be
organized as part of MULTICONF-10.
⢠International
Conference on Artificial Intelligence and Pattern Recognition (AIPR-10)
⢠International
Conference on Automation, Robotics and Control Systems (ARCS-10)
⢠International
Conference on Bioinformatics, Computational Biology, Genomics and
Chemoinformatics (BCBGC-10)
⢠International
Conference on Computer Communications and Networks (CCN-10)
⢠International
Conference on Enterprise Information Systems and Web Technologies (EISWT-10)
⢠International
Conference on High Performance Computing Systems (HPCS-10)
⢠International
Conference on Information Security and Privacy (ISP-10)
⢠International
Conference on Image and Video Processing and Computer Vision (IVPCV-10)
⢠International
Conference on Software Engineering Theory and Practice (SETP-10)
⢠International
Conference on Theoretical and Mathematical Foundations of Computer Science
(TMFCS-10)
MULTICONF-10
will be held at Imperial Swan Hotel and Suites. It is a full-service resort
that puts you in the middle of the fun!
Located 1/2 block south of the famed International Drive, the hotel is just
minutes from great entertainment like Walt Disney World® Resort, Universal
Studios and Sea World Orlando. Guests can enjoy free scheduled transportation
to these theme parks, as well as spacious accommodations, outdoor pools and
on-site dining â all situated on 10 tropically landscaped acres. Here, guests
can experience a full-service resort with discount hotel pricing in Orlando.
Please
see the website http://www.PromoteResearch.org for more details.
Sincerely
John
Edward
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20100305/0b0e33fb/attachment.html
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 21, Issue 3
****************************************