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: Lazy vs Strict ponderings... (Heinrich Apfelmus) 2. haskell install on low memory server? (Rob Nikander) 3. Re: haskell install on low memory server? (Felipe Almeida Lessa) 4. Re: haskell install on low memory server? (Rob Nikander) 5. Re: haskell install on low memory server? (Felipe Almeida Lessa) 6. Re: haskell install on low memory server? (Daniel Fischer) 7. Re: Using Iteratees to write to a file (Magnus Therning) 8. Re: haskell install on low memory server? (Rob Nikander) ---------------------------------------------------------------------- Message: 1 Date: Sat, 19 Mar 2011 12:50:18 +0100 From: Heinrich Apfelmus <apfel...@quantentunnel.de> Subject: Re: [Haskell-beginners] Lazy vs Strict ponderings... To: beginners@haskell.org Message-ID: <im259q$78c$1...@dough.gmane.org> Content-Type: text/plain; charset=UTF-8; format=flowed Sean Charles wrote: > I *think* I understand about lazy evaluation and its effects on I/O and > that it can internally create thunks, promises, continuations etc. > whatever you want to call them, and then at some point there will be a > sudden spike in memory and CPU loads as something triggers a whole chain > of promises to be fulfilled but what I don't have a feel for is just how > serious a problem that might be today in say, a simple desktop application. > > [...] > > Is it something one needs to worry about at all or should one just code > away and write the application and then worry!? > > I think that having a clearer understanding of what 'types' of problems > and their implementations have on CPU/RAM would be a good one to have! The practitioner's approach to laziness is usually the following sequence of approximations, which could be called "the lazy approach to laziness": 0) Don't worry about performance. Write programs that are correct instead. Laziness helps a lot with writing clean and compositional code. Example: zipWith (,) [1..] xs 1) Look out for common laziness gotchas. There are essentially only two of them: i) Unevaluated expressions that take way more space than their evaluated forms. Prototypical example foldl (+) [1..n] ii) Memory leaks due to sharing. Prototypical example average xs = sum xs / length xs 2) Don't worry about memory leaks until they actually appear. If they do, use a profiling tool to find out what's going on. Most likely, one of the two things above happened in an interesting way. Note that you might want to be a bit more careful when writing a real time system. In that case, would suggest to only use abstractions whose performance is easy to reason about and to keep the core code fairly small, so that you have a clear picture of what is going on. Other than that, there is no need to worry about garbage collection or laziness. Regards, Heinrich Apfelmus -- http://apfelmus.nfshost.com ------------------------------ Message: 2 Date: Sat, 19 Mar 2011 10:14:31 -0400 From: Rob Nikander <rob.nikan...@gmail.com> Subject: [Haskell-beginners] haskell install on low memory server? To: beginners@haskell.org Message-ID: <AANLkTim2=wt4rmd-uy1v9w-yp+tgdb+cr+ycewqth...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Hi, I'd like to install Haskell on a linux virtual server with about 600 MB of RAM. (Maybe that is doomed to failure?) The goal is to try "happstack" for web apps, behind nginx. Compiling the whole platform is asking for OpenGL... so I thought I would get cabal and install pieces that I want. I downloaded the 'generic ghc binary' from here: http://hackage.haskell.org/platform/linux.html and that seems to work. But when I download the cabal-install tarball and try to run it's 'bootstrap.sh' I run out of memory. Is there a way to tell it to use less memory? ------- shell commands ------- $ cd cabal-install-0.10.2 $ sh bootstrap.sh Checking installed packages for ghc-7.0.2... Cabal is already installed and the version is ok. transformers-0.2.2.0 will be downloaded and installed. mtl-2.0.1.0 will be downloaded and installed. parsec-3.1.1 will be downloaded and installed. network-2.3.0.2 will be downloaded and installed. time is already installed and the version is ok. HTTP-4000.1.1 will be downloaded and installed. zlib-0.5.3.1 will be downloaded and installed. Downloading transformers-0.2.2.0... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 17148 100 17148 0 0 27246 0 --:--:-- --:--:-- --:--:-- 39420 [1 of 1] Compiling Main ( Setup.hs, Setup.o ) Linking Setup ... collect2: ld terminated with signal 9 [Killed] Error during cabal-install bootstrap: Compiling the Setup script failed ------- end of shell commands ------- It seems strange that `ld` would need to use ~450 MB, which is what it's doing to get killed by the kernel. Any ideas? thanks, Rob ------------------------------ Message: 3 Date: Sat, 19 Mar 2011 14:25:21 +0000 From: Felipe Almeida Lessa <felipe.le...@gmail.com> Subject: Re: [Haskell-beginners] haskell install on low memory server? To: Rob Nikander <rob.nikan...@gmail.com> Cc: beginners@haskell.org Message-ID: <AANLkTi=eh3q+ggshmp5mpry7jogdrt9aupfx-py0a...@mail.gmail.com> Content-Type: text/plain; charset=UTF-8 On Sat, Mar 19, 2011 at 2:14 PM, Rob Nikander <rob.nikan...@gmail.com> wrote: > Hi, > > I'd like to install Haskell on a linux virtual server with about 600 > MB of RAM. ?(Maybe that is doomed to failure?) ?The goal is to try > "happstack" for web apps, behind nginx. ?Compiling the whole platform > is asking for OpenGL... so I thought I would get cabal and install > pieces that I want. ?I downloaded the 'generic ghc binary' from here: > http://hackage.haskell.org/platform/linux.html and that seems to work. > ?But when I download the cabal-install tarball and try to run it's > 'bootstrap.sh' I run out of memory. ?Is there a way to tell it to use > less memory? You don't really need to compile GHC by yourself on the memory constrained machine. First of all, you may use a binary distribution. And second, you may compile on a different machine with more RAM. That said, compiling Haskell programs on such low memory computers isn't really difficult, provided your program isn't as big as GHC. I've been succesfully using an AWS micro instance with 595 MiB of RAM and an Yesod app. (But I have some swap memory should it be needed.) HTH, =) -- Felipe. ------------------------------ Message: 4 Date: Sat, 19 Mar 2011 10:41:50 -0400 From: Rob Nikander <rob.nikan...@gmail.com> Subject: Re: [Haskell-beginners] haskell install on low memory server? To: Felipe Almeida Lessa <felipe.le...@gmail.com> Cc: beginners@haskell.org Message-ID: <AANLkTikO1zDVhn9hJxROpEhfzCcQfav-KC85NJSA=s...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 On Sat, Mar 19, 2011 at 10:25 AM, Felipe Almeida Lessa <felipe.le...@gmail.com> wrote: > On Sat, Mar 19, 2011 at 2:14 PM, Rob Nikander <rob.nikan...@gmail.com> wrote: >> ... >> is asking for OpenGL... so I thought I would get cabal and install >> pieces that I want. ?I downloaded the 'generic ghc binary' from here: >> http://hackage.haskell.org/platform/linux.html and that seems to work. >> ?But when I download the cabal-install tarball and try to run it's >> 'bootstrap.sh' I run out of memory. ?Is there a way to tell it to use >> less memory? > > You don't really need to compile GHC by yourself on the memory > constrained machine. ?First of all, you may use a binary distribution. > ?And second, you may compile on a different machine with more RAM. But I'm not compiling GHC, am I? I downloaded the binary, and it works. I thought I was trying to install cabal, because I don't see it included in the GHC binaries. >From the error message in my previous email, it looks like it dies trying to compile "transformers". I also have a Micro EC2 instance. If there was a 'yum' haskell package for this "Amazon Linux" I'd use that, but I don't see one. thanks, Rob ------------------------------ Message: 5 Date: Sat, 19 Mar 2011 15:02:15 +0000 From: Felipe Almeida Lessa <felipe.le...@gmail.com> Subject: Re: [Haskell-beginners] haskell install on low memory server? To: Rob Nikander <rob.nikan...@gmail.com> Cc: beginners@haskell.org Message-ID: <aanlktinz2lm40pvm8upjjfmoy9aoehrz8rqivyf+o...@mail.gmail.com> Content-Type: text/plain; charset=UTF-8 On Sat, Mar 19, 2011 at 2:41 PM, Rob Nikander <rob.nikan...@gmail.com> wrote: > But I'm not compiling GHC, am I? ?I downloaded the binary, and it > works. ?I thought I was trying to install cabal, because I don't see > it included in the GHC binaries. I think I have misunderstood your snippet. =) > From the error message in my previous email, it looks like it dies > trying to compile "transformers". Yes, that seems so. > I also have a Micro EC2 instance. ?If there was a 'yum' haskell > package for this "Amazon Linux" I'd use that, but I don't see one. I have installed Ubuntu on my micro instance and downloaded GHC from there. However I've installed many other packages through cabal. Perhaps the difference is the swap file? You may try # dd if=/dev/zero of=/tmp/swap bs=1M count=1024 # mkswap /tmp/swap # swapon /tmp/swap HTH, =) -- Felipe. ------------------------------ Message: 6 Date: Sat, 19 Mar 2011 16:11:21 +0100 From: Daniel Fischer <daniel.is.fisc...@googlemail.com> Subject: Re: [Haskell-beginners] haskell install on low memory server? To: beginners@haskell.org Message-ID: <201103191611.21851.daniel.is.fisc...@googlemail.com> Content-Type: Text/Plain; charset="iso-8859-1" On Saturday 19 March 2011 15:14:31, Rob Nikander wrote: > Hi, > > I'd like to install Haskell on a linux virtual server with about 600 > MB of RAM. (Maybe that is doomed to failure?) The goal is to try > "happstack" for web apps, behind nginx. Compiling the whole platform > is asking for OpenGL... so I thought I would get cabal and install > pieces that I want. I downloaded the 'generic ghc binary' from here: > http://hackage.haskell.org/platform/linux.html and that seems to work. > But when I download the cabal-install tarball and try to run it's > 'bootstrap.sh' I run out of memory. Is there a way to tell it to use > less memory? > > ------- shell commands ------- > > $ cd cabal-install-0.10.2 > $ sh bootstrap.sh > Checking installed packages for ghc-7.0.2... > Cabal is already installed and the version is ok. > transformers-0.2.2.0 will be downloaded and installed. > mtl-2.0.1.0 will be downloaded and installed. > parsec-3.1.1 will be downloaded and installed. > network-2.3.0.2 will be downloaded and installed. > time is already installed and the version is ok. > HTTP-4000.1.1 will be downloaded and installed. > zlib-0.5.3.1 will be downloaded and installed. > > Downloading transformers-0.2.2.0... > % Total % Received % Xferd Average Speed Time Time Time > Current Dload Upload Total Spent Left Speed 100 17148 100 > 17148 0 0 27246 0 --:--:-- --:--:-- --:--:-- 39420 [1 of > 1] Compiling Main ( Setup.hs, Setup.o ) > Linking Setup ... > collect2: ld terminated with signal 9 [Killed] That means it's OOM-killed while linking the setup script? That should not be (nor should it be OOM when compiling any of those packages). Although, I just tested and linking the default Setup.hs used 300MB here, so 450MB is not impossible. There's a lot to link in from the Cabal library, perhaps also the ghc-api (the unstripped executable was 5.6MB, which is surprisingly huge, the stripped is still 3.1MB, normally executables are smaller). > > Error during cabal-install bootstrap: > Compiling the Setup script failed > > ------- end of shell commands ------- > > It seems strange that `ld` would need to use ~450 MB, which is what > it's doing to get killed by the kernel. > > Any ideas? You could try installing them (and afterwards cabal-install) the old way, $ runghc ./Setup.hs configure --user $ runghc ./Setup.hs build $ runghc ./Setup.hs install But if ghc is killed linking the default setup script, it will probably get killed each time you try to cabal install a package because that involves linking a setup script. > > thanks, > Rob ------------------------------ Message: 7 Date: Sat, 19 Mar 2011 16:29:54 +0000 From: Magnus Therning <mag...@therning.org> Subject: Re: [Haskell-beginners] Using Iteratees to write to a file To: beginners@haskell.org Message-ID: <20110319162954.GB7489@ohann> Content-Type: text/plain; charset="us-ascii" On Sat, Mar 19, 2011 at 01:01:46AM -0700, Richard Wallace wrote: > Hello everyone, > > I've been reading "Iteratee: Teaching an Old Fold New Tricks" from > the Monad Reader Issue 16 and am having a problem figuring out how > to use the streamToFile function. Specifically, I can't figure out > how to feed the Iteratee data to write to the file. If I run > > ghci> runIter $ streamToFile "/tmp/stream" > > Then the file is created but not populated with any data - which is > natural since I didn't give it any data. I have no clue how to give > it data though. I'd really appreciate it if someone could show me > how to write "Hello world!" or something else equally mundane to get > me going. I've been banging my head on this for hours now. I think you need to get your data from somewhere, an Enumerator, e.g. an Enumerator for a file handle. I haven't looked at the Iteratee API for a while, but I believe that an Enumerator basically is of the type Iteratee -> Iteratee, which means that something along the lines of runIter $ enumerateHandle h (streamToFile "/tmp/stream") ought to copy the content of the handle into the file. The documentation for Enumerator[1] is an excellent resource for understanding iteratees. Even if you don't plan on using the Enumerator package itself. /M [1] http://hackage.haskell.org/package/enumerator -- Magnus Therning OpenPGP: 0xAB4DFBA4 email: mag...@therning.org jabber: mag...@therning.org twitter: magthe http://therning.org/magnus Most software today is very much like an Egyptian pyramid with millions of bricks piled on top of each other, with no structural integrity, but just done by brute force and thousands of slaves. -- Alan Kay -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: not available URL: <http://www.haskell.org/pipermail/beginners/attachments/20110319/fa142eda/attachment-0001.pgp> ------------------------------ Message: 8 Date: Sat, 19 Mar 2011 13:17:39 -0400 From: Rob Nikander <rob.nikan...@gmail.com> Subject: Re: [Haskell-beginners] haskell install on low memory server? To: Felipe Almeida Lessa <felipe.le...@gmail.com> Cc: beginners@haskell.org Message-ID: <aanlktikpfjeqsnurvwhhpnunb6epu512+l6uvygfu...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 On Sat, Mar 19, 2011 at 11:02 AM, Felipe Almeida Lessa <felipe.le...@gmail.com> wrote: > You may try > > # dd if=/dev/zero of=/tmp/swap bs=1M count=1024 > # mkswap /tmp/swap > # swapon /tmp/swap Thanks, with the swap space it is now compiling. Rob ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 33, Issue 26 *****************************************