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. Re: SOLVED - Stack overflow, but hard to understand (Magnus Therning) 2. Re: SOLVED - Stack overflow, but hard to understand (Michael Mossey) 3. Haskell Output Help (Chandni Navani) 4. Re: Haskell Output Help (aditya siram) 5. Re: Haskell Output Help (aditya siram) 6. how to set command args in ghci (Kui Ma) 7. Re: how to set command args in ghci (Yusaku Hashimoto) 8. Re: how to set command args in ghci (Yusaku Hashimoto) ---------------------------------------------------------------------- Message: 1 Date: Wed, 21 Oct 2009 16:49:23 +0100 From: Magnus Therning <mag...@therning.org> Subject: Re: [Haskell-beginners] SOLVED - Stack overflow, but hard to understand To: Michael Mossey <m...@alumni.caltech.edu> Cc: beginners@haskell.org Message-ID: <e040b520910210849j4af70f45q540f57ffc3c63...@mail.gmail.com> Content-Type: text/plain; charset=UTF-8 On Wed, Oct 21, 2009 at 9:44 AM, Michael Mossey <m...@alumni.caltech.edu> wrote: > > > Magnus Therning wrote: >> >> On 20/10/09 20:32, Michael Mossey wrote: >>> >>> Okay, I figured this out. mapM is not lazy, at least not for a monad that >>> has state and under the circumstance you demand the state out the other >>> side. >> >> If I understand what you are saying then this behaviour isn't unexpected. >> Â If >> you have a monad with state, and you ask for the final state, then it's >> likely >> that everything happening in that particular monad will has to be >> evaluated. > > Hi Magnus, > > Yes, that's what I was trying to imply. I realized it is mathematically > impossible for mapM to be lazy for a monad with state. > > mapM doesn't seem to be lazy anywhere. For example, this program > > main = do > Â buffers <- forM ["file1.txt","file2.txt","file3.txt"] readFile > Â print . take 1 . concat $ buffers > > will, according to my experiments with the profiler, read all three files. > It's possible to imagine lazy behavior here, but no doubt there is a > technical reason against it. Laziness in combination with IO is a difficult thing. Just search the archives to see the number of threads about it. >>> I may rewrite the program. Or I may consider the ISS principle. >>> ("Increase the stack, stupid.") >> >> You may also be able to improve the situation by adding a bit of >> strictness. >> In some cases the thunks resulting from laziness can take up a lot of >> space. >> Forcing evaluation, at well thought out locations in your program, may >> both >> speed things up and reduce memory/stack usage. > > You are probably right... I am having trouble spanning the gap between "my > current understanding" and "well thought-out locations." Real World Haskell > has a chapter on this, so I may look there. > > I was able to get the program to run by removing all places that I had > created a chain of Rand computations that forced evaluation of the last one. > I replaced these with computations that did not require evaluation of the > last one. > > However, my program was still forced to read more files than it really > needed in the end, as the above snippet demonstrates. Just out of curiosity, did you verify that all three files were completely *read*, as opposed to all three opened, but only the first line of the first file being read? /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnusï¼ therningï¼org Jabber: magnusï¼ therningï¼org http://therning.org/magnus identi.ca|twitter: magthe ------------------------------ Message: 2 Date: Wed, 21 Oct 2009 12:46:55 -0700 From: Michael Mossey <m...@alumni.caltech.edu> Subject: Re: [Haskell-beginners] SOLVED - Stack overflow, but hard to understand To: beginners <beginners@haskell.org> Message-ID: <4adf652f.3040...@alumni.caltech.edu> Content-Type: text/plain; charset=UTF-8; format=flowed Magnus Therning wrote: > > Just out of curiosity, did you verify that all three files were > completely *read*, as opposed to all three opened, but only the first > line of the first file being read? > > /M > Actually, no I didn't verify that, in this example. I was thinking about my other program in which I used mapM over the characters of the file onto a Rand monad. That one definitely read all the characters of the file---certain processing routines were called about 30,000 times (according to the profiler). This makes sense to me now, because I was asking for the state out the other side of the mapM. Thanks, Mike ------------------------------ Message: 3 Date: Thu, 22 Oct 2009 12:11:07 -0700 (PDT) From: Chandni Navani <chandni...@yahoo.com> Subject: [Haskell-beginners] Haskell Output Help To: beginners@haskell.org Message-ID: <334456.88538...@web51608.mail.re2.yahoo.com> Content-Type: text/plain; charset="iso-8859-1" I have a list of lists which all contain strings. [[String]]. I need to figure out how to print them so that after each individual string, there is a new line. If this is the initial list [["abc", "cde"] ["fgh", "ghi"]] [["abc" "cde"] ["fgh", "ghi"]] Can anyone help me figure this out? Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20091022/0f4da085/attachment-0001.html ------------------------------ Message: 4 Date: Thu, 22 Oct 2009 21:53:57 -0500 From: aditya siram <aditya.si...@gmail.com> Subject: Re: [Haskell-beginners] Haskell Output Help To: chandni...@yahoo.com Cc: beginners@haskell.org Message-ID: <594f78210910221953n2268a74cl51dee946fb610...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" Is this what you need? print $ foldl (++) [] [["abc", "cde"], ["fgh", "ghi"]] -deech On Thu, Oct 22, 2009 at 2:11 PM, Chandni Navani <chandni...@yahoo.com>wrote: > I have a list of lists which all contain strings. [[String]]. I need to > figure out how to print them so that after each individual string, there is > a new line. > > If this is the initial list [["abc", "cde"] ["fgh", "ghi"]] > [["abc" > "cde"] > ["fgh", > "ghi"]] > > Can anyone help me figure this out? Thanks. > > > > > > _______________________________________________ > 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/20091022/8b5bff23/attachment-0001.html ------------------------------ Message: 5 Date: Thu, 22 Oct 2009 21:59:22 -0500 From: aditya siram <aditya.si...@gmail.com> Subject: Re: [Haskell-beginners] Haskell Output Help To: chandni...@yahoo.com Cc: beginners@haskell.org Message-ID: <594f78210910221959o7c98fbfo78eec42f915a7...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" Sorry, forgot about the newline. How's this? mapM putStrLn $ concat [["abc", "cde"], ["fgh", "ghi"]] -deech On Thu, Oct 22, 2009 at 9:53 PM, aditya siram <aditya.si...@gmail.com>wrote: > Is this what you need? > > print $ foldl (++) [] [["abc", "cde"], ["fgh", "ghi"]] > > -deech > > On Thu, Oct 22, 2009 at 2:11 PM, Chandni Navani <chandni...@yahoo.com>wrote: > >> I have a list of lists which all contain strings. [[String]]. I need to >> figure out how to print them so that after each individual string, there is >> a o line. >> >> If this is the initial list [["abc", "cde"] ["fgh", "ghi"]] >> [["abc" >> "cde"] >> ["fgh", >> "ghi"]] >> >> Can anyone help me figure this out? Thanks. >> >> >> >> >> >> _______________________________________________ >> 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/20091022/9bd05e2e/attachment-0001.html ------------------------------ Message: 6 Date: Fri, 23 Oct 2009 17:59:51 +0800 From: Kui Ma <mkl...@hotmail.com> Subject: [Haskell-beginners] how to set command args in ghci To: <beginners@haskell.org> Message-ID: <blu138-w12ee640972829a4d6a5e8dc9...@phx.gbl> Content-Type: text/plain; charset="gb2312" Is it possible to set the Command Arguments when running the main function in ghci? Thanks, Kui _________________________________________________________________ Windows Live: Friends get your Flickr, Yelp, and Digg updates when they e-mail you. http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_3:092010 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20091023/dcbc1c63/attachment-0001.html ------------------------------ Message: 7 Date: Fri, 23 Oct 2009 19:40:46 +0900 From: Yusaku Hashimoto <nonow...@gmail.com> Subject: Re: [Haskell-beginners] how to set command args in ghci To: Kui Ma <mkl...@hotmail.com> Cc: beginners@haskell.org Message-ID: <d17c24b90910230340w653f4798l3a57d6b69bb0c...@mail.gmail.com> Content-Type: text/plain; charset=UTF-8 :set args foo bar should work. FYI, type :? to ghci to see all commands. HTH -nwn 2009/10/23 Kui Ma <mkl...@hotmail.com>: > Is it possible to set the Command Arguments when running the main function > in ghci? > > Thanks, > Kui > > > > ________________________________ > Windows Live: Friends get your Flickr, Yelp, and Digg updates when they > e-mail you. > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners > > ------------------------------ Message: 8 Date: Fri, 23 Oct 2009 19:43:22 +0900 From: Yusaku Hashimoto <nonow...@gmail.com> Subject: Re: [Haskell-beginners] how to set command args in ghci To: Kui Ma <mkl...@hotmail.com> Cc: beginners@haskell.org Message-ID: <d17c24b90910230343w1a24acaer8f318538fc416...@mail.gmail.com> Content-Type: text/plain; charset=UTF-8 or :ma foo bar On Fri, Oct 23, 2009 at 7:40 PM, Yusaku Hashimoto <nonow...@gmail.com> wrote: > :set args foo bar > > should work. FYI, type :? to ghci to see all commands. > > HTH > > -nwn > > 2009/10/23 Kui Ma <mkl...@hotmail.com>: >> Is it possible to set the Command Arguments when running the main function >> in ghci? >> >> Thanks, >> Kui >> >> >> >> ________________________________ >> Windows Live: Friends get your Flickr, Yelp, and Digg updates when they >> e-mail you. >> _______________________________________________ >> 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 End of Beginners Digest, Vol 16, Issue 17 *****************************************