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: attoparsec and EOF (Arthur Clune) 2. Re: attoparsec and EOF (Arthur Clune) 3. Re: histogram over large data (Rados?aw Szymczyszyn) 4. Re: histogram over large data (Stephen Tetley) 5. Re: histogram over large data (Ian Knopke) 6. graphics.gloss errors (Gregory Guthrie) 7. wxHaskell install errors (Gregory Guthrie) 8. Re: graphics.gloss errors (Brent Yorgey) 9. Re: graphics.gloss errors (Gregory Guthrie) 10. Re: histogram over large data (Stephen Tetley) ---------------------------------------------------------------------- Message: 1 Date: Tue, 5 Jun 2012 15:29:03 +0100 From: Arthur Clune <art...@clune.org> Subject: Re: [Haskell-beginners] attoparsec and EOF To: beginners@haskell.org Message-ID: <CAAa4kjx1T=oMqhFL+a4vzxR61nUea0ETWP+iyX=ozkqnj8o...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 And to answer my own question.....I should use parseOnly. -- Arthur Clune art...@clune.org On Tue, Jun 5, 2012 at 10:56 AM, Arthur Clune <art...@clune.org> wrote: > I'm writing a simple attoparsec parser, which works fine except for > handling end of file: ------------------------------ Message: 2 Date: Tue, 5 Jun 2012 15:42:55 +0100 From: Arthur Clune <art...@clune.org> Subject: Re: [Haskell-beginners] attoparsec and EOF To: beginners@haskell.org Message-ID: <CAAa4kjw0UpB9SFDfGWThaQRPbVW-w7obELuY=qe=dkiubfr...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 And to answer my own question.....I should use parseOnly. -- Arthur Clune art...@clune.org On Tue, Jun 5, 2012 at 10:56 AM, Arthur Clune <art...@clune.org> wrote: > I'm writing a simple attoparsec parser, which works fine except for > handling end of file: ------------------------------ Message: 3 Date: Tue, 5 Jun 2012 20:41:42 +0200 From: Rados?aw Szymczyszyn <lav...@gmail.com> Subject: Re: [Haskell-beginners] histogram over large data To: beginners@haskell.org Message-ID: <CAG=dco3qq++adaxfrytifr0r5qfesc3gsjhghiefzabsheu...@mail.gmail.com> Content-Type: text/plain; charset=UTF-8 Hi Ian, In case you were looking for an example to get your teeth into you might be interested in these: https://gist.github.com/2876666 These two scripts both serve the same purpose of building a map of word counts from a text file. They both use Data.Text for Unicode IO, but each tests a different structure. Though unordered-containers package with its Data.HashMap is often suggested as an efficient mapping structure, in my case (of these two scripts) the Data.HashTable from standard library wins taking circa half the time to run on the same dataset (though it's not purely functional as its actions operate in the IO monad). Finally, what puzzles me the most, is that a roughly equivalent script in Python which just reads the same datafile into a standard dict performs in about 1/3 of the time of the faster one of the above two and Python's hardly a fast language... Bewildering, indeed. Hope I didn't put you off :) ------------------------------ Message: 4 Date: Tue, 5 Jun 2012 21:06:00 +0100 From: Stephen Tetley <stephen.tet...@gmail.com> Subject: Re: [Haskell-beginners] histogram over large data To: Rados?aw Szymczyszyn <lav...@gmail.com> Cc: beginners@haskell.org Message-ID: <CAB2TPRBR9c5b3X5K7aaaHp5sOgJ8TZUeEnkmqSjU83zmJ2f=l...@mail.gmail.com> Content-Type: text/plain; charset=UTF-8 On 5 June 2012 19:41, Rados?aw Szymczyszyn <lav...@gmail.com> wrote: > > Finally, what puzzles me the most, is that a roughly equivalent script > in Python which just reads the same datafile into a standard dict > performs in about 1/3 of the time of the faster one of the above two > and Python's hardly a fast language... Bewildering, indeed. Dicts are efficient in Python though (as they are efficiently implemented in C). Python often seems to beat Haskell in micro-benchmarks that just fill a dictionary then run a simple query / summation on it. ------------------------------ Message: 5 Date: Tue, 5 Jun 2012 21:09:49 +0100 From: Ian Knopke <ian.kno...@gmail.com> Subject: Re: [Haskell-beginners] histogram over large data To: Stephen Tetley <stephen.tet...@gmail.com> Cc: beginners@haskell.org Message-ID: <cac+f4wmk3kovxddjqth79w8diftaqufm3azovlnxmk25pme...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Hi Stephen, I see now I didn't explain myself especially well. One way to build a frequency count in haskell comes from LYAHFGG, chapter 7: ghci> map (\l@(x:xs) -> (x,length l)) . group . sort $ [1,1,1,1,2,2,2,2,3,3,2,2,2,5,6,7] [(1,4),(2,7),(3,2),(5,1),(6,1),(7,1)] my guess would be that the problem with this, unless haskell is a lot more magical than I thought, is that it requires all the entries to be held in memory to do the sort (and then the group I suppose). The database has hundreds of millions of entries. My previous example in perl builds results cumulatively as it retrieves each entry from the db - get_next_from_db() is basically an iterator that returns undef once it runs out of entries (using DBI, which is an SQL wrapper very similar to HDBC. I only wrote it that way to focus on the real problem.) I could also do this in haskell with something like accumArray but it would require a pass through to know what all the possible categorical values are first. Also, if I understand correctly this would also be quite slow. What I'm really looking for is suggestions about the best or idiomatic "haskell" way to cumulatively build these results as it goes along, in a reasonable amount of time. For instance, my knowledge of updatable data structures in haskell isn't very good. Is there something obvious or well-known that I'm overlooking? In general, I'm trying to move my haskell knowledge from toy problem level to being useful for real world problems. Ian On Tue, Jun 5, 2012 at 7:54 AM, Stephen Tetley <stephen.tet...@gmail.com> wrote: > It's likely the while loop can be replaced with a fold which has a Map > (or IntMap if the key is an Int) as the accumulator. For a large Map > you will need to pay attention to inserting elements strictly... > > The more complicated bit is without any extra knowledge about the > implementation of the "database" `get_next_from_db()` is currently > magic. ------------------------------ Message: 6 Date: Tue, 5 Jun 2012 15:23:42 -0500 From: Gregory Guthrie <guth...@mum.edu> Subject: [Haskell-beginners] graphics.gloss errors To: "beginners@haskell.org" <beginners@haskell.org> Message-ID: <08ef9da445c4b5439c4733e1f35705ba01a2767cb...@mail.cs.mum.edu> Content-Type: text/plain; charset="us-ascii" Why do I get this error, when trying the first line example from: http://hackage.haskell.org/packages/archive/gloss/1.0.0.0/doc/html/Graphics-Gloss.html >ghci GHCi, version 7.4.1: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. Prelude> :m Graphics.Gloss Prelude Graphics.Gloss> let main = displayInWindow "My Window" (200, 200) (10, 10) white (Circle 80) <interactive>:4:12: Not in scope: `displayInWindow' Also I notice that cabal shows the current version of GLFW as GLFW-0.5.0.1, But their web-site shows it as 2.7.5 - big difference?! I have: Gloss 1.7.4.1 GLUT 2.3.0.0 GLFW 0.5.0.1 Opengl 2.5.0.0 ------------------------------ Message: 7 Date: Tue, 5 Jun 2012 15:23:15 -0500 From: Gregory Guthrie <guth...@mum.edu> Subject: [Haskell-beginners] wxHaskell install errors To: "beginners@haskell.org" <beginners@haskell.org> Message-ID: <08ef9da445c4b5439c4733e1f35705ba01a2767cb...@mail.cs.mum.edu> Content-Type: text/plain; charset="us-ascii" I had all of the wxHaskell programs installed and working fine, but now with an update to Haskell Platform and thus also ghci, I need to upgrade all of them (the previously working programs fail) requiring an update for the underlying wxWidgets from 2.8 to 2.9 versions. I downloaded and built wxWidgets 2.9, since the current wxHaskell libraries require it (I couldn't find any existing binaries online). The compile seemed to be successful, but when I then try to use it from the wxHaskell programs I get an error that I don't know how to fix: C: >cabal install wx Resolving dependencies... [1 of 1] Compiling Main ( C:\Users\guthrie\AppData\Local\Temp\wxc-0. 90.0.3-7324\wxc-0.90.0.3\Setup.hs, C:\Users\guthrie\AppData\Local\Temp\wxc-0.90. 0.3-7324\wxc-0.90.0.3\dist\setup\Main.o ) Linking C:\Users\guthrie\AppData\Local\Temp\wxc-0.90.0.3-7324\wxc-0.90.0.3\dist\ setup\setup.exe ... Configuring wxc-0.90.0.3... Configuring wxc to build against wxWidgets 2.9 setup.exe: Missing dependencies on foreign libraries: * Missing C libraries: wxmsw29ud_all, wxtiffd, wxjpegd, wxpngd, wxzlibd,wxregexud, wxexpatd, wxregexud This problem can usually be solved by installing the system packages that provide these libraries (you may need the "-dev" versions). If the libraries are already installed but in a non-standard location then you can use the flags --extra-include-dirs= and --extra-lib-dirs= to specify where they are. cabal: Error: some packages failed to install: wx-0.90.0.1 depends on wxc-0.90.0.3 which failed to install. wxc-0.90.0.3 failed during the configure step. The exception was: ExitFailure 1 wxcore-0.90.0.1 depends on wxc-0.90.0.3 which failed to install. ------------------------------ Message: 8 Date: Tue, 5 Jun 2012 16:33:30 -0400 From: Brent Yorgey <byor...@seas.upenn.edu> Subject: Re: [Haskell-beginners] graphics.gloss errors To: beginners@haskell.org Message-ID: <20120605203329.ga11...@seas.upenn.edu> Content-Type: text/plain; charset=us-ascii On Tue, Jun 05, 2012 at 03:23:42PM -0500, Gregory Guthrie wrote: > > Also I notice that cabal shows the current version of GLFW as > GLFW-0.5.0.1, But their web-site shows it as 2.7.5 - big > difference?! I don't know the answer to the question about gloss. But re: the above, note that the version of the GLFW library itself and the version of the Haskell package called GLFW (which provides bindings to the GLFW library) are completely different things. 0.5.0.1 appears to be the latest version of the Haskell package. -Brent ------------------------------ Message: 9 Date: Tue, 5 Jun 2012 15:36:36 -0500 From: Gregory Guthrie <guth...@mum.edu> Subject: Re: [Haskell-beginners] graphics.gloss errors To: "beginners@haskell.org" <beginners@haskell.org> Message-ID: <08ef9da445c4b5439c4733e1f35705ba01a2767cb...@mail.cs.mum.edu> Content-Type: text/plain; charset="us-ascii" Apparently I needed to upgrade my examples, the API seems to have changed across versions. ------------------------------------------- > Subject: graphics.gloss errors > > Why do I get this error, when trying the first line example from: > > http://hackage.haskell.org/packages/archive/gloss/1.0.0.0/doc/html/Graphics-Gloss.html > > >ghci > GHCi, version 7.4.1: http://www.haskell.org/ghc/ :? for help Loading package > ghc-prim ... > linking ... done. > Loading package integer-gmp ... linking ... done. > Loading package base ... linking ... done. > Prelude> :m Graphics.Gloss > Prelude Graphics.Gloss> let main = displayInWindow "My Window" (200, 200) > (10, 10) white > (Circle 80) > <interactive>:4:12: Not in scope: `displayInWindow' > > Also I notice that cabal shows the current version of GLFW as GLFW-0.5.0.1, > But their > web-site shows it as 2.7.5 - big difference?! > > I have: > Gloss 1.7.4.1 > GLUT 2.3.0.0 > GLFW 0.5.0.1 > Opengl 2.5.0.0 ------------------------------ Message: 10 Date: Tue, 5 Jun 2012 21:48:38 +0100 From: Stephen Tetley <stephen.tet...@gmail.com> Subject: Re: [Haskell-beginners] histogram over large data To: Ian Knopke <ian.kno...@gmail.com> Cc: beginners@haskell.org Message-ID: <cab2tprbuezuuouj96d2tsxntfvgrp7973tacrudgcy9m849...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Hi Ian You really don't want to use a sort as it needs the whole list in memory (or length as that counts its way through a list...). If your data is integers and sparse - IntMap (provided you don't overflow Int size) or the HashMaps suggested by Radoslaw should work. If the data isn't sparse there are mutable arrays or (probably) Data.Vector - I haven't got round to using the latter yet so can't really comment on its suitability with respect to mutability. If your data isn't integers you need to work out how to make a good key from it so you can map key to count. You can "fold" a Map or mutable array through a traversal of the data - lists provide the usual fold (foldr) but if you have data stored in a database there should be libraries for folding with an "iteraratee" - again I haven't got round to using any of the iteratee packages yet so couldn't comment on which one is the most appropriate. Best wishes Stephen ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 48, Issue 5 ****************************************