Send Beginners mailing list submissions to beginners@haskell.org 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 beginners-requ...@haskell.org
You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..." Today's Topics: 1. Strange difference in behaviour between ghc and ghci (Matthew Moppett) 2. Re: Strange difference in behaviour between ghc and ghci (Arlen Cuss) 3. Re: flatten comma operator (Arlen Cuss) 4. Re: Strange difference in behaviour between ghc and ghci (Andres L?h) 5. Re: Strange difference in behaviour between ghc and ghci (Henry Lockyer) 6. Re: Strange difference in behaviour between ghc and ghci (Henry Lockyer) 7. Re: Strange difference in behaviour between ghc and ghci (Matthew Moppett) ---------------------------------------------------------------------- Message: 1 Date: Thu, 7 Jun 2012 21:22:23 +1000 From: Matthew Moppett <matthewmopp...@gmail.com> Subject: [Haskell-beginners] Strange difference in behaviour between ghc and ghci To: beginners@haskell.org Message-ID: <CAMLEjZAi7waUto4TaqegwJ1-4eBCT=ifcvjaylatpjuxkcp...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" I have a very simple Haskell file (HelloWorld.hs) that reads like this: main = do putStr "What's your name? " n <- getLine putStrLn $ "Pleased to meet you, " ++ n When I load it into ghci, I get the following result, as expected: [1 of 1] Compiling Main ( HelloWorld.hs, interpreted ) Ok, modules loaded: Main. *Main> main What's your name? Matt Pleased to meet you, Matt *Main> However, when I compile the same file using ghc and run it in a terminal, I get a very different result: matt@matt-Lenovo-G575:~/Haskell$ ghc HelloWorld.hs [1 of 1] Compiling Main ( HelloWorld.hs, HelloWorld.o ) Linking HelloWorld ... matt@matt-Lenovo-G575:~/Haskell$ ./HelloWorld Matt What's your name? Pleased to meet you, Matt matt@matt-Lenovo-G575:~/Haskell$ -- in other words, the getLine action is being run before the putStr action, for some strange reason. Is this a bug? Can anyone enlighten me as to what might be going on? Regards, Matt. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20120607/90f03058/attachment-0001.htm> ------------------------------ Message: 2 Date: Thu, 7 Jun 2012 21:28:53 +1000 From: Arlen Cuss <a...@unnali.com> Subject: Re: [Haskell-beginners] Strange difference in behaviour between ghc and ghci To: Matthew Moppett <matthewmopp...@gmail.com> Cc: beginners@haskell.org Message-ID: <525ca83d7d7c47888342df367da02...@unnali.com> Content-Type: text/plain; charset="utf-8" Hello! See this similar mailing list question from 2006: http://www.haskell.org/pipermail/haskell/2006-September/018430.html The short answer is that GHCi buffers differently, so you need to be more explicit about flushing. HTH, Arlen On Thursday, 7 June 2012 at 9:22 PM, Matthew Moppett wrote: > I have a very simple Haskell file (HelloWorld.hs) that reads like this: > > main = do > putStr "What's your name? " > n <- getLine > putStrLn $ "Pleased to meet you, " ++ n > > > When I load it into ghci, I get the following result, as expected: > > [1 of 1] Compiling Main ( HelloWorld.hs, interpreted ) > Ok, modules loaded: Main. > *Main> main > What's your name? Matt > Pleased to meet you, Matt > *Main> > > > However, when I compile the same file using ghc and run it in a terminal, I > get a very different result: > > matt@matt-Lenovo-G575:~/Haskell$ ghc HelloWorld.hs > [1 of 1] Compiling Main ( HelloWorld.hs, HelloWorld.o ) > Linking HelloWorld ... > matt@matt-Lenovo-G575:~/Haskell$ ./HelloWorld > Matt > What's your name? Pleased to meet you, Matt > matt@matt-Lenovo-G575:~/Haskell$ > > > > -- in other words, the getLine action is being run before the putStr action, > for some strange reason. > > Is this a bug? Can anyone enlighten me as to what might be going on? > > Regards, > > Matt. > _______________________________________________ > Beginners mailing list > Beginners@haskell.org (mailto:Beginners@haskell.org) > http://www.haskell.org/mailman/listinfo/beginners ------------------------------ Message: 3 Date: Thu, 7 Jun 2012 21:30:32 +1000 From: Arlen Cuss <a...@unnali.com> Subject: Re: [Haskell-beginners] flatten comma operator To: Brandon Allbery <allber...@gmail.com> Cc: beginners@haskell.org Message-ID: <e6227490970f4be6a30ba0462f72c...@unnali.com> Content-Type: text/plain; charset="utf-8" Hmm. I've tested over 6,432 to work, but I'm not sure this has any point any more ? ;-) On Thursday, 7 June 2012 at 7:17 AM, Brandon Allbery wrote: > On Wed, Jun 6, 2012 at 7:06 AM, Arlen Cuss <a...@unnali.com > (mailto:a...@unnali.com)> wrote: > > And as Brent pointed out also, it is. :) By the way, so is > > (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)! > > I suspect GHC allows any number. The > > > Maybe not any number; more than 127 elements in a tuple used to cause core > dumps.... > > -- > brandon s allbery allber...@gmail.com (mailto:allber...@gmail.com) > wandering unix systems administrator (available) (412) 475-9364 vm/sms ------------------------------ Message: 4 Date: Thu, 7 Jun 2012 13:30:54 +0200 From: Andres L?h <and...@well-typed.com> Subject: Re: [Haskell-beginners] Strange difference in behaviour between ghc and ghci To: Matthew Moppett <matthewmopp...@gmail.com> Cc: beginners@haskell.org Message-ID: <caljd_v4th7hkem52e3sjzm9vsqyfqwggvddao8su4b+r8mk...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Hi. > -- in other words, the getLine action is being run before the putStr action, > for some strange reason. > > Is this a bug? Can anyone enlighten me as to what might be going on? See http://www.haskell.org/ghc/docs/7.4.1/html/users_guide/ghci-faq.html Last item in the list. Cheers, Andres -- Andres L?h, Haskell Consultant Well-Typed LLP, http://www.well-typed.com ------------------------------ Message: 5 Date: Thu, 7 Jun 2012 12:32:59 +0100 From: Henry Lockyer <henry.lock...@ntlworld.com> Subject: Re: [Haskell-beginners] Strange difference in behaviour between ghc and ghci To: Matthew Moppett <matthewmopp...@gmail.com> Cc: beginners@haskell.org Message-ID: <548313a4-46aa-4cf2-83c0-737c3235f...@ntlworld.com> Content-Type: text/plain; charset=us-ascii A very quick reply and without reading carefully considering what may be different in GHCI (!), but the output buffer flushes (at least on my system) with newline (if you don;t flush it 'manually'). I suspect if you use putStrLn for 'what's your name' you may get something more like what you want. On 7 Jun 2012, at 12:22, Matthew Moppett wrote: > I have a very simple Haskell file (HelloWorld.hs) that reads like this: > > main = do > putStr "What's your name? " > n <- getLine > putStrLn $ "Pleased to meet you, " ++ n > > When I load it into ghci, I get the following result, as expected: > > [1 of 1] Compiling Main ( HelloWorld.hs, interpreted ) > Ok, modules loaded: Main. > *Main> main > What's your name? Matt > Pleased to meet you, Matt > *Main> > > However, when I compile the same file using ghc and run it in a terminal, I > get a very different result: > > matt@matt-Lenovo-G575:~/Haskell$ ghc HelloWorld.hs > [1 of 1] Compiling Main ( HelloWorld.hs, HelloWorld.o ) > Linking HelloWorld ... > matt@matt-Lenovo-G575:~/Haskell$ ./HelloWorld > Matt > What's your name? Pleased to meet you, Matt > matt@matt-Lenovo-G575:~/Haskell$ > > > -- in other words, the getLine action is being run before the putStr action, > for some strange reason. > > Is this a bug? Can anyone enlighten me as to what might be going on? > > Regards, > > Matt. > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners ------------------------------ Message: 6 Date: Thu, 7 Jun 2012 12:40:16 +0100 From: Henry Lockyer <henry.lock...@ntlworld.com> Subject: Re: [Haskell-beginners] Strange difference in behaviour between ghc and ghci To: Henry Lockyer <henry.lock...@ntlworld.com> Cc: beginners@haskell.org Message-ID: <46bc0907-01fb-4e3c-a3c5-0445c6593...@ntlworld.com> Content-Type: text/plain; charset=us-ascii in other words, in your version "What's your name?" *has* been put in the IO output buffer but this has not been flushed to the terminal yet. You then input your name (without having seen the prompt you were expecting (yet)) and then the newline of your subsequent putStrLn flushes both bits of output at the same time. On 7 Jun 2012, at 12:32, Henry Lockyer wrote: > A very quick reply and without reading carefully considering what may be > different in GHCI (!), > but the output buffer flushes (at least on my system) with newline (if you > don;t flush it 'manually'). > I suspect if you use putStrLn for 'what's your name' you may get something > more like what you want. > > > On 7 Jun 2012, at 12:22, Matthew Moppett wrote: > >> I have a very simple Haskell file (HelloWorld.hs) that reads like this: >> >> main = do >> putStr "What's your name? " >> n <- getLine >> putStrLn $ "Pleased to meet you, " ++ n >> >> When I load it into ghci, I get the following result, as expected: >> >> [1 of 1] Compiling Main ( HelloWorld.hs, interpreted ) >> Ok, modules loaded: Main. >> *Main> main >> What's your name? Matt >> Pleased to meet you, Matt >> *Main> >> >> However, when I compile the same file using ghc and run it in a terminal, I >> get a very different result: >> >> matt@matt-Lenovo-G575:~/Haskell$ ghc HelloWorld.hs >> [1 of 1] Compiling Main ( HelloWorld.hs, HelloWorld.o ) >> Linking HelloWorld ... >> matt@matt-Lenovo-G575:~/Haskell$ ./HelloWorld >> Matt >> What's your name? Pleased to meet you, Matt >> matt@matt-Lenovo-G575:~/Haskell$ >> >> >> -- in other words, the getLine action is being run before the putStr action, >> for some strange reason. >> >> Is this a bug? Can anyone enlighten me as to what might be going on? >> >> Regards, >> >> Matt. >> _______________________________________________ >> Beginners mailing list >> Beginners@haskell.org >> http://www.haskell.org/mailman/listinfo/beginners > > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners ------------------------------ Message: 7 Date: Thu, 7 Jun 2012 21:52:43 +1000 From: Matthew Moppett <matthewmopp...@gmail.com> Subject: Re: [Haskell-beginners] Strange difference in behaviour between ghc and ghci To: beginners@haskell.org Message-ID: <CAMLEjZARLrkP7ghZDgXvrTdcuzTezF=eu97plwskgp82q82...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" OK -- thanks everybody for your enlightening responses. Regards, Matt. On Thu, Jun 7, 2012 at 9:40 PM, Henry Lockyer <henry.lock...@ntlworld.com>wrote: > in other words, in your version "What's your name?" *has* been put in the > IO output buffer but this has not been flushed > to the terminal yet. You then input your name (without having seen the > prompt you were expecting (yet)) and then > the newline of your subsequent putStrLn flushes both bits of output at the > same time. > > On 7 Jun 2012, at 12:32, Henry Lockyer wrote: > > > A very quick reply and without reading carefully considering what may be > different in GHCI (!), > > but the output buffer flushes (at least on my system) with newline (if > you don;t flush it 'manually'). > > I suspect if you use putStrLn for 'what's your name' you may get > something more like what you want. > > > > > > On 7 Jun 2012, at 12:22, Matthew Moppett wrote: > > > >> I have a very simple Haskell file (HelloWorld.hs) that reads like this: > >> > >> main = do > >> putStr "What's your name? " > >> n <- getLine > >> putStrLn $ "Pleased to meet you, " ++ n > >> > >> When I load it into ghci, I get the following result, as expected: > >> > >> [1 of 1] Compiling Main ( HelloWorld.hs, interpreted ) > >> Ok, modules loaded: Main. > >> *Main> main > >> What's your name? Matt > >> Pleased to meet you, Matt > >> *Main> > >> > >> However, when I compile the same file using ghc and run it in a > terminal, I get a very different result: > >> > >> matt@matt-Lenovo-G575:~/Haskell$ ghc HelloWorld.hs > >> [1 of 1] Compiling Main ( HelloWorld.hs, HelloWorld.o ) > >> Linking HelloWorld ... > >> matt@matt-Lenovo-G575:~/Haskell$ ./HelloWorld > >> Matt > >> What's your name? Pleased to meet you, Matt > >> matt@matt-Lenovo-G575:~/Haskell$ > >> > >> > >> -- in other words, the getLine action is being run before the putStr > action, for some strange reason. > >> > >> Is this a bug? Can anyone enlighten me as to what might be going on? > >> > >> Regards, > >> > >> Matt. > >> _______________________________________________ > >> Beginners mailing list > >> Beginners@haskell.org > >> http://www.haskell.org/mailman/listinfo/beginners > > > > > > _______________________________________________ > > Beginners mailing list > > Beginners@haskell.org > > http://www.haskell.org/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20120607/a9fcd490/attachment.htm> ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 48, Issue 14 *****************************************