Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.haskell.org/cgi-bin/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: Beginners Digest, Vol 100, Issue 20 (Mahdi Dibaiee) 2. Re: Beginners Digest, Vol 100, Issue 20 (Imants Cekusins) 3. Re: Beginners Digest, Vol 100, Issue 19 (Ashish Negi) 4. Re: Beginners Digest, Vol 100, Issue 19 (Norbert Melzer) 5. Re: Beginners Digest, Vol 100, Issue 19 (Matt Williams) ---------------------------------------------------------------------- Message: 1 Date: Sat, 29 Oct 2016 13:18:11 -0400 From: Mahdi Dibaiee <mdiba...@aol.com> To: beginners@haskell.org Subject: Re: [Haskell-beginners] Beginners Digest, Vol 100, Issue 20 Message-ID: <1581172e335-25c9-3...@webstg-a07.mail.aol.com> Content-Type: text/plain; charset="utf-8" That's not generally true (but I will give my guess about your assumption after this). See the example in the article I linked: ``` import Data.Char(toUpper) main = do inpStr <- readFile "input.txt" writeFile "output.txt" (map toUpper inpStr) ``` Here, `inputStr` has to be evaluated in order to run `map toUpper` on it, but it's done character by character. Character is read, `toUpper` is run on it, it's written to the file. (Though it might not be a character unless we use `NoBuffering`, it's going to be lines or blocks) Now, I guess your assumption _might_ be true in my case, because `show` might not be able to generate the string character by character (which is very likely), in this case, show will give us the whole string in one piece, leading to an out-of-memory error as the big string is getting loaded to memory in order to be used by `writeFile`. This is just a guess, I would appreciate it if someone could actually prove it. What do you think Imants? -----Original Message----- From: beginners-request <beginners-requ...@haskell.org> To: beginners <beginners@haskell.org> Sent: Sat, Oct 29, 2016 3:44 pm Subject: Beginners Digest, Vol 100, Issue 20 Send Beginners mailing list submissions to beginners@haskell.orgTo subscribe or unsubscribe via the World Wide Web, visit http://mail.haskell.org/cgi-bin/mailman/listinfo/beginnersor, via email, send a message with subject or body 'help' to beginners-request@haskell.orgYou can reach the person managing the list at beginners-owner@haskell.orgWhen replying, please edit your Subject line so it is more specificthan "Re: Contents of Beginners digest..."Today's Topics: 1. Writing huge result of `show` to file results in out of memory (Mahdi Dibaiee) 2. Re: Writing huge result of `show` to file results in out of memory (Imants Cekusins) Attached Message From Mahdi Dibaiee <mdiba...@aol.com> To beginners@haskell.org Subject [Haskell-beginners] Writing huge result of `show` to file resultsin out of memory Date Fri, 28 Oct 2016 12:57:22 -0400 I know that there are other ways of doing it, I just want to understand where lies the problem here. I just read the realworldhaskell book by O'Reilly, in one section, Lazy I/O [0], it's explained that there should be no problem writing big strings, without consuming the whole string to files, however big they are. I would appreciate it if someone could point out the problem there. Thanks [0]: http://book.realworldhaskell.org/read/io.html#io.lazy Attached Message From Imants Cekusins <ima...@gmail.com> To The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject Re: [Haskell-beginners] Writing huge result of `show` to fileresults in out of memory Date Fri, 28 Oct 2016 19:13:23 +0200 > there should be no problem writing big strings, without consuming the whole > string lazy means evaluated when needed. However when a string is evaluated, it is evaluated fully, I guess. _______________________________________________Beginners mailing listBeginners@haskell.orghttp://mail.haskell.org/cgi-bin/mailman/listinfo/beginners -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20161029/0351055d/attachment-0001.html> ------------------------------ Message: 2 Date: Sat, 29 Oct 2016 19:46:00 +0200 From: Imants Cekusins <ima...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Beginners Digest, Vol 100, Issue 20 Message-ID: <cap1qinbh2xof0xo0f-6dfjzz9fsatdtkr_ilwmhhpc+ycj8...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" here is a very comprehensive explanation of lazy evaluation: https://github.com/takenobu-hs/lazy_evaluation I understand < 5% of this so can't add to it. about your particular problem, I would not try to rely on lazy evaluation (regardless of how it actually works) but instead break data in chunks, serialize and write the chunks to disk using libraries. This should work. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20161029/d552afd8/attachment-0001.html> ------------------------------ Message: 3 Date: Sun, 30 Oct 2016 14:30:27 +0530 From: Ashish Negi <thisismyidash...@gmail.com> To: beginners@haskell.org Subject: Re: [Haskell-beginners] Beginners Digest, Vol 100, Issue 19 Message-ID: <CAMo8VbFKmDesB4ZOYtoiHE0B3NEdCOfFzb4z9F=fnaafspc...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" Can you write your own custom function for converting the data structure to string ? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20161030/f239f630/attachment-0001.html> ------------------------------ Message: 4 Date: Sun, 30 Oct 2016 09:09:43 +0000 From: Norbert Melzer <timmel...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Beginners Digest, Vol 100, Issue 19 Message-ID: <CA+bCVssuu5U-cw0sfQCR-O=nd89cpodzywphng3xx29fjfv...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" When replying to the digest, could you provide more context? Ashish Negi <thisismyidash...@gmail.com> schrieb am So., 30. Okt. 2016 10:00: > Can you write your own custom function for converting the data structure > to string ? > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20161030/64e743ff/attachment-0001.html> ------------------------------ Message: 5 Date: Sun, 30 Oct 2016 09:18:59 +0000 From: Matt Williams <matt.williams45...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Beginners Digest, Vol 100, Issue 19 Message-ID: <caftvgqz6hwudv6m0ovyp4wld_uzr5-bmnmqjlat6wihznoq...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" I suspect you want to provide your own definition of Show. Most tutorials show how to do this. M On Sun, 30 Oct 2016, 09:00 Ashish Negi, <thisismyidash...@gmail.com> wrote: > Can you write your own custom function for converting the data structure > to string ? > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20161030/554aafda/attachment.html> ------------------------------ Subject: Digest Footer _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners ------------------------------ End of Beginners Digest, Vol 100, Issue 21 ******************************************