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. Integer performance of GHC (Sebasti?n E. Peyrott) 2. Re: mayBe stuck (prad) 3. Re: Integer performance of GHC (Brandon S Allbery KF8NH) 4. Re: Integer performance of GHC (Sebasti?n E. Peyrott) 5. Re: mayBe stuck (Dean Herington) 6. Re: Integer performance of GHC (David Virebayre) 7. Re: Re: mayBe stuck (Brent Yorgey) 8. Foreign function interface? (Mathew de Detrich) 9. Re: Foreign function interface? (Mathew de Detrich) ---------------------------------------------------------------------- Message: 1 Date: Sat, 7 Aug 2010 00:32:23 -0300 From: Sebasti?n E. Peyrott <pse...@gmail.com> Subject: [Haskell-beginners] Integer performance of GHC To: beginners@haskell.org Message-ID: <aanlkti=hk_uexvop=chnwq8d1zm494ewby80zdjro...@mail.gmail.com> Content-Type: text/plain; charset=UTF-8 Hi, I'm looking for information on Haskell's viability for heavy integer math. My (very) naive tests show Haskell lagging behind C even when doing heavy (manual) inlining, compiling with special optimizations (funbox-strict-fields) and using continuation-passing-style when possible. Of course, being a beginner myself, I don't really know how good my code is. For reference, I wrote a simple MD5 implementation. It's as fast as the one in Happstack (Happstack.Crypto.MD5), which on my computer runs around 2.77 times slower then the base version from GNU coreutils (md5sum). GHC primitives appear as the next logical step in my tests, however I've been having problems using fixed sizes for integers (Word32# comes with no prim-ops defined?). Do you have any insights on this? Is it reasonable to expect Haskell integer performance to reach the levels of C with current implementations? Which are the limiting factors? Thanks! ------------------------------ Message: 2 Date: Fri, 6 Aug 2010 21:06:24 -0700 From: prad <p...@towardsfreedom.com> Subject: [Haskell-beginners] Re: mayBe stuck To: beginners@haskell.org Message-ID: <20100806210624.630ca...@gom> Content-Type: text/plain; charset=US-ASCII On Fri, 6 Aug 2010 13:38:56 +0100 Brent Yorgey <byor...@seas.upenn.edu> wrote: > you shift the burden of proving that it is safe from the compiler > onto yourself > ... > Here are some off the top of my head, for > beginners reading this who might not already know: > > fromJust > head > tail > init > last > (!!) > i'm trying to follow this conversation. the problem is that some of these functions don't behave nicely for some inputs right? like tail [] also, is it better to use pattern matching (x:xs) than head and tail? could that be part of the point here too? -- In friendship, prad ... with you on your journey Towards Freedom http://www.towardsfreedom.com (website) Information, Inspiration, Imagination - truly a site for soaring I's ------------------------------ Message: 3 Date: Sat, 07 Aug 2010 00:09:22 -0400 From: Brandon S Allbery KF8NH <allb...@ece.cmu.edu> Subject: Re: [Haskell-beginners] Integer performance of GHC To: beginners@haskell.org Message-ID: <4c5cdc72.8020...@ece.cmu.edu> Content-Type: text/plain; charset=UTF-8 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 8/6/10 23:32 , Sebastián E. Peyrott wrote: > Do you have any insights on this? Is it reasonable to expect Haskell > integer performance to reach the levels of C with current > implementations? Which are the limiting factors? Integer, or Int? In theory Integer should use Int when possible under the covers, but that may not always do what you expect --- and Integer, being arbitrary precision, will never be as fast as native Int math. - -- brandon s. allbery [linux,solaris,freebsd,perl] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.10 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkxc3HIACgkQIn7hlCsL25VWIgCePL5sZCEL87WWoVQXJIUlgC1d PUwAmQEqtanpLJHa7amkz7GP9qH5rkBg =SoCp -----END PGP SIGNATURE----- ------------------------------ Message: 4 Date: Sat, 7 Aug 2010 01:40:25 -0300 From: Sebasti?n E. Peyrott <pse...@gmail.com> Subject: Re: [Haskell-beginners] Integer performance of GHC To: beginners@haskell.org Message-ID: <aanlktimggvb-x95a0wgqktruexsqc03q2sfcyjbmv...@mail.gmail.com> Content-Type: text/plain; charset=UTF-8 I meant fixed precision integers (such as Int). Sorry I wasn't clear about that. On Sat, Aug 7, 2010 at 1:09 AM, Brandon S Allbery KF8NH <allb...@ece.cmu.edu> wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On 8/6/10 23:32 , Sebastián E. Peyrott wrote: >> Do you have any insights on this? Is it reasonable to expect Haskell >> integer performance to reach the levels of C with current >> implementations? Which are the limiting factors? > > Integer, or Int?  In theory Integer should use Int when possible under the > covers, but that may not always do what you expect --- and Integer, being > arbitrary precision, will never be as fast as native Int math. > > - -- > brandon s. allbery   [linux,solaris,freebsd,perl]   >  allb...@kf8nh.com > system administrator  [openafs,heimdal,too many hats]  allb...@ece.cmu.edu > electrical and computer engineering, carnegie mellon university    KF8NH > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v2.0.10 (Darwin) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ > > iEYEARECAAYFAkxc3HIACgkQIn7hlCsL25VWIgCePL5sZCEL87WWoVQXJIUlgC1d > PUwAmQEqtanpLJHa7amkz7GP9qH5rkBg > =SoCp > -----END PGP SIGNATURE----- > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners > ------------------------------ Message: 5 Date: Sat, 7 Aug 2010 02:05:54 -0400 From: Dean Herington <heringtonla...@mindspring.com> Subject: [Haskell-beginners] Re: mayBe stuck To: prad <p...@towardsfreedom.com>, beginners@haskell.org Message-ID: <a06240800c882a69f5...@[10.0.1.4]> Content-Type: text/plain; charset="us-ascii" ; format="flowed" At 11:04 AM -0700 8/6/10, prad wrote: >On Fri, 6 Aug 2010 03:43:30 -0400 >Dean Herington <heringtonla...@mindspring.com> wrote: > >> I would write something like: >> >> br [] = [] >> br ss = let (h, t) = break eqD ss >> in h : case t of >> [] -> [] >> _ : t -> br t >> >thx dean. that certainly looks cleaner than mine, but i'm not sure i >have seen this construct before. > >i thought let/in was used like this: > >aaa = let y = 1+2 > z = 4+6 > in y+z > >which is like > >aaa = y + z > where y = 1+2 > z = 4+6 > >in other words, you just define the parts first and use the "in" to >define the main expression. > >but here it seems you are defining what appears to be the main item >let (h,t) = break eqD ss >to get the tuple parts and then forming your array (which really is >the main item) using these parts as >h : t >with t being given 2 options. > >this is very interesting to me as i had not seen such a construct >before. Choosing between `let` and `where` is usually a matter of taste. I use both, depending on whether I think it's clearer to present the logic "bottom-up" or "top-down". Here's the `where`-style equivalent of the `let` version: br [] = [] br ss = h : case t of [] -> [] _ : t' -> br t' where (h, t) = break eqD ss For a reason I probably can't articulate well, I find the `let` version more readable in this case. Perhaps it's because I understand the function as (1) `break`ing on '%', then (2) dealing with the details of recursing. Cheers, Dean ------------------------------ Message: 6 Date: Sat, 7 Aug 2010 08:59:17 +0200 From: David Virebayre <dav.vire+hask...@gmail.com> Subject: Re: [Haskell-beginners] Integer performance of GHC To: Sebasti?n E. Peyrott <pse...@gmail.com> Cc: beginners@haskell.org Message-ID: <aanlktimcqpxpt2ozgpw6dr6dcmddylp4gsayvsz5j...@mail.gmail.com> Content-Type: text/plain; charset=UTF-8 2010/8/7 Sebastián E. Peyrott <pse...@gmail.com>: > Hi, I'm looking for information on Haskell's viability for heavy > integer math. My (very) naive tests show Haskell lagging behind C even Relevant links : Benefits of the LLVM code generator (lots of other relevant posts on Dons' blog) http://donsbot.wordpress.com/2010/02/21/smoking-fast-haskell-code-using-ghcs-new-llvm-codegen/ Archive of threads about loop unrolling : http://www.haskell.org/pipermail/glasgow-haskell-users/2009-March/thread.html#16741 (Also check some of the links in "You might also be interested in:") http://efreedom.com/Question/1-2978979/Haskell-math-performance David. ------------------------------ Message: 7 Date: Sat, 7 Aug 2010 09:26:10 +0100 From: Brent Yorgey <byor...@seas.upenn.edu> Subject: Re: [Haskell-beginners] Re: mayBe stuck To: beginners@haskell.org Message-ID: <20100807082609.ga27...@seas.upenn.edu> Content-Type: text/plain; charset=us-ascii On Fri, Aug 06, 2010 at 09:06:24PM -0700, prad wrote: > On Fri, 6 Aug 2010 13:38:56 +0100 > Brent Yorgey <byor...@seas.upenn.edu> wrote: > > > > you shift the burden of proving that it is safe from the compiler > > onto yourself > > ... > > Here are some off the top of my head, for > > beginners reading this who might not already know: > > > > fromJust > > head > > tail > > init > > last > > (!!) > > > i'm trying to follow this conversation. the problem is that some of > these functions don't behave nicely for some inputs right? like tail [] All of these functions are "partial", which means that they are undefined (crash with an error) for some inputs. If possible you should try to program only with "total" functions (functions which are defined for every input) since then you know your program will not crash. > > also, is it better to use pattern matching (x:xs) than head and tail? > could that be part of the point here too? Yes, that's exactly right. -Brent ------------------------------ Message: 8 Date: Sat, 7 Aug 2010 19:21:44 +1000 From: Mathew de Detrich <dete...@gmail.com> Subject: [Haskell-beginners] Foreign function interface? To: beginners@haskell.org Message-ID: <aanlktikz_rg4obmse=9takm41ctnhcurtcn5yn2d4...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" ---------- Forwarded message ---------- From: Mathew de Detrich <dete...@gmail.com> Date: Sat, Aug 7, 2010 at 7:19 PM Subject: Re: [Haskell-beginners] Foreign function interface? To: aditya siram <aditya.si...@gmail.com> Actually it is possible to use C++ with FFI without having to use a C Wrapper (albeit its quite complicated) http://www.haskell.org/haskellwiki/Cxx_foreign_function_interface <http://www.haskell.org/haskellwiki/GHC/Using_the_FFI>Also refer to http://qthaskell.berlios.de/ (thats a practical example of QtHaskell, which is a haskell binding to a C++ library, being Qt) <http://qthaskell.berlios.de/> On Sat, Jul 31, 2010 at 6:49 AM, aditya siram <aditya.si...@gmail.com>wrote: > > Can it interface with C++ as well as C? > No you have to wrap your C++ code in C. > -deech <Beginners@haskell.org> > > _______________________________________________ > 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/20100807/495f596f/attachment-0001.html ------------------------------ Message: 9 Date: Sat, 7 Aug 2010 19:22:32 +1000 From: Mathew de Detrich <dete...@gmail.com> Subject: Re: [Haskell-beginners] Foreign function interface? To: beginners@haskell.org Message-ID: <aanlktikh0c7hsk5rtdkeg05h2fbp-fwfosqujbxcq...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" eh woops, sorry about what happened above with the mailing list, still figuring out mutt =D On Sat, Aug 7, 2010 at 7:21 PM, Mathew de Detrich <dete...@gmail.com> wrote: > > > ---------- Forwarded message ---------- > From: Mathew de Detrich <dete...@gmail.com> > Date: Sat, Aug 7, 2010 at 7:19 PM > Subject: Re: [Haskell-beginners] Foreign function interface? > To: aditya siram <aditya.si...@gmail.com> > > > Actually it is possible to use C++ with FFI without having to use a C > Wrapper (albeit its quite complicated) > http://www.haskell.org/haskellwiki/Cxx_foreign_function_interface > > <http://www.haskell.org/haskellwiki/GHC/Using_the_FFI>Also refer to > http://qthaskell.berlios.de/ (thats a practical example of QtHaskell, > which is a haskell binding to a C++ library, being Qt) > > <http://qthaskell.berlios.de/> > > On Sat, Jul 31, 2010 at 6:49 AM, aditya siram <aditya.si...@gmail.com>wrote: > >> > Can it interface with C++ as well as C? >> No you have to wrap your C++ code in C. >> -deech <Beginners@haskell.org> >> >> _______________________________________________ >> 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/20100807/688e4999/attachment.html ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 26, Issue 16 *****************************************