From wrwills at gmail.com Mon Feb 1 00:08:57 2010 From: wrwills at gmail.com (Robert Wills) Date: Sun Jan 31 23:40:35 2010 Subject: [Haskell-cafe] Anyone recommend a VPS? In-Reply-To: References: <29bf512f1001311202w778d81e6ia8f53b37bfdf051e@mail.gmail.com> <87wryyxb8i.fsf@gregorycollins.net> <1264973017-sup-4833@nixos> <29bf512f1001311337q67c8c880x32f3c2ee613632cd@mail.gmail.com> Message-ID: I use Webfaction. http://www.webfaction.com/services/hosting It's not a personal vps but you get ssh access and you can run any webserver you want-- even a Haskell one: http://wrwills.webfactional.com/2009/10/30/Haskell-on-a-Webfaction-Host They support Postgres databases too. It's cheaper than a vps (I'm paying $8.50 a month but you can pay as little as $5.50), but possibly not as convenient. -Rob On Sun, Jan 31, 2010 at 11:05 PM, Tom Tobin wrote: > On Sun, Jan 31, 2010 at 3:37 PM, Michael Snoyman wrote: >> OK, I guess the unananimous opinion in linode ;). Thanks for the input >> everyone! > > If it helps make your client even more comfortable: not only do I use > Linode for my personal VPS, but we use them at work to host some > fairly popular websites. ?Our sysadmin absolutely loves them to death; > he's always raving about how easy our hosting is now since moving > there. ?:-) > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From michael at snoyman.com Mon Feb 1 00:29:56 2010 From: michael at snoyman.com (Michael Snoyman) Date: Mon Feb 1 00:01:35 2010 Subject: [Haskell-cafe] Anyone recommend a VPS? In-Reply-To: References: <29bf512f1001311202w778d81e6ia8f53b37bfdf051e@mail.gmail.com> <87wryyxb8i.fsf@gregorycollins.net> <1264973017-sup-4833@nixos> <29bf512f1001311337q67c8c880x32f3c2ee613632cd@mail.gmail.com> Message-ID: <29bf512f1001312129u34e8f3eare5c314e970e505d4@mail.gmail.com> On Mon, Feb 1, 2010 at 7:08 AM, Robert Wills wrote: > I use Webfaction. > > http://www.webfaction.com/services/hosting > > It's not a personal vps but you get ssh access and you can run any > webserver you want-- even a Haskell one: > > http://wrwills.webfactional.com/2009/10/30/Haskell-on-a-Webfaction-Host > > They support Postgres databases too. > > It's cheaper than a vps (I'm paying $8.50 a month but you can pay as > little as $5.50), but possibly not as convenient. > > -Rob > > On Sun, Jan 31, 2010 at 11:05 PM, Tom Tobin wrote: > > On Sun, Jan 31, 2010 at 3:37 PM, Michael Snoyman > wrote: > >> OK, I guess the unananimous opinion in linode ;). Thanks for the input > >> everyone! > > > > If it helps make your client even more comfortable: not only do I use > > Linode for my personal VPS, but we use them at work to host some > > fairly popular websites. Our sysadmin absolutely loves them to death; > > he's always raving about how easy our hosting is now since moving > > there. :-) > > Funny, I use a similar approach for my personal sites when I host them on nearlyfreespeech. My one complaint is that they use FreeBSD instead of Linux; if I found a webhost that let me compile straight from my Arch/Ubuntu box, I'd be very happy. (I'm sure they exist, but now I'm kind of addicted to nearlyfreespeech's cheap pricing...) Thanks for the suggestion. Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100201/af7572fb/attachment.html From tittoassini at gmail.com Mon Feb 1 03:09:42 2010 From: tittoassini at gmail.com (Pasqualino "Titto" Assini) Date: Mon Feb 1 02:41:20 2010 Subject: [Haskell-cafe] Anyone recommend a VPS? In-Reply-To: <29bf512f1001312129u34e8f3eare5c314e970e505d4@mail.gmail.com> References: <29bf512f1001311202w778d81e6ia8f53b37bfdf051e@mail.gmail.com> <87wryyxb8i.fsf@gregorycollins.net> <1264973017-sup-4833@nixos> <29bf512f1001311337q67c8c880x32f3c2ee613632cd@mail.gmail.com> <29bf512f1001312129u34e8f3eare5c314e970e505d4@mail.gmail.com> Message-ID: <2d34474e1002010009y700c09b2h5ac2db4f50e11e49@mail.gmail.com> In Europe, http://www.ovh.com has quite good prices. titto From torsten.grust at uni-tuebingen.de Mon Feb 1 03:14:40 2010 From: torsten.grust at uni-tuebingen.de (Torsten Grust) Date: Mon Feb 1 02:51:53 2010 Subject: [Haskell-cafe] Re: OT: Literature on translation of lambda calculus to combinators References: <4B615EDB.3090207@fit.vutbr.cz> Message-ID: Dear all, Du?an Kol?? fit.vutbr.cz> writes: > [...] > Could anyone provide a link to some paper/book (electronic version of > both preferred, even if not free) that describes an algorithm of > translation of untyped lambda calculus expression to a set of > combinators? Preferably SKI or BCKW. I'm either feeding google with > wrong question or there is no link available now... 13 years ago (ugh...) I've posted a tutorial-style treatment of the compilation of Dave Turner's SASL to SKI. Also addresses reduction and simple optimizations of the resulting SKI programs. http://www-db.informatik.uni-tuebingen.de/files/publications/sasl.ps.gz Cheers, ?Torsten From mark.spezzano at chariot.net.au Mon Feb 1 03:45:22 2010 From: mark.spezzano at chariot.net.au (Mark Spezzano) Date: Mon Feb 1 03:17:04 2010 Subject: [Haskell-cafe] Trapping getChar before echo In-Reply-To: <4B657E48.5040503@btinternet.com> References: <3605445B-84F5-4CFF-A655-24060162FE5F@chariot.net.au> <1264932763.2595.0.camel@cangaroo> <4B657E48.5040503@btinternet.com> Message-ID: <3133120B-E9DA-4C56-B3C1-D95AC485734A@chariot.net.au> I've tried this example and it just lets me type in anything in CAPITALS, which is nice, but Delete key doesn't delete and the arrow keys unfortunately let me manoeuvre the cursor all over the screen. Also the biggest problem is that Enter doesn't terminate the input session. Isn't there a simple way to do something like this? Surely Haskell must have a standard getLine function that support CAPITALS and backspacing and no arrow keys. Arrows keys with history would be nice. Mark On 31/01/2010, at 11:27 PM, Andrew Coppin wrote: > Michael Hartl wrote: >> import System.IO >> import Data.Char >> >> main = do >> hSetEcho stdin False >> hSetBuffering stdin NoBuffering >> hSetBuffering stdout NoBuffering >> scanLine >> where scanLine = do c <- hGetChar stdin >> putChar . toUpper $ c >> scanLine >> > > Last time I tried something like this [on Windows], it didn't seem to work. I wanted to trap arrow keys and so forth, but they seem to be being used for input history. (I.e., pressing the up-arrow produces previously-entered lines of text, and none of this appears to be reaching the Haskell program itself.) Has this changed since I tried it last year? > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From thaldyron at gmail.com Mon Feb 1 03:51:13 2010 From: thaldyron at gmail.com (Peter Robinson) Date: Mon Feb 1 03:23:10 2010 Subject: [Haskell-cafe] Anyone recommend a VPS? In-Reply-To: <2d34474e1002010009y700c09b2h5ac2db4f50e11e49@mail.gmail.com> References: <29bf512f1001311202w778d81e6ia8f53b37bfdf051e@mail.gmail.com> <87wryyxb8i.fsf@gregorycollins.net> <1264973017-sup-4833@nixos> <29bf512f1001311337q67c8c880x32f3c2ee613632cd@mail.gmail.com> <29bf512f1001312129u34e8f3eare5c314e970e505d4@mail.gmail.com> <2d34474e1002010009y700c09b2h5ac2db4f50e11e49@mail.gmail.com> Message-ID: I use http://www.bytemark.co.uk/ and I'm quite satisfied. They offer Ubuntu, Debian and CentOS. Peter From maydwell at gmail.com Mon Feb 1 04:14:25 2010 From: maydwell at gmail.com (Lyndon Maydwell) Date: Mon Feb 1 03:46:05 2010 Subject: [Haskell-cafe] Trapping getChar before echo In-Reply-To: <3133120B-E9DA-4C56-B3C1-D95AC485734A@chariot.net.au> References: <3605445B-84F5-4CFF-A655-24060162FE5F@chariot.net.au> <1264932763.2595.0.camel@cangaroo> <4B657E48.5040503@btinternet.com> <3133120B-E9DA-4C56-B3C1-D95AC485734A@chariot.net.au> Message-ID: It might be worth looking at something like a curses library. On Mon, Feb 1, 2010 at 4:45 PM, Mark Spezzano wrote: > I've tried this example and it just lets me type in anything in CAPITALS, which is nice, but Delete key doesn't delete and the arrow keys unfortunately let me manoeuvre the cursor all over the screen. Also the biggest problem is that Enter doesn't terminate the input session. > > Isn't there a simple way to do something like this? > > Surely Haskell must have a standard getLine function that support CAPITALS and backspacing and no arrow keys. Arrows keys with history would be nice. > > Mark > > > On 31/01/2010, at 11:27 PM, Andrew Coppin wrote: > >> Michael Hartl wrote: >>> import System.IO >>> import Data.Char >>> >>> main = do >>> ?hSetEcho stdin False >>> ?hSetBuffering stdin NoBuffering >>> ?hSetBuffering stdout NoBuffering >>> ?scanLine >>> ? ? ?where scanLine = do ? ? ? ? ? ? ? c <- hGetChar stdin >>> ? ? ? ? ? ? ?putChar . toUpper $ c >>> ? ? ? ? ? ? ?scanLine >>> >> >> Last time I tried something like this [on Windows], it didn't seem to work. I wanted to trap arrow keys and so forth, but they seem to be being used for input history. (I.e., pressing the up-arrow produces previously-entered lines of text, and none of this appears to be reaching the Haskell program itself.) Has this changed since I tried it last year? >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From matthias.goergens at googlemail.com Mon Feb 1 08:48:16 2010 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Mon Feb 1 08:20:12 2010 Subject: [Haskell-cafe] OT: Literature on translation of lambda calculus to combinators In-Reply-To: <4B615EDB.3090207@fit.vutbr.cz> References: <4B615EDB.3090207@fit.vutbr.cz> Message-ID: Dear Du?an, You can also find an algorithm in everyone's favourite book in combinatorial logic "To Mock a Mockingbird" (http://en.wikipedia.org/wiki/To_Mock_a_Mockingbird). Cheers, Matthias. From dpx.infinity at gmail.com Mon Feb 1 09:11:12 2010 From: dpx.infinity at gmail.com (Vladimir Matveev) Date: Mon Feb 1 08:42:45 2010 Subject: [Haskell-cafe] Determining application directory In-Reply-To: <100F9B44-B313-4AC9-81E9-34A9ADD5E802@gmail.com> References: <20100127170656.GA5673@googolplex> <100F9B44-B313-4AC9-81E9-34A9ADD5E802@gmail.com> Message-ID: <20100201141112.GA7065@googolplex> I wrote several times that I want determine application directory under Windows only. Unix version will store its config in predefined location, in /etc. Anyway, one not subscribed man wrote me about special library to solve this problem - http://hackage.haskell.org/package/executable-path On Fri, Jan 29, 2010 at 11:16:25AM -0800, Scott A. Waterman wrote: > 'FindBin' is also useful. > http://hackage.haskell.org/package/FindBin > > While System.Directory is quite useful, it doesn't contain a > function to obtain > the directory in which the running program lives. You can get the > current > (working) directory (e.g. unix's 'getpwd'), and you can try to find an > executable by searching the $PATH, but you can't find the program you > are currently running. > > --ts > > On Jan 27, 2010, at 9:06 AM, Matveev Vladimir wrote: > > >Hi, > >I'm writing cross-platform application in Haskell which should be > >running under Windows and Linux. Under Linux configuration is stored > >in the /etc directory, and under Windows configuration is meant to > >be in > >the application directory. So, is there a way to get an application > >directory path under Windows? I remember that there is a way to do > >this > >using WinAPI, but how to do this Haskell? > >_______________________________________________ > >Haskell-Cafe mailing list > >Haskell-Cafe@haskell.org > >http://www.haskell.org/mailman/listinfo/haskell-cafe > From ekmett at gmail.com Mon Feb 1 10:02:44 2010 From: ekmett at gmail.com (Edward Kmett) Date: Mon Feb 1 09:34:20 2010 Subject: [Haskell-cafe] Anyone up for Google SoC 2010? In-Reply-To: <863507BC-FD78-49A0-9A77-C97B9431F7E7@cs.york.ac.uk> References: <863507BC-FD78-49A0-9A77-C97B9431F7E7@cs.york.ac.uk> Message-ID: <7fb8f82f1002010702y6fd0a40dp91a49a4598e46181@mail.gmail.com> I would happily participate as a mentor again and I am willing to step up as administrator if you want to get it off your plate. -Edward Kmett On Sun, Jan 31, 2010 at 6:04 AM, Malcolm Wallace < malcolm.wallace@cs.york.ac.uk> wrote: > Google has announced that the Summer of Code programme will be running > again this year. If haskell.org people would like to take part again this > year, then we need volunteers: > > First, > * suggestions for suitable projects > (in the past this was organised using a reddit) > * an administrator to co-ordinate the application to Google > (I have done it for the last three years but am very willing > to hand on to someone else) > > Google will accept applications from organisations in the period 8th - 12th > March 2010, approx 1900UTC. > > If haskell.org is accepted again, students can apply between 29th March - > 9th April. > More volunteers will be required: > > * to review student applications and choose which to accept > * to supervise the accepted students > > Both of these roles are called "mentor" in the Google system. Putting > together a good team of mentors before applying as an organisation is > helpful towards us being accepted into the programme. > > Regards, > Malcolm > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100201/82f9a761/attachment.html From haberg at math.su.se Mon Feb 1 10:04:48 2010 From: haberg at math.su.se (Hans Aberg) Date: Mon Feb 1 09:36:28 2010 Subject: [Haskell-cafe] OT: Literature on translation of lambda calculus to combinators In-Reply-To: <4B615EDB.3090207@fit.vutbr.cz> References: <4B615EDB.3090207@fit.vutbr.cz> Message-ID: On 28 Jan 2010, at 10:54, Du?an Kol?? wrote: > Could anyone provide a link to some paper/book (electronic version > of both preferred, even if not free) that describes an algorithm of > translation of untyped lambda calculus expression to a set of > combinators? Preferably SKI or BCKW. I'm either feeding google with > wrong question or there is no link available now... Here is a paper that uses that standard arithmetic operators that Church defined: http://www.dcs.ed.ac.uk/home/pgh/amen.ps Hans From johan.tibell at gmail.com Mon Feb 1 11:07:34 2010 From: johan.tibell at gmail.com (Johan Tibell) Date: Mon Feb 1 10:39:32 2010 Subject: [Haskell-cafe] Anyone up for Google SoC 2010? In-Reply-To: <7fb8f82f1002010702y6fd0a40dp91a49a4598e46181@mail.gmail.com> References: <863507BC-FD78-49A0-9A77-C97B9431F7E7@cs.york.ac.uk> <7fb8f82f1002010702y6fd0a40dp91a49a4598e46181@mail.gmail.com> Message-ID: <90889fe71002010807t723c9a1bmbcab65772ee0e2e6@mail.gmail.com> I'd be willing to mentor again. I think it's really important that we think hard about coming up with projects which improve the core Haskell tool chain this year. Cheers, Johan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100201/141c27a0/attachment.html From gue.schmidt at web.de Mon Feb 1 12:03:45 2010 From: gue.schmidt at web.de (=?ISO-8859-15?Q?G=FCnther_Schmidt?=) Date: Mon Feb 1 11:35:47 2010 Subject: [Haskell-cafe] very strange utf8 problem Message-ID: <4B670971.80603@web.de> Hi all, I know this sounds daft but I do have good reason to ask. Is it possible that GHC's core itself has a problem with a particular Umlaut only? HDBC-ODBC won't read in data from an SQLite database as soon as it comes accross a *lowercase* U-Umlaut ("?") ghci crashes. Other Umlauts ("?", "?" and "?") pass however. This is the error message: readUTF8Char: illegal UTF-8 character 252 As I said, other Umlauts do pass. I got this very message quite often, usually when working with databases and not always using HDBC but also Takusen. I kept blaming it on HDBC-ODBC or the input data but I might have been wrong there. G?nther From jason.dusek at gmail.com Mon Feb 1 12:11:51 2010 From: jason.dusek at gmail.com (Jason Dusek) Date: Mon Feb 1 11:43:27 2010 Subject: [Haskell-cafe] Anyone recommend a VPS? In-Reply-To: <1264973017-sup-4833@nixos> References: <29bf512f1001311202w778d81e6ia8f53b37bfdf051e@mail.gmail.com> <87wryyxb8i.fsf@gregorycollins.net> <1264973017-sup-4833@nixos> Message-ID: <42784f261002010911x5c260696x9c711dd685ffb9ac@mail.gmail.com> 2010/01/31 Marc Weber : > If all you want is standard debian or such it does'nt matter. > However I tried installing NixOS Linux and I've had lot's of > trouble until switching to linode. NixOS was up and running > within 30min then.. How did you get NixOS on your Linode system? They don't seem to offer it, last I checked. I'm looking in to doing this with PRGMR, which has pretty good pricing though it's not nearly as featureful as Linode. -- Jason Dusek From dave at zednenem.com Mon Feb 1 12:22:07 2010 From: dave at zednenem.com (David Menendez) Date: Mon Feb 1 11:53:43 2010 Subject: [Haskell-cafe] very strange utf8 problem In-Reply-To: <4B670971.80603@web.de> References: <4B670971.80603@web.de> Message-ID: <49a77b7a1002010922nc2d230m42251c61b2e212ec@mail.gmail.com> 2010/2/1 G?nther Schmidt : > Hi all, > > I know this sounds daft but I do have good reason to ask. > > Is it possible that GHC's core itself has a problem with a particular Umlaut > only? > > HDBC-ODBC won't read in data from an SQLite database as soon as it comes > accross a *lowercase* U-Umlaut ("?") ghci crashes. Other Umlauts ("?", "?" > and "?") pass however. > > This is the error message: > > ?readUTF8Char: illegal UTF-8 character 252 > > As I said, other Umlauts do pass. I suspect something is trying to read ISO-Latin-1 data as UTF-8. 252 is the Unicode and Latin-1 code point for "?", but in UTF-8 it's written in two bytes as 0xC3BC. -- Dave Menendez From s.clover at gmail.com Mon Feb 1 13:00:23 2010 From: s.clover at gmail.com (sterl) Date: Mon Feb 1 12:32:17 2010 Subject: [Haskell-cafe] Anyone up for Google SoC 2010? In-Reply-To: <863507BC-FD78-49A0-9A77-C97B9431F7E7@cs.york.ac.uk> References: <863507BC-FD78-49A0-9A77-C97B9431F7E7@cs.york.ac.uk> Message-ID: <4B6716B7.2020902@gmail.com> Malcolm Wallace wrote: > Google has announced that the Summer of Code programme will be running > again this year. If haskell.org people would like to take part again > this year, then we need volunteers: I'd be happy to mentor again as well. It's important to bear in mind that the total number of mentors plays a small role in slot allocation, but far more important is to maximize the amount of high-quality applications -- the more students we encourage to submit proposals, the more proposals we will be able to fund: http://socghop.appspot.com/document/show/program/google/gsoc2009/studentallocations Cheers, Sterl. From monnier at iro.umontreal.ca Mon Feb 1 14:39:11 2010 From: monnier at iro.umontreal.ca (Stefan Monnier) Date: Mon Feb 1 14:11:09 2010 Subject: [Haskell-cafe] Re: Non-termination of type-checking References: <20100130084436.01FB217415@Adric.ern.nps.edu> <201001300903.56724.dan.doel@gmail.com> Message-ID: > And I'm pretty sure that there's no way to convince Agda that F = R, > or something similar, because, despite the fact that Agda has > injective type constructors like GHC (R x = R y => x = y), it doesn't > let you make the inference R Unit = F Unit => R = F. Of course, in > Agda, one could arguably say that it's true, because Agda has no type > case, so there's (I'm pretty sure) no way to write an F such that > R T = F T, but R U /= F U, for some U /= T. It's easy to construct an F that is different from R but agrees with R for the case of Unit: F = ? _ -> R Unit So there's a good reason why Agda doesn't let F and R unify: it would really be completely wrong. Stefan From holgersiegel74 at yahoo.de Mon Feb 1 14:51:50 2010 From: holgersiegel74 at yahoo.de (Holger Siegel) Date: Mon Feb 1 14:23:32 2010 Subject: [Haskell-cafe] Re: Very imperfect hash function In-Reply-To: <1264707462.15071.7.camel@picard> References: <1264707462.15071.7.camel@picard> Message-ID: <1265053910.7163.8.camel@cornfed> Am Donnerstag, den 28.01.2010, 19:37 +0000 schrieb Maciej Piechotka: > On Thu, 2010-01-28 at 14:07 -0500, Steve Schafer wrote: > > I'm looking for some algorithmic suggestions: > > > > I have a set of several hundred key/value pairs. The keys are 32-bit > > integers, and are all distinct. The values are also integers, but the > > number of values is small (only six in my current problem). So, > > obviously, several keys map to the same value. > > > > For some subsets of keys, examining only a small portion of the key's > > bits is enough to determine the associated value. For example, there may > > be 250 keys that all have the same most-significant byte, and all 250 > > map to the same value. There are also keys at the other extreme, where > > two keys that differ in only one bit position map to different values. > > > > The data are currently in a large lookup table. To save space, I'd like > > to convert that into a sort of hash function: > > > > hash :: key -> value > > > > My question is this: Is there any kind of generic approach that can make > > use of the knowledge about the internal redundancy of the keys to come > > up with an efficient function? > > > > Steve Schafer > > Fenestra Technologies Corp. > > http://www.fenestra.com/ > > Maybe: > > data TTree a = TTree Int (TTree a) (TTree a) > | TNode a > -- | THashNode > > hash :: TTree a -> Int32 -> a > hash (TNode v) _ = v > hash (TTree b l r) k = if testBit k b then hash r k else hash l k > -- hash (THashNode h) k = lookupHashTable h k This looks like you have re-invented Binary Decision Diagrams (BDDs). :) > Of course you need to code efficiently the tree. When you fix the order in which the bits are tested, you can take advantage of sharing. This way you reach an efficient representation called Reduced Ordered Binary Decision Diagram (ROBDD). Unfortunately, a bad order may lead to exponential size (in the number of bits), and finding a good order can be NP-hard. Regards, Holger From jeremy at n-heptane.com Mon Feb 1 15:08:04 2010 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Mon Feb 1 14:39:41 2010 Subject: [Haskell-cafe] Re: could we get a Data instance for Data.Text.Text? In-Reply-To: References: <20100126175522.GA18671@kira.casa> Message-ID: Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: data-instance-for-text.dpatch Type: application/octet-stream Size: 2332 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100201/50b37796/data-instance-for-text.obj From leather at cs.uu.nl Mon Feb 1 16:54:23 2010 From: leather at cs.uu.nl (Sean Leather) Date: Mon Feb 1 16:26:18 2010 Subject: [Haskell-cafe] Generating repeatable arbitrary values with QuickCheck 2 Message-ID: <3c6288ab1002011354j7909e2a4w6116ff685c081224@mail.gmail.com> I would like to generate an arbitrary (large) value to benchmark the performance of constructing that value with isomorphic types. It seems like QuickCheck might be useful in this regards. Has anyone done something similar? In versions 1.*, there was a generate function: generate :: Int -> StdGen -> Gen a -> a > generate n rnd (Gen m) = m size rnd' > where (size, rnd') = randomR (0, n) rnd > That seems to have disappeared in versions 2.*, and I didn't find a clear replacement. I came up with using the destructor for Gen: unGen :: Gen a -> StdGen -> Int -> a > The function generate seems to have a little something extra, though I'm not sure if it's necessary. Is this true, or should I write an equivalent generate function? As an aside, it would be nice to have a generate function in the library, even if it is only a wrapper for unGen. In the end, I would write something like the following: unGen arbitrary (mkStdGen 11) 5 :: [Int] > This produces, for example, [5,1,-2,-4,2]. I also want to generate the same value for a type isomorphic to [Int]. unGen arbitrary (mkStdGen 11) 5 :: List Int > Unfortunately, this produces Cons 4 (Cons 3 (Cons (-2) (Cons 0 (Cons (-1) Nil)))): same length but different values. The Arbitrary instances are the same. I had similar results with generate from QC 1. Any suggestions on how to do this? With another library perhaps? Thanks, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100201/796cb597/attachment.html From timothyea at comcast.net Mon Feb 1 20:47:00 2010 From: timothyea at comcast.net (Tim Attwood) Date: Mon Feb 1 20:19:04 2010 Subject: [Haskell-cafe] Re: Trapping getChar before echo In-Reply-To: <4B657E48.5040503@btinternet.com> References: <3605445B-84F5-4CFF-A655-24060162FE5F@chariot.net.au><1264932763.2595.0.camel@cangaroo> <4B657E48.5040503@btinternet.com> Message-ID: > Last time I tried something like this [on Windows], it didn't seem to > work. I wanted to trap arrow keys and so forth, but they seem to be being > used for input history. (I.e., pressing the up-arrow produces > previously-entered lines of text, and none of this appears to be reaching > the Haskell program itself.) Has this changed since I tried it last year? Doesn't work in windows, at least up till 6.10.1. There's a work-around though. {-# LANGUAGE ForeignFunctionInterface #-} import Data.Char import Control.Monad (liftM, forever) import Foreign.C.Types getHiddenChar = liftM (chr.fromEnum) c_getch foreign import ccall unsafe "conio.h getch" c_getch :: IO CInt main = do forever $ do c <- getHiddenChar putStrLn $ show (fromEnum c) From ok at cs.otago.ac.nz Mon Feb 1 21:05:34 2010 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Mon Feb 1 20:37:15 2010 Subject: [Haskell-cafe] Very imperfect hash function In-Reply-To: <8ABC3AEC-52F1-46CE-8C1B-00F65E580421@math.su.se> References: <9979e72e1001290352ka513e9bl7c068699427d0d9f@mail.gmail.com> <6518D9D0-39F1-4601-A75E-32E503885C79@math.su.se> <9979e72e1001290657m1c5f6c99od8ffe9b1ab8a0e3f@mail.gmail.com> <9979e72e1001311107y19667426ke9e34ee6615a7f76@mail.gmail.com> <8ABC3AEC-52F1-46CE-8C1B-00F65E580421@math.su.se> Message-ID: On Feb 1, 2010, at 9:04 AM, Hans Aberg wrote: > A simple hash-function for strings is to simply exclusive-or the > bytes and then reduce modulo a prime number, Simply exclusive-oring the bytes will give you at most 256 distinct results. (For an ASCII source, 128 distinct results.) After that, there hardly seems to be any point in reduction modulo a prime. This approach can't tell a CAT from an ACT or a DOG from a GOD, which is another strike against it. (It also can't tell a TITTLE from a TILE, or a BOTTLE from a BOLE, for obvious reasons.) From z_axis at 163.com Mon Feb 1 21:22:23 2010 From: z_axis at 163.com (zaxis) Date: Mon Feb 1 20:53:57 2010 Subject: [Haskell-cafe] About code style ? Message-ID: <27414627.post@talk.nabble.com> For me i like C style instead of layout. For example, func1 a = do -- ... a * 2 -- ... I always write it as: func1 a = do { -- ...; a * 2; -- ...; } However, i donot know how to write pure function using C style. func1 a = { -- ...; a * 2; -- ...; } will not compile without `do`. Sincerely! ----- fac n = foldr (*) 1 [1..n] -- View this message in context: http://old.nabble.com/About-code-style---tp27414627p27414627.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From ivan.miljenovic at gmail.com Mon Feb 1 21:37:12 2010 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Mon Feb 1 21:08:53 2010 Subject: [Haskell-cafe] About code style ? In-Reply-To: <27414627.post@talk.nabble.com> (zaxis's message of "Mon, 1 Feb 2010 18:22:23 -0800 (PST)") References: <27414627.post@talk.nabble.com> Message-ID: <87hbq05pnr.fsf@gmail.com> zaxis writes: > However, i donot know how to write pure function using C style. > func1 a = { > -- ...; > a * 2; > -- ...; > } You mean imperatively? Short answer: you can't and you shouldn't. Slightly longer answer: you can possibly fudge something together using the Identity monad from mtl, but that will involve wrapping/unwrapping everywhere. Learn to think about how to chain/group functions together to form more of a "pipeline" rather than a sequence of statements. Haskell =/= C. -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com From mle+hs at mega-nerd.com Mon Feb 1 21:37:44 2010 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Mon Feb 1 21:09:23 2010 Subject: [Haskell-cafe] About code style ? In-Reply-To: <27414627.post@talk.nabble.com> References: <27414627.post@talk.nabble.com> Message-ID: <20100202133744.9bbc98e2.mle+hs@mega-nerd.com> zaxis wrote: > For me i like C style instead of layout. For example, > func1 a = do > -- ... > a * 2 > -- ... > > I always write it as: > func1 a = do { > -- ...; > a * 2; > -- ...; > } Honestly, don't do this. When you're coding in Haskell you should write idiomatic Haskell and when doing C, do idiomatic C. Inventing your own coding style for a language will make it difficult for other people who know and use that language to read your code and sooner or later you will want to or need to work with others. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From ok at cs.otago.ac.nz Mon Feb 1 22:52:50 2010 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Mon Feb 1 22:24:26 2010 Subject: [Haskell-cafe] Re: Very imperfect hash function In-Reply-To: <1265053910.7163.8.camel@cornfed> References: <1264707462.15071.7.camel@picard> <1265053910.7163.8.camel@cornfed> Message-ID: <6407EED2-246A-4B1D-9AC8-C2221A5823C9@cs.otago.ac.nz> >> On Thu, 2010-01-28 at 14:07 -0500, Steve Schafer wrote: >>> I'm looking for some algorithmic suggestions: >>> >>> I have a set of several hundred key/value pairs. The keys are 32-bit >>> integers, and are all distinct. The values are also integers, but >>> the >>> number of values is small (only six in my current problem). So, >>> obviously, several keys map to the same value. Instead of mapping keys to values, map keys to sets of values, where each set of values is represented by a small bit string. In your present case, one byte would be enough. >>> >>> >>> For some subsets of keys, examining only a small portion of the >>> key's >>> bits is enough to determine the associated value. For example, >>> there may >>> be 250 keys that all have the same most-significant byte, and all >>> 250 >>> map to the same value. There are also keys at the other extreme, >>> where >>> two keys that differ in only one bit position map to different >>> values. On today's machines, "several hundred" pairs counts as trivial. Start by using a Data.IntMap of bytes and look for something else only if that doesn't pay off. This already takes advantage of the bit-string nature of your keys, by the way. From bos at serpentine.com Tue Feb 2 01:03:44 2010 From: bos at serpentine.com (Bryan O'Sullivan) Date: Tue Feb 2 00:35:17 2010 Subject: [Haskell-cafe] Re: could we get a Data instance for Data.Text.Text? In-Reply-To: References: <20100126175522.GA18671@kira.casa> Message-ID: On Mon, Feb 1, 2010 at 12:08 PM, Jeremy Shaw wrote: > Attached. > Data/Text.hs:175:63: Module `Data.Data' does not export `mkNoRepType' Can you send a followup patch that works against GHC 6.10.4, please? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100202/c88c55bf/attachment.html From es at ertes.de Tue Feb 2 01:51:40 2010 From: es at ertes.de (Ertugrul Soeylemez) Date: Tue Feb 2 01:23:10 2010 Subject: [Haskell-cafe] Re: About code style ? References: <27414627.post@talk.nabble.com> Message-ID: <20100202075140.59f4b88e@tritium.streitmacht.eu> Hello zaxis, as others have noted, you are trying to write C in Haskell. Well, that gains you nothing and rather gets you into trouble. If you want to write C, then use instead and not Haskell, because the idioms you're used to in C will not work at all in Haskell. Note for example that the 'do' keyword is misleading. It does not introduce imperative code, but monadic code, which may well be pure. To answer your question: There are no blocks in Haskell, which you could put into braces. Don't think in blocks of code, because that is C, not Haskell, and it's plain wrong. You are not going to write any for/while loops anyway. Thinking that way may have a negative impact on your Haskell coding style. The only place where braces are used is record types and many Haskell programmers (including me) consider this an ugly syntax. But don't worry, you'll get used to the new syntax and eventually fall in love with it, because it will make your life easier. I myself came from years of C/C++ experience and had similar difficulties in the beginning. Greets Ertugrul zaxis wrote: > > For me i like C style instead of layout. For example, > func1 a = do > -- ... > a * 2 > -- ... > > I always write it as: > func1 a = do { > -- ...; > a * 2; > -- ...; > } > > However, i donot know how to write pure function using C style. > func1 a = { > -- ...; > a * 2; > -- ...; > } > > will not compile without `do`. > > Sincerely! > > ----- > fac n = foldr (*) 1 [1..n] -- nightmare = unsafePerformIO (getWrongWife >>= sex) http://blog.ertes.de/ From miguelimo38 at yandex.ru Tue Feb 2 01:58:17 2010 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Tue Feb 2 01:29:55 2010 Subject: [Haskell-cafe] About code style ? In-Reply-To: <27414627.post@talk.nabble.com> References: <27414627.post@talk.nabble.com> Message-ID: > However, i donot know how to write pure function using C style. > func1 a = { > -- ...; > a * 2; > -- ...; > } What do you mean by "a * 2"? If you don't use this value, don't calculate it. From gcross at phys.washington.edu Tue Feb 2 02:43:56 2010 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Tue Feb 2 02:15:34 2010 Subject: [Haskell-cafe] About code style ? In-Reply-To: <27414627.post@talk.nabble.com> References: <27414627.post@talk.nabble.com> Message-ID: Ditto what everyone else has said. But to clarify what's going on: The braces are used to introduce a list of "things", such as monadic actions, data fields, or declarations. For example, consider the following code: f a = let { a_times_2 = a*2; a_times_4 = a*4; } in a_times_2+a_times_4 main = putStrLn $ "f 3 = " ++ show (f 3) The reason why my code compiled and yours didn't is because the compiler saw that the braces were being used to introduce a list of declarations, and the reason why it knew this was because of the "let" keyword. By contrast, in your code it doesn't see a "let", so it assumes that you must be introducing a list of monadic actions. Hence it yells at you for not putting in a "do". Remember that a pure function is merely a definition of what the output is for a given input. It does not say anything about *how* to do this. Thus, you should never think of a pure function as being a list of actions but rather (approximately) a definition which may require some additional declarations (such as introduced by "let") solely for the purpose of making it easier for *you* to *express* what its value is. (I say approximately because the way you express it does affect the way it gets computed despite technically being pure, but this is not something you should be worrying about right now.) But again, even though you could use curly brackets and semicolons as I illustrated above, you really should be using whitespace as it is the standard practice; others reading your code may be confused by their presence and so have to work harder to figure out what is going on. Cheers, Greg On Feb 1, 2010, at 6:22 PM, zaxis wrote: > > For me i like C style instead of layout. For example, > func1 a = do > -- ... > a * 2 > -- ... > > I always write it as: > func1 a = do { > -- ...; > a * 2; > -- ...; > } > > However, i donot know how to write pure function using C style. > func1 a = { > -- ...; > a * 2; > -- ...; > } > > will not compile without `do`. > > Sincerely! > > ----- > fac n = foldr (*) 1 [1..n] > -- > View this message in context: http://old.nabble.com/About-code-style---tp27414627p27414627.html > Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From z_axis at 163.com Tue Feb 2 03:33:26 2010 From: z_axis at 163.com (zaxis) Date: Tue Feb 2 03:04:59 2010 Subject: [Haskell-cafe] About code style ? In-Reply-To: <27414627.post@talk.nabble.com> References: <27414627.post@talk.nabble.com> Message-ID: <27416932.post@talk.nabble.com> thanks for all suggestions. zaxis wrote: > > For me i like C style instead of layout. For example, > func1 a = do > -- ... > a * 2 > -- ... > > I always write it as: > func1 a = do { > -- ...; > a * 2; > -- ...; > } > > However, i donot know how to write pure function using C style. > func1 a = { > -- ...; > a * 2; > -- ...; > } > > will not compile without `do`. > > Sincerely! > ----- fac n = foldr (*) 1 [1..n] -- View this message in context: http://old.nabble.com/About-code-style---tp27414627p27416932.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From haberg at math.su.se Tue Feb 2 03:50:07 2010 From: haberg at math.su.se (Hans Aberg) Date: Tue Feb 2 03:21:44 2010 Subject: [Haskell-cafe] Very imperfect hash function In-Reply-To: References: <9979e72e1001290352ka513e9bl7c068699427d0d9f@mail.gmail.com> <6518D9D0-39F1-4601-A75E-32E503885C79@math.su.se> <9979e72e1001290657m1c5f6c99od8ffe9b1ab8a0e3f@mail.gmail.com> <9979e72e1001311107y19667426ke9e34ee6615a7f76@mail.gmail.com> <8ABC3AEC-52F1-46CE-8C1B-00F65E580421@math.su.se> Message-ID: <9B008CA5-CAA8-4B24-A054-8BF32A8FA285@math.su.se> On 2 Feb 2010, at 03:05, Richard O'Keefe wrote: >> A simple hash-function for strings is to simply exclusive-or the >> bytes and then reduce modulo a prime number, > > Simply exclusive-oring the bytes will give you at most 256 distinct > results. (For an ASCII source, 128 distinct results.) After that, > there hardly seems to be any point in reduction modulo a prime. Right - I just gave an example of how simple hash functions may be created. The original question deals with Int32s, not strings. As already mentioned before, there are more advance libraries here http://en.wikipedia.org/wiki/Perfect_hash_function but they are not written in Haskell. So you have to rewrite them or use the FFI. > This approach can't tell a CAT from an ACT or a DOG from a GOD, which > is another strike against it. (It also can't tell a TITTLE from a > TILE, > or a BOTTLE from a BOLE, for obvious reasons.) The hash function just tries to produce random lookup values, which are used to flatten the average depth of the lookup table at the entries of the array. So there is a tradeoff between a fast hash function, and one that does a good job. Hans From kwangraecho at gmail.com Tue Feb 2 04:35:45 2010 From: kwangraecho at gmail.com (=?EUC-KR?B?wbaxpLeh?=) Date: Tue Feb 2 04:07:21 2010 Subject: [Haskell-cafe] want to post haskell question Message-ID: <98f46b31002020135y5b2c9391n333b7acaac4994ee@mail.gmail.com> hi I have a question about haskell coding. Matrices One of many ways to define matrices in Haskell is the list of matrix rows, where a row is a list of double precision oating point numbers: type Matrix=[[Double]] Using this type you should define the following functions (definition of dim is given as an inspirational example). dim :: Matrix -> (Int,Int) --returns matrix dimension (number of rows and columns) dim m = if (not.isMatrix) m then error "Not a matrix" else (length m, length (head m)) isMatrix :: Matrix -> Bool --checks whether all rows have the same length isMatrix m = and [length (head m) == length a | a <- m] I have done upto here and I am stuck on multSM. multSM :: Double -> Matrix -> Matrix --multiplies a scalar and a matrix when I do: multSM d m = [[(b*a)| b<-[d], a<-(head m)]] or [map (*d) (head m)] ...I get (using Hugs): Main> multSM 3 [[2,3,4],[1,3,4],[6,3,0]] [[6.0,9.0,12.0]] So I solve 3 [2,3,4] but I do not know how to get the rest 3 [[1,3,4],[6,3,0]. Please help me on this problem. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100202/16f25880/attachment.html From ozgurakgun at gmail.com Tue Feb 2 04:51:32 2010 From: ozgurakgun at gmail.com (Ozgur Akgun) Date: Tue Feb 2 04:23:07 2010 Subject: [Haskell-cafe] want to post haskell question In-Reply-To: <98f46b31002020135y5b2c9391n333b7acaac4994ee@mail.gmail.com> References: <98f46b31002020135y5b2c9391n333b7acaac4994ee@mail.gmail.com> Message-ID: <7be1feae1002020151v3e337ffxf60a77a9aa08403b@mail.gmail.com> Hi, Try to understand this: type Matrix = [[Double]] multSM :: Double -> Matrix -> Matrix multSM d m = map (\ i -> map (\ j -> d*j ) i) m Now try this for multSM (instead of the above definition) multSM = map . map . (*) Hope it helps, On 2 February 2010 09:35, ??? wrote: > > hi I have a question about haskell coding. > > Matrices > > One of many ways to define matrices in Haskell is the list of matrix rows, > where a row is a list of double precision oating point numbers: > > type Matrix=[[Double]] > > Using this type you should define the following functions (definition of > dim is given as an inspirational example). > > dim :: Matrix -> (Int,Int) --returns matrix dimension (number of rows and columns) > dim m = if (not.isMatrix) m then error "Not a matrix" else (length m, length (head m)) > > isMatrix :: Matrix -> Bool --checks whether all rows have the same length > isMatrix m = and [length (head m) == length a | a <- m] > > I have done upto here and I am stuck on multSM. > > multSM :: Double -> Matrix -> Matrix --multiplies a scalar and a matrix > > when I do: > > multSM d m = [[(b*a)| b<-[d], a<-(head m)]] or [map (*d) (head m)] > > ...I get (using Hugs): > > Main> multSM 3 [[2,3,4],[1,3,4],[6,3,0]] [[6.0,9.0,12.0]] > > So I solve 3 [2,3,4] but I do not know how to get the rest 3 > [[1,3,4],[6,3,0]. > > Please help me on this problem. > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- Ozgur Akgun -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100202/28ad3802/attachment.html From miguelimo38 at yandex.ru Tue Feb 2 05:01:14 2010 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Tue Feb 2 04:36:40 2010 Subject: [Haskell-cafe] want to post haskell question In-Reply-To: <98f46b31002020135y5b2c9391n333b7acaac4994ee@mail.gmail.com> References: <98f46b31002020135y5b2c9391n333b7acaac4994ee@mail.gmail.com> Message-ID: <4B67F7EA.4040709@yandex.ru> > |multSM d m = [[(b*a)| b<-[d], a<-(head m)]] Well, let's see what do we have here. We have []'s around something. "Something" is [(b*a)| b<-[d], a<-(head m)], which is just a legal Haskell value, so our "mutlSM d m" has to be a one-element list, with the only element being equal to what we put inside the brackets. It's like [1] or ["Hello"], just with more complex expression inside. This unique value is, as we've seen, [(b*a)| b<-[d], a<-(head m)]. Here we also have []'s around something, but this new "something" is NOT a legal Haskell value; it's a list comprehension. That means that we have something like this: multSM d m = [concatMap (\b -> concatMap (\a -> b*a) (head m)) [d]] Now, concatMap f [d] = f d, so multSM d m = [concatMap (\a -> d*a) (head m)] and if m = [m1:ms], then multSM d m = [concatMap (\a -> d*a) m1] So, you take first row ("head" only takes the first element of the list, you know), multiply it by "d", and make a one-element list of it. From mark.spezzano at chariot.net.au Tue Feb 2 06:26:58 2010 From: mark.spezzano at chariot.net.au (Mark Spezzano) Date: Tue Feb 2 05:58:35 2010 Subject: [Haskell-cafe] Category Theory woes Message-ID: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> Hi all, I'm trying to learn Haskell and have come across Monads. I kind of understand monads now, but I would really like to understand where they come from. So I got a copy of Barr and Well's Category Theory for Computing Science Third Edition, but the book has really left me dumbfounded. It's a good book. But I'm just having trouble with the proofs in Chapter 1--let alone reading the rest of the text. Are there any references to things like "Hom Sets" and "Hom Functions" in the literature somewhere and how to use them? The only book I know that uses them is this one. Has anyone else found it frustratingly difficult to find details on easy-to-diget material on Category theory. The Chapter that I'm stuck on is actually labelled Preliminaries and so I reason that if I can't do this, then there's not much hope for me understanding the rest of the book... Maybe there are books on Discrete maths or Algebra or Set Theory that deal more with Hom Sets and Hom Functions? Thanks, Mark Spezzano. From nfjinjing at gmail.com Tue Feb 2 06:31:17 2010 From: nfjinjing at gmail.com (Jinjing Wang) Date: Tue Feb 2 06:03:42 2010 Subject: [Haskell-cafe] About code style ? In-Reply-To: <27416932.post@talk.nabble.com> References: <27414627.post@talk.nabble.com> <27416932.post@talk.nabble.com> Message-ID: <81ea7d401002020331v20016dbdwd2caca40f9cd62b0@mail.gmail.com> fac n = let { f = foldr (*) 1 [1..n] } in f :D sorry for double reply, need to cc cafe, this is fun. On Tue, Feb 2, 2010 at 4:33 PM, zaxis wrote: > > thanks for all suggestions. > > > zaxis wrote: >> >> For me i like C style instead of layout. For example, >> func1 a = do >> ? ? ?-- ... >> ? ? ?a * 2 >> ? ? ?-- ... >> >> I always write it as: >> func1 a = do { >> ? -- ...; >> ? ?a * 2; >> ? -- ...; >> } >> >> However, i donot know how to write pure function using C style. >> func1 a = { >> ? -- ...; >> ? ?a * 2; >> ? -- ...; >> } >> >> will not compile without `do`. >> >> Sincerely! >> > > > ----- > fac n = foldr (*) 1 [1..n] > -- > View this message in context: http://old.nabble.com/About-code-style---tp27414627p27416932.html > Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- jinjing From mark.spezzano at chariot.net.au Tue Feb 2 06:36:34 2010 From: mark.spezzano at chariot.net.au (Mark Spezzano) Date: Tue Feb 2 06:08:11 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> Message-ID: I should probably add that I am trying various proofs that involve injective and surjective properties of Hom Sets and Hom functions. Does anyone know what Hom stands for? I need a text for a newbie. Mark On 02/02/2010, at 9:56 PM, Mark Spezzano wrote: > Hi all, > > I'm trying to learn Haskell and have come across Monads. I kind of understand monads now, but I would really like to understand where they come from. So I got a copy of Barr and Well's Category Theory for Computing Science Third Edition, but the book has really left me dumbfounded. It's a good book. But I'm just having trouble with the proofs in Chapter 1--let alone reading the rest of the text. > > Are there any references to things like "Hom Sets" and "Hom Functions" in the literature somewhere and how to use them? The only book I know that uses them is this one. > > Has anyone else found it frustratingly difficult to find details on easy-to-diget material on Category theory. The Chapter that I'm stuck on is actually labelled Preliminaries and so I reason that if I can't do this, then there's not much hope for me understanding the rest of the book... > > Maybe there are books on Discrete maths or Algebra or Set Theory that deal more with Hom Sets and Hom Functions? > > Thanks, > > Mark Spezzano. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From miguelimo38 at yandex.ru Tue Feb 2 06:36:41 2010 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Tue Feb 2 06:12:07 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> Message-ID: <4B680E49.80704@yandex.ru> Hom(A, B) is just a set of morphisms from A to B. Mark Spezzano wrote: > I should probably add that I am trying various proofs that involve injective and surjective properties of Hom Sets and Hom functions. > > Does anyone know what Hom stands for? > > I need a text for a newbie. > > Mark > > On 02/02/2010, at 9:56 PM, Mark Spezzano wrote: > >> Hi all, >> >> I'm trying to learn Haskell and have come across Monads. I kind of understand monads now, but I would really like to understand where they come from. So I got a copy of Barr and Well's Category Theory for Computing Science Third Edition, but the book has really left me dumbfounded. It's a good book. But I'm just having trouble with the proofs in Chapter 1--let alone reading the rest of the text. >> >> Are there any references to things like "Hom Sets" and "Hom Functions" in the literature somewhere and how to use them? The only book I know that uses them is this one. >> >> Has anyone else found it frustratingly difficult to find details on easy-to-diget material on Category theory. The Chapter that I'm stuck on is actually labelled Preliminaries and so I reason that if I can't do this, then there's not much hope for me understanding the rest of the book... >> >> Maybe there are books on Discrete maths or Algebra or Set Theory that deal more with Hom Sets and Hom Functions? >> >> Thanks, >> >> Mark Spezzano. >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From Alistair.Bayley at invesco.com Tue Feb 2 07:01:25 2010 From: Alistair.Bayley at invesco.com (Bayley, Alistair) Date: Tue Feb 2 06:32:59 2010 Subject: [Haskell-cafe] About code style ? In-Reply-To: <27416932.post@talk.nabble.com> References: <27414627.post@talk.nabble.com> <27416932.post@talk.nabble.com> Message-ID: <125EACD0CAE4D24ABDB4D148C4593DA9110266EC@GBLONXMB02.corp.amvescap.net> > From: haskell-cafe-bounces@haskell.org > [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of zaxis > > > > For me i like C style instead of layout. For example, > > func1 a = do { > > -- ...; > > a * 2; > > -- ...; > > } The report has all the gory details. The brace+semicolon syntax isn't just for do-blocks; it can be used anywhere that indenting is used to specify scope. Section 2.7: http://www.haskell.org/onlinereport/lexemes.html#lexemes-layout Section 9.3: http://www.haskell.org/onlinereport/syntax-iso.html#layout Alistair ***************************************************************** Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. ***************************************************************** From kwangraecho at gmail.com Tue Feb 2 07:15:32 2010 From: kwangraecho at gmail.com (=?EUC-KR?B?wbaxpLeh?=) Date: Tue Feb 2 06:47:05 2010 Subject: [Haskell-cafe] matrix question Message-ID: <98f46b31002020415j7b41a5bar3698d13e3f206d08@mail.gmail.com> define functions type Matrix=[[Double]] multMM :: Matrix -> Matrix -> Matrix --multiplies two matrices det :: Matrix -> Double --computes the determinant of a matrix inv :: Matrix -> Matrix --inverts a matrix i stuck on those problems can any one help me out? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100202/845cd156/attachment.html From haberg at math.su.se Tue Feb 2 07:26:35 2010 From: haberg at math.su.se (Hans Aberg) Date: Tue Feb 2 06:58:08 2010 Subject: [Haskell-cafe] matrix question In-Reply-To: <98f46b31002020415j7b41a5bar3698d13e3f206d08@mail.gmail.com> References: <98f46b31002020415j7b41a5bar3698d13e3f206d08@mail.gmail.com> Message-ID: <6D8D39B4-08A4-45E1-BE17-50D9B9F2DE14@math.su.se> On 2 Feb 2010, at 13:15, ??? wrote: > define functions > > type Matrix=[[Double]] > > multMM :: Matrix -> Matrix -> Matrix --multiplies two matrices > det :: Matrix -> Double --computes the determinant of a matrix > inv :: Matrix -> Matrix --inverts a matrix > > i stuck on those problems > > can any one help me out? Plug in the word "matrix" on ; then there comes up matches "Prelude extensions" which has that type. There is also a Numeric Prelude. Hans From leather at cs.uu.nl Tue Feb 2 07:34:54 2010 From: leather at cs.uu.nl (Sean Leather) Date: Tue Feb 2 07:06:48 2010 Subject: [Haskell-cafe] Re: Generating repeatable arbitrary values with QuickCheck 2 In-Reply-To: <3c6288ab1002011354j7909e2a4w6116ff685c081224@mail.gmail.com> References: <3c6288ab1002011354j7909e2a4w6116ff685c081224@mail.gmail.com> Message-ID: <3c6288ab1002020434l496d0f41se869234ad0968de4@mail.gmail.com> Correction about the latter part... > In the end, I would write something like the following: > > unGen arbitrary (mkStdGen 11) 5 :: [Int] >> > > This produces, for example, [5,1,-2,-4,2]. I also want to generate the same > value for a type isomorphic to [Int]. > > unGen arbitrary (mkStdGen 11) 5 :: List Int >> > > Unfortunately, this produces Cons 4 (Cons 3 (Cons (-2) (Cons 0 (Cons (-1) > Nil)))): same length but different values. The Arbitrary instances are the > same. The Arbitrary instance were _slightly_ different, but different enough. ;) Now, the values are isomorphic. Thankfully, purity is restored. Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100202/1f93e932/attachment.html From agarcia at babel.ls.fi.upm.es Tue Feb 2 07:53:48 2010 From: agarcia at babel.ls.fi.upm.es (=?ISO-8859-1?Q?=C1lvaro_Garc=EDa_P=E9rez?=) Date: Tue Feb 2 07:25:23 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> Message-ID: You may try Pierce's "Basic Category Theory for Computer Scientists" or Awodey's "Category Theory", whose style is rather introductory. Both of them (I think) have a chapter about functors where they explain the Hom functor and related topics. Alvaro. 2010/2/2 Mark Spezzano > I should probably add that I am trying various proofs that involve > injective and surjective properties of Hom Sets and Hom functions. > > Does anyone know what Hom stands for? > > I need a text for a newbie. > > Mark > > On 02/02/2010, at 9:56 PM, Mark Spezzano wrote: > > > Hi all, > > > > I'm trying to learn Haskell and have come across Monads. I kind of > understand monads now, but I would really like to understand where they come > from. So I got a copy of Barr and Well's Category Theory for Computing > Science Third Edition, but the book has really left me dumbfounded. It's a > good book. But I'm just having trouble with the proofs in Chapter 1--let > alone reading the rest of the text. > > > > Are there any references to things like "Hom Sets" and "Hom Functions" in > the literature somewhere and how to use them? The only book I know that uses > them is this one. > > > > Has anyone else found it frustratingly difficult to find details on > easy-to-diget material on Category theory. The Chapter that I'm stuck on is > actually labelled Preliminaries and so I reason that if I can't do this, > then there's not much hope for me understanding the rest of the book... > > > > Maybe there are books on Discrete maths or Algebra or Set Theory that > deal more with Hom Sets and Hom Functions? > > > > Thanks, > > > > Mark Spezzano. > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100202/4b38b956/attachment.html From A.E.Lawrence at lboro.ac.uk Tue Feb 2 09:31:15 2010 From: A.E.Lawrence at lboro.ac.uk (A E Lawrence) Date: Tue Feb 2 09:02:59 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> Message-ID: <4B683733.1070006@lboro.ac.uk> Mark Spezzano wrote: > I need a text for a newbie. While the other books suggested are excellent, I think that they would be hard going if you find Barr & Wells difficult. The simplest introduction to the ideas of category theory that I know is "Conceptual Mathematics" by F W Lawvere & S H Schanuel. There are a great many online resources including many good books on category theory. But Barr & Wells is one of the best for application to Computing. ael From haskell at utr.dk Tue Feb 2 10:03:42 2010 From: haskell at utr.dk (Ulrik Rasmussen) Date: Tue Feb 2 09:35:26 2010 Subject: [Haskell-cafe] Tracer for Haskell showing substitutions Message-ID: <20100202150341.GA4586@squish> Hi all, I was wondering if someone has written a tracer/debugger that shows you how a given Haskell expression is evaluated, by generating all the intermediate states of the expression until it is in normal form? For instance, given the following code: > take' 0 xs = [] > take' n (x:xs) = x : take' (n-1) xs > exp = take' 2 [1,2,3,4,5,6] the trace of 'exp' would generate something like this: > exp = take' 2 [1,2,3,4,5,6] > exp = (\n (x:xs) -> x : take' (n-1) xs) 2 [1,2,3,4,5,6] > exp = 1 : take' (2-1) [2,3,4,5,6] > exp = 1 : take' 1 [2,3,4,5,6] > exp = 1 : (\n (x:xs) -> x : take' (n-1) xs) 1 [2,3,4,5,6] > exp = 1 : 2 : take' (1-1) [3,4,5,6] > exp = 1 : 2 : take' 0 [3,4,5,6] > exp = 1 : 2 : (\0 xs -> []) 0 [3,4,5,6] > exp = 1 : 2 : [] > exp = [1,2] That is, all the substitutions performed when evaluating 'exp' from left to right. I was thinking that something like this could be rather useful when teaching or learning Haskell. Thanks, Ulrik From jvranish at gmail.com Tue Feb 2 10:08:41 2010 From: jvranish at gmail.com (Job Vranish) Date: Tue Feb 2 09:40:18 2010 Subject: [Haskell-cafe] matrix question In-Reply-To: <98f46b31002020415j7b41a5bar3698d13e3f206d08@mail.gmail.com> References: <98f46b31002020415j7b41a5bar3698d13e3f206d08@mail.gmail.com> Message-ID: I have a little haskell matrix library for fixed sized matricies on github: http://github.com/jvranish/VectorMatix which I've just realized is horribly out of date...I'll update it tonight and probably push it to hackage too... but if you're really want to stick with the [[Double]] type, you can add a Foldable and Traversable instance to ZipLists and do this: instance Foldable ZipList where foldMap f (ZipList x) = foldMap f x instance Traversable ZipList where traverse f (ZipList x) = ZipList <$> traverse f x toZipList a = ZipList $ fmap ZipList a fromZipList a = getZipList $ fmap getZipList a multMM :: (Num a) => [[a]] -> [[a]] -> [[a]] multMM a b = fromZipList $ multMMA (toZipList a) (toZipList b) -- I about fell off my chair when I discovered you could do matrix multiplication like this: multMMA :: (Traversable f, Num a, Applicative f, Applicative row, Applicative col, Traversable col) => row (f a) -> f (col a) -> row (col a) multMMA a b = traverse (liftA2 dot a . pure) (sequenceA b) dot :: (Foldable t, Num a, Applicative t) => t a -> t a -> a dot a b = sum $ pure (*) <*> a <*> b My matrix library uses a Gaussian elimination function (which operates on lists) as well as det and inv functions which should be easily adaptable to work on lists. I'll make sure to push the updated code up tonight. - Job On Tue, Feb 2, 2010 at 7:15 AM, ??? wrote: > define functions > > type Matrix=[[Double]] > > multMM :: Matrix -> Matrix -> Matrix --multiplies two matrices > det :: Matrix -> Double --computes the determinant of a matrix > inv :: Matrix -> Matrix --inverts a matrix > > i stuck on those problems > > can any one help me out? > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100202/981e3188/attachment.html From asviraspossible at gmail.com Tue Feb 2 10:12:11 2010 From: asviraspossible at gmail.com (Victor Nazarov) Date: Tue Feb 2 09:43:44 2010 Subject: [Haskell-cafe] GUI programming Message-ID: Hello, I've been writing some GUI application with Gtk2hs. It's an interpreter for lambda-calculus and combinatory logic, it's GPL and if you interested I can share it with cafe. The problem is that the GUI code has become very ugly and I'm tempted to rewrite it totally. I've been looking forward to the FRP stuff, but I've never seen a single definition of the term. Conal Eliot's "denotational programming" is too general to be definition. I want to try Grapefruit, but I got totally lost when I see arrow notation. I consider more lightweight and more imperative approach, something closer to CSP (Communicating Secuential Processes) then FRP. I've just crafted some sample program to illustrate my idea. The behaviour is a monad and it's IO monad so you can do any IO (Gtk2hs) programming you wish. The differences is that you don't attach static event handlers and tries to determine what to do dependent on application state. You attach and detach handlers as much as possible. Behaviour looks like a process that can stop execution and wait for some GUI event. When event arrived it continues execution. Do you see this approach viable. There are steel some details to emerge: * How to wait for several events * How to handle IO exceptions Here is the code: {-# LANGUAGE ExistentialQuantification #-} module Main where import Data.IORef import System.Glib import Graphics.UI.Gtk import Control.Monad.Trans type Event obj = IO () -> IO (ConnectId obj) data Behaviour a = forall b. BBind (Behaviour b) (b -> Behaviour a) | BIO (IO a) | forall obj. GObjectClass obj => BWaitEvent (Event obj) (Behaviour a) instance Monad Behaviour where action >>= generator = BBind action generator return a = BIO (return a) instance MonadIO Behaviour where liftIO action = BIO action runBehaviour :: Behaviour a -> IO a runBehaviour (BBind (BWaitEvent event after) f) = runBehaviour (BWaitEvent event (after >>= f)) runBehaviour (BBind (BIO a) f) = a >>= \x -> runBehaviour (f x) runBehaviour (BBind (BBind a f) g) = runBehaviour (a >>= (\x -> f x >>= g)) runBehaviour (BIO a) = a runBehaviour (BWaitEvent event after) = do sigIdRef <- newIORef (error "You can't access sigIdRef before signal is connected") sigId <- event $ do sigId <- readIORef sigIdRef signalDisconnect sigId runBehaviour after return () writeIORef sigIdRef sigId return (error "You can't expect result from behaviour") waitEvent :: GObjectClass obj => Event obj -> Behaviour () waitEvent event = BWaitEvent event (return ()) main :: IO () main = do initGUI window <- windowNew onDestroy window mainQuit set window [windowTitle := "Hello World"] button <- buttonNew let buttonB label = do liftIO $ set button [buttonLabel := label] waitEvent (onClicked button) buttonB (label ++ "*") runBehaviour (buttonB "*") set window [containerChild := button] widgetShowAll window mainGUI -- Victor Nazarov -------------- next part -------------- A non-text attachment was scrubbed... Name: Main.hs Type: text/x-haskell Size: 1727 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100202/f1c1a644/Main.bin From maydwell at gmail.com Tue Feb 2 10:38:18 2010 From: maydwell at gmail.com (Lyndon Maydwell) Date: Tue Feb 2 10:09:51 2010 Subject: [Haskell-cafe] Game of life in haskell. Message-ID: Hi Cafe. I've made a basic game of life implementation with Haskell and OpenGL: https://github.com/sordina/Life/ The basic premise is to generate a random snapshot, then iterate the successor function on it to create an infinite list of snapshots, then output them using OpenGL. I haven't really run into any major issues aside from not being able to figure out how to automatically rerun the display function, however I believe this is an OpenGL problem, and not related to the Haskell side (press 'n' to move to the next snapshot for now). To run the game: cabal configure && cabal build && ./dist/build/life/life I'm intending to improve the performance, and add more advanced features, but I thought I'd get some feedback first. Can anyone see a way to make this code more idiomatic, or any optimizations I might have missed? I'm still fairly new to Haskell and I haven't really come to grips with monad-transformers and the like yet, so if any advanced techniques are applicable here it would really help me link what I think I understand to reality :-) Also, is something like this worth uploading to Hackage, or should I leave it on github? Thanks guys. From sergueyz at gmail.com Tue Feb 2 10:48:45 2010 From: sergueyz at gmail.com (Serguey Zefirov) Date: Tue Feb 2 10:20:21 2010 Subject: [Haskell-cafe] Game of life in haskell. In-Reply-To: References: Message-ID: <600376291002020748u2ea43beej78af2e721282382c@mail.gmail.com> 2010/2/2 Lyndon Maydwell : > Hi Cafe. > > I've made a basic game of life implementation with Haskell and OpenGL: > https://github.com/sordina/Life/ > > I'm intending to improve the performance, and add more advanced > features, but I thought I'd get some feedback first. Can anyone see a > way to make this code more idiomatic, or any optimizations I might > have missed? Arrays are not fully "idiomatic" for Haskell as they are hard to update functionally. Also, their use incurs quadratic update cost for simple scene with two gliders that fly in different directions. So I advice you to use Data.Map.Map and Data.Set.Set data structures. How? It's an easy question. ;) From maydwell at gmail.com Tue Feb 2 10:57:52 2010 From: maydwell at gmail.com (Lyndon Maydwell) Date: Tue Feb 2 10:29:25 2010 Subject: [Haskell-cafe] Game of life in haskell. In-Reply-To: <600376291002020748u2ea43beej78af2e721282382c@mail.gmail.com> References: <600376291002020748u2ea43beej78af2e721282382c@mail.gmail.com> Message-ID: I chose the array mainly for the fast lookup time compared to lists, are you suggesting something like creating a "Map (X,Y) Health"? I'm not currently updating any structures, rather creating the successor from scratch. I can see how the map may work very well for the sparse nature of non-early life games now that I think of it. On Tue, Feb 2, 2010 at 11:48 PM, Serguey Zefirov wrote: > 2010/2/2 Lyndon Maydwell : >> Hi Cafe. >> >> I've made a basic game of life implementation with Haskell and OpenGL: >> https://github.com/sordina/Life/ >> >> I'm intending to improve the performance, and add more advanced >> features, but I thought I'd get some feedback first. Can anyone see a >> way to make this code more idiomatic, or any optimizations I might >> have missed? > > Arrays are not fully "idiomatic" for Haskell as they are hard to > update functionally. > > Also, their use incurs quadratic update cost for simple scene with two > gliders that fly in different directions. > > So I advice you to use Data.Map.Map and Data.Set.Set data structures. > > How? It's an easy question. ;) > From sergueyz at gmail.com Tue Feb 2 11:10:05 2010 From: sergueyz at gmail.com (Serguey Zefirov) Date: Tue Feb 2 10:41:40 2010 Subject: [Haskell-cafe] Game of life in haskell. In-Reply-To: References: <600376291002020748u2ea43beej78af2e721282382c@mail.gmail.com> Message-ID: <600376291002020810t7e37c398oa3bcd52c41d5fbe6@mail.gmail.com> 2010/2/2 Lyndon Maydwell : > I chose the array mainly for the fast lookup time compared to lists, > are you suggesting something like creating a "Map (X,Y) Health"? I'm > not currently updating any structures, rather creating the successor > from scratch. I can see how the map may work very well for the sparse > nature of non-early life games now that I think of it. Because your Health is basically Bool, you can use Set (X,Y) for a set of live objects. Creation of new Array is (without knowing some subtle details) is O(max coordinates difference between live cells). Creation of new Set (X,Y) is O(NlogN) (N = number of live objects). Most of the cells in Life are empty, so the Set/Map approach is faster. Also it leads to very concise code. Actually, your solution with arrays is the most often occured solution an imperative programmer will come with. It is simple but not scalable and not particularly fast. From maydwell at gmail.com Tue Feb 2 11:17:24 2010 From: maydwell at gmail.com (Lyndon Maydwell) Date: Tue Feb 2 10:48:56 2010 Subject: [Haskell-cafe] Game of life in haskell. In-Reply-To: <600376291002020810t7e37c398oa3bcd52c41d5fbe6@mail.gmail.com> References: <600376291002020748u2ea43beej78af2e721282382c@mail.gmail.com> <600376291002020810t7e37c398oa3bcd52c41d5fbe6@mail.gmail.com> Message-ID: I'm avoiding hard-coding bools anywhere as I intend to allow fuzzy-representations at some point. On Wed, Feb 3, 2010 at 12:10 AM, Serguey Zefirov wrote: > 2010/2/2 Lyndon Maydwell : >> I chose the array mainly for the fast lookup time compared to lists, >> are you suggesting something like creating a "Map (X,Y) Health"? I'm >> not currently updating any structures, rather creating the successor >> from scratch. I can see how the map may work very well for the sparse >> nature of non-early life games now that I think of it. > > Because your Health is basically Bool, you can use Set (X,Y) for a set > of live objects. > > Creation of new Array is (without knowing some subtle details) is > O(max coordinates difference between live cells). Creation of new Set > (X,Y) is O(NlogN) (N = number of live objects). Most of the cells in > Life are empty, so the Set/Map approach is faster. Also it leads to > very concise code. > > Actually, your solution with arrays is the most often occured solution > an imperative programmer will come with. It is simple but not scalable > and not particularly fast. > From manuel.a.castro at gmail.com Tue Feb 2 11:37:30 2010 From: manuel.a.castro at gmail.com (man) Date: Tue Feb 2 11:09:06 2010 Subject: [Haskell-cafe] matrix question In-Reply-To: References: <98f46b31002020415j7b41a5bar3698d13e3f206d08@mail.gmail.com> Message-ID: <47a7e7c61002020837l45bb18e3rfa3547939cf19d8f@mail.gmail.com> http://hackage.haskell.org/package/hmatrix-0.8.1.1 it wraps gls, blas and lapack (so you need to install the libraries). On Tue, Feb 2, 2010 at 4:08 PM, Job Vranish wrote: > I have a little haskell matrix library for fixed sized matricies on github: > http://github.com/jvranish/VectorMatix > which I've just realized is horribly out of date...I'll update it tonight > and probably push it to hackage too... > > but if you're really want to stick with the [[Double]] type, > you can add a Foldable and Traversable instance to ZipLists and do this: > > instance Foldable ZipList where > foldMap f (ZipList x) = foldMap f x > > instance Traversable ZipList where > traverse f (ZipList x) = ZipList <$> traverse f x > > toZipList a = ZipList $ fmap ZipList a > fromZipList a = getZipList $ fmap getZipList a > > multMM :: (Num a) => [[a]] -> [[a]] -> [[a]] > multMM a b = fromZipList $ multMMA (toZipList a) (toZipList b) > > -- I about fell off my chair when I discovered you could do matrix > multiplication like this: > multMMA :: (Traversable f, Num a, Applicative f, Applicative row, > Applicative col, Traversable col) => > row (f a) -> f (col a) -> row (col a) > multMMA a b = traverse (liftA2 dot a . pure) (sequenceA b) > > dot :: (Foldable t, Num a, Applicative t) => t a -> t a -> a > dot a b = sum $ pure (*) <*> a <*> b > > > My matrix library uses a Gaussian elimination function (which operates on > lists) as well as det and inv functions which should be easily adaptable to > work on lists. > > I'll make sure to push the updated code up tonight. > > - Job > > > > > > On Tue, Feb 2, 2010 at 7:15 AM, ??? wrote: > >> define functions >> >> type Matrix=[[Double]] >> >> multMM :: Matrix -> Matrix -> Matrix --multiplies two matrices >> det :: Matrix -> Double --computes the determinant of a matrix >> inv :: Matrix -> Matrix --inverts a matrix >> >> i stuck on those problems >> >> can any one help me out? >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- happy hacking... man -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100202/022c2e71/attachment.html From jon at ffconsultancy.com Tue Feb 2 13:26:08 2010 From: jon at ffconsultancy.com (Jon Harrop) Date: Tue Feb 2 11:42:16 2010 Subject: [Haskell-cafe] Game of life in haskell. In-Reply-To: <600376291002020810t7e37c398oa3bcd52c41d5fbe6@mail.gmail.com> References: <600376291002020810t7e37c398oa3bcd52c41d5fbe6@mail.gmail.com> Message-ID: <201002021826.08089.jon@ffconsultancy.com> On Tuesday 02 February 2010 16:10:05 Serguey Zefirov wrote: > Actually, your solution with arrays is the most often occured solution > an imperative programmer will come with. It is simple but not scalable > and not particularly fast. What gave you that impression? -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e From wchogg at gmail.com Tue Feb 2 12:16:03 2010 From: wchogg at gmail.com (Creighton Hogg) Date: Tue Feb 2 11:47:36 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> Message-ID: <814617241002020916o59f45a5cg622c150c363c4913@mail.gmail.com> 2010/2/2 ?lvaro Garc?a P?rez > You may try Pierce's "Basic Category Theory for Computer Scientists" or > Awodey's "Category Theory", whose style is rather introductory. Both of them > (I think) have a chapter about functors where they explain the Hom functor > and related topics. > I think Awodey's book is pretty fantastic, actually, but I'd avoid Pierce. Unlike "Types and Programming Languages", I think "Basic Category Theory..." is a bit eccentric in its presentation and doesn't help the reader build intuition. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100202/8efcc1c2/attachment.html From ezra.lalonde at gmail.com Tue Feb 2 13:03:50 2010 From: ezra.lalonde at gmail.com (Ezra Lalonde) Date: Tue Feb 2 12:35:21 2010 Subject: [Haskell-cafe] Tracer for Haskell showing substitutions In-Reply-To: <20100202150341.GA4586@squish> References: <20100202150341.GA4586@squish> Message-ID: <27424789.post@talk.nabble.com> Hi, "Hat": The Haskell Tracer. http://www.haskell.org/hat/ >From the site: Hat helps locating errors in programs. Furthermore, it is useful for understanding how a (correct) program works, especially for teaching and program maintenance. Hat is not a time or space profiler. Hat can be used for programs that terminate normally, that terminate with an error message or that terminate when interrupted by the programmer. "Vital"/"Pivotal": it's dead, but it may be interesting to you anyway. http://www.cs.kent.ac.uk/projects/pivotal/ http://www.cs.kent.ac.uk/projects/vital/ >From the site: Pivotal has similar goals to its predecessor system, Vital. In particular: * Documents are live in the sense that, if a document is changed, the displayed values are automatically re-evaluated. Thus documents are always in a consistent state. * Direct manipulation of ADT values is supported. That is, an end user is able to manipulate the text of a Haskell module simply by point-and-click mouse operations on displayed values. Pen and paper work too. Ezra. Ulrik Rasmussen-2 wrote: > > Hi all, > > I was wondering if someone has written a tracer/debugger that shows you > how a given Haskell expression is evaluated, by generating all the > intermediate states of the expression until it is in normal form? > > For instance, given the following code: > >> take' 0 xs = [] >> take' n (x:xs) = x : take' (n-1) xs >> exp = take' 2 [1,2,3,4,5,6] > > the trace of 'exp' would generate something like this: > >> exp = take' 2 [1,2,3,4,5,6] >> exp = (\n (x:xs) -> x : take' (n-1) xs) 2 [1,2,3,4,5,6] >> exp = 1 : take' (2-1) [2,3,4,5,6] >> exp = 1 : take' 1 [2,3,4,5,6] >> exp = 1 : (\n (x:xs) -> x : take' (n-1) xs) 1 [2,3,4,5,6] >> exp = 1 : 2 : take' (1-1) [3,4,5,6] >> exp = 1 : 2 : take' 0 [3,4,5,6] >> exp = 1 : 2 : (\0 xs -> []) 0 [3,4,5,6] >> exp = 1 : 2 : [] >> exp = [1,2] > > That is, all the substitutions performed when evaluating 'exp' from left > to right. > > I was thinking that something like this could be rather useful when > teaching or learning Haskell. > > > Thanks, > > Ulrik > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- View this message in context: http://old.nabble.com/Tracer-for-Haskell-showing-substitutions-tp27421880p27424789.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From sergueyz at gmail.com Tue Feb 2 13:23:06 2010 From: sergueyz at gmail.com (Serguey Zefirov) Date: Tue Feb 2 12:54:39 2010 Subject: [Haskell-cafe] Game of life in haskell. In-Reply-To: References: <600376291002020748u2ea43beej78af2e721282382c@mail.gmail.com> <600376291002020810t7e37c398oa3bcd52c41d5fbe6@mail.gmail.com> Message-ID: <600376291002021023g1e97ecc4vb6796abfc5ad2aab@mail.gmail.com> 2010/2/2 Lyndon Maydwell : > I'm avoiding hard-coding bools anywhere as I intend to allow > fuzzy-representations at some point. What is the meaning of fuzzy Game of Life? Where can I read about? Or you're planning to average field over some time interval? In the latter case you still will be faster using Sets, converting them into Maps using singleton, doing some unionsWith and then map with (/timeInterval). From sergueyz at gmail.com Tue Feb 2 13:23:59 2010 From: sergueyz at gmail.com (Serguey Zefirov) Date: Tue Feb 2 12:55:34 2010 Subject: [Haskell-cafe] Game of life in haskell. In-Reply-To: <201002021826.08089.jon@ffconsultancy.com> References: <600376291002020810t7e37c398oa3bcd52c41d5fbe6@mail.gmail.com> <201002021826.08089.jon@ffconsultancy.com> Message-ID: <600376291002021023w5510249fpf9cad19ffed6aa5c@mail.gmail.com> 2010/2/2 Jon Harrop : > On Tuesday 02 February 2010 16:10:05 Serguey Zefirov wrote: >> Actually, your solution with arrays is the most often occured solution >> an imperative programmer will come with. It is simple but not scalable >> and not particularly fast. > > What gave you that impression? Discussion in Russian Smalltalk User Group. A solution in APL: http://catpad.net/michael/apl/ Some experience before (my own first implementation and some of my friends). Or, you're asking about scalability and speed? From jon at ffconsultancy.com Tue Feb 2 14:54:21 2010 From: jon at ffconsultancy.com (Jon Harrop) Date: Tue Feb 2 13:10:30 2010 Subject: [Haskell-cafe] Game of life in haskell. In-Reply-To: <600376291002021023w5510249fpf9cad19ffed6aa5c@mail.gmail.com> References: <201002021826.08089.jon@ffconsultancy.com> <600376291002021023w5510249fpf9cad19ffed6aa5c@mail.gmail.com> Message-ID: <201002021954.22028.jon@ffconsultancy.com> On Tuesday 02 February 2010 18:23:59 Serguey Zefirov wrote: > 2010/2/2 Jon Harrop : > > On Tuesday 02 February 2010 16:10:05 Serguey Zefirov wrote: > >> Actually, your solution with arrays is the most often occured solution > >> an imperative programmer will come with. It is simple but not scalable > >> and not particularly fast. > > > > What gave you that impression? > > Discussion in Russian Smalltalk User Group. > A solution in APL: http://catpad.net/michael/apl/ > Some experience before (my own first implementation and some of my > friends). > > Or, you're asking about scalability and speed? I meant the scalability and speed. An imperative solution should be simpler, more scalable and faster than any purely functional solution. -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e From leimy2k at gmail.com Tue Feb 2 13:44:25 2010 From: leimy2k at gmail.com (David Leimbach) Date: Tue Feb 2 13:16:01 2010 Subject: [Haskell-cafe] Game of life in haskell. In-Reply-To: <201002021954.22028.jon@ffconsultancy.com> References: <201002021826.08089.jon@ffconsultancy.com> <600376291002021023w5510249fpf9cad19ffed6aa5c@mail.gmail.com> <201002021954.22028.jon@ffconsultancy.com> Message-ID: <3e1162e61002021044y5e9a7415xa25a6eb70590c406@mail.gmail.com> On Tue, Feb 2, 2010 at 11:54 AM, Jon Harrop wrote: > On Tuesday 02 February 2010 18:23:59 Serguey Zefirov wrote: > > 2010/2/2 Jon Harrop : > > > On Tuesday 02 February 2010 16:10:05 Serguey Zefirov wrote: > > >> Actually, your solution with arrays is the most often occured solution > > >> an imperative programmer will come with. It is simple but not scalable > > >> and not particularly fast. > > > > > > What gave you that impression? > > > > Discussion in Russian Smalltalk User Group. > > A solution in APL: http://catpad.net/michael/apl/ > > Some experience before (my own first implementation and some of my > > friends). > > > > Or, you're asking about scalability and speed? > > I meant the scalability and speed. An imperative solution should be > simpler, > more scalable and faster than any purely functional solution. > That's a pretty strange comment. Why do you think an imperative solution is simpler, faster and more scalable? If functional programming can't provide any one of those, it's not worth anything, and based on the membership in this list, the interest in it these days, and the fact that I've seen many occasions where functional programming lends itself to a faster implementation (in terms of time to implement and test) that's actually readable sooner than a lot of imperative approaches, I find your claim to be quite contrary and smells of "trollishness". Dave > > -- > Dr Jon Harrop, Flying Frog Consultancy Ltd. > http://www.ffconsultancy.com/?e > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100202/9a021f5b/attachment-0001.html From sergueyz at gmail.com Tue Feb 2 13:44:41 2010 From: sergueyz at gmail.com (Serguey Zefirov) Date: Tue Feb 2 13:16:18 2010 Subject: [Haskell-cafe] Game of life in haskell. In-Reply-To: <201002021954.22028.jon@ffconsultancy.com> References: <201002021826.08089.jon@ffconsultancy.com> <600376291002021023w5510249fpf9cad19ffed6aa5c@mail.gmail.com> <201002021954.22028.jon@ffconsultancy.com> Message-ID: <600376291002021044q33d501c6vbfac3fcdddc3d138@mail.gmail.com> 2010/2/2 Jon Harrop : >> Or, you're asking about scalability and speed? > > I meant the scalability and speed. An imperative solution should be simpler, > more scalable and faster than any purely functional solution. So, please, provide any and we'll discuss difference between ours. Mine is here: http://thesz.livejournal.com/1028039.html (sorry for russian text, the solution is pure Haskell anyway;) From dons at galois.com Tue Feb 2 13:48:19 2010 From: dons at galois.com (Don Stewart) Date: Tue Feb 2 13:19:58 2010 Subject: [Haskell-cafe] Game of life in haskell. In-Reply-To: <3e1162e61002021044y5e9a7415xa25a6eb70590c406@mail.gmail.com> References: <201002021826.08089.jon@ffconsultancy.com> <600376291002021023w5510249fpf9cad19ffed6aa5c@mail.gmail.com> <201002021954.22028.jon@ffconsultancy.com> <3e1162e61002021044y5e9a7415xa25a6eb70590c406@mail.gmail.com> Message-ID: <20100202184819.GH4289@whirlpool.galois.com> leimy2k: > > > On Tue, Feb 2, 2010 at 11:54 AM, Jon Harrop wrote: > > On Tuesday 02 February 2010 18:23:59 Serguey Zefirov wrote: > > 2010/2/2 Jon Harrop : > > > On Tuesday 02 February 2010 16:10:05 Serguey Zefirov wrote: > > >> Actually, your solution with arrays is the most often occured solution > > >> an imperative programmer will come with. It is simple but not scalable > > >> and not particularly fast. > > > > > > What gave you that impression? > > > > Discussion in Russian Smalltalk User Group. > > A solution in APL: http://catpad.net/michael/apl/ > > Some experience before (my own first implementation and some of my > > friends). > > > > Or, you're asking about scalability and speed? > > I meant the scalability and speed. An imperative solution should be > simpler, more scalable and faster than any purely functional solution. > > That's a pretty strange comment. Why do you think an imperative solution is > simpler, faster and more scalable? Don't feed the troll^[1] -- Don [1]. Top 10 signs you have a troll (pick any you think relevant) - http://www.haskell.org/haskellwiki/Protect_the_community/Notes#Identify_poisonous_people - Conceit + won't engage/argue with other positions + makes sweeping claims. empty statements about a project's success + reopens topics from years ago From ryani.spam at gmail.com Tue Feb 2 13:48:55 2010 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue Feb 2 13:20:26 2010 Subject: [Haskell-cafe] Re: Generating repeatable arbitrary values with QuickCheck 2 In-Reply-To: <3c6288ab1002020434l496d0f41se869234ad0968de4@mail.gmail.com> References: <3c6288ab1002011354j7909e2a4w6116ff685c081224@mail.gmail.com> <3c6288ab1002020434l496d0f41se869234ad0968de4@mail.gmail.com> Message-ID: <2f9b2d31002021048s3399622cyf3743531a3abfd64@mail.gmail.com> Gen slightly breaks the monad laws: > arbitrary >>= return is not the same as > return () >>= const arbitrary because each bind splits the generator, so you end up with a different seed passed to arbitrary in these two cases. If the observable value is "some random object" this is a safe fudge, but if you want repeatable, it doesn't quite work. You need your instances to be exactly identical, down to the associativity of binds, in order to get the same results. -- ryan On Tue, Feb 2, 2010 at 4:34 AM, Sean Leather wrote: > Correction about the latter part... > >> >> In the end, I would write something like the following: >> >>> unGen arbitrary (mkStdGen 11) 5 :: [Int] >> >> This produces, for example, [5,1,-2,-4,2]. I also want to generate the >> same value for a type isomorphic to [Int]. >> >>> unGen arbitrary (mkStdGen 11) 5 :: List Int >> >> Unfortunately, this produces Cons 4 (Cons 3 (Cons (-2) (Cons 0 (Cons (-1) >> Nil)))): same length but different values. The Arbitrary instances are the >> same. > > The Arbitrary instance were _slightly_ different, but different enough. ;) > Now, the values are isomorphic. Thankfully, purity is restored. > > Sean > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From dlb at patriot.net Tue Feb 2 13:59:43 2010 From: dlb at patriot.net (dlb@patriot.net) Date: Tue Feb 2 13:31:16 2010 Subject: [Haskell-cafe] Failure to load hmatric Message-ID: <55188.128.100.5.138.1265137183.squirrel@www.patriot.net> OK, I'm working on matrix stuff in Haskell now (I've been trying to get the professor to approve that) and when I use cabal install to install hmatrix, it fails at HUnit with: ----------- Configuring HUnit-1.2.2.1... Preprocessing library HUnit-1.2.2.1... Preprocessing executables for HUnit-1.2.2.1... Building HUnit-1.2.2.1... [1 of 5] Compiling Test.HUnit.Terminal ( Test/HUnit/Terminal.hs, dist/build/Test/HUnit/Terminal.o ) [2 of 5] Compiling Test.HUnit.Lang ( Test/HUnit/Lang.hs, dist/build/Test/HUnit/Lang.o ) [3 of 5] Compiling Test.HUnit.Base ( Test/HUnit/Base.hs, dist/build/Test/HUnit/Base.o ) [4 of 5] Compiling Test.HUnit.Text ( Test/HUnit/Text.hs, dist/build/Test/HUnit/Text.o ) [5 of 5] Compiling Test.HUnit ( Test/HUnit.hs, dist/build/Test/HUnit.o ) /usr/bin/ar: creating dist/build/libHSHUnit-1.2.2.1.a Test/HUnit/Lang.hs:22:1: lexical error at character 'i' cabal: Error: some packages failed to install: HUnit-1.2.2.1 failed during the building phase. The exception was: exit: ExitFailure 1 ---------------- Short term question: what the heck do I do with this? Long term question: how can I handle cabal failures of this type without bothering the list every time? Dave Barton University of Toronto From gwern0 at gmail.com Tue Feb 2 14:12:56 2010 From: gwern0 at gmail.com (Gwern Branwen) Date: Tue Feb 2 13:44:27 2010 Subject: [Haskell-cafe] Failure to load hmatric In-Reply-To: <55188.128.100.5.138.1265137183.squirrel@www.patriot.net> References: <55188.128.100.5.138.1265137183.squirrel@www.patriot.net> Message-ID: On Tue, Feb 2, 2010 at 1:59 PM, wrote: > OK, I'm working on matrix stuff in Haskell now (I've been trying to get > the professor to approve that) and when I use cabal install to install > hmatrix, it fails at HUnit with: > ----------- > Configuring HUnit-1.2.2.1... > Preprocessing library HUnit-1.2.2.1... > Preprocessing executables for HUnit-1.2.2.1... > Building HUnit-1.2.2.1... > [1 of 5] Compiling Test.HUnit.Terminal ( Test/HUnit/Terminal.hs, > dist/build/Test/HUnit/Terminal.o ) > [2 of 5] Compiling Test.HUnit.Lang ?( Test/HUnit/Lang.hs, > dist/build/Test/HUnit/Lang.o ) > [3 of 5] Compiling Test.HUnit.Base ?( Test/HUnit/Base.hs, > dist/build/Test/HUnit/Base.o ) > [4 of 5] Compiling Test.HUnit.Text ?( Test/HUnit/Text.hs, > dist/build/Test/HUnit/Text.o ) > [5 of 5] Compiling Test.HUnit ? ? ? ( Test/HUnit.hs, > dist/build/Test/HUnit.o ) > /usr/bin/ar: creating dist/build/libHSHUnit-1.2.2.1.a > > Test/HUnit/Lang.hs:22:1: lexical error at character 'i' > cabal: Error: some packages failed to install: > HUnit-1.2.2.1 failed during the building phase. The exception was: > exit: ExitFailure 1 > ---------------- > > Short term question: ?what the heck do I do with this? > > Long term question: how can I handle cabal failures of this type without > bothering the list every time? > > Dave Barton > University of Toronto Well, the obvious thing to do is to look at the line causing the error. The line and surrounding lines are: ------------------------------- -- Imports -- ------- import Data.List (isPrefixOf) 21: #if defined(__GLASGOW_HASKELL__) || defined(__HUGS__) import Data.Dynamic import Control.Exception as E #else import System.IO.Error (ioeGetErrorString, try) #endif ----------------------------------- Line 12 is the first CPP directive in the file; GHC doesn't understand CPP unless you tell it to. So one could look at the hunit.cabal and try to figure out why CPP wasn't enabled, or one could add into the first line of the file '{-# LANGUAGE CPP #-}' and work around it. But you can't start if you don't know what the problem is. -- gwern From dave at zednenem.com Tue Feb 2 14:25:04 2010 From: dave at zednenem.com (David Menendez) Date: Tue Feb 2 13:56:38 2010 Subject: [Haskell-cafe] Re: Generating repeatable arbitrary values with QuickCheck 2 In-Reply-To: <2f9b2d31002021048s3399622cyf3743531a3abfd64@mail.gmail.com> References: <3c6288ab1002011354j7909e2a4w6116ff685c081224@mail.gmail.com> <3c6288ab1002020434l496d0f41se869234ad0968de4@mail.gmail.com> <2f9b2d31002021048s3399622cyf3743531a3abfd64@mail.gmail.com> Message-ID: <49a77b7a1002021125k4f260adakdbcb187f873412e@mail.gmail.com> On Tue, Feb 2, 2010 at 1:48 PM, Ryan Ingram wrote: > Gen slightly breaks the monad laws: > >> arbitrary >>= return > is not the same as >> return () >>= const arbitrary > because each bind splits the generator, so you end up with a different > seed passed to arbitrary in these two cases. > > If the observable value is "some random object" this is a safe fudge, > but if you want repeatable, it doesn't quite work. ?You need your > instances to be exactly identical, down to the associativity of binds, > in order to get the same results. We could avoid that problem by redefining Gen as a state transformer monad. newtype Gen a = MkGen { unGen :: StdGen -> Int -> (a, StdGen) } instance Monad Gen where return a = MkGen $ \r _ -> (a,r) MkGen m >>= k = MkGen $ \r n -> let (a,r') = m r n in unGen (k a) r' n I'm pretty sure all the Gen primitives can be similarly redefined. -- Dave Menendez From arne.d.h at gmail.com Tue Feb 2 15:10:09 2010 From: arne.d.h at gmail.com (Arne D Halvorsen) Date: Tue Feb 2 14:42:14 2010 Subject: [Haskell-cafe] Game of life in haskell. In-Reply-To: <201002021826.08089.jon@ffconsultancy.com> References: <600376291002020810t7e37c398oa3bcd52c41d5fbe6@mail.gmail.com> <201002021826.08089.jon@ffconsultancy.com> Message-ID: <188524DC-50C8-45F6-92AB-BAE24EDB7DAD@gmail.com> Den 2. feb. 2010 kl. 19.26 skrev Jon Harrop : > On Tuesday 02 February 2010 16:10:05 Serguey Zefirov wrote: >> Actually, your solution with arrays is the most often occured >> solution >> an imperative programmer will come with. It is simple but not >> scalable >> and not particularly fast. > > What gave you that impression? If I may butt in here: to get a scalable, fast Game of Life, you should look into Hashlife (by Gosper?) as exemplified in the open source application Golly. It gives an astonishing speedup, and it would be interesting to see it expressed in Haskell. Regards, Arne D Halvorsen > > -- > Dr Jon Harrop, Flying Frog Consultancy Ltd. > http://www.ffconsultancy.com/?e > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From arne.d.h at gmail.com Tue Feb 2 15:23:29 2010 From: arne.d.h at gmail.com (Arne D Halvorsen) Date: Tue Feb 2 14:55:34 2010 Subject: [Haskell-cafe] SYB/Generics documentation inaccessible Message-ID: I have tried to access a few of the documents on generics that are referred to from wikipedia, from the GHC documentation, from hackage and from the wiki. These documents (on vu.nl, subdirectory boilerplate and strafunski) are apparently forbidden to me, and have been for some weeks. I tried to mail a webmaster and some other mentioned mail addresses, but the mails bounced. Could somebody make the docs accessible, or should it be re-hosted on Hackage? Regards Arne D Halvorsen From dominic at steinitz.org Tue Feb 2 15:28:01 2010 From: dominic at steinitz.org (Dominic Steinitz) Date: Tue Feb 2 15:00:29 2010 Subject: [Haskell-cafe] Re: Category Theory woes References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> Message-ID: Mark Spezzano chariot.net.au> writes: > > Maybe there are books on Discrete maths or Algebra or Set Theory that deal more with Hom Sets and Hom Functions? > Googling "haskell category theory" I got: http://en.wikibooks.org/wiki/Haskell/Category_theory http://www.haskell.org/haskellwiki/Category_theory and many others. The latter has a list of books. Perhaps people could update with books they are familiar with and add comments? Dominic. From leather at cs.uu.nl Tue Feb 2 15:30:31 2010 From: leather at cs.uu.nl (Sean Leather) Date: Tue Feb 2 15:02:27 2010 Subject: [Haskell-cafe] Re: Generating repeatable arbitrary values with QuickCheck 2 In-Reply-To: <49a77b7a1002021125k4f260adakdbcb187f873412e@mail.gmail.com> References: <3c6288ab1002011354j7909e2a4w6116ff685c081224@mail.gmail.com> <3c6288ab1002020434l496d0f41se869234ad0968de4@mail.gmail.com> <2f9b2d31002021048s3399622cyf3743531a3abfd64@mail.gmail.com> <49a77b7a1002021125k4f260adakdbcb187f873412e@mail.gmail.com> Message-ID: <3c6288ab1002021230i22b6caeeg15e98692c2af3a1b@mail.gmail.com> On Tue, Feb 2, 2010 at 20:25, David Menendez wrote: > On Tue, Feb 2, 2010 at 1:48 PM, Ryan Ingram wrote: > > Gen slightly breaks the monad laws: > > > >> arbitrary >>= return > > is not the same as > >> return () >>= const arbitrary > > because each bind splits the generator, so you end up with a different > > seed passed to arbitrary in these two cases. > Ah yes, that was exactly the problem. > > If the observable value is "some random object" this is a safe fudge, > > but if you want repeatable, it doesn't quite work. You need your > > instances to be exactly identical, down to the associativity of binds, > > in order to get the same results. > > We could avoid that problem by redefining Gen as a state transformer monad. > > newtype Gen a = MkGen { unGen :: StdGen -> Int -> (a, StdGen) } > > instance Monad Gen where > return a = MkGen $ \r _ -> (a,r) > MkGen m >>= k = MkGen $ \r n -> let (a,r') = m r n in unGen (k a) r' n > > I'm pretty sure all the Gen primitives can be similarly redefined. > And I'm guessing I haven't been or won't be the only one running into this issue. Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100202/87ce07c9/attachment.html From arne.d.h at gmail.com Tue Feb 2 15:51:43 2010 From: arne.d.h at gmail.com (Arne Dehli Halvorsen) Date: Tue Feb 2 15:23:16 2010 Subject: [Haskell-cafe]SYB/Generics documentation inaccessible In-Reply-To: References: Message-ID: <203d94091002021251p63e3a9ffi1376077c23ec758a@mail.gmail.com> I have tried to access a few of the documents on generics that are referred to from wikipedia, from the GHC documentation, from hackage and from the wiki. These documents (on vu.nl, subdirectory boilerplate and strafunski) are apparently forbidden to me, and have been for some weeks. I tried to mail a webmaster and some other mentioned mail addresses, but the mails bounced. Could somebody make the docs accessible, or should it be re-hosted on Hackage? Regards Arne D Halvorsen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100202/bbae7c19/attachment.html From dot at dotat.at Tue Feb 2 16:07:59 2010 From: dot at dotat.at (Tony Finch) Date: Tue Feb 2 15:39:31 2010 Subject: [Haskell-cafe] Game of life in haskell. In-Reply-To: <188524DC-50C8-45F6-92AB-BAE24EDB7DAD@gmail.com> References: <600376291002020810t7e37c398oa3bcd52c41d5fbe6@mail.gmail.com> <201002021826.08089.jon@ffconsultancy.com> <188524DC-50C8-45F6-92AB-BAE24EDB7DAD@gmail.com> Message-ID: On Tue, 2 Feb 2010, Arne D Halvorsen wrote: > > If I may butt in here: to get a scalable, fast Game of Life, you should look > into Hashlife (by Gosper?) as exemplified in the open source application > Golly. It gives an astonishing speedup, and it would be interesting to see it > expressed in Haskell. I played around with implementing hashlife a few years ago. It is a truly beautiful algorithm, and mind-expanding if all you know is representing Life as an array of booleans. The problem with implementing it in Haskell is it relies on persistent object identities (of the branches of a quadtree) that it hashes in order to memoize quadtree creation. This makes what ought to be a beautifully quasi-functional algorithm look ugly and imperative. Tony. -- f.anthony.n.finch http://dotat.at/ GERMAN BIGHT HUMBER: SOUTHWEST 5 TO 7. MODERATE OR ROUGH. SQUALLY SHOWERS. MODERATE OR GOOD. From dot at dotat.at Tue Feb 2 16:23:02 2010 From: dot at dotat.at (Tony Finch) Date: Tue Feb 2 15:54:35 2010 Subject: [Haskell-cafe] Game of life in haskell. In-Reply-To: <600376291002020810t7e37c398oa3bcd52c41d5fbe6@mail.gmail.com> References: <600376291002020748u2ea43beej78af2e721282382c@mail.gmail.com> <600376291002020810t7e37c398oa3bcd52c41d5fbe6@mail.gmail.com> Message-ID: On Tue, 2 Feb 2010, Serguey Zefirov wrote: > > Creation of new Array is (without knowing some subtle details) is > O(max coordinates difference between live cells). Creation of new Set > (X,Y) is O(NlogN) (N = number of live objects). Most of the cells in > Life are empty, so the Set/Map approach is faster. Also it leads to > very concise code. I have a small and relatively quick Life algorithm that's based on lists, so it should translato to Haskell quite nicely. The basic representation of the Life universe is a sorted list of the co-ordinates of live cells. You can compute a new generation in one scan of the list, or rather a kind of zip3 that scans a 3x3 box along three adjacent rows, skipping empty space. It's much faster if, instead of storing one live cell in each list element, you store a small word-sized bitmap. You can then use SIMD-within-a-register to combine the three rows of cells and emit a new bitmap if it is non-zero. Have a look at http://dotat.at/prog/life/life.html for the story of how I developed the algorithm, including C source (about 40 lines of code). I've written a couple of other articles about SWAR techniques for Life: http://fanf.livejournal.com/81169.html http://fanf.livejournal.com/93032.html Getting the bits onto the screen quickly is the hardest part :-) Tony. -- f.anthony.n.finch http://dotat.at/ GERMAN BIGHT HUMBER: SOUTHWEST 5 TO 7. MODERATE OR ROUGH. SQUALLY SHOWERS. MODERATE OR GOOD. From edgar at ymonad.com Tue Feb 2 16:22:43 2010 From: edgar at ymonad.com (edgar@ymonad.com) Date: Tue Feb 2 15:55:47 2010 Subject: [Haskell-cafe] Game of life in haskell. In-Reply-To: <188524DC-50C8-45F6-92AB-BAE24EDB7DAD@gmail.com> References: <600376291002020810t7e37c398oa3bcd52c41d5fbe6@mail.gmail.com> <201002021826.08089.jon@ffconsultancy.com> <188524DC-50C8-45F6-92AB-BAE24EDB7DAD@gmail.com> Message-ID: <20100202212243.GD19038@ymonad.members.linode.com> http://dotat.at/prog/life/hslife.hs [], Edgar On Tue, 02/Feb/2010 at 21:10 +0100, Arne D Halvorsen wrote: > > Den 2. feb. 2010 kl. 19.26 skrev Jon Harrop : > > >On Tuesday 02 February 2010 16:10:05 Serguey Zefirov wrote: > >>Actually, your solution with arrays is the most often occured > >>solution > >>an imperative programmer will come with. It is simple but not > >>scalable > >>and not particularly fast. > > > >What gave you that impression? > > If I may butt in here: to get a scalable, fast Game of Life, you > should look into Hashlife (by Gosper?) as exemplified in the open > source application Golly. It gives an astonishing speedup, and it > would be interesting to see it expressed in Haskell. > > Regards, > Arne D Halvorsen > > > >-- > >Dr Jon Harrop, Flying Frog Consultancy Ltd. > >http://www.ffconsultancy.com/?e > >_______________________________________________ > >Haskell-Cafe mailing list > >Haskell-Cafe@haskell.org > >http://www.haskell.org/mailman/listinfo/haskell-cafe > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From ryani.spam at gmail.com Tue Feb 2 17:04:13 2010 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue Feb 2 16:35:46 2010 Subject: [Haskell-cafe] Re: Generating repeatable arbitrary values with QuickCheck 2 In-Reply-To: <49a77b7a1002021125k4f260adakdbcb187f873412e@mail.gmail.com> References: <3c6288ab1002011354j7909e2a4w6116ff685c081224@mail.gmail.com> <3c6288ab1002020434l496d0f41se869234ad0968de4@mail.gmail.com> <2f9b2d31002021048s3399622cyf3743531a3abfd64@mail.gmail.com> <49a77b7a1002021125k4f260adakdbcb187f873412e@mail.gmail.com> Message-ID: <2f9b2d31002021404v6b3a86a7id0cf612e2f9573f7@mail.gmail.com> On Tue, Feb 2, 2010 at 11:25 AM, David Menendez wrote: > We could avoid that problem by redefining Gen as a state transformer monad. > > newtype Gen a = MkGen { unGen :: StdGen -> Int -> (a, StdGen) } Unfortunately, this makes things like > infinite_xs <- sequence (repeat arbitrary) no longer work, since the state never comes out the other side. Which is a pretty significant change. -- ryan From ndmitchell at gmail.com Tue Feb 2 17:06:49 2010 From: ndmitchell at gmail.com (Neil Mitchell) Date: Tue Feb 2 16:38:26 2010 Subject: [Haskell-cafe] Anyone up for Google SoC 2010? In-Reply-To: <4B6716B7.2020902@gmail.com> References: <863507BC-FD78-49A0-9A77-C97B9431F7E7@cs.york.ac.uk> <4B6716B7.2020902@gmail.com> Message-ID: <404396ef1002021406m73eaae64j8a63f20eabd528b5@mail.gmail.com> I'd also be happy to mentor. Where is the official place to collect project ideas? We used trac previously, are we still using it or are we now on Reddit? Thanks, Neil 2010/2/1 sterl : > Malcolm Wallace wrote: >> >> Google has announced that the Summer of Code programme will be running again this year. ?If haskell.org people would like to take part again this year, then we need volunteers: > > I'd be happy to mentor again as well. It's important to bear in mind that the total number of mentors plays a small role in slot allocation, but far more important is to maximize the amount of high-quality applications -- the more students we encourage to submit proposals, the more proposals we will be able to fund: http://socghop.appspot.com/document/show/program/google/gsoc2009/studentallocations > > Cheers, > Sterl. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ryani.spam at gmail.com Tue Feb 2 17:09:18 2010 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue Feb 2 16:40:50 2010 Subject: [Haskell-cafe] Re: Generating repeatable arbitrary values with QuickCheck 2 In-Reply-To: <2f9b2d31002021404v6b3a86a7id0cf612e2f9573f7@mail.gmail.com> References: <3c6288ab1002011354j7909e2a4w6116ff685c081224@mail.gmail.com> <3c6288ab1002020434l496d0f41se869234ad0968de4@mail.gmail.com> <2f9b2d31002021048s3399622cyf3743531a3abfd64@mail.gmail.com> <49a77b7a1002021125k4f260adakdbcb187f873412e@mail.gmail.com> <2f9b2d31002021404v6b3a86a7id0cf612e2f9573f7@mail.gmail.com> Message-ID: <2f9b2d31002021409w1922875fi78766a88c324f69c@mail.gmail.com> Although now that I think about it, most of these could be pretty easily fixed by a new primitive: > splitGen :: Gen a -> Gen a > splitGen m = MkGen spg where > spg g n = (a, g2) where > (g1, g2) = split g > (a, _) = unGen m g1 n Then you could do > infinite_xs <- splitGen $ sequence (repeat arbitrary) -- ryan On Tue, Feb 2, 2010 at 2:04 PM, Ryan Ingram wrote: > On Tue, Feb 2, 2010 at 11:25 AM, David Menendez wrote: >> We could avoid that problem by redefining Gen as a state transformer monad. >> >> newtype Gen a = MkGen { unGen :: StdGen -> Int -> (a, StdGen) } > > Unfortunately, this makes things like >> ?infinite_xs <- sequence (repeat arbitrary) > no longer work, since the state never comes out the other side. > > Which is a pretty significant change. > > ?-- ryan > From ndmitchell at gmail.com Tue Feb 2 17:11:13 2010 From: ndmitchell at gmail.com (Neil Mitchell) Date: Tue Feb 2 16:42:46 2010 Subject: [Haskell-cafe] Hackage Package version ranges Message-ID: <404396ef1002021411r7c1cdd5exd4850150a7e0c25a@mail.gmail.com> Hi, I maintain the Haskell package HLint. HLint depends on haskell-src-exts, cpphs, hscolour and uniplate, plus things which are shipped with GHC. For each of the external library dependencies, I have to specify a version constraint. For example, I developed HLint against cpphs-1.10 so I can write one of: 1) cpphs == 1.10.* 2) cpphs >= 1.10 I know (1) works, since I've tested it. However, every time I use (1) some distro (usually Arch) emails me to say they need wider ranges so they can get all their packages consistent. I then usually flip to (2). Then, sometime later, someone releases a new version of cpphs that changes the interface in a way that breaks HLint, and I get emails from users, and tend to go back to (1). Flip flopping between version constraints isn't a great idea. What should I do? Alternatively, if I could sign up to be emailed when something went wrong, I'd happily fix it. i.e. I'd like an email either when my package fails to compile against the latest version of all packages but within my constrained range, or when the latest version falls outside my constraint range. Thanks, Neil From johan.tibell at gmail.com Tue Feb 2 17:11:41 2010 From: johan.tibell at gmail.com (Johan Tibell) Date: Tue Feb 2 16:43:38 2010 Subject: [Haskell-cafe] Anyone up for Google SoC 2010? In-Reply-To: <404396ef1002021406m73eaae64j8a63f20eabd528b5@mail.gmail.com> References: <863507BC-FD78-49A0-9A77-C97B9431F7E7@cs.york.ac.uk> <4B6716B7.2020902@gmail.com> <404396ef1002021406m73eaae64j8a63f20eabd528b5@mail.gmail.com> Message-ID: <90889fe71002021411g7b1005c3k4ae5bf7001362447@mail.gmail.com> On Tue, Feb 2, 2010 at 2:06 PM, Neil Mitchell wrote: > I'd also be happy to mentor. Where is the official place to collect > project ideas? We used trac previously, are we still using it or are > we now on Reddit? Is there a way to prune the reddit list? Some of the projects (like 'text') are already done. Also, voting doesn't work well for reddit as we're still seeing votes from last year. -- Johan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100202/7a6be4bd/attachment.html From ndmitchell at gmail.com Tue Feb 2 17:16:07 2010 From: ndmitchell at gmail.com (Neil Mitchell) Date: Tue Feb 2 16:47:41 2010 Subject: [Haskell-cafe]SYB/Generics documentation inaccessible In-Reply-To: <203d94091002021251p63e3a9ffi1376077c23ec758a@mail.gmail.com> References: <203d94091002021251p63e3a9ffi1376077c23ec758a@mail.gmail.com> Message-ID: <404396ef1002021416u74432856me6f61adbb1b53b00@mail.gmail.com> I emailed Simon Peyton Jones about this a few weeks ago (he links to these pages) and got the reply "thanks, will chase" - so people are aware of it. The links are in many places, which is a bit of a shame. Thanks, Neil On Tue, Feb 2, 2010 at 8:51 PM, Arne Dehli Halvorsen wrote: > > I have tried to access a few of the documents on generics that are referred > to from wikipedia, from the GHC documentation, from hackage and from the > wiki. These documents (on vu.nl, subdirectory boilerplate and strafunski) > are apparently forbidden to me, and have been for some weeks. I tried to > mail a webmaster and some other mentioned mail addresses, but the mails > bounced. Could somebody make the docs accessible, or should it be re-hosted > on Hackage? > > Regards > Arne D Halvorsen > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From dot at dotat.at Tue Feb 2 17:17:02 2010 From: dot at dotat.at (Tony Finch) Date: Tue Feb 2 16:48:36 2010 Subject: [Haskell-cafe] Game of life in haskell. Message-ID: On Tue, 2 Feb 2010, edgar@ymonad.com wrote: > http://dotat.at/prog/life/hslife.hs Er, yes, I didn't link to that in my earlier message because it's a half-completed attempt. I think I got to the stage of realising that I needed to write a monad or a monad transformer to thread the hash cons state through the code without it getting in the way. For those interested in Hash Life whether or not it's written in Haskell, there's a description of how it works in http://dotat.at/prog/life/hashlife.c though that code is also incomplete. Tony. -- f.anthony.n.finch http://dotat.at/ GERMAN BIGHT HUMBER: SOUTHWEST 5 TO 7. MODERATE OR ROUGH. SQUALLY SHOWERS. MODERATE OR GOOD. From stephen.tetley at gmail.com Tue Feb 2 17:17:20 2010 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Tue Feb 2 16:49:02 2010 Subject: [Haskell-cafe]SYB/Generics documentation inaccessible In-Reply-To: <203d94091002021251p63e3a9ffi1376077c23ec758a@mail.gmail.com> References: <203d94091002021251p63e3a9ffi1376077c23ec758a@mail.gmail.com> Message-ID: <5fdc56d71002021417v64fce4a1mfa2628d8f0c0437e@mail.gmail.com> Hello The most of the papers the Wikipedia page links to should be publicly accessible, I've just checked the ones hosted at Utrecht University (e.g the Generic Haskell manual and Andres L\ohs thesis). Ralf Hinze has changed universities, so the link to http://www.informatik.uni-bonn.de/~ralf/publications/ICFP04.pdf unfortunately has gone, you could try asking him for a copy as it is not online at his new address: http://www.comlab.ox.ac.uk/people/publications/date/Ralf.Hinze.html. It looks like the Generics code hosted at Haskell.org is somewhat in transit as the machine hosting it have been swapped out. The haskellwiki page - http://www.haskell.org/haskellwiki/GPBench - points here (now defunct): Darcs repository: http://darcs.haskell.org/generics That repository is temporarily hosted here: http://old-darcs.well-typed.com/generics/ The comparison suite with examples for SYB, PolyP, Smash etc etc is in the folder 'comparsion': http://old-darcs.well-typed.com/generics/comparison/ Best wishes Stephen From jpm at cs.uu.nl Tue Feb 2 17:25:22 2010 From: jpm at cs.uu.nl (=?ISO-8859-1?Q?Jos=E9_Pedro_Magalh=E3es?=) Date: Tue Feb 2 16:57:14 2010 Subject: [Haskell-cafe] SYB/Generics documentation inaccessible In-Reply-To: References: Message-ID: <52f14b211002021425u17063c90w37ff3dc3c9c424db@mail.gmail.com> A few days ago I changed the links from the SYB wiki [1] to point to an archived version of the vu.nl webpage: http://web.archive.org/web/20080622204226/http://www.cs.vu.nl/boilerplate/ But it would be nice to have the webpage up again, somewhere. Cheers, Pedro [1] http://www.cs.uu.nl/wiki/bin/view/GenericProgramming/SYB On Tue, Feb 2, 2010 at 21:23, Arne D Halvorsen wrote: > I have tried to access a few of the documents on generics that are referred > to from wikipedia, from the GHC documentation, from hackage and from the > wiki. These documents (on vu.nl, subdirectory boilerplate and strafunski) > are apparently forbidden to me, and have been for some weeks. I tried to > mail a webmaster and some other mentioned mail addresses, but the mails > bounced. Could somebody make the docs accessible, or should it be re-hosted > on Hackage? > > Regards > Arne D Halvorsen > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100202/919b600a/attachment.html From jesper.louis.andersen at gmail.com Tue Feb 2 17:28:49 2010 From: jesper.louis.andersen at gmail.com (Jesper Louis Andersen) Date: Tue Feb 2 17:00:44 2010 Subject: [Haskell-cafe] Hackage Package version ranges In-Reply-To: <404396ef1002021411r7c1cdd5exd4850150a7e0c25a@mail.gmail.com> References: <404396ef1002021411r7c1cdd5exd4850150a7e0c25a@mail.gmail.com> Message-ID: <56a0a2841002021428o680f197eob4e90b4f394e701c@mail.gmail.com> On Tue, Feb 2, 2010 at 11:11 PM, Neil Mitchell wrote: > > Alternatively, if I could sign up to be emailed when something went > wrong, I'd happily fix it. i.e. I'd like an email either when my > package fails to compile against the latest version of all packages > but within my constrained range, or when the latest version falls > outside my constraint range. > Getting correct dependency convergence through automatic building of packages and error-emails would be fairly interesting I think. The problem is not new as all software with dependencies are bound to run against its wall at some point - so perhaps there are some thoughts out there about what works and what doesn't. There is a reminiscence of buildbot in this as well. Generally, you want an environment where your package is built against all platforms currently under support at intervals to catch these kinds of errors. However, getting the infrastructure set up for this is a somewhat daunting task. -- J. From stephen.tetley at gmail.com Tue Feb 2 17:29:52 2010 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Tue Feb 2 17:01:29 2010 Subject: [Haskell-cafe]SYB/Generics documentation inaccessible In-Reply-To: <5fdc56d71002021417v64fce4a1mfa2628d8f0c0437e@mail.gmail.com> References: <203d94091002021251p63e3a9ffi1376077c23ec758a@mail.gmail.com> <5fdc56d71002021417v64fce4a1mfa2628d8f0c0437e@mail.gmail.com> Message-ID: <5fdc56d71002021429o5982c90du32cf461c975a913b@mail.gmail.com> Apologies for the rather garbled last message (I was trying to type whilst checking a multitude of links in a plethora or browser windows)... The SYB papers are here http://research.microsoft.com/en-us/um/people/simonpj/Papers/hmap/ The code seems to have vanished at the moment, maybe someone has the latest copy. I used Strafunski quite a bit myself, so I should have an archive of the last release if you want that. Best wishes Stephen From ndmitchell at gmail.com Tue Feb 2 17:32:00 2010 From: ndmitchell at gmail.com (Neil Mitchell) Date: Tue Feb 2 17:03:33 2010 Subject: [Haskell-cafe] Hackage Package version ranges In-Reply-To: <56a0a2841002021428o680f197eob4e90b4f394e701c@mail.gmail.com> References: <404396ef1002021411r7c1cdd5exd4850150a7e0c25a@mail.gmail.com> <56a0a2841002021428o680f197eob4e90b4f394e701c@mail.gmail.com> Message-ID: <404396ef1002021432j2c933cbdv1cc2ac87da0b4689@mail.gmail.com> >> Alternatively, if I could sign up to be emailed when something went >> wrong, I'd happily fix it. i.e. I'd like an email either when my >> package fails to compile against the latest version of all packages >> but within my constrained range, or when the latest version falls >> outside my constraint range. >> > > Getting correct dependency convergence through automatic building of > packages and error-emails would be fairly interesting I think. The > problem is not new as all software with dependencies are bound to run > against its wall at some point - so perhaps there are some thoughts > out there about what works and what doesn't. Note that giving an error message when the latest constrained version fails to build is really hard, and requires building the package. An email simply saying "you say cpphs-1.10.* which excludes the most recent one which is cpphs-1.11" just requires parsing the cabal files, and is much easier. It's not as useful, but it might be a useful first step. Thanks, Neil From gwern0 at gmail.com Tue Feb 2 17:50:24 2010 From: gwern0 at gmail.com (Gwern Branwen) Date: Tue Feb 2 17:21:57 2010 Subject: [Haskell-cafe] Anyone up for Google SoC 2010? In-Reply-To: <90889fe71002021411g7b1005c3k4ae5bf7001362447@mail.gmail.com> References: <863507BC-FD78-49A0-9A77-C97B9431F7E7@cs.york.ac.uk> <4B6716B7.2020902@gmail.com> <404396ef1002021406m73eaae64j8a63f20eabd528b5@mail.gmail.com> <90889fe71002021411g7b1005c3k4ae5bf7001362447@mail.gmail.com> Message-ID: On Tue, Feb 2, 2010 at 5:11 PM, Johan Tibell wrote: > On Tue, Feb 2, 2010 at 2:06 PM, Neil Mitchell wrote: >> >> I'd also be happy to mentor. Where is the official place to collect >> project ideas? We used trac previously, are we still using it or are >> we now on Reddit? > > Is there a way to prune the reddit list? Some of the projects (like 'text') > are already done. Also, voting doesn't work well for reddit as we're still > seeing votes from last year. > -- Johan You can prune them personally with 'hide', and I suppose the subreddit moderator can delete expired entries. -- gwern From batterseapower at hotmail.com Tue Feb 2 18:16:04 2010 From: batterseapower at hotmail.com (Max Bolingbroke) Date: Tue Feb 2 17:47:35 2010 Subject: [Haskell-cafe] Anyone up for Google SoC 2010? In-Reply-To: <863507BC-FD78-49A0-9A77-C97B9431F7E7@cs.york.ac.uk> References: <863507BC-FD78-49A0-9A77-C97B9431F7E7@cs.york.ac.uk> Message-ID: <9d4d38821002021516m3e6c3394pa5b485f45c88889b@mail.gmail.com> 2010/1/31 Malcolm Wallace : > Both of these roles are called "mentor" in the Google system. ?Putting > together a good team of mentors before applying as an organisation is > helpful towards us being accepted into the programme. Having experienced being a student on the SoC program, I'd be happy to try my hand at reviewing applications and supervising projects (in particular, compiler-related ones). Cheers, Max From ok at cs.otago.ac.nz Tue Feb 2 18:34:53 2010 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Tue Feb 2 18:06:32 2010 Subject: [Haskell-cafe] matrix question In-Reply-To: <98f46b31002020415j7b41a5bar3698d13e3f206d08@mail.gmail.com> References: <98f46b31002020415j7b41a5bar3698d13e3f206d08@mail.gmail.com> Message-ID: On Feb 3, 2010, at 1:15 AM, ??? wrote: > define functions > > type Matrix=[[Double]] > > multMM :: Matrix -> Matrix -> Matrix --multiplies two matrices > det :: Matrix -> Double --computes the determinant of a matrix > inv :: Matrix -> Matrix --inverts a matrix > > i stuck on those problems Stuck how, exactly? Writing a good matrix inversion procedure is seriously tricky in any programming language (unless you are using rational arithmetic, in which case it's tricky in a different way). Indeed, I think every book I've come across says "DON'T compute multMM x (inv y)" but instead use a "solve" method. You'll find matrix multiplication easy enough if you draw a few diagrams and think in terms of operations on rows and columns rather than in terms of array elements. For matrix inversion, Gaussian elimination with partial pivoting is tedious rather than difficult. The same conversion-to-triangular process will give you determinant. From ok at cs.otago.ac.nz Tue Feb 2 18:54:58 2010 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Tue Feb 2 18:26:38 2010 Subject: [Haskell-cafe] Game of life in haskell. In-Reply-To: <20100202184819.GH4289@whirlpool.galois.com> References: <201002021826.08089.jon@ffconsultancy.com> <600376291002021023w5510249fpf9cad19ffed6aa5c@mail.gmail.com> <201002021954.22028.jon@ffconsultancy.com> <3e1162e61002021044y5e9a7415xa25a6eb70590c406@mail.gmail.com> <20100202184819.GH4289@whirlpool.galois.com> Message-ID: I understood the ""simple but not scalable and not particularly fast" claim *NOT* as a claim about imperative languages but in context as a claim about using two-dimensional arrays of booleans to implement Conway's Life. One message in this thread has already pointed to a solution (in C) that in effect uses a bit-packed sparse representation to achieve high speed. The point is that that approach takes time (and space) per generation proportional to the number of occupied cells, not the size of the space, and that is the basis of the "scaling" claim. A simple Haskell analogue, which has the right asymptotic cost, would be to represent a Life generation by a list of (row_number, [col_no, ..., col_no]) pairs in strictly ascending order of row number, where each pair contains a list of the numbers of the occupied columns in strictly ascending order. The space is (number of occupied cells * a constant) + (number of occupied rows * another constant). Computing the next generation then amounts to a bunch of 3-way merges. From gue.schmidt at web.de Tue Feb 2 19:00:41 2010 From: gue.schmidt at web.de (=?ISO-8859-15?Q?G=FCnther_Schmidt?=) Date: Tue Feb 2 18:32:43 2010 Subject: [Haskell-cafe] functional references and HList? Message-ID: <4B68BCA9.2010201@web.de> Hi all, I wonder if there is some a "field of use" overlap between HList and functional references aka accessors. Do both tackle the same problem? G?nther From maydwell at gmail.com Tue Feb 2 19:15:19 2010 From: maydwell at gmail.com (Lyndon Maydwell) Date: Tue Feb 2 18:46:51 2010 Subject: [Haskell-cafe] Game of life in haskell. In-Reply-To: References: Message-ID: Thanks for the replies. I have heard of Hash Life, but I thought I'd try a more naive approach first, build up some type-classes, then create some more interesting implementations (although I think I'd struggle with implementing Hash Life in haskell at this point). > What is the meaning of fuzzy Game of Life? Where can I read about? I don't think there are any official rules for fuzzy Life, and it would really be a different automaton, but you can still get some of the same Life phenomenon occurring in it. It gets mentioned reasonably often and shows up if you google for it. (For example: http://cogprints.org/1479/0/life.html) I'd like to create something of a cellular-automaton engine with a fair degree of flexibility (2d/3d, boolean/fuzzy/other, different neighborhoods). It could make a fairly nice screen-saver if it were polished, but I can't really see any applications beyond that. From z_axis at 163.com Tue Feb 2 19:15:56 2010 From: z_axis at 163.com (zaxis) Date: Tue Feb 2 18:47:26 2010 Subject: [Haskell-cafe] About code style ? In-Reply-To: <81ea7d401002020331v20016dbdwd2caca40f9cd62b0@mail.gmail.com> References: <27414627.post@talk.nabble.com> <27416932.post@talk.nabble.com> <81ea7d401002020331v20016dbdwd2caca40f9cd62b0@mail.gmail.com> Message-ID: <27429649.post@talk.nabble.com> fac n = let { f = foldr (*) 1 [1..n] } in f VERY interesting :) Jinjing Wang wrote: > > fac n = let { > f = foldr (*) 1 [1..n] > } in f > > :D > > sorry for double reply, need to cc cafe, this is fun. > > On Tue, Feb 2, 2010 at 4:33 PM, zaxis wrote: >> >> thanks for all suggestions. >> >> >> zaxis wrote: >>> >>> For me i like C style instead of layout. For example, >>> func1 a = do >>> ? ? ?-- ... >>> ? ? ?a * 2 >>> ? ? ?-- ... >>> >>> I always write it as: >>> func1 a = do { >>> ? -- ...; >>> ? ?a * 2; >>> ? -- ...; >>> } >>> >>> However, i donot know how to write pure function using C style. >>> func1 a = { >>> ? -- ...; >>> ? ?a * 2; >>> ? -- ...; >>> } >>> >>> will not compile without `do`. >>> >>> Sincerely! >>> >> >> >> ----- >> fac n = foldr (*) 1 [1..n] >> -- >> View this message in context: >> http://old.nabble.com/About-code-style---tp27414627p27416932.html >> Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > > > -- > jinjing > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > ----- fac n = foldr (*) 1 [1..n] -- View this message in context: http://old.nabble.com/About-code-style---tp27414627p27429649.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From magnus at therning.org Tue Feb 2 19:41:45 2010 From: magnus at therning.org (Magnus Therning) Date: Tue Feb 2 19:13:19 2010 Subject: [Haskell-cafe] setNonBlockingFD? Message-ID: <4B68C649.5080102@therning.org> network-fancy fails to build because "Not in scope: 'setNonBlockingFD'". Any pointers to what should be used in 6.12? /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100202/02b4b1ff/signature.bin From johan.tibell at gmail.com Tue Feb 2 19:44:47 2010 From: johan.tibell at gmail.com (Johan Tibell) Date: Tue Feb 2 19:16:38 2010 Subject: [Haskell-cafe] setNonBlockingFD? In-Reply-To: <4B68C649.5080102@therning.org> References: <4B68C649.5080102@therning.org> Message-ID: <90889fe71002021644w694751fbwfb5aa5957fff8c81@mail.gmail.com> On Tue, Feb 2, 2010 at 4:41 PM, Magnus Therning wrote: > network-fancy fails to build because "Not in scope: 'setNonBlockingFD'". > Any > pointers to what should be used in 6.12? > I have the following in 'network': #if __GLASGOW_HASKELL__ < 611 System.Posix.Internals.setNonBlockingFD fd #else System.Posix.Internals.setNonBlockingFD fd True #endif -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100202/12e1a495/attachment.html From jon at ffconsultancy.com Tue Feb 2 21:04:46 2010 From: jon at ffconsultancy.com (Jon Harrop) Date: Tue Feb 2 19:20:52 2010 Subject: [Haskell-cafe] Game of life in haskell. In-Reply-To: References: <20100202184819.GH4289@whirlpool.galois.com> Message-ID: <201002030204.46391.jon@ffconsultancy.com> On Tuesday 02 February 2010 23:54:58 Richard O'Keefe wrote: > I understood the ""simple but not scalable and not particularly fast" > claim *NOT* as a claim about imperative languages but in context as > a claim about using two-dimensional arrays of booleans to implement > Conway's Life. Fair enough. If you want to model either an infinite board or a very sparse one then a sparse data structure will be asymptotically faster. But they won't be simpler and asymptotically efficient mutable data structures will be faster again. > One message in this thread has already pointed to a > solution (in C) that in effect uses a bit-packed sparse representation > to achieve high speed. The point is that that approach takes time (and > space) per generation proportional to the number of occupied cells, > not the size of the space, and that is the basis of the "scaling" claim. > A simple Haskell analogue, which has the right asymptotic cost, would > be to represent a Life generation by a list of > (row_number, [col_no, ..., col_no]) > pairs in strictly ascending order of row number, where each pair > contains a list of the numbers of the occupied columns in strictly > ascending order. The space is (number of occupied cells * a constant) > + (number of occupied rows * another constant). Computing the next > generation then amounts to a bunch of 3-way merges. That will be a lot faster than using Map or Set but you're still paying a lot for the indirections between cons cells. Mutating an array in-place would be significantly faster and no more difficult to code correctly because this is such a trivial algorithm. -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e From ivan.miljenovic at gmail.com Tue Feb 2 20:13:47 2010 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Tue Feb 2 19:45:26 2010 Subject: [Haskell-cafe] Hackage Package version ranges In-Reply-To: <404396ef1002021411r7c1cdd5exd4850150a7e0c25a@mail.gmail.com> (Neil Mitchell's message of "Tue, 2 Feb 2010 22:11:13 +0000") References: <404396ef1002021411r7c1cdd5exd4850150a7e0c25a@mail.gmail.com> Message-ID: <87r5p3xgs4.fsf@gmail.com> Neil Mitchell writes: > However, every time I use (1) some distro (usually Arch) emails me to > say they need wider ranges so they can get all their packages > consistent. Well, in Gentoo we normally resort to using sed to fix these kinds of things. If we can do it, I'm sure the Arch package managers are able to do so. It might be more annoying, but IMHO it's a bigger problem when a developer is too lax in constraints (since then we've got to tweak the constraints until we find ones that _do_ work). -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com From ivan.miljenovic at gmail.com Tue Feb 2 20:14:55 2010 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Tue Feb 2 19:46:36 2010 Subject: [Haskell-cafe] matrix question In-Reply-To: <47a7e7c61002020837l45bb18e3rfa3547939cf19d8f@mail.gmail.com> (man's message of "Tue, 2 Feb 2010 17:37:30 +0100") References: <98f46b31002020415j7b41a5bar3698d13e3f206d08@mail.gmail.com> <47a7e7c61002020837l45bb18e3rfa3547939cf19d8f@mail.gmail.com> Message-ID: <87mxzrxgq8.fsf@gmail.com> man writes: > http://hackage.haskell.org/package/hmatrix-0.8.1.1 > > it wraps gls, blas and lapack (so you need to install the libraries). There's also the blas package if you just want blas support. -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com From dot at dotat.at Tue Feb 2 20:17:57 2010 From: dot at dotat.at (Tony Finch) Date: Tue Feb 2 19:48:39 2010 Subject: [Haskell-cafe] Game of life in haskell. In-Reply-To: <201002030204.46391.jon@ffconsultancy.com> References: <20100202184819.GH4289@whirlpool.galois.com> <201002030204.46391.jon@ffconsultancy.com> Message-ID: <5ECB4D79-BE7B-4CE1-961D-25589924A41A@dotat.at> On 3 Feb 2010, at 02:04, Jon Harrop wrote: > On Tuesday 02 February 2010 23:54:58 Richard O'Keefe wrote: >> >> One message in this thread has already pointed to a >> solution (in C) that in effect uses a bit-packed sparse >> representation >> to achieve high speed. The point is that that approach takes time >> (and >> space) per generation proportional to the number of occupied cells, >> not the size of the space, and that is the basis of the "scaling" >> claim. >> A simple Haskell analogue, which has the right asymptotic cost, would >> be to represent a Life generation by a list of >> (row_number, [col_no, ..., col_no]) >> pairs in strictly ascending order of row number, where each pair >> contains a list of the numbers of the occupied columns in strictly >> ascending order. The space is (number of occupied cells * a >> constant) >> + (number of occupied rows * another constant). Computing the next >> generation then amounts to a bunch of 3-way merges. > > That will be a lot faster than using Map or Set but you're still > paying a lot > for the indirections between cons cells. Mutating an array in-place > would be > significantly faster and no more difficult to code correctly because > this is > such a trivial algorithm. Richard's description is pretty much exactly what I had in mind for a Haskell version of my C code. The C translates to Haskell so well because its data structure is immutable: the new generation is written to fresh memory then the old generation becomes garbage. The old generation is scanned in the order it is written (albeit by three pointers with a row between each one) which is inconvenient for linked lists. However the algorithm is symmetrical so it doesn't mind processing the universe in alternating directions, so long as the rendering code can cope :-) The indirections are less bad than they might be because the code will always be following a pointer to an adjacent memory location, because of the algorithm's simple allocation behaviour. But it'll be about twice as slow as the C equivalent because it uses twice the memory. Efficient mutate-in-place Life algorithms become disgustingly complicated before they can beat listlife. Tony. -- f.anthony.n.finch http://dotat.at/ From jon at ffconsultancy.com Tue Feb 2 22:11:34 2010 From: jon at ffconsultancy.com (Jon Harrop) Date: Tue Feb 2 20:27:40 2010 Subject: [Haskell-cafe] Game of life in haskell. In-Reply-To: <3e1162e61002021044y5e9a7415xa25a6eb70590c406@mail.gmail.com> References: <201002021954.22028.jon@ffconsultancy.com> <3e1162e61002021044y5e9a7415xa25a6eb70590c406@mail.gmail.com> Message-ID: <201002030311.34683.jon@ffconsultancy.com> On Tuesday 02 February 2010 18:44:25 David Leimbach wrote: > On Tue, Feb 2, 2010 at 11:54 AM, Jon Harrop wrote: > > I meant the scalability and speed. An imperative solution should be > > simpler, more scalable and faster than any purely functional solution. > > That's a pretty strange comment. Why do you think an imperative solution > is simpler, faster and more scalable? Mutation can avoid lots of unnecessary allocations and indirections with minimal risk of error in this case. > If functional programming can't provide any one of those, it's not worth > anything, I doubt programming paradigms live or die according to whether or not they can implement Conway's Game of Life simply and efficiently. > and based on the membership in this list, the interest in it > these days, and the fact that I've seen many occasions where functional > programming lends itself to a faster implementation (in terms of time to > implement and test) that's actually readable sooner than a lot of > imperative approaches... Of Conway's Game of Life? -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e From thomas.dubuisson at gmail.com Tue Feb 2 21:26:37 2010 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Tue Feb 2 20:58:10 2010 Subject: [Haskell-cafe] matrix question In-Reply-To: <98f46b31002020415j7b41a5bar3698d13e3f206d08@mail.gmail.com> References: <98f46b31002020415j7b41a5bar3698d13e3f206d08@mail.gmail.com> Message-ID: <4c44d90b1002021826j34cb0374s79cc70ded8ced511@mail.gmail.com> This is identical to the homework problem posted on stackoverflow: http://stackoverflow.com/questions/2182300/haskell-matrix-scalar-multilple-question Do not post homework problems to the cafe! If you feel compelled to then identify an aspect that is tricky to you, show us what you tried, and identify it as homework. Thomas On Tue, Feb 2, 2010 at 4:15 AM, ??? wrote: > define functions > > type Matrix=[[Double]] > > multMM :: Matrix -> Matrix -> Matrix --multiplies two matrices > det :: Matrix -> Double --computes the determinant of a matrix > inv :: Matrix -> Matrix --inverts a matrix > > i stuck on those problems > > can any one help me out? > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From jon at ffconsultancy.com Tue Feb 2 22:45:52 2010 From: jon at ffconsultancy.com (Jon Harrop) Date: Tue Feb 2 21:01:58 2010 Subject: [Haskell-cafe] Game of life in haskell. In-Reply-To: <7F496E9A-D0A8-48C7-8546-D8FA665EA110@cs.otago.ac.nz> References: <201002030204.46391.jon@ffconsultancy.com> <7F496E9A-D0A8-48C7-8546-D8FA665EA110@cs.otago.ac.nz> Message-ID: <201002030345.52766.jon@ffconsultancy.com> On Wednesday 03 February 2010 01:08:33 Richard O'Keefe wrote: > On Feb 3, 2010, at 3:04 PM, Jon Harrop wrote: > > Fair enough. If you want to model either an infinite board or a very > > sparse one then a sparse data structure will be asymptotically faster. But > > they won't be simpler and asymptotically efficient mutable data > > structures will be faster again. > > Did I say a word about mutability? The whole point of my message > was that the original message WASN'T about mutable or immutable > data structures but about dense (2d array) or sparse data structures. When Serguey said that arrays were not idiomatic Haskell because they are "hard to update functionally" I assumed he was talking about mutable vs immutable data structures. > >> A simple Haskell analogue, which has the right asymptotic cost, > > > > That will be a lot faster than using Map or Set but you're still > > paying a lot for the indirections between cons cells. Mutating an array > > in-place would be significantly faster and no more difficult to code > > correctly because this is such a trivial algorithm. > > Again, you seem to be responding to something that wasn't said. > No claim was made that the list of (row,[col...]) pairs approach > was *FAST*, Were you not talking about performance when you said "the right asymptotic cost"? > or indeed that the code to manipulate it was notable for simplicity, only > that the data structure in itself is simple. Ok. > I once had Prolog code running faster than the Fortran code it was > based on. Mutable arrays are not in themselves a guarantee of > efficiency, and while I don't imagine that you believe that, the > paragraph I quoted came uncomfortably close to saying it. My statements were specifically about Conway's Game of Life. > In fact mutating an array in place probably would be a bit trickier > because you _can't_ mutate the row you are just calculating; you will > need the old version for the next row. Yes, of course. You would read from and write to different mutable data structures, swapping over their roles. Like double buffering or Cheney's to and from spaces. > And in a sparse-compressed representation, the new and old rows will seldom > be the same size. Just use a conventional resizeable array and it will amortize all those costly allocations for you without complicating the code at all. > For what it's worth, the sparse-compressed code that someone pointed > to, and which I alluded to, is written in C. Remember, the original > message didn't say *arrays* were a poor choice, He said: "Arrays are not fully "idiomatic" for Haskell as they are hard to update functionally." Is that not saying that arrays were a poor choice? > but that the "obvious" *2d array of boolean* was a poor choice. And that's > the (only) claim I defended. The OP was solving a dense problem on a finite board. Is a 2d array of booleans really such a bad choice in that context? Even if you change the problem to a sparse one, how large must it be before a solution like Serguey's becomes competitively efficient in practice? -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e From artyom.shalkhakov at gmail.com Tue Feb 2 22:17:34 2010 From: artyom.shalkhakov at gmail.com (Artyom Shalkhakov) Date: Tue Feb 2 21:49:05 2010 Subject: [Haskell-cafe] GUI programming In-Reply-To: References: Message-ID: <2076f2f91002021917g31fed148q7c67a1ab9cad52a@mail.gmail.com> Hello Victor, 2010/2/2, Victor Nazarov : > I've been writing some GUI application with Gtk2hs. It's an > interpreter for lambda-calculus and combinatory logic, it's GPL and if > you interested I can share it with cafe. Sure, why not? > I consider more lightweight and more imperative approach, something > closer to CSP (Communicating Secuential Processes) then FRP. I've just > crafted some sample program to illustrate my idea. All this process calculus stuff reminds me of Fudgets. Maybe this approach is more pragmatic at the moment: even more so, I think it's theoretical underpinnings are appealing as well. Who said that all programming should be reduced to pure functions? :-) As a side note, there's a book "How to Design Worlds" which discusses interactive purely functional programming (using games as an example). While it is only tangentially related to GUI programming, I wonder if their approach can be adapted for use in GUIs. Cheers, Artyom Shalkhakov > The behaviour is a monad and it's IO monad so you can do any IO > (Gtk2hs) programming you wish. The differences is that you don't > attach static event handlers and tries to determine what to do > dependent on application state. You attach and detach handlers as much > as possible. Behaviour looks like a process that can stop execution > and wait for some GUI event. When event arrived it continues > execution. > > Do you see this approach viable. There are steel some details to emerge: > * How to wait for several events > * How to handle IO exceptions > > Here is the code: > {-# LANGUAGE ExistentialQuantification #-} > module Main where > > import Data.IORef > import System.Glib > import Graphics.UI.Gtk > import Control.Monad.Trans > > type Event obj = IO () -> IO (ConnectId obj) > > data Behaviour a = > forall b. BBind (Behaviour b) (b -> Behaviour a) > | BIO (IO a) > | forall obj. GObjectClass obj => BWaitEvent (Event obj) (Behaviour a) > > instance Monad Behaviour > where action >>= generator = BBind action generator > return a = BIO (return a) > > instance MonadIO Behaviour > where liftIO action = BIO action > > runBehaviour :: Behaviour a -> IO a > runBehaviour (BBind (BWaitEvent event after) f) = runBehaviour > (BWaitEvent event (after >>= f)) > runBehaviour (BBind (BIO a) f) = a >>= \x -> runBehaviour (f x) > runBehaviour (BBind (BBind a f) g) = runBehaviour (a >>= (\x -> f x >>= g)) > runBehaviour (BIO a) = a > runBehaviour (BWaitEvent event after) = > do sigIdRef <- newIORef (error "You can't access sigIdRef before > signal is connected") > sigId <- event $ > do sigId <- readIORef sigIdRef > signalDisconnect sigId > runBehaviour after > return () > writeIORef sigIdRef sigId > return (error "You can't expect result from behaviour") > > waitEvent :: GObjectClass obj => Event obj -> Behaviour () > waitEvent event = BWaitEvent event (return ()) > > main :: IO () > main = > do initGUI > window <- windowNew > onDestroy window mainQuit > set window [windowTitle := "Hello World"] > button <- buttonNew > let buttonB label = > do liftIO $ set button [buttonLabel := label] > waitEvent (onClicked button) > buttonB (label ++ "*") > runBehaviour (buttonB "*") > set window [containerChild := button] > widgetShowAll window > mainGUI > > > -- > Victor Nazarov > From gcross at phys.washington.edu Tue Feb 2 22:33:51 2010 From: gcross at phys.washington.edu (Gregory Crosswhite) Date: Tue Feb 2 22:07:52 2010 Subject: [Haskell-cafe] Game of life in haskell. In-Reply-To: <201002030311.34683.jon@ffconsultancy.com> References: <201002021954.22028.jon@ffconsultancy.com> <3e1162e61002021044y5e9a7415xa25a6eb70590c406@mail.gmail.com> <201002030311.34683.jon@ffconsultancy.com> Message-ID: <66DEE482-B745-444F-A09A-1C788C120C7B@phys.washington.edu> On Feb 2, 2010, at 7:11 PM, Jon Harrop wrote: > I doubt programming paradigms live or die according to whether or not they can > implement Conway's Game of Life simply and efficiently. This makes an awesome quote. :-) - Greg From leimy2k at gmail.com Tue Feb 2 22:43:49 2010 From: leimy2k at gmail.com (David Leimbach) Date: Tue Feb 2 22:15:20 2010 Subject: [Haskell-cafe] Game of life in haskell. In-Reply-To: <66DEE482-B745-444F-A09A-1C788C120C7B@phys.washington.edu> References: <201002021954.22028.jon@ffconsultancy.com> <3e1162e61002021044y5e9a7415xa25a6eb70590c406@mail.gmail.com> <201002030311.34683.jon@ffconsultancy.com> <66DEE482-B745-444F-A09A-1C788C120C7B@phys.washington.edu> Message-ID: <3e1162e61002021943ja63540djb28732e64d1bc256@mail.gmail.com> On Tue, Feb 2, 2010 at 7:33 PM, Gregory Crosswhite < gcross@phys.washington.edu> wrote: > On Feb 2, 2010, at 7:11 PM, Jon Harrop wrote: > > > I doubt programming paradigms live or die according to whether or not > they can > > implement Conway's Game of Life simply and efficiently. > > This makes an awesome quote. :-) > > - Greg > This whole thread has been rather odd. The sort of processing that goes on in Conway's Game of Life is pretty common. I've seen it implemented a good many different ways, including with GCD from apple where each cell could potentially be its own thread (good scalability test for apple it seems... neat code, doesn't even use Cocoa). I've got some very simple code for Conway's Game of Life, but it is not my own. It's from Dr. Graham Hutton's excellent Haskell introductory book. Doesn't even use external libraries from the Prelude. It's short and easy to read, and renders by plotting characters a terminal using escape sequences (so I guess it's VT100 at least required to run it). I'm left somewhat confused by people believing they know enough about functional programming to make claims like these, or that the processing used in Conway's Game of Life might not be important. As someone who's worked in HPC for 1/3 his life and his entire career, I find this to be a pretty closed minded approach to computer science. The worst form of ignorance is when you think you've got the answer to everything already... It's sad to see that going on here. Dave > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100202/c8856cd6/attachment.html From ivan.miljenovic at gmail.com Tue Feb 2 23:25:13 2010 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Tue Feb 2 22:56:49 2010 Subject: [Haskell-cafe] Game of life in haskell. In-Reply-To: <66DEE482-B745-444F-A09A-1C788C120C7B@phys.washington.edu> (Gregory Crosswhite's message of "Tue, 2 Feb 2010 19:33:51 -0800") References: <201002021954.22028.jon@ffconsultancy.com> <3e1162e61002021044y5e9a7415xa25a6eb70590c406@mail.gmail.com> <201002030311.34683.jon@ffconsultancy.com> <66DEE482-B745-444F-A09A-1C788C120C7B@phys.washington.edu> Message-ID: <87iqafx7x2.fsf@gmail.com> Gregory Crosswhite writes: > On Feb 2, 2010, at 7:11 PM, Jon Harrop wrote: > >> I doubt programming paradigms live or die according to whether or not they can >> implement Conway's Game of Life simply and efficiently. > > This makes an awesome quote. :-) You mean Jon actually said something clever and interesting for once? :o -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com From jmillikin at gmail.com Wed Feb 3 00:30:03 2010 From: jmillikin at gmail.com (John Millikin) Date: Wed Feb 3 00:01:55 2010 Subject: [Haskell-cafe] GHC/base API documentation has been generated incorrectly Message-ID: <3283f7fe1002022130r50b3eeck5562a0338312f818@mail.gmail.com> Looking at (for example) the docs for 'bracket'[1], the parameter documentation has been "shifted" up by one. The source code[2] looks correct, so perhaps Haddock is parsing it incorrectly? Docs for other functions, such as 'showSigned'[3], exhibit the same error. [1] http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Exception.html#v%3Abracket [2] http://www.haskell.org/ghc/docs/latest/html/libraries/base/src/Control-Exception-Base.html#bracket [3] http://www.haskell.org/ghc/docs/latest/html/libraries/base/Numeric.html#v%3AshowSigned From kwangraecho at gmail.com Wed Feb 3 01:38:17 2010 From: kwangraecho at gmail.com (=?EUC-KR?B?wbaxpLeh?=) Date: Wed Feb 3 01:09:48 2010 Subject: [Haskell-cafe] multMM :: Matrix -> Matrix -> Matrix --multiplies two matrices question (Homework) Message-ID: <98f46b31002022238m6b288c0w7a49d1ffc8c9ee2@mail.gmail.com> hi i was trying to solve it but All i got is type Matrix=[[Double]] multMM :: Matrix -> Matrix -> Matrix --multiplies two matrices multMM m t = [[sum (zipWith (*) (head m)(a)) ] ]where a = [head a | a<- t] Main> multMM [[2,1,-6],[1,-3,2]] [[1,0,-3],[0,4,20],[-2,1,1]] [[14.0]] from this i could get only the first multiplication 14 that is by 2*1 + 1*0 + -6*-2 = 14 how can i make this go throw all rows and colums to get multiple of matrixs? Thank you~ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100203/5379796e/attachment.html From kh at cs.st-andrews.ac.uk Wed Feb 3 03:08:52 2010 From: kh at cs.st-andrews.ac.uk (Kevin Hammond) Date: Wed Feb 3 02:40:26 2010 Subject: [Haskell-cafe] Lectureships and Chair at St Andrews Message-ID: <18F88CE2-96AB-4238-91D3-3164A7E746E9@cs.st-andrews.ac.uk> We have vacancies for one chair (full professor) and two lectureships (assistant professor) in computer science at the University of St Andrews. It would be good to have some applications from our community. http://www.jobs.ac.uk/job/AAK643/2-lectureships-/ http://www.jobs.ac.uk/job/AAK633/chair-in-human-computer-interaction-/ Please do not be put off that the chair advert specifies "Human-Computer Interaction". Candidates with an excellent research background will always be considered. Best Wishes, Kevin -------- Kevin Hammond, Professor of Computer Science, University of St Andrews T: +44-1334 463241 F: +44-1334-463278 W: http://www.cs.st-andrews.ac.uk/~kh In accordance with University policy on electronic mail, this email reflects the opinions of the individual concerned, may contain confidential or copyright information that should not be copied or distributed without permission, may be of a private or personal nature unless explicitly indicated otherwise, and should not under any circumstances be taken as an official statement of University policy or procedure (see http://www.st-and.ac.uk). The University of St Andrews is a charity registered in Scotland : No SC013532 From haberg at math.su.se Wed Feb 3 04:30:06 2010 From: haberg at math.su.se (Hans Aberg) Date: Wed Feb 3 04:03:41 2010 Subject: [Haskell-cafe] multMM :: Matrix -> Matrix -> Matrix --multiplies two matrices question (Homework) In-Reply-To: <98f46b31002022238m6b288c0w7a49d1ffc8c9ee2@mail.gmail.com> References: <98f46b31002022238m6b288c0w7a49d1ffc8c9ee2@mail.gmail.com> Message-ID: <90CC61AD-3729-48BA-B355-5DE3469A5734@math.su.se> On 3 Feb 2010, at 07:38, ??? wrote: > hi i was trying to solve it but > > All i got is > type Matrix=[[Double]] > > multMM :: Matrix -> Matrix -> Matrix --multiplies two matrices > multMM m t = [[sum (zipWith (*) (head m)(a)) ] ]where a = [head > a | a<- t] > > > Main> multMM [[2,1,-6],[1,-3,2]] [[1,0,-3],[0,4,20],[-2,1,1]] > [[14.0]] > > from this i could get only the first multiplication 14 that is > by 2*1 + 1*0 + -6*-2 = 14 > > how can i make this go throw all rows and colums to get multiple of > matrixs? Perhaps you might try the beginners mailing list: http://haskell.org/haskellwiki/Mailing_lists http://haskell.org/mailman/listinfo/beginners because here, people will just assume one wants effective solutions. :-) Anyway, the page I mentioned before has a matrix multiplication: http://haskell.org/haskellwiki/Prelude_extensions It uses the function transpose(), which is in the module Data.List. I find looking into the modules of Hugs useful, on my computer they are in /usr/local/lib/hugs/packages but those for GHC are also available online: http://www.haskell.org/ghc/docs/latest/html/libraries/ Hans From nccb2 at kent.ac.uk Wed Feb 3 06:26:09 2010 From: nccb2 at kent.ac.uk (Neil Brown) Date: Wed Feb 3 05:57:54 2010 Subject: [Haskell-cafe] GHC/base API documentation has been generated incorrectly In-Reply-To: <3283f7fe1002022130r50b3eeck5562a0338312f818@mail.gmail.com> References: <3283f7fe1002022130r50b3eeck5562a0338312f818@mail.gmail.com> Message-ID: <4B695D51.1020805@kent.ac.uk> Hi, I noticed this on another package recently. Turned out it's already been reported as a haddock bug (http://trac.haskell.org/haddock/ticket/128) and fixed. I guess this will be sorted when the fixed version of haddock is used to re-generate the docs. Thanks, Neil. John Millikin wrote: > Looking at (for example) the docs for 'bracket'[1], the parameter > documentation has been "shifted" up by one. The source code[2] looks > correct, so perhaps Haddock is parsing it incorrectly? Docs for other > functions, such as 'showSigned'[3], exhibit the same error. > > [1] http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Exception.html#v%3Abracket > [2] http://www.haskell.org/ghc/docs/latest/html/libraries/base/src/Control-Exception-Base.html#bracket > [3] http://www.haskell.org/ghc/docs/latest/html/libraries/base/Numeric.html#v%3AshowSigned > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From david.waern at gmail.com Wed Feb 3 06:31:29 2010 From: david.waern at gmail.com (David Waern) Date: Wed Feb 3 06:03:00 2010 Subject: [Haskell-cafe] GHC/base API documentation has been generated incorrectly In-Reply-To: <3283f7fe1002022130r50b3eeck5562a0338312f818@mail.gmail.com> References: <3283f7fe1002022130r50b3eeck5562a0338312f818@mail.gmail.com> Message-ID: 2010/2/3 John Millikin : > Looking at (for example) the docs for 'bracket'[1], the parameter > documentation has been "shifted" up by one. The source code[2] looks > correct, so perhaps Haddock is parsing it incorrectly? Docs for other > functions, such as 'showSigned'[3], exhibit the same error. Hi John, This has already been fixed and the fix will be in the next release. Thanks, David From jesper.louis.andersen at gmail.com Wed Feb 3 07:57:30 2010 From: jesper.louis.andersen at gmail.com (Jesper Louis Andersen) Date: Wed Feb 3 07:29:20 2010 Subject: [Haskell-cafe] Hackage Package version ranges In-Reply-To: <87r5p3xgs4.fsf@gmail.com> References: <404396ef1002021411r7c1cdd5exd4850150a7e0c25a@mail.gmail.com> <87r5p3xgs4.fsf@gmail.com> Message-ID: <56a0a2841002030457s63d1eecmc254106481a42899@mail.gmail.com> On Wed, Feb 3, 2010 at 2:13 AM, Ivan Lazar Miljenovic wrote: > > Well, in Gentoo we normally resort to using sed to fix these kinds of > things. ?If we can do it, I'm sure the Arch package managers are able to > do so. > > It might be more annoying, but IMHO it's a bigger problem when a > developer is too lax in constraints (since then we've got to tweak the > constraints until we find ones that _do_ work). > That is not a bad idea. The only problem I can see with that approach is the error-reports will be hard to understand if they are not filtered through the maintainer of said Gentoo-package. I usually configure my git-repositories to use 'git describe' and add a -dirty or -tainted to that if the tree is not clean when building. This tend to capture the problem of local patches and gives me a hint that something is altered :) -- J. From ivan.miljenovic at gmail.com Wed Feb 3 08:04:42 2010 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Wed Feb 3 07:36:17 2010 Subject: [Haskell-cafe] Hackage Package version ranges In-Reply-To: <56a0a2841002030457s63d1eecmc254106481a42899@mail.gmail.com> (Jesper Louis Andersen's message of "Wed, 3 Feb 2010 13:57:30 +0100") References: <404396ef1002021411r7c1cdd5exd4850150a7e0c25a@mail.gmail.com> <87r5p3xgs4.fsf@gmail.com> <56a0a2841002030457s63d1eecmc254106481a42899@mail.gmail.com> Message-ID: <87sk9iwjv9.fsf@gmail.com> Jesper Louis Andersen writes: > On Wed, Feb 3, 2010 at 2:13 AM, Ivan Lazar Miljenovic >> Well, in Gentoo we normally resort to using sed to fix these kinds of >> things. ?If we can do it, I'm sure the Arch package managers are able to >> do so. > > That is not a bad idea. The only problem I can see with that approach > is the error-reports will be hard to understand if they are not > filtered through the maintainer of said Gentoo-package. I usually > configure my git-repositories to use 'git describe' and add a -dirty > or -tainted to that if the tree is not clean when building. This tend > to capture the problem of local patches and gives me a hint that > something is altered :) Well, I was only talking about it from a package management point of view, in which case users do come and complain to us first ;-) Note that the sed'ding is done via the Gentoo ebuild for the package, as are any patches we apply; as such there's no "fixed" tarball or anything floating around for any of these packages. -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com From apfelmus at quantentunnel.de Wed Feb 3 08:11:42 2010 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Wed Feb 3 07:44:10 2010 Subject: [Haskell-cafe] Re: GUI programming In-Reply-To: References: Message-ID: Victor Nazarov wrote: > data Behaviour a = > forall b. BBind (Behaviour b) (b -> Behaviour a) > | BIO (IO a) > | forall obj. GObjectClass obj => BWaitEvent (Event obj) (Behaviour a) > > instance Monad Behaviour > where action >>= generator = BBind action generator > return a = BIO (return a) > > instance MonadIO Behaviour > where liftIO action = BIO action > > runBehaviour :: Behaviour a -> IO a > runBehaviour (BBind (BWaitEvent event after) f) = runBehaviour > (BWaitEvent event (after >>= f)) > runBehaviour (BBind (BIO a) f) = a >>= \x -> runBehaviour (f x) > runBehaviour (BBind (BBind a f) g) = runBehaviour (a >>= (\x -> f x >>= g)) Just a minor note: you can somewhat clean up your code by using a generic monad, as implemented in my cabal package operational http://hackage.haskell.org/package/operational and described in Heinrich Apfelmus. The Operational Monad Tutorial. In http://themonadreader.wordpress.com/2010/01/26/issue-15/ Regards, Heinrich Apfelmus -- http://apfelmus.nfshost.com From alexander.treptow at googlemail.com Wed Feb 3 08:10:52 2010 From: alexander.treptow at googlemail.com (Alexander Treptow) Date: Wed Feb 3 07:45:06 2010 Subject: [Haskell-cafe] Multi-Class monadic type? Message-ID: <4B6975DC.2090808@googlemail.com> Hi, i got a little problem and don't know how to solve that. Hope you can help me. code: ---------- module Test where {-# LANGUAGE Rank2Types, RankNTypes #-} import Control.Monad.Trans data TestType = TestType {tst :: (Conf a, MonadIO m) => m a} class Conf a where get :: MonadIO m => m a testFunc :: (forall a. Conf a, MonadIO m => m a) -> TestType testFunc = TestType -------------- error: -------------- Test.hs:11:23 Class `Conf' used as a type In the type signature for `testFunc': testFunc :: (forall a. Conf a, (MonadIO m) => m a) -> TestType -------------- explanation: I need a data type that creates a record with a member that has no fixed type, because its not known at compile-time. The Rank2Types language extension fits that need, but i figured out that i ll need to make that time monadic to avoid the use of unsafePerformIO in the program that uses this lib. Thanks and greetings, Alex From stephen.tetley at gmail.com Wed Feb 3 08:47:47 2010 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Wed Feb 3 08:19:17 2010 Subject: [Haskell-cafe] Multi-Class monadic type? In-Reply-To: <4B6975DC.2090808@googlemail.com> References: <4B6975DC.2090808@googlemail.com> Message-ID: <5fdc56d71002030547o7b907122jc91d3b5f3123af56@mail.gmail.com> On 3 February 2010 13:10, Alexander Treptow wrote: > I need a data type that creates a record with a member that has no fixed > type, because its not known at compile-time. A type unknown at compile-type pretty much defines a dynamic type, so how about Data.Dynamic? Although Data.Dynamic uses unsafePerformIO there are other ways of encoding dynamic types that don't. Best wishes Stephen From asviraspossible at gmail.com Wed Feb 3 08:51:55 2010 From: asviraspossible at gmail.com (Victor Nazarov) Date: Wed Feb 3 08:23:25 2010 Subject: [Haskell-cafe] Re: GUI programming In-Reply-To: References: Message-ID: On Wed, Feb 3, 2010 at 4:11 PM, Heinrich Apfelmus wrote: > Victor Nazarov wrote: >> data Behaviour a = >> ? forall b. BBind (Behaviour b) (b -> Behaviour a) >> ? | BIO (IO a) >> ? | forall obj. GObjectClass obj => BWaitEvent (Event obj) (Behaviour a) >> >> instance Monad Behaviour >> ?where action >>= generator = BBind action generator >> ? ? ? ?return a = BIO (return a) >> >> instance MonadIO Behaviour >> ?where liftIO action = BIO action >> >> runBehaviour :: Behaviour a -> IO a >> runBehaviour (BBind (BWaitEvent event after) f) = runBehaviour >> (BWaitEvent event (after >>= f)) >> runBehaviour (BBind (BIO a) f) = a >>= \x -> runBehaviour (f x) >> runBehaviour (BBind (BBind a f) g) = runBehaviour (a >>= (\x -> f x >>= g)) > > Just a minor note: you can somewhat clean up your code by using a > generic monad, as implemented in my cabal package ?operational > > ? http://hackage.haskell.org/package/operational > > and described in > > ? Heinrich Apfelmus. The Operational Monad Tutorial. > ? In http://themonadreader.wordpress.com/2010/01/26/issue-15/ > > Thank you. It seems relevant. I'll have a look at it. Speaking about packages. What is current community status of monad transformers packages. I'm using MonadIO class and there are mtl, monads-fd, monads-tf packages that provide it. I personally prefer type families to functional dependencies. Should I use monads-tf, or should I stick to mtl? -- Victor Nazarov From miguelimo38 at yandex.ru Wed Feb 3 08:50:07 2010 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Wed Feb 3 08:24:39 2010 Subject: [Haskell-cafe] Multi-Class monadic type? In-Reply-To: <4B6975DC.2090808@googlemail.com> References: <4B6975DC.2090808@googlemail.com> Message-ID: <4B697F0F.2080007@yandex.ru> Error message suggests that you've used "Conf" improperly. testFunc :: (forall a. Conf a, MonadIO m => m a) -> TestType is illegal, as I recall, you should use another pair of brackets: testFunc :: (forall a. (Conf a, MonadIO m) => m a) -> TestType Alexander Treptow wrote: > Hi, > i got a little problem and don't know how to solve that. Hope you can > help me. > > code: > ---------- > module Test where > {-# LANGUAGE Rank2Types, RankNTypes #-} > import Control.Monad.Trans > > data TestType = TestType > {tst :: (Conf a, MonadIO m) => m a} > > class Conf a where > get :: MonadIO m => m a > > testFunc :: (forall a. Conf a, MonadIO m => m a) -> TestType > testFunc = TestType > -------------- > error: > -------------- > Test.hs:11:23 > Class `Conf' used as a type > In the type signature for `testFunc': > testFunc :: (forall a. Conf a, (MonadIO m) => m a) -> TestType > -------------- > > explanation: > I need a data type that creates a record with a member that has no fixed > type, because its not known at compile-time. The Rank2Types language > extension fits that need, but i figured out that i ll need to make that > time monadic to avoid the use of unsafePerformIO in the program that > uses this lib. > > Thanks and greetings, > Alex > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From haskell at benmachine.co.uk Wed Feb 3 09:13:12 2010 From: haskell at benmachine.co.uk (Ben Millwood) Date: Wed Feb 3 08:44:43 2010 Subject: [Haskell-cafe] Multi-Class monadic type? In-Reply-To: <4B6975DC.2090808@googlemail.com> References: <4B6975DC.2090808@googlemail.com> Message-ID: On Wed, Feb 3, 2010 at 1:10 PM, Alexander Treptow wrote: > testFunc :: (forall a. Conf a, MonadIO m => m a) -> TestType At a guess, this function takes a tuple containing a forall a. Conf a and a MonadIO m => m a, which is not what you meant. As Miguel says, more parentheses are the answer. From alexander.treptow at googlemail.com Wed Feb 3 09:17:36 2010 From: alexander.treptow at googlemail.com (Alexander Treptow) Date: Wed Feb 3 08:51:51 2010 Subject: [Haskell-cafe] Multi-Class monadic type? In-Reply-To: <4B697F0F.2080007@yandex.ru> References: <4B6975DC.2090808@googlemail.com> <4B697F0F.2080007@yandex.ru> Message-ID: <4B698580.4010602@googlemail.com> Thanks, i tried it with your code changes but then i ll only get a type mismatch Test.hs:12:11: Couldn't match expected type `forall a. (Conf a, MonadIO m) => m a' against inferred type `forall a (m1 :: * -> *). (Conf a, MonadIO m1) => m1 a' In the expression: TestType In the definition of `testFunc': testFunc = TestType Miguel Mitrofanov schrieb: > Error message suggests that you've used "Conf" improperly. > > testFunc :: (forall a. Conf a, MonadIO m => m a) -> TestType > > is illegal, as I recall, you should use another pair of brackets: > > testFunc :: (forall a. (Conf a, MonadIO m) => m a) -> TestType > > Alexander Treptow wrote: >> Hi, >> i got a little problem and don't know how to solve that. Hope you can >> help me. >> >> code: >> ---------- >> module Test where >> {-# LANGUAGE Rank2Types, RankNTypes #-} >> import Control.Monad.Trans >> >> data TestType = TestType >> {tst :: (Conf a, MonadIO m) => m a} >> >> class Conf a where >> get :: MonadIO m => m a >> >> testFunc :: (forall a. Conf a, MonadIO m => m a) -> TestType >> testFunc = TestType >> -------------- >> error: >> -------------- >> Test.hs:11:23 >> Class `Conf' used as a type >> In the type signature for `testFunc': >> testFunc :: (forall a. Conf a, (MonadIO m) => m a) -> TestType >> -------------- >> >> explanation: >> I need a data type that creates a record with a member that has no fixed >> type, because its not known at compile-time. The Rank2Types language >> extension fits that need, but i figured out that i ll need to make that >> time monadic to avoid the use of unsafePerformIO in the program that >> uses this lib. >> >> Thanks and greetings, >> Alex >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > From alexander.treptow at googlemail.com Wed Feb 3 09:41:17 2010 From: alexander.treptow at googlemail.com (Alexander Treptow) Date: Wed Feb 3 09:15:32 2010 Subject: [Haskell-cafe] Multi-Class monadic type? References: 4B697F0F.2080007@yandex.ru Message-ID: <4B698B0D.1040004@googlemail.com> Edit: it is running, testFunc :: (forall a m. (Conf a, MonadIO m) => m a) -> TestType is the solution ;) ---------- Thanks, i tried it with your code changes but then i ll only get a type mismatch Test.hs:12:11: Couldn't match expected type `forall a. (Conf a, MonadIO m) => m a' against inferred type `forall a (m1 :: * -> *). (Conf a, MonadIO m1) => m1 a' In the expression: TestType In the definition of `testFunc': testFunc = TestType Miguel Mitrofanov schrieb: >/ Error message suggests that you've used "Conf" improperly. />/ />/ testFunc :: (forall a. Conf a, MonadIO m => m a) -> TestType />/ />/ is illegal, as I recall, you should use another pair of brackets: />/ />/ testFunc :: (forall a. (Conf a, MonadIO m) => m a) -> TestType />/ />/ Alexander Treptow wrote: />>/ Hi, />>/ i got a little problem and don't know how to solve that. Hope you can />>/ help me. />>/ />>/ code: />>/ ---------- />>/ module Test where />>/ {-# LANGUAGE Rank2Types, RankNTypes #-} />>/ import Control.Monad.Trans />>/ />>/ data TestType = TestType />>/ {tst :: (Conf a, MonadIO m) => m a} />>/ />>/ class Conf a where />>/ get :: MonadIO m => m a />>/ />>/ testFunc :: (forall a. Conf a, MonadIO m => m a) -> TestType />>/ testFunc = TestType />>/ -------------- />>/ error: />>/ -------------- />>/ Test.hs:11:23 />>/ Class `Conf' used as a type />>/ In the type signature for `testFunc': />>/ testFunc :: (forall a. Conf a, (MonadIO m) => m a) -> TestType />>/ -------------- />>/ />>/ explanation: />>/ I need a data type that creates a record with a member that has no fixed />>/ type, because its not known at compile-time. The Rank2Types language />>/ extension fits that need, but i figured out that i ll need to make that />>/ time monadic to avoid the use of unsafePerformIO in the program that />>/ uses this lib. />>/ />>/ Thanks and greetings, />>/ Alex />>/ />>/ _______________________________________________ />>/ Haskell-Cafe mailing list />>/ Haskell-Cafe at haskell.org />>/ http://www.haskell.org/mailman/listinfo/haskell-cafe />>/ />/ / From ekmett at gmail.com Wed Feb 3 10:13:41 2010 From: ekmett at gmail.com (Edward Kmett) Date: Wed Feb 3 09:45:10 2010 Subject: [Haskell-cafe] functional references and HList? In-Reply-To: <4B68BCA9.2010201@web.de> References: <4B68BCA9.2010201@web.de> Message-ID: <7fb8f82f1002030713v1a191af7t57bf647c229a035@mail.gmail.com> I see them as addressing separate issues. They overlap in that they both address the notion of how to access attributes in some sense, but really they are complementary techniques. HList as used by OOHaskell provides you with a mechanism by which you can define extensible records and structural subtyping. Functional references let you both read and write 'attributes' in a structure. These can be chained to access members of members. These techniques can be used together to get extensible records that have settable fields in the form of functional references, where these references can be chained together. HList/OOHaskell doesn't concern itself with the 'deep reference' problem, and functional references do not concern themselves directly with extensible records. -Edward Kmett 2010/2/2 G?nther Schmidt > Hi all, > > I wonder if there is some a "field of use" overlap between HList and > functional references aka accessors. > > Do both tackle the same problem? > > G?nther > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100203/23462a1a/attachment.html From gracjanpolak at gmail.com Wed Feb 3 10:45:20 2010 From: gracjanpolak at gmail.com (Gracjan Polak) Date: Wed Feb 3 10:17:13 2010 Subject: [Haskell-cafe] The errorCalls and ioErrors in extensible exceptions way Message-ID: Hi all, I have base==3.* code that uses errorCalls and ioErrors to intercept either ErrorCall or IOError that may arise in deeper code. I'd like to convert this code to base==4.* new exceptions. -- | Evaluate the argument and catch error call exceptions errorToErr :: Monad m => a -> Err m a errorToErr x = let e = unsafePerformIO (tryJust errorCalls (evaluate x)) in ErrorT (return e) -- | Catch IO errors in the error monad. ioErrorToErr :: IO a -> Err IO a ioErrorToErr = ErrorT . liftM (either (Left . show) Right) . tryJust ioErrors Look here for more context: http://hackage.haskell.org/packages/archive/haxr/3000.5/doc/html/Network-XmlRpc-Internals.html#5 I know that just importing OldException will do the trick for now. But I'd like to know how to do such a trick in extensible exceptions way. Also that unsafePerformIO looks a bit scary. Isn't there a better way to achieve purpose? -- Gracjan From jwlato at gmail.com Wed Feb 3 10:56:09 2010 From: jwlato at gmail.com (John Lato) Date: Wed Feb 3 10:27:39 2010 Subject: [Haskell-cafe] matrix question Message-ID: <9979e72e1002030756h61c2feabj2915ae34a1fa0b4e@mail.gmail.com> > From: Ivan Lazar Miljenovic > > man writes: >> http://hackage.haskell.org/package/hmatrix-0.8.1.1 >> >> it wraps gls, blas and lapack (so you need to install the libraries). > > There's also the blas package if you just want blas support. I've been using blas recently with very good results. It's great if all you need are simple matrix operations. I just wanted to point out that it doesn't install on ghc-6.12.1 because the ieee dependency provides a type class instance for CLDouble, which was omitted from ghc-6.12.1. I got around this by commenting out the instance in CLDouble in the ieee package, then everything installed and runs properly (using OSX 10.6, compiled with -faccelerate). John From magnus at therning.org Wed Feb 3 14:51:34 2010 From: magnus at therning.org (Magnus Therning) Date: Wed Feb 3 14:23:05 2010 Subject: [Haskell-cafe] setNonBlockingFD? In-Reply-To: <90889fe71002021644w694751fbwfb5aa5957fff8c81@mail.gmail.com> References: <4B68C649.5080102@therning.org> <90889fe71002021644w694751fbwfb5aa5957fff8c81@mail.gmail.com> Message-ID: On Wed, Feb 3, 2010 at 00:44, Johan Tibell wrote: > On Tue, Feb 2, 2010 at 4:41 PM, Magnus Therning wrote: >> >> network-fancy fails to build because "Not in scope: 'setNonBlockingFD'". >> ?Any >> pointers to what should be used in 6.12? > > I have the following in 'network': > #if __GLASGOW_HASKELL__ < 611 > ?? ?System.Posix.Internals.setNonBlockingFD fd > #else > ?? ?System.Posix.Internals.setNonBlockingFD fd True > #endif Thanks. That pointed me in the right direction. I've posted the attached patch as a suggested fix to the developer. Hopefully there'll be a compilable version on Hackage soon. /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe -------------- next part -------------- A non-text attachment was scrubbed... Name: setNonBlockingFD.patch Type: text/x-patch Size: 2189 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100203/cb3be25b/setNonBlockingFD.bin From gwern0 at gmail.com Wed Feb 3 17:30:52 2010 From: gwern0 at gmail.com (Gwern Branwen) Date: Wed Feb 3 17:02:21 2010 Subject: [Haskell-cafe] Anyone up for Google SoC 2010? In-Reply-To: <863507BC-FD78-49A0-9A77-C97B9431F7E7@cs.york.ac.uk> References: <863507BC-FD78-49A0-9A77-C97B9431F7E7@cs.york.ac.uk> Message-ID: On Sun, Jan 31, 2010 at 6:04 AM, Malcolm Wallace wrote: > Google has announced that the Summer of Code programme will be running again > this year. ?If haskell.org people would like to take part again this year, > then we need volunteers: > > First, > ? ?* suggestions for suitable projects > ? ? ? ? ?(in the past this was organised using a reddit) > ? ?* an administrator to co-ordinate the application to Google > ? ? ? ? ?(I have done it for the last three years but am very willing > ? ? ? ? ? to hand on to someone else) > > Google will accept applications from organisations in the period 8th - 12th > March 2010, approx 1900UTC. > > If haskell.org is accepted again, students can apply between 29th March - > 9th April. > More volunteers will be required: > > ? ?* to review student applications and choose which to accept > ? ?* to supervise the accepted students > > Both of these roles are called "mentor" in the Google system. ?Putting > together a good team of mentors before applying as an organisation is > helpful towards us being accepted into the programme. > > Regards, > ? ?Malcolm Gosh, is it that time of the year again? That reminds me to update my running account of SoCs at http://community.haskell.org/~gwern/wiki/Haskell%20Summer%20of%20Code.page for the 2008 and 2009 results. I was able to update 2008 results to 4 successes, 3 failures. 2009 is still uncertain at 2 successes, 1 failure, and 2 unknown. My general conclusions about good SoC projects are much the same as last year's conclusions: http://www.mail-archive.com/haskell-cafe@haskell.org/msg53623.html I would add though that projects really need to be focused. I marked down nominolo's GHC API SoC as a failure because as far as I could ascertain, he couldn't do much of anything, it was so much of a mess. That it was not a good target for a short intense SoC, but rather the target of slow multi-year refactoring & clean-up, might have been more obvious if more specifics had to have been adduced. -- gwern -------------- next part -------------- A non-text attachment was scrubbed... Name: haskell_summer_of_code.pdf Type: application/pdf Size: 187813 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100203/a0421fb4/haskell_summer_of_code-0001.pdf From ndmitchell at gmail.com Wed Feb 3 17:34:34 2010 From: ndmitchell at gmail.com (Neil Mitchell) Date: Wed Feb 3 17:06:06 2010 Subject: [Haskell-cafe] Anyone up for Google SoC 2010? In-Reply-To: References: <863507BC-FD78-49A0-9A77-C97B9431F7E7@cs.york.ac.uk> Message-ID: <404396ef1002031434i1f0388fduef0eab93ee040c01@mail.gmail.com> Hi Gwern, Please update: "haskell-src-exts -> haskell-src" **Unknown** This project was an unqualified success. haskell-src-exts is now one of the most commonly used Haskell libraries, achieved the goals in the project proposal, and is an essential piece of Haskell infrastructure. I couldn't be more pleased with how this project turned out. Thanks, Neil From hjgtuyl at chello.nl Wed Feb 3 20:14:06 2010 From: hjgtuyl at chello.nl (Henk-Jan van Tuyl) Date: Wed Feb 3 19:45:26 2010 Subject: [Haskell-cafe] Anyone up for Google SoC 2010? In-Reply-To: <404396ef1002031434i1f0388fduef0eab93ee040c01@mail.gmail.com> References: <863507BC-FD78-49A0-9A77-C97B9431F7E7@cs.york.ac.uk> <404396ef1002031434i1f0388fduef0eab93ee040c01@mail.gmail.com> Message-ID: On Wed, 03 Feb 2010 23:34:34 +0100, Neil Mitchell wrote: > Hi Gwern, > > Please update: "haskell-src-exts -> haskell-src" **Unknown** > > This project was an unqualified success. haskell-src-exts is now one > of the most commonly used Haskell libraries, achieved the goals in the > project proposal, and is an essential piece of Haskell infrastructure. You can see this using Roel van Dijk's reversed dependencies overview [1]: 23 direct and 57 indirect dependencies on haskell-src-exts-1.8.0 Regards, Henk-Jan van Tuyl [1] http://bifunctor.homelinux.net/~roel/cgi-bin/hackage-scripts/package/haskell-src-exts -- http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html -- From oleg at okmij.org Thu Feb 4 01:48:10 2010 From: oleg at okmij.org (oleg@okmij.org) Date: Thu Feb 4 01:21:42 2010 Subject: [Haskell-cafe] HList darcs repo Message-ID: <20100204064810.BA99317362@Adric.ern.nps.edu> HList (and OOHaskell, for that matter) are now hosted on community.haskell.org, in the directories /srv/code/HList /srv/code/OOHaskell The repositories are also available at these URLs: http://code.haskell.org/HList/ http://code.haskell.org/OOHaskell/ Many thanks to Ian Lynagh for moving the repositories. Ian has kindly set up the redirection so that the old, used in many places URL http://darcs.haskell.org/HList/ still works. It now redirects to code.haskell.org. From waldmann at imn.htwk-leipzig.de Thu Feb 4 02:01:49 2010 From: waldmann at imn.htwk-leipzig.de (Johannes Waldmann) Date: Thu Feb 4 01:33:33 2010 Subject: [Haskell-cafe] programmatic DB interface? Message-ID: <4B6A70DD.8020503@imn.htwk-leipzig.de> Hello. What is currently the recommended higher level data base interface for Haskell? I want to construct queries in a programmatic/algebraic way, and I want typed queries and results. - I guess I want LINQ. The examples in http://book.realworldhaskell.org/read/using-databases.html seem to construct queries as strings. That's horrible! Looks exactly like PHP! Well, no, but it's a lower abstraction level than that I want to work at. I'm sure I'm just missing some package/framework here. Would takusen help? Where's its home page? this does not work: http://darcs.haskell.org/takusen/ Best, Johannes. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 260 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100204/f761f2a2/signature.bin From gue.schmidt at web.de Thu Feb 4 03:26:43 2010 From: gue.schmidt at web.de (=?ISO-8859-1?Q?G=FCnther_Schmidt?=) Date: Thu Feb 4 02:58:35 2010 Subject: [Haskell-cafe] Re: programmatic DB interface? In-Reply-To: <4B6A70DD.8020503@imn.htwk-leipzig.de> References: <4B6A70DD.8020503@imn.htwk-leipzig.de> Message-ID: <4B6A84C3.30701@web.de> Hello Johannes, I think you are looking for HaskellDB, you can find it on hackage. I've been working with it myself and can absolutely recommend it. It is actively maintained by Justin Bailey. It's a EDSL for relational algebra which gets translated into SQL. It can use HDBC for instance as its *driver* to databases supported by HDBC. As with LINQ you need to put an initial effort into describing the tables and their columns of the database first, once that is done you can go ahead and express your queries in the EDSL, *typesafe* and higher-orderish too. HaskellDB was originally developed by Daan Leijen and Erik Meijer, two of the great old ones, both very well known here in the Haskell community. There are 2 papers describing the foundations of HaskellDB, google for Domain specific embedded compilers and The lambda calculus abroad (Chapter 5 of a rather large paper). both authored by Daan Leijen and Erik Meijer. HTH G?nther Am 04.02.10 08:01, schrieb Johannes Waldmann: > Hello. > > What is currently the recommended > higher level data base interface for Haskell? > > I want to construct queries in a programmatic/algebraic way, > and I want typed queries and results. - I guess I want LINQ. > > The examples in > http://book.realworldhaskell.org/read/using-databases.html > seem to construct queries as strings. > That's horrible! Looks exactly like PHP! > > Well, no, but it's a lower abstraction level > than that I want to work at. > I'm sure I'm just missing some package/framework here. > > Would takusen help? Where's its home page? > this does not work: http://darcs.haskell.org/takusen/ > > Best, Johannes. > > > > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From waldmann at imn.htwk-leipzig.de Thu Feb 4 03:47:17 2010 From: waldmann at imn.htwk-leipzig.de (Johannes Waldmann) Date: Thu Feb 4 03:19:11 2010 Subject: [Haskell-cafe] Re: programmatic DB interface? References: <4B6A70DD.8020503@imn.htwk-leipzig.de> <4B6A84C3.30701@web.de> Message-ID: > I think you are looking for HaskellDB, thanks, I'll look into it. > As with LINQ you need to put an initial effort into describing the > tables [...] according to the documentation, that's what dbdirect is for? I see the source, but not how to build it. J. From waldmann at imn.htwk-leipzig.de Thu Feb 4 03:59:11 2010 From: waldmann at imn.htwk-leipzig.de (Johannes Waldmann) Date: Thu Feb 4 03:31:03 2010 Subject: [Haskell-cafe] Re: programmatic DB interface? References: <4B6A70DD.8020503@imn.htwk-leipzig.de> <4B6A84C3.30701@web.de> Message-ID: > can use HDBC for instance as its *driver* to databases supported by HDBC. ok, so I guess I need haskelldb-hdbc-postgresql but hdbc-postgresql has build failures http://hackage.haskell.org/package/HDBC-postgresql From ivan.miljenovic at gmail.com Thu Feb 4 04:16:32 2010 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Thu Feb 4 03:48:07 2010 Subject: [Haskell-cafe] Re: programmatic DB interface? In-Reply-To: (Johannes Waldmann's message of "Thu, 4 Feb 2010 08:59:11 +0000 (UTC)") References: <4B6A70DD.8020503@imn.htwk-leipzig.de> <4B6A84C3.30701@web.de> Message-ID: <87zl3pfjin.fsf@gmail.com> Johannes Waldmann writes: > > ok, so I guess I need haskelldb-hdbc-postgresql > but hdbc-postgresql has build failures > http://hackage.haskell.org/package/HDBC-postgresql Looks like HDBC-postgresql's Setup.hs needs to be updated to use newer versions of Cabal properly; if you're using the latest release of the Haskell Platform then I think it will build OK. -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com From waldmann at imn.htwk-leipzig.de Thu Feb 4 04:39:00 2010 From: waldmann at imn.htwk-leipzig.de (Johannes Waldmann) Date: Thu Feb 4 04:10:55 2010 Subject: [Haskell-cafe] Re: programmatic DB interface? References: <4B6A70DD.8020503@imn.htwk-leipzig.de> <4B6A84C3.30701@web.de> <87zl3pfjin.fsf@gmail.com> Message-ID: > if you're using the latest release of the Haskell Platform [...] but this would not work with ghc-6.12 ... Anyway the trick is to remove "AnyVersion" from Setup.hs (thanks, Michael!) From apfelmus at quantentunnel.de Thu Feb 4 05:16:45 2010 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Thu Feb 4 04:48:32 2010 Subject: [Haskell-cafe] Re: GUI programming In-Reply-To: References: Message-ID: Victor Nazarov wrote: > Speaking about packages. What is current community status of monad > transformers packages. I'm using MonadIO class and there are mtl, > monads-fd, monads-tf packages that provide it. I personally prefer > type families to functional dependencies. Should I use monads-tf, or > should I stick to mtl? As I understand it, mtl is to be replaced by transformers and one of the monads-* packages in the future, though there is no clear recommendation yet. See also http://thread.gmane.org/gmane.comp.lang.haskell.libraries/12229/ Also, it seems that there is currently no community preference choice for either type families or functional dependencies. Personally, I didn't want to think about this and simply chose mtl . But if you like type families a lot, I see no problem with going ahead and using transformers + monads-tf . Regards, Heinrich Apfelmus -- http://apfelmus.nfshost.com From felipe.lessa at gmail.com Thu Feb 4 07:08:44 2010 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Thu Feb 4 06:40:17 2010 Subject: [Haskell-cafe] Re: programmatic DB interface? In-Reply-To: <4B6A84C3.30701@web.de> References: <4B6A70DD.8020503@imn.htwk-leipzig.de> <4B6A84C3.30701@web.de> Message-ID: <20100204120844.GB1596@kira.casa> On Thu, Feb 04, 2010 at 09:26:43AM +0100, G?nther Schmidt wrote: > I think you are looking for HaskellDB, you can find it on hackage. > I've been working with it myself and can absolutely recommend it. > > It is actively maintained by Justin Bailey. It's been some time since I last tried HaskellDB but it used to generate SQL queries that no SGBD could ever optimize :D. Do you have better experiencies in the performance camp? Thanks, -- Felipe. From martijn at van.steenbergen.nl Thu Feb 4 07:18:20 2010 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Thu Feb 4 06:49:58 2010 Subject: [Haskell-cafe] functional references and HList? In-Reply-To: <7fb8f82f1002030713v1a191af7t57bf647c229a035@mail.gmail.com> References: <4B68BCA9.2010201@web.de> <7fb8f82f1002030713v1a191af7t57bf647c229a035@mail.gmail.com> Message-ID: <4B6ABB0C.1000300@van.steenbergen.nl> Edward Kmett wrote: > Functional references let you both read and write 'attributes' in a > structure. These can be chained to access members of members. You can also use them to build bidirectional views on fields (and compose those again as well). Martijn. From gue.schmidt at web.de Thu Feb 4 08:00:53 2010 From: gue.schmidt at web.de (=?UTF-8?B?R8O8bnRoZXIgU2NobWlkdA==?=) Date: Thu Feb 4 07:32:21 2010 Subject: [Haskell-cafe] functional references and HList? In-Reply-To: <4B6ABB0C.1000300@van.steenbergen.nl> References: <4B68BCA9.2010201@web.de> <7fb8f82f1002030713v1a191af7t57bf647c229a035@mail.gmail.com> <4B6ABB0C.1000300@van.steenbergen.nl> Message-ID: <4B6AC505.2090606@web.de> Hi, from all this I'm not so sure that these two techniques do not overlap. I mean HList tries to provide a technique for extensible Records, or composable data structures. So far it is possible in Haskell to extend / compose Data Structures but not at run-time and also rather clumsily. One could of course use tuples or rather nested pairs to compose data structures too, which would work at run-time. But that would be very hard to maintain. HList implements this composability by elaborate type-level programming. In my opinion functional references allows for this too but not through type-level programming. Am I wrong? G?nther Am 04.02.10 13:18, schrieb Martijn van Steenbergen: > Edward Kmett wrote: >> Functional references let you both read and write 'attributes' in a >> structure. These can be chained to access members of members. > > You can also use them to build bidirectional views on fields (and > compose those again as well). > > Martijn. > From alistair at abayley.org Thu Feb 4 08:11:27 2010 From: alistair at abayley.org (Alistair Bayley) Date: Thu Feb 4 07:42:56 2010 Subject: [Haskell-cafe] programmatic DB interface? In-Reply-To: <4B6A70DD.8020503@imn.htwk-leipzig.de> References: <4B6A70DD.8020503@imn.htwk-leipzig.de> Message-ID: <79d7c4981002040511y34d5d4a9ice2cb44071291fe9@mail.gmail.com> > What is currently the recommended > higher level data base interface for Haskell? > > I want to construct queries in a programmatic/algebraic way, > > Would takusen help? Where's its home page? > this does not work: http://darcs.haskell.org/takusen/ Takusen still requires you to supply queries as strings, so no, it wouldn't help. BTW, it has moved to http://code.haskell.org/takusen The only game in town is HaskellDB, AFAIK. Alistair From gue.schmidt at web.de Thu Feb 4 08:11:27 2010 From: gue.schmidt at web.de (=?ISO-8859-15?Q?G=FCnther_Schmidt?=) Date: Thu Feb 4 07:43:28 2010 Subject: [Haskell-cafe] Nested Types stack size ... Message-ID: <4B6AC77F.4090605@web.de> Hi, I'm using deeply nested types in my app and exceed some stack-size in ghci. I can't remember the runtime option I have to pass to ghci anymore, it's been about a year since I last pursued this approach. Is it also possible to set this stack-size via pragma in the source code? G?nther From ron at gamr7.com Thu Feb 4 08:46:07 2010 From: ron at gamr7.com (Ron de Bruijn) Date: Thu Feb 4 08:12:53 2010 Subject: [Haskell-cafe] Nested Types stack size ... In-Reply-To: <4B6AC77F.4090605@web.de> References: <4B6AC77F.4090605@web.de> Message-ID: <4B6ACF9F.9020606@gamr7.com> Hi, G?nther Schmidt schreef: > Hi, > > I'm using deeply nested types in my app and exceed some stack-size in ghci. > > I can't remember the runtime option I have to pass to ghci anymore, it's > been about a year since I last pursued this approach. ghci +RTS --help suggests -K Sets the maximum stack size (default 8M) Egs: -K32k -K512k. ghci is just another Haskell program which uses the GHC RTS. > > Is it also possible to set this stack-size via pragma in the source code? Via an OPTIONS_GHC pragma, if possible. -- Best Regards, Ron de Bruijn, Developer, Gamr7 From gue.schmidt at web.de Thu Feb 4 08:52:18 2010 From: gue.schmidt at web.de (=?ISO-8859-15?Q?G=FCnther_Schmidt?=) Date: Thu Feb 4 08:23:46 2010 Subject: [Haskell-cafe] Re: Nested Types stack size ... In-Reply-To: <4B6ACF9F.9020606@gamr7.com> References: <4B6AC77F.4090605@web.de> <4B6ACF9F.9020606@gamr7.com> Message-ID: <4B6AD112.1070700@web.de> Hello Ron, thank you, but it was not the run-time stack size I meant. It was the stack size for nested types which defaults to 20 or so IIRC. My nested types currently go to about 23 deep. G?nther Am 04.02.10 14:46, schrieb Ron de Bruijn: > Hi, > > G?nther Schmidt schreef: >> Hi, >> >> I'm using deeply nested types in my app and exceed some stack-size in >> ghci. >> >> I can't remember the runtime option I have to pass to ghci anymore, >> it's been about a year since I last pursued this approach. > ghci +RTS --help suggests -K Sets the maximum stack size (default 8M) > Egs: -K32k -K512k. ghci is just another Haskell program which uses the > GHC RTS. >> >> Is it also possible to set this stack-size via pragma in the source code? > Via an OPTIONS_GHC pragma, if possible. From gue.schmidt at web.de Thu Feb 4 08:52:18 2010 From: gue.schmidt at web.de (=?ISO-8859-15?Q?G=FCnther_Schmidt?=) Date: Thu Feb 4 08:24:13 2010 Subject: [Haskell-cafe] Re: Nested Types stack size ... In-Reply-To: <4B6ACF9F.9020606@gamr7.com> References: <4B6AC77F.4090605@web.de> <4B6ACF9F.9020606@gamr7.com> Message-ID: <4B6AD112.1070700@web.de> Hello Ron, thank you, but it was not the run-time stack size I meant. It was the stack size for nested types which defaults to 20 or so IIRC. My nested types currently go to about 23 deep. G?nther Am 04.02.10 14:46, schrieb Ron de Bruijn: > Hi, > > G?nther Schmidt schreef: >> Hi, >> >> I'm using deeply nested types in my app and exceed some stack-size in >> ghci. >> >> I can't remember the runtime option I have to pass to ghci anymore, >> it's been about a year since I last pursued this approach. > ghci +RTS --help suggests -K Sets the maximum stack size (default 8M) > Egs: -K32k -K512k. ghci is just another Haskell program which uses the > GHC RTS. >> >> Is it also possible to set this stack-size via pragma in the source code? > Via an OPTIONS_GHC pragma, if possible. From sergueyz at gmail.com Thu Feb 4 09:26:08 2010 From: sergueyz at gmail.com (Serguey Zefirov) Date: Thu Feb 4 08:57:39 2010 Subject: [Haskell-cafe] Re: Nested Types stack size ... In-Reply-To: <4B6AD112.1070700@web.de> References: <4B6AC77F.4090605@web.de> <4B6ACF9F.9020606@gamr7.com> <4B6AD112.1070700@web.de> Message-ID: <600376291002040626p7ff6b77l7b6b8b2f7a5e7c01@mail.gmail.com> 2010/2/4 G?nther Schmidt : > Hello Ron, > > thank you, but it was not the run-time stack size I meant. It was the stack > size for nested types which defaults to 20 or so IIRC. My nested types > currently go to about 23 deep. -fcontext-stack=100 From emartinm at fdi.ucm.es Thu Feb 4 10:32:24 2010 From: emartinm at fdi.ucm.es (=?ISO-8859-1?Q?Enrique_Mart=EDn?=) Date: Thu Feb 4 10:03:52 2010 Subject: [Haskell-cafe] Translation of Haskell type classes Message-ID: <4B6AE888.3030708@fdi.ucm.es> Hello all, few days ago I made some experiments with Haskell type classes. I wrote a small Haskell program for searching in sorted lists, defining my own type classes for equality (MyEq) and order (MyOrd) so that they only have one member function: -------------------------------------------------------- class MyEq a where eq :: a -> a -> Bool class MyEq a => MyOrd a where less :: a -> a -> Bool data Nat = Z | S Nat instance MyEq Nat where eq Z Z = True eq Z (S x) = False eq (S x) Z = False eq (S x) (S y) = eq x y instance MyOrd Nat where less Z Z = False less Z (S x) = True less (S x ) Z = False less (S x) (S y) = less x y search :: MyOrd a => a -> [a] -> Bool search x [] = False search x (y:ys) = (eq x y) || (less y x && search x ys) -------------------------------------------------------- I also wrote the translation of this program using the classical approach of dictionaries that appears in "How to make ad-hoc polymorphism less ad hoc", Wadler & Blott 1989 or "Type Classes in Haskell", Cordelia V. Hall et. al. 1996. -------------------------------------------------------- -- From the definition of type class MyEq data DictMyEq a = DictMyEq (a -> a -> Bool) eq :: DictMyEq a -> (a -> a -> Bool) eq (DictMyEq x) = x -- From the definition of type class MyOrd data DictMyOrd a = DictMyOrd (DictMyEq a) (a -> a -> Bool) getMyEqFromMyOrd :: DictMyOrd a -> DictMyEq a getMyEqFromMyOrd (DictMyOrd x y) = x less :: DictMyOrd a -> (a -> a -> Bool) less (DictMyOrd x y) = y data Nat = Z | S Nat -- From the instance MyEq Nat eqNat :: Nat -> Nat -> Bool eqNat Z Z = True eqNat Z (S x) = False eqNat (S x) Z = False eqNat (S x) (S y) = eqNat x y dictMyEqNat :: DictMyEq Nat dictMyEqNat = DictMyEq eqNat -- From the instance MyOrd Nat lessNat :: Nat -> Nat -> Bool lessNat Z Z = False lessNat Z (S x) = True lessNat (S x ) Z = False lessNat (S x) (S y) = lessNat x y dictMyOrdNat :: DictMyOrd Nat dictMyOrdNat = DictMyOrd dictMyEqNat lessNat search :: DictMyOrd a -> a -> [a] -> Bool search _ x [] = False search dict x (y:ys) = (eq (getMyEqFromMyOrd dict) x y) || (less dict y x && search dict x ys) -------------------------------------------------------- I made some tests in GHC 6.8.2 and I noticed that the original program with type classes runs pretty faster than the translated program. For example, reducing the expression search (S Z) (replicate 1000000 Z) needs 2.07 seconds in the original program. However the translated expression search dictMyOrdNat (S Z) (replicate 1000000 Z) needs 3.10 seconds in the translated program, which is one more second. Surprised with the results, I repeated the test this time in Hugs Sept. 2006. I noticed that the difference was not so big: search (S Z) (replicate 100000 Z) --> (2100051 reductions, 2798068 cells, 2 garbage collections) search dictMyOrdNat (S Z) (replicate 100000 Z) --> (2200051 reductions, 2898067 cells, 3 garbage collections) My first idea was that type classes were implemented using the approach of dictionaries, but the test showed me that it is not true (mainly in GHC). Then I discovered the paper "Implementing Haskell overloading", Augustsson 1993, when he describes some ways to improve the speed of Haskell overloading. So my questions are: 1) is the enhancement obtained only using the optimizations of Augustsson's paper? 2) Could anyone tell me where I can find the translation of type classes that GHC and Hugs use? Thank you very much, Enrique M. From gue.schmidt at web.de Thu Feb 4 10:49:05 2010 From: gue.schmidt at web.de (=?ISO-8859-1?Q?G=FCnther_Schmidt?=) Date: Thu Feb 4 10:20:32 2010 Subject: [Haskell-cafe] Re: Nested Types stack size ... In-Reply-To: <600376291002040626p7ff6b77l7b6b8b2f7a5e7c01@mail.gmail.com> References: <4B6AC77F.4090605@web.de> <4B6ACF9F.9020606@gamr7.com> <4B6AD112.1070700@web.de> <600376291002040626p7ff6b77l7b6b8b2f7a5e7c01@mail.gmail.com> Message-ID: <4B6AEC71.1050005@web.de> Hello Serguey, great, that's the one! Can I set this in the source code itself too? G?nther Am 04.02.10 15:26, schrieb Serguey Zefirov: > 2010/2/4 G?nther Schmidt: > >> Hello Ron, >> >> thank you, but it was not the run-time stack size I meant. It was the stack >> size for nested types which defaults to 20 or so IIRC. My nested types >> currently go to about 23 deep. >> > -fcontext-stack=100 > From sergueyz at gmail.com Thu Feb 4 10:53:07 2010 From: sergueyz at gmail.com (Serguey Zefirov) Date: Thu Feb 4 10:24:32 2010 Subject: [Haskell-cafe] Re: Nested Types stack size ... In-Reply-To: <4B6AEC71.1050005@web.de> References: <4B6AC77F.4090605@web.de> <4B6ACF9F.9020606@gamr7.com> <4B6AD112.1070700@web.de> <600376291002040626p7ff6b77l7b6b8b2f7a5e7c01@mail.gmail.com> <4B6AEC71.1050005@web.de> Message-ID: <600376291002040753j516cc242sb539b1d9b08eb12a@mail.gmail.com> 2010/2/4 G?nther Schmidt : > Hello Serguey, > > great, that's the one! > > Can I set this in the source code itself too? No, as far as I know. Last time I tried it on 6.10.1, so it's pretty far from now. ;) From bulat.ziganshin at gmail.com Thu Feb 4 11:06:32 2010 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Feb 4 10:38:14 2010 Subject: [Haskell-cafe] Re: Nested Types stack size ... In-Reply-To: <4B6AEC71.1050005@web.de> References: <4B6AC77F.4090605@web.de> <4B6ACF9F.9020606@gamr7.com> <4B6AD112.1070700@web.de> <600376291002040626p7ff6b77l7b6b8b2f7a5e7c01@mail.gmail.com> <4B6AEC71.1050005@web.de> Message-ID: <1174132688.20100204190632@gmail.com> Hello G?nther, Thursday, February 4, 2010, 6:49:05 PM, you wrote: > Can I set this in the source code itself too? http://www.haskell.org/ghc/docs/latest/html/users_guide/flag-reference.html says that this option is dynamic so afaik it should work -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From leimy2k at gmail.com Thu Feb 4 11:29:38 2010 From: leimy2k at gmail.com (David Leimbach) Date: Thu Feb 4 11:01:04 2010 Subject: [Haskell-cafe] safe lazy IO or Iteratee? Message-ID: <3e1162e61002040829p54dc9798rfc0919768e2a0292@mail.gmail.com> Hi everyone, This is not an attempt to start a flame war. I'm just trying to get a good feel for the advantages and disadvantages of the newer safe lazy io lib available on Hackage vs using Iteratee. It does appear to me that using something like Itereatee gives a bit of room to really tweak the low level enumerator/iteratee relationship, and, if you asked my old boss, I'm just a big fan of folds too, I use them a lot in my Erlang :-), so Iteratee really does appeal to me on many levels. Yet at the same time, I'm quite enamored with the beauty of "interact" and functions of that sort. I realize mixing the effects of the lazy IO and pure code may not be the clearest way to write code for everyone, but there is something about being able to get linewise data as interact (unlines . fmap someLineWiseFunction . lines) that is just kind of cool. Dave -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100204/9461450d/attachment.html From mlesniak at uni-kassel.de Thu Feb 4 11:50:57 2010 From: mlesniak at uni-kassel.de (Michael Lesniak) Date: Thu Feb 4 11:22:24 2010 Subject: [Haskell-cafe] Sparks created, but not used (par/pseq, ST monad) Message-ID: <5f8b37691002040850i5cbcdb9fo298631b7ec4369cc@mail.gmail.com> Hello haskell-cafe, I currently have a problem with running par/pseq in the ST monad. The function testST is the minimal counterexample that works -- or, to be more clear, does not work as expected for me. As a remark, the tasks/function calls in my "real application" are much more computational expensive, but the code is too long to post here. > -- File ST.lhs > module Main where > import Control.Monad.ST > import Control.Parallel > main = testST > > testST :: IO () > testST = do > putStrLn "Starting" > (runST $ f 10) `pseq` putStrLn "Stopping" > where > f :: forall s. Int -> ST s () > f n = do > p $ "\nTask:" ++ show n > if n < 0 > then return () > else do > (n1,n2) <- return (n-1,n-2) > q n1 > q n2 > a <- f n1 > b <- f n2 > (a `par` b) `pseq` return a > > -- Some helper functions > p x = unsafeIOToST (putStrLn x) > q x = unsafeIOToST (print x) As far as I understand, compiling with ghc --make -O2 -threaded ST.lhs -o st -XRankNTypes and running with ./st +RTS -N -s should create sparks that could be run in parallel. The problem I have now, is that sparks are created but not converted, according to -s output: ... a lot of (uninteresting) stuff SPARKS: 232 (0 converted, 0 pruned) ... I have not found any information on this type of behaviour on the net and would be glad if someone could give me points or hints what's happening and how I can improve this. Cheers, Michael -- Dipl.-Inf. Michael C. Lesniak University of Kassel Programming Languages / Methodologies Research Group Department of Computer Science and Electrical Engineering Wilhelmsh?her Allee 73 34121 Kassel Phone: +49-(0)561-804-6269 From nowgate at yahoo.com Thu Feb 4 12:07:28 2010 From: nowgate at yahoo.com (michael rice) Date: Thu Feb 4 11:38:54 2010 Subject: [Haskell-cafe] Stack ADT? Message-ID: <274886.22747.qm@web31101.mail.mud.yahoo.com> Can't find a Stack datatype on Hoogle? Where should I look? Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100204/b53b7e0f/attachment.html From sebf at informatik.uni-kiel.de Thu Feb 4 12:16:19 2010 From: sebf at informatik.uni-kiel.de (Sebastian Fischer) Date: Thu Feb 4 11:47:47 2010 Subject: [Haskell-cafe] Stack ADT? In-Reply-To: <274886.22747.qm@web31101.mail.mud.yahoo.com> References: <274886.22747.qm@web31101.mail.mud.yahoo.com> Message-ID: <3550179C-5484-470F-B701-AC479B2818FE@informatik.uni-kiel.de> On Feb 4, 2010, at 6:07 PM, michael rice wrote: > Can't find a Stack datatype on Hoogle? Where should I look? Could not find one on Hackage either. Probably because its so easy to handcraft your own: newtype Stack a = Stack [a] emptyStack = Stack [] isEmptyStack (Stack xs) = null xs push x (Stack xs) = Stack (x:xs) pop (Stack (_:xs)) = Stack xs top (Stack (x:_)) = x I saw such stacks in Haskell only for educational purposes. Usually, people seem to use lists directly. Sebastian -- Underestimating the novelty of the future is a time-honored tradition. (D.G.) From waldmann at imn.htwk-leipzig.de Thu Feb 4 12:23:46 2010 From: waldmann at imn.htwk-leipzig.de (Johannes Waldmann) Date: Thu Feb 4 11:56:53 2010 Subject: [Haskell-cafe] Re: programmatic DB interface? References: <4B6A70DD.8020503@imn.htwk-leipzig.de> <4B6A84C3.30701@web.de> <87zl3pfjin.fsf@gmail.com> Message-ID: anyone know what's happening here? I get this when executing a query via haskelldb-hdbc-postgresql-0.12 (The date is actually in the DB, so it's not a connection problem.) Convertible: error converting source data SqlString "2008-10-29 00:00:00" of type SqlValue to type Data.Time.LocalTime.LocalTime.LocalTime: Cannot parse using default format string "%Y-%m-%dT%T%Q" From nowgate at yahoo.com Thu Feb 4 12:27:23 2010 From: nowgate at yahoo.com (michael rice) Date: Thu Feb 4 11:58:51 2010 Subject: [Haskell-cafe] Stack ADT? In-Reply-To: <3550179C-5484-470F-B701-AC479B2818FE@informatik.uni-kiel.de> Message-ID: <749042.93771.qm@web31104.mail.mud.yahoo.com> I was looking here: http://www.haskell.org/haskellwiki/Abstract_data_type I haven't done much with modules so I'm guessing what you've provided is the guts of StackImpl, to hide the implementation? Thanks, Michael --- On Thu, 2/4/10, Sebastian Fischer wrote: From: Sebastian Fischer Subject: Re: [Haskell-cafe] Stack ADT? To: "haskell-cafe Cafe" Date: Thursday, February 4, 2010, 12:16 PM On Feb 4, 2010, at 6:07 PM, michael rice wrote: > Can't find a Stack datatype on Hoogle? Where should I look? Could not find one on Hackage either. Probably because its so easy to handcraft your own: ? ? newtype Stack a = Stack [a] ? ? emptyStack = Stack [] ? ? isEmptyStack (Stack xs) = null xs ? ? push x (Stack xs) = Stack (x:xs) ? ? pop (Stack (_:xs)) = Stack xs ? ? top (Stack (x:_)) = x I saw such stacks in Haskell only for educational purposes. Usually, people seem to use lists directly. Sebastian --Underestimating the novelty of the future is a time-honored tradition. (D.G.) _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100204/885cfc14/attachment.html From caseyh at istar.ca Thu Feb 4 12:29:17 2010 From: caseyh at istar.ca (Casey Hawthorne) Date: Thu Feb 4 12:00:47 2010 Subject: [Haskell-cafe] Stack ADT? In-Reply-To: <274886.22747.qm@web31101.mail.mud.yahoo.com> References: <274886.22747.qm@web31101.mail.mud.yahoo.com> Message-ID: On Thu, 4 Feb 2010 09:07:28 -0800 (PST), you wrote: >Can't find a Stack datatype on Hoogle? Where should I look? > >Michael > From "Algorithms: a functional programming approach" Second edition Fethi Rabhi Guy Lapalme data Stack a = EmptyStk | Stk a (Stack a) push x s = Stk x s pop EmptyStk = error "pop from an empty stack" pop (Stk _ s) = s top EmptyStk = error "top from an empty stack" top (Stk x _) = x emptyStack = EmptyStk stackEmpty EmptyStk = True stackEmpty _ = False newtype Stack a = Stk [a] push x (Stk xs) = Stk (x:xs) pop (Stk []) = error "pop from an empty stack" pop (Stk (_:xs)) = Stk xs top (Stk []) = error "top from an empty stack" top (Stk (x:_)) = x emptyStack = Stk [] stackEmpty (Stk []) = True stackEmpty (Stk _ ) = False -- Regards, Casey From colin at colina.demon.co.uk Thu Feb 4 12:38:33 2010 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Thu Feb 4 12:10:01 2010 Subject: [Haskell-cafe] Re: programmatic DB interface? In-Reply-To: (Johannes Waldmann's message of "Thu, 4 Feb 2010 17:23:46 +0000 (UTC)") References: <4B6A70DD.8020503@imn.htwk-leipzig.de> <4B6A84C3.30701@web.de> <87zl3pfjin.fsf@gmail.com> Message-ID: >>>>> "Johannes" == Johannes Waldmann writes: Johannes> anyone know what's happening here? I get this when Johannes> executing a query via haskelldb-hdbc-postgresql-0.12 (The Johannes> date is actually in the DB, so it's not a connection Johannes> problem.) Johannes> Convertible: error converting source data SqlString Johannes> "2008-10-29 00:00:00" of type SqlValue to type Johannes> Data.Time.LocalTime.LocalTime.LocalTime: Cannot parse Johannes> using default format string "%Y-%m-%dT%T%Q" I had this sort of problem. I sent a patch on the haskell-db list to use UTC - I believe the release behaviour is incorrect. You might check the list archives, as they have a better memory than I. -- Colin Adams Preston Lancashire From caseyh at istar.ca Thu Feb 4 12:38:42 2010 From: caseyh at istar.ca (Casey Hawthorne) Date: Thu Feb 4 12:10:15 2010 Subject: [Haskell-cafe] Stack ADT? In-Reply-To: <274886.22747.qm@web31101.mail.mud.yahoo.com> References: <274886.22747.qm@web31101.mail.mud.yahoo.com> Message-ID: <4d1mm5tigba8cmap3nmdl9cbevkvfsaonv@4ax.com> On Thu, 4 Feb 2010 09:07:28 -0800 (PST), you wrote: >Can't find a Stack datatype on Hoogle? Where should I look? > >Michael > From "Algorithms: a functional programming approach" Second edition Fethi Rabhi Guy Lapalme To be more complete. module Stack(Stack,push,pop,top,emptyStack,stackEmpty) where push :: a-> Stack a -> Stack a pop :: Stack a -> Stack a top :: Stack a -> a emptyStack :: Stack a stackEmpty :: Stack a -> Bool data Stack a = EmptyStk | Stk a (Stack a) push x s = Stk x s pop EmptyStk = error "pop from an empty stack" pop (Stk _ s) = s top EmptyStk = error "top from an empty stack" top (Stk x _) = x emptyStack = EmptyStk stackEmpty EmptyStk = True stackEmpty _ = False newtype Stack a = Stk [a] push x (Stk xs) = Stk (x:xs) pop (Stk []) = error "pop from an empty stack" pop (Stk (_:xs)) = Stk xs top (Stk []) = error "top from an empty stack" top (Stk (x:_)) = x emptyStack = Stk [] stackEmpty (Stk []) = True stackEmpty (Stk _ ) = False -- Regards, Casey From daniel.is.fischer at web.de Thu Feb 4 13:22:25 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Feb 4 12:56:01 2010 Subject: [Haskell-cafe] Translation of Haskell type classes In-Reply-To: <4B6AE888.3030708@fdi.ucm.es> References: <4B6AE888.3030708@fdi.ucm.es> Message-ID: <201002041922.26203.daniel.is.fischer@web.de> Am Donnerstag 04 Februar 2010 16:32:24 schrieb Enrique Mart?n: > Hello all, > > few days ago I made some experiments with Haskell type classes. I wrote > a small Haskell program for searching in sorted lists, defining my own > type classes for equality (MyEq) and order (MyOrd) so that they only > have one member function: > > > I made some tests in GHC 6.8.2 and I noticed that the original program > with type classes runs pretty faster than the translated program. For > example, reducing the expression > search (S Z) (replicate 1000000 Z) > needs 2.07 seconds in the original program. However the translated > expression > search dictMyOrdNat (S Z) (replicate 1000000 Z) > needs 3.10 seconds in the translated program, which is one more second. > > Surprised with the results, I repeated the test this time in Hugs Sept. > 2006. I noticed that the difference was not so big: > search (S Z) (replicate 100000 Z) --> (2100051 reductions, > 2798068 cells, 2 garbage collections) > search dictMyOrdNat (S Z) (replicate 100000 Z) --> (2200051 > reductions, 2898067 cells, 3 garbage collections) > > > My first idea was that type classes were implemented using the approach > of dictionaries, but the test showed me that it is not true (mainly in > GHC). It is the approach used by GHC (you can see it by looking at the core you get with the flag -ddump-simpl). The point is that you ran the code interpreted. Now, dictionary-passing for type classes is baked into the compiler, it's rather good at it even on interpreted code, while if you implement it yourself, you get ordinary function calls, looking up the comparison function on each iteration, probably. The difference disappears if you compile the code, at least with optimisations. > Then I discovered the paper "Implementing Haskell overloading", > Augustsson 1993, when he describes some ways to improve the speed of > Haskell overloading. > > So my questions are: > 1) is the enhancement obtained only using the optimizations of > Augustsson's paper? > 2) Could anyone tell me where I can find the translation of type > classes that GHC and Hugs use? > > Thank you very much, > > Enrique M. From Christian.Maeder at dfki.de Thu Feb 4 13:35:43 2010 From: Christian.Maeder at dfki.de (Christian Maeder) Date: Thu Feb 4 13:07:11 2010 Subject: [Haskell-cafe] Re: Translation of Haskell type classes In-Reply-To: <4B6AE888.3030708@fdi.ucm.es> References: <4B6AE888.3030708@fdi.ucm.es> Message-ID: <4B6B137F.1020209@dfki.de> try: type DictMyEq a = a -> a -> Bool -- From the definition of type class MyOrd type DictOrd a = (DictMyEq a, a -> a -> Bool) data Nat = Z | S Nat -- From the instance MyEq Nat eqNat :: Nat -> Nat -> Bool eqNat Z Z = True eqNat Z (S x) = False eqNat (S x) Z = False eqNat (S x) (S y) = eqNat x y -- From the instance MyOrd Nat lessNat :: Nat -> Nat -> Bool lessNat Z Z = False lessNat Z (S x) = True lessNat (S x ) Z = False lessNat (S x) (S y) = lessNat x y search :: DictOrd a -> a -> [a] -> Bool search _ _ [] = False search d@(eq, less) x (y : ys) = eq x y || less y x && search d x ys with: search (eqNat, lessNat) (S Z) (replicate 1000000 Z) This performs as fast as the class version for me (ghci-6.10.4) Compiling with optimization should show no difference between all versions. hugs-Sept2006 shows (21000051 reductions, 27998068 cells, 28 garbage collections) versus (19000049 reductions, 25998064 cells, 26 garbage collections) in favor of the version without classes for me. Selecting the dictionary components seems to be a problem when interpreting the code using ghci. Cheers Christian Enrique Mart?n schrieb: > Hello all, > > few days ago I made some experiments with Haskell type classes. I wrote > a small Haskell program for searching in sorted lists, defining my own > type classes for equality (MyEq) and order (MyOrd) so that they only > have one member function: > > -------------------------------------------------------- > class MyEq a where > eq :: a -> a -> Bool > class MyEq a => MyOrd a where > less :: a -> a -> Bool > data Nat = Z | S Nat > > instance MyEq Nat where > eq Z Z = True > eq Z (S x) = False > eq (S x) Z = False > eq (S x) (S y) = eq x y > instance MyOrd Nat where > less Z Z = False > less Z (S x) = True > less (S x ) Z = False > less (S x) (S y) = less x y > > search :: MyOrd a => a -> [a] -> Bool > search x [] = False > search x (y:ys) = (eq x y) || (less y x && search x ys) > -------------------------------------------------------- > > I also wrote the translation of this program using the classical > approach of dictionaries that appears in "How to make ad-hoc > polymorphism less ad hoc", Wadler & Blott 1989 or "Type Classes in > Haskell", Cordelia V. Hall et. al. 1996. > > -------------------------------------------------------- > -- From the definition of type class MyEq > data DictMyEq a = DictMyEq (a -> a -> Bool) > > eq :: DictMyEq a -> (a -> a -> Bool) > eq (DictMyEq x) = x > > -- From the definition of type class MyOrd > data DictMyOrd a = DictMyOrd (DictMyEq a) (a -> a -> Bool) > > getMyEqFromMyOrd :: DictMyOrd a -> DictMyEq a > getMyEqFromMyOrd (DictMyOrd x y) = x > > less :: DictMyOrd a -> (a -> a -> Bool) > less (DictMyOrd x y) = y > > data Nat = Z | S Nat > > > -- From the instance MyEq Nat > eqNat :: Nat -> Nat -> Bool > eqNat Z Z = True > eqNat Z (S x) = False > eqNat (S x) Z = False > eqNat (S x) (S y) = eqNat x y > dictMyEqNat :: DictMyEq Nat > dictMyEqNat = DictMyEq eqNat > > > -- From the instance MyOrd Nat > lessNat :: Nat -> Nat -> Bool > lessNat Z Z = False > lessNat Z (S x) = True > lessNat (S x ) Z = False > lessNat (S x) (S y) = lessNat x y > > dictMyOrdNat :: DictMyOrd Nat > dictMyOrdNat = DictMyOrd dictMyEqNat lessNat > > > search :: DictMyOrd a -> a -> [a] -> Bool > search _ x [] = False > search dict x (y:ys) = (eq (getMyEqFromMyOrd dict) x y) || (less dict y > x && search dict x ys) > -------------------------------------------------------- > > > I made some tests in GHC 6.8.2 and I noticed that the original program > with type classes runs pretty faster than the translated program. For > example, reducing the expression > search (S Z) (replicate 1000000 Z) > needs 2.07 seconds in the original program. However the translated > expression > search dictMyOrdNat (S Z) (replicate 1000000 Z) > needs 3.10 seconds in the translated program, which is one more second. > > Surprised with the results, I repeated the test this time in Hugs Sept. > 2006. I noticed that the difference was not so big: > search (S Z) (replicate 100000 Z) --> (2100051 reductions, 2798068 > cells, 2 garbage collections) > search dictMyOrdNat (S Z) (replicate 100000 Z) --> (2200051 > reductions, 2898067 cells, 3 garbage collections) > > My first idea was that type classes were implemented using the approach > of dictionaries, but the test showed me that it is not true (mainly in > GHC). Then I discovered the paper "Implementing Haskell overloading", > Augustsson 1993, when he describes some ways to improve the speed of > Haskell overloading. > > So my questions are: > 1) is the enhancement obtained only using the optimizations of > Augustsson's paper? > 2) Could anyone tell me where I can find the translation of type > classes that GHC and Hugs use? > > Thank you very much, > > Enrique M. From nccb2 at kent.ac.uk Thu Feb 4 13:40:21 2010 From: nccb2 at kent.ac.uk (Neil Brown) Date: Thu Feb 4 13:12:06 2010 Subject: [Haskell-cafe] ANN: progression-0.1 Message-ID: <4B6B1495.8070205@kent.ac.uk> Hi all, I've just uploaded the first release of Progression to Hackage. Progression is a small library that pulls together several other libraries and utilities (particularly Criterion) to support the optimisation of Haskell programs. To use it, you wrap up your benchmarks in a program that passes them to Progression. When you run this program, Progression records the benchmarks, and offers to draw you a graph comparing these latest times to a selection (specified by you) of previously recorded times. What you get is a graph that allows you to see if your changes have made enough difference over your benchmarks for you to keep the change (or whether it has made most of them worse, and you need to roll back!). Progression doesn't include any benchmarking logic; it delegates all that to the Criterion library, and plots the resulting mean (with confidence intervals). More details and an example graph are available in a blog post: http://chplib.wordpress.com/2010/02/04/progression-supporting-optimisation-in-haskell/ Feedback is welcome, either here or in the comments on the blog post. Thanks, Neil. From daniel.is.fischer at web.de Thu Feb 4 13:51:28 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Feb 4 13:24:48 2010 Subject: [Haskell-cafe] Sparks created, but not used (par/pseq, ST monad) In-Reply-To: <5f8b37691002040850i5cbcdb9fo298631b7ec4369cc@mail.gmail.com> References: <5f8b37691002040850i5cbcdb9fo298631b7ec4369cc@mail.gmail.com> Message-ID: <201002041951.29091.daniel.is.fischer@web.de> Am Donnerstag 04 Februar 2010 17:50:57 schrieb Michael Lesniak: > Hello haskell-cafe, > > I currently have a problem with running par/pseq in the ST monad. The > function testST is the minimal counterexample that works -- or, to be > more clear, does not work as expected for me. As a remark, the > tasks/function calls in my "real application" are much more > computational expensive, but the code is too long to post here. > > > -- File ST.lhs > > module Main where > > import Control.Monad.ST > > import Control.Parallel > > main = testST > > > > testST :: IO () > > testST = do > > putStrLn "Starting" > > (runST $ f 10) `pseq` putStrLn "Stopping" > > where > > f :: forall s. Int -> ST s () > > f n = do > > p $ "\nTask:" ++ show n > > if n < 0 > > then return () > > else do > > (n1,n2) <- return (n-1,n-2) > > q n1 > > q n2 > > a <- f n1 > > b <- f n2 > > (a `par` b) `pseq` return a > > > > -- Some helper functions > > p x = unsafeIOToST (putStrLn x) > > q x = unsafeIOToST (print x) > > As far as I understand, compiling with > > ghc --make -O2 -threaded ST.lhs -o st -XRankNTypes > > and running with > > ./st +RTS -N -s You'd need to give a number of capacities, I think (-N2 e.g.). > > should create sparks that could be run in parallel. The problem I have > now, is that sparks are created but not converted, according to -s > output: > > ... a lot of (uninteresting) stuff > SPARKS: 232 (0 converted, 0 pruned) > ... > > I have not found any information on this type of behaviour on the net > and would be glad if someone could give me points or hints what's > happening and how I can improve this. I think with the strict ST monad, when you have a <- f n1 b <- f n2 they are already evaluated, so there's no point in sparking evaluation in parallel. > > Cheers, > Michael From michael at snoyman.com Thu Feb 4 14:27:34 2010 From: michael at snoyman.com (Michael Snoyman) Date: Thu Feb 4 13:59:01 2010 Subject: [Haskell-cafe] Re: programmatic DB interface? In-Reply-To: References: <4B6A70DD.8020503@imn.htwk-leipzig.de> <4B6A84C3.30701@web.de> <87zl3pfjin.fsf@gmail.com> Message-ID: <29bf512f1002041127x74fbf370vf2fa7a81564f3fb2@mail.gmail.com> On Thu, Feb 4, 2010 at 7:38 PM, Colin Paul Adams wrote: > >>>>> "Johannes" == Johannes Waldmann > writes: > > Johannes> anyone know what's happening here? I get this when > Johannes> executing a query via haskelldb-hdbc-postgresql-0.12 (The > Johannes> date is actually in the DB, so it's not a connection > Johannes> problem.) > > Johannes> Convertible: error converting source data SqlString > Johannes> "2008-10-29 00:00:00" of type SqlValue to type > Johannes> Data.Time.LocalTime.LocalTime.LocalTime: Cannot parse > Johannes> using default format string "%Y-%m-%dT%T%Q" > > I had this sort of problem. I sent a patch on the haskell-db list to use > UTC - I believe the release behaviour is incorrect. > > You might check the list archives, as they have a better memory than I. > > I actually just came up against this as well in HDBC-postgresql. As a workaround, when I read a timestamp I concatenate with an empty string (||'') and then read with my own parse string: "%Y-%m-%d %T%Q" This seems to work just fine. I'd like to debug it more, but I'm working on a short-deadline project. Hopefully when the month is out I'll be able to submit some patches for the problems I've run into. The other one that comes to mind off hand is I can't write to BYTEA fields either. Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100204/1d2eea5e/attachment.html From spam at scientician.net Thu Feb 4 14:43:30 2010 From: spam at scientician.net (Bardur Arantsson) Date: Thu Feb 4 14:15:29 2010 Subject: [Haskell-cafe] sendfile leaking descriptors on Linux? Message-ID: Hi all, I've been using the sendfile package off Hackage, but it seems to be leaking file descriptors when using the Linux-native build. What's happening in my specific case is the following: 1) client requests a range of a file 2) server starts sending the range 3) client disconnects before receiving the whole file This happens over and over with the client requesting different ranges of the file (so the client does make progress). If I use the portable build of the sendfile package, everything works fine for hours and hours of this happening. If I use the Linux-native build of the sendfile package, the server will eventually run out of file descriptors. According to "lsof" the files that are being kept open are the data files being sent in 2) above. This is on GHC 6.10.x (Ubuntu). Is anyone else seeing this? Anyone got any idea what's going on? Cheers, From mauricio.antunes at gmail.com Thu Feb 4 14:46:24 2010 From: mauricio.antunes at gmail.com (=?ISO-8859-1?Q?Maur=ED=ADcio_CA?=) Date: Thu Feb 4 14:18:18 2010 Subject: [Haskell-cafe] Re: GUI programming In-Reply-To: References: Message-ID: > The problem is that the GUI code has become very ugly and I'm > tempted to rewrite it totally. I've been looking forward to the > FRP stuff, but I've never seen a single definition of the term. > Conal Eliot's "denotational programming" is too general to be > definition. I want to try Grapefruit, but I got totally lost > when I see arrow notation. This is not what you are looking for, but if you also want to check something extremely less powerfull but extremely more simple, you may consider this sugestion I made some time ago for a GUI library: http://article.gmane.org/gmane.comp.lang.haskell.cafe/66638 Best, Maur?cio From taruti at taruti.net Thu Feb 4 15:28:45 2010 From: taruti at taruti.net (Taru Karttunen) Date: Thu Feb 4 15:00:12 2010 Subject: [Haskell-cafe] setNonBlockingFD? In-Reply-To: References: <4B68C649.5080102@therning.org> <90889fe71002021644w694751fbwfb5aa5957fff8c81@mail.gmail.com> Message-ID: <1265315243-sup-8949@oz.taruti.net> Excerpts from Magnus Therning's message of Wed Feb 03 21:51:34 +0200 2010: > Thanks. That pointed me in the right direction. I've posted the > attached patch as a suggested fix to the developer. Hopefully > there'll be a compilable version on Hackage soon. There is now 0.1.5 on Hackage with GHC 6.12 support. - Taru Karttunen From jmillikin at gmail.com Thu Feb 4 15:51:59 2010 From: jmillikin at gmail.com (John Millikin) Date: Thu Feb 4 15:23:48 2010 Subject: [Haskell-cafe] safe lazy IO or Iteratee? In-Reply-To: <3e1162e61002040829p54dc9798rfc0919768e2a0292@mail.gmail.com> References: <3e1162e61002040829p54dc9798rfc0919768e2a0292@mail.gmail.com> Message-ID: <3283f7fe1002041251m75e83d6cxb82c3888487b2e2c@mail.gmail.com> Both have advantages and disadvantages. The primary advantage of lazy IO over iteratees is that it's much, *much* easier to understand -- existing experience with monads can be used immediately. The downsides of lazy IO, of course, are well documented[1][2][3]. Some are fixed by the safe/strict IO packages. However, safe lazy IO is still "unpredictable" in that it's difficult to know how many resources will be used, the order of some operations (eg, releasing handles), or whether some particular expression will throw an exception. Iteratees are useful because the author can make and verify guarantees about performance (eg, "this code will never read more than 4 KiB at once"). They also allow pure code to determine the behavior of IO, safely, which is useful when writing libraries which must deal with large amounts of data (eg, streaming a file over HTTP). The Hyena web server is written using iteratees, and from what I've heard the authors have been quite happy with their properties. I've also found iteratees to perform somewhat better than lazy IO, though I don't know why. Downside: iteratees are very hard to understand. I wrote a decently-sized article about them[4] trying to figure out how to make them useful, and some comments in one of Oleg's implementations[5] suggest that the "iteratee" package is subtly wrong. Oleg has written at least three versions (non-monadic, monadic, monadic CPS) and I've no idea why or whether their differences are important. Even dons says he didn't understand them until after writing his own iteratee-based IO layer[6]. tl;dr: Lots of smart people, with a history of being right about this sort of thing, say iteratees are better. Evidence suggests iteratee-based IO is faster and more predictable than lazy IO. Iteratees are really hard to understand. [1] http://okmij.org/ftp/Haskell/Iteratee/Lazy-vs-correct.txt [2] http://www.kuliniewicz.org/blog/archives/2010/01/27/happstack-and-streaming-part-4-the-flaw/ [3] http://forums.xkcd.com/viewtopic.php?f=11&t=46780 [4] http://ianen.org/articles/understanding-iteratees/ [5] http://okmij.org/ftp/Haskell/Iteratee/IterateeM.hs , search for "Drawbacks of this encoding" [6] http://stackoverflow.com/questions/1319705/introduction-or-simple-examples-for-iteratee On Thu, Feb 4, 2010 at 08:29, David Leimbach wrote: > Hi everyone, > This is not an attempt to start a flame war. ?I'm just trying to get a good > feel for the advantages and disadvantages of the newer safe lazy io lib > available on Hackage vs using Iteratee. > It does appear to me that using something like Itereatee gives a bit of room > to really tweak the low level enumerator/iteratee relationship, and, if you > asked my old boss, I'm just a big fan of folds too, I use them a lot in my > Erlang :-), so Iteratee really does appeal to me on many levels. > Yet at the same time, I'm quite enamored with the beauty of "interact" and > functions of that sort. ?I realize mixing the effects of the lazy IO and > pure code may not be the clearest way to write code for everyone, but there > is something about being able to get linewise data as > interact (unlines . fmap someLineWiseFunction . lines) > that is just kind of cool. > Dave > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From leimy2k at gmail.com Thu Feb 4 16:12:24 2010 From: leimy2k at gmail.com (David Leimbach) Date: Thu Feb 4 15:43:51 2010 Subject: [Haskell-cafe] safe lazy IO or Iteratee? In-Reply-To: <3283f7fe1002041251m75e83d6cxb82c3888487b2e2c@mail.gmail.com> References: <3e1162e61002040829p54dc9798rfc0919768e2a0292@mail.gmail.com> <3283f7fe1002041251m75e83d6cxb82c3888487b2e2c@mail.gmail.com> Message-ID: <3e1162e61002041312u647ffd15h3b1305d38ffe968c@mail.gmail.com> Thanks for the detailed response below... I must be able to understand how the resources will be used in my system for mission-critical, long-running applications. Dave On Thu, Feb 4, 2010 at 12:51 PM, John Millikin wrote: > Both have advantages and disadvantages. The primary advantage of lazy > IO over iteratees is that it's much, *much* easier to understand -- > existing experience with monads can be used immediately. The downsides > of lazy IO, of course, are well documented[1][2][3]. > > Some are fixed by the safe/strict IO packages. However, safe lazy IO > is still "unpredictable" in that it's difficult to know how many > resources will be used, the order of some operations (eg, releasing > handles), or whether some particular expression will throw an > exception. > > Iteratees are useful because the author can make and verify guarantees > about performance (eg, "this code will never read more than 4 KiB at > once"). They also allow pure code to determine the behavior of IO, > safely, which is useful when writing libraries which must deal with > large amounts of data (eg, streaming a file over HTTP). The Hyena web > server is written using iteratees, and from what I've heard the > authors have been quite happy with their properties. > > I've also found iteratees to perform somewhat better than lazy IO, > though I don't know why. > > Downside: iteratees are very hard to understand. I wrote a > decently-sized article about them[4] trying to figure out how to make > them useful, and some comments in one of Oleg's implementations[5] > suggest that the "iteratee" package is subtly wrong. Oleg has written > at least three versions (non-monadic, monadic, monadic CPS) and I've > no idea why or whether their differences are important. Even dons says > he didn't understand them until after writing his own iteratee-based > IO layer[6]. > > tl;dr: Lots of smart people, with a history of being right about this > sort of thing, say iteratees are better. Evidence suggests > iteratee-based IO is faster and more predictable than lazy IO. > Iteratees are really hard to understand. > > [1] http://okmij.org/ftp/Haskell/Iteratee/Lazy-vs-correct.txt > [2] > http://www.kuliniewicz.org/blog/archives/2010/01/27/happstack-and-streaming-part-4-the-flaw/ > [3] http://forums.xkcd.com/viewtopic.php?f=11&t=46780 > [4] http://ianen.org/articles/understanding-iteratees/ > [5] http://okmij.org/ftp/Haskell/Iteratee/IterateeM.hs , search for > "Drawbacks of this encoding" > [6] > http://stackoverflow.com/questions/1319705/introduction-or-simple-examples-for-iteratee > > On Thu, Feb 4, 2010 at 08:29, David Leimbach wrote: > > Hi everyone, > > This is not an attempt to start a flame war. I'm just trying to get a > good > > feel for the advantages and disadvantages of the newer safe lazy io lib > > available on Hackage vs using Iteratee. > > It does appear to me that using something like Itereatee gives a bit of > room > > to really tweak the low level enumerator/iteratee relationship, and, if > you > > asked my old boss, I'm just a big fan of folds too, I use them a lot in > my > > Erlang :-), so Iteratee really does appeal to me on many levels. > > Yet at the same time, I'm quite enamored with the beauty of "interact" > and > > functions of that sort. I realize mixing the effects of the lazy IO and > > pure code may not be the clearest way to write code for everyone, but > there > > is something about being able to get linewise data as > > interact (unlines . fmap someLineWiseFunction . lines) > > that is just kind of cool. > > Dave > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100204/1cebbef2/attachment.html From bulat.ziganshin at gmail.com Thu Feb 4 16:26:14 2010 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Feb 4 15:57:45 2010 Subject: [Haskell-cafe] safe lazy IO or Iteratee? In-Reply-To: <3283f7fe1002041251m75e83d6cxb82c3888487b2e2c@mail.gmail.com> References: <3e1162e61002040829p54dc9798rfc0919768e2a0292@mail.gmail.com> <3283f7fe1002041251m75e83d6cxb82c3888487b2e2c@mail.gmail.com> Message-ID: <587605319.20100205002614@gmail.com> Hello John, Thursday, February 4, 2010, 11:51:59 PM, you wrote: > tl;dr: Lots of smart people, with a history of being right about this > sort of thing, say iteratees are better. Evidence suggests > iteratee-based IO is faster and more predictable than lazy IO. > Iteratees are really hard to understand. thank you! good time for iteratee tutorials? ;) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From gwern0 at gmail.com Thu Feb 4 17:04:25 2010 From: gwern0 at gmail.com (Gwern Branwen) Date: Thu Feb 4 16:35:50 2010 Subject: [Haskell-cafe] Anyone up for Google SoC 2010? In-Reply-To: References: <863507BC-FD78-49A0-9A77-C97B9431F7E7@cs.york.ac.uk> <404396ef1002031434i1f0388fduef0eab93ee040c01@mail.gmail.com> Message-ID: On Wed, Feb 3, 2010 at 8:14 PM, Henk-Jan van Tuyl wrote: > On Wed, 03 Feb 2010 23:34:34 +0100, Neil Mitchell > wrote: > >> Hi Gwern, >> >> Please update: "haskell-src-exts -> haskell-src" **Unknown** >> >> This project was an unqualified success. ?haskell-src-exts is now one >> of the most commonly used Haskell libraries, achieved the goals in the >> project proposal, and is an essential piece of Haskell infrastructure. > > You can see this using Roel van Dijk's reversed dependencies overview [1]: > 23 direct and 57 indirect dependencies on haskell-src-exts-1.8.0 > > Regards, > Henk-Jan van Tuyl And how many of those used haskell-src-exts *before* the SoC project? And would have used it regardless? You can't point to a popular project which got a SoC student, and say look at how popular it is - obviously the SoC student was hugely successful. -- gwern From pumpkingod at gmail.com Thu Feb 4 17:18:34 2010 From: pumpkingod at gmail.com (Daniel Peebles) Date: Thu Feb 4 16:50:00 2010 Subject: [Haskell-cafe] Stack ADT? In-Reply-To: References: <274886.22747.qm@web31101.mail.mud.yahoo.com> Message-ID: > > data Stack a = EmptyStk | Stk a (Stack a) I find it amusing that the book defined a type that is exactly isomorphic to the standard list (EmptyStk === [] and Stk === (:)). I guess it's just for clarity? On Thu, Feb 4, 2010 at 12:29 PM, Casey Hawthorne wrote: > On Thu, 4 Feb 2010 09:07:28 -0800 (PST), you wrote: > > >Can't find a Stack datatype on Hoogle? Where should I look? > > > >Michael > > > > > From "Algorithms: a functional programming approach" > Second edition > Fethi Rabhi > Guy Lapalme > > > data Stack a = EmptyStk > | > Stk a (Stack a) > > push x s = Stk x s > > pop EmptyStk = error "pop from an empty stack" > pop (Stk _ s) = s > > top EmptyStk = error "top from an empty stack" > top (Stk x _) = x > > emptyStack = EmptyStk > > stackEmpty EmptyStk = True > stackEmpty _ = False > > > > > newtype Stack a = Stk [a] > > push x (Stk xs) = Stk (x:xs) > > pop (Stk []) = error "pop from an empty stack" > pop (Stk (_:xs)) = Stk xs > > top (Stk []) = error "top from an empty stack" > top (Stk (x:_)) = x > > emptyStack = Stk [] > > stackEmpty (Stk []) = True > stackEmpty (Stk _ ) = False > > > -- > Regards, > Casey > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100204/6456e1ca/attachment.html From leimy2k at gmail.com Thu Feb 4 17:39:25 2010 From: leimy2k at gmail.com (David Leimbach) Date: Thu Feb 4 17:10:51 2010 Subject: [Haskell-cafe] safe lazy IO or Iteratee? In-Reply-To: <587605319.20100205002614@gmail.com> References: <3e1162e61002040829p54dc9798rfc0919768e2a0292@mail.gmail.com> <3283f7fe1002041251m75e83d6cxb82c3888487b2e2c@mail.gmail.com> <587605319.20100205002614@gmail.com> Message-ID: <3e1162e61002041439jc21931ag805df8bdf5be85ca@mail.gmail.com> On Thu, Feb 4, 2010 at 1:26 PM, Bulat Ziganshin wrote: > Hello John, > > Thursday, February 4, 2010, 11:51:59 PM, you wrote: > > > tl;dr: Lots of smart people, with a history of being right about this > > sort of thing, say iteratees are better. Evidence suggests > > iteratee-based IO is faster and more predictable than lazy IO. > > Iteratees are really hard to understand. > > thank you! good time for iteratee tutorials? ;) > > I put up my version of "cat" on my blog... http://leimy9.blogspot.com I'm just using runInteractiveCommand, and then putting the Handle returned through an enumerator/iteratee processing fold to get the contents. > > -- > Best regards, > Bulat mailto:Bulat.Ziganshin@gmail.com > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100204/c70e0fa1/attachment.html From daniel.is.fischer at web.de Thu Feb 4 17:40:07 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Feb 4 17:13:24 2010 Subject: [Haskell-cafe] Stack ADT? In-Reply-To: References: <274886.22747.qm@web31101.mail.mud.yahoo.com> Message-ID: <201002042340.07566.daniel.is.fischer@web.de> Am Donnerstag 04 Februar 2010 23:18:34 schrieb Daniel Peebles: > > data Stack a ? = EmptyStk | Stk a (Stack a) > > I find it amusing that the book defined a type that is exactly > isomorphic to the standard list (EmptyStk === [] and Stk === (:)). I > guess it's just for clarity? Also type safety, I think. However, I prefer newtype Stack a = Stack [a] From sebf at informatik.uni-kiel.de Thu Feb 4 18:29:07 2010 From: sebf at informatik.uni-kiel.de (Sebastian Fischer) Date: Thu Feb 4 18:00:39 2010 Subject: [Haskell-cafe] Stack ADT? In-Reply-To: <749042.93771.qm@web31104.mail.mud.yahoo.com> References: <749042.93771.qm@web31104.mail.mud.yahoo.com> Message-ID: <2176AF22-6B41-4159-A5AD-5F793AC68C5B@informatik.uni-kiel.de> On Feb 4, 2010, at 6:27 PM, michael rice wrote: > I haven't done much with modules so I'm guessing what you've > provided is the guts of StackImpl, to hide the implementation? Right. In order to make the Stack type abstract, you can hide the Stack data (that is, newtype) constructor and only export the Stack type constructor and the operations. You can use the following module header (I should have provided it in the first place): module Data.Stack (Stack, emptyStack, isEmptyStack, push, pop, top) where Making the Stack type abstract has the advantage that you can later change the implementation without affecting users of your Stack library which can only depend on its interface. Sebastian -- Underestimating the novelty of the future is a time-honored tradition. (D.G.) From eric.kow at gmail.com Thu Feb 4 18:29:33 2010 From: eric.kow at gmail.com (Eric Y. Kow) Date: Thu Feb 4 18:01:05 2010 Subject: [Haskell-cafe] Re: Anyone up for Google SoC 2010? In-Reply-To: <863507BC-FD78-49A0-9A77-C97B9431F7E7@cs.york.ac.uk> Message-ID: <20100204232932.GA27262@dewdrop.local> On 31 Jan 2010, Malcolm Wallace pointed out: > Google has announced that the Summer of Code programme will be running > again this year. If haskell.org people would like to take part again > this year, then we need volunteers: The Darcs Team would certainly be delighted to participate in GSoC 2010, perhaps under the haskell.org umbrella. Leslie Hawthorne from Google has suggested the possibility of them being "able to wrangle an extra slot or two for [Haskell.org] if they are acting as an umbrella org for darcs." http://lists.osuosl.org/pipermail/darcs-users/2009-October/021761.html I think we should make it very very clear that we would like this! > First, > * suggestions for suitable projects > (in the past this was organised using a reddit) > * an administrator to co-ordinate the application to Google > (I have done it for the last three years but am very willing > to hand on to someone else) I'll mention the Darcs ideas page here: http://wiki.darcs.net/GoogleSummerOfCode We're particularly interested in three things: (i) making Darcs faster (ii) building nice GUI tools and (iii) working seamlessly with SVN/Git repositories As for (i), we are also particularly interested in benchmarking. Criterion and now Progression seem like really great tools; hopefully, we can put them to good use. Meanwhile, perhaps there is extra room for tools that help large programs in their benchmarking? Two particularities may be [A] not always knowing how to get good benchmarks out of large coarse grained tasks ("run darcs check on this repository") and [B] big benchmarks ("run darcs check... on the GHC repo") > Google will accept applications from organisations in the period 8th - > 12th March 2010, approx 1900UTC. > > If haskell.org is accepted again, students can apply between 29th > March - 9th April. > More volunteers will be required: > > * to review student applications and choose which to accept > * to supervise the accepted students > > Both of these roles are called "mentor" in the Google system. Putting > together a good team of mentors before applying as an organisation is > helpful towards us being accepted into the programme. I'll volunteer as a mentor if it helps. Darcs users: if you have a few spare hours this summer, this would be a most excellent way to participate. Stick your hand up :-) -- Eric Kow PGP Key ID: 08AC04F9 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 195 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100204/755fbd24/attachment.bin From me at mornfall.net Thu Feb 4 18:41:38 2010 From: me at mornfall.net (Petr Rockai) Date: Thu Feb 4 18:12:41 2010 Subject: [Haskell-cafe] Re: Anyone up for Google SoC 2010? In-Reply-To: <20100204232932.GA27262@dewdrop.local> (Eric Y. Kow's message of "Thu, 4 Feb 2010 23:29:33 +0000") References: <863507BC-FD78-49A0-9A77-C97B9431F7E7@cs.york.ac.uk> <20100204232932.GA27262@dewdrop.local> Message-ID: <878wb87eml.fsf@twilight.int.mornfall.net.> Hello! [snip] > We're particularly interested in three things: > (i) making Darcs faster > (ii) building nice GUI tools and > (iii) working seamlessly with SVN/Git repositories [snip] >> Both of these roles are called "mentor" in the Google system. Putting >> together a good team of mentors before applying as an organisation is >> helpful towards us being accepted into the programme. > > I'll volunteer as a mentor if it helps. > > Darcs users: if you have a few spare hours this summer, this would be > a most excellent way to participate. Stick your hand up :-) I am volunteering as a mentor as well. My schedule is too crammed to go the student way this year (and, probably, any future year). I am particularly interested in mentoring (i) kinds of projects mentioned by Eric above, but other will do, depending on what prospective students come up with. Yours, Petr. From jwlato at gmail.com Thu Feb 4 19:34:06 2010 From: jwlato at gmail.com (John Lato) Date: Thu Feb 4 19:05:32 2010 Subject: [Haskell-cafe] safe lazy IO or Iteratee? Message-ID: <9979e72e1002041634v256b2433pf563b28d20f8eadd@mail.gmail.com> Hello, > From: David Leimbach > > Hi everyone, > > Yet at the same time, I'm quite enamored with the beauty of "interact" and > functions of that sort. ?I realize mixing the effects of the lazy IO and > pure code may not be the clearest way to write code for everyone, but there > is something about being able to get linewise data as > > interact (unlines . fmap someLineWiseFunction . lines) > > that is just kind of cool. I think so too. I really like the "interact" style of code; I find it supremely elegant. However I also find it insufficient for many interesting cases. One general problem is the difficulty of embedding monadic code into interact functions. Usually "interact" requires a pure function. Although in many cases I think it would be possible to have interactM :: (String -> IO String) -> IO () in practice these functions don't usually exist, perhaps because they can have some surprising behavior. In my opinion IO is a weakness of Haskell, and many Haskell users either subconciously or actively seek out alternative approaches. I offer as evidence the frequency with which beginners ask the cafe about "handle closed before data could be read" errors, and also the proliferation of IO libraries. I know which I approach I think represents the best way forward, but I would be surprised if there was a community consensus at this point. In any case, I'm glad there are a multitude of options and each probably has a place and purpose. Cheers, John Lato From ok at cs.otago.ac.nz Thu Feb 4 20:43:16 2010 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Thu Feb 4 20:14:44 2010 Subject: [Haskell-cafe] Stack ADT? In-Reply-To: <4d1mm5tigba8cmap3nmdl9cbevkvfsaonv@4ax.com> References: <274886.22747.qm@web31101.mail.mud.yahoo.com> <4d1mm5tigba8cmap3nmdl9cbevkvfsaonv@4ax.com> Message-ID: <72DB471B-0A61-49CC-9AA1-1797E524C849@cs.otago.ac.nz> On Feb 5, 2010, at 6:38 AM, Casey Hawthorne wrote: > On Thu, 4 Feb 2010 09:07:28 -0800 (PST), you wrote: > >> Can't find a Stack datatype on Hoogle? Where should I look? >> >> Michael >> module Stack(Stack,push,pop,top,emptyStack,stackEmpty) where ... Or just use a list. A more Haskellish approach to stacks than using "pop" and "top" would be something like this: newtype Stack t = [t] emptyStack = Stack [] stackPush (Stack s) = Stack (x:s) viewStack (Stack []) = Nothing viewStack (Stack (top:rest)) = Just (top, Stack rest) Instead of if stackEmpty s then ... else ... top s ... pop s ... do case viewStack s of Nothing -> ... Just (top, rest) -> ... Note that none of the functions in this interface can fail. > From tphyahoo at gmail.com Thu Feb 4 20:44:55 2010 From: tphyahoo at gmail.com (Thomas Hartman) Date: Thu Feb 4 20:16:23 2010 Subject: [Haskell-cafe] sendfile leaking descriptors on Linux? In-Reply-To: References: Message-ID: <910ddf451002041744r363954a9ne42527d23bee6d2e@mail.gmail.com> Do you have a test script to reproduce the behavior? I am interested in this patch-tag uses sendfile (via happstack) to serve static data, and I'd like to know if I'm affected by this. 2010/2/4 Bardur Arantsson : > Hi all, > > I've been using the sendfile package off Hackage, but it seems to be leaking > file descriptors when using the Linux-native build. > > What's happening in my specific case is the following: > > ? 1) client requests a range of a file > ? 2) server starts sending the range > ? 3) client disconnects before receiving the whole file > > This happens over and over with the client requesting different ranges of > the file (so the client does make progress). > > If I use the portable build of the sendfile package, everything works fine > for hours and hours of this happening. > > If I use the Linux-native build of the sendfile package, the server > will eventually run out of file descriptors. According to "lsof" the files > that are being kept open are the data files being sent in 2) above. > > This is on GHC 6.10.x (Ubuntu). > > Is anyone else seeing this? Anyone got any idea what's going on? > > Cheers, > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From jeremy at n-heptane.com Thu Feb 4 20:58:56 2010 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Thu Feb 4 20:30:23 2010 Subject: [Haskell-cafe] sendfile leaking descriptors on Linux? In-Reply-To: References: Message-ID: Well, that's not good. I wonder how we are supposed to know that the client has disconnected... We use withBinaryFile to open the file, so if an uncaught except is being thrown then that should close the file handle.. If you look in Network.Socket.SendFile.Linux, you will see that when the C sendfile() function returns -1, we throw an exception, unless it is the EAGAIN error. So, that should cause us to close the files when an error occurs. There is one possible odd case.. if sendfile returns 0, then we assume nothing went wrong and keep trying to resend the data until everything is sent. If it keeps returning 0 then we just keep trying even though nothing is happening. (Or if we keep getting EAGAIN errors..). But I am not sure that either of these cases would actually happen in practice. Another cause might be if threadWaitWrite is just never returning after the client disconnects.. - jeremy On Thu, Feb 4, 2010 at 1:43 PM, Bardur Arantsson wrote: > Hi all, > > I've been using the sendfile package off Hackage, but it seems to be > leaking file descriptors when using the Linux-native build. > > What's happening in my specific case is the following: > > 1) client requests a range of a file > 2) server starts sending the range > 3) client disconnects before receiving the whole file > > This happens over and over with the client requesting different ranges of > the file (so the client does make progress). > > If I use the portable build of the sendfile package, everything works fine > for hours and hours of this happening. > > If I use the Linux-native build of the sendfile package, the server > will eventually run out of file descriptors. According to "lsof" the files > that are being kept open are the data files being sent in 2) above. > > This is on GHC 6.10.x (Ubuntu). > > Is anyone else seeing this? Anyone got any idea what's going on? > > Cheers, > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100204/666b0e5e/attachment.html From jeremy at n-heptane.com Thu Feb 4 21:05:20 2010 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Thu Feb 4 20:36:51 2010 Subject: [Haskell-cafe] sendfile leaking descriptors on Linux? In-Reply-To: References: Message-ID: Actually, We should start by testing if native sendfile leaks file descriptors even when the whole file is sent. We have a test suite, but I am not sure if it tests for file handle leaking... - jeremy On Thu, Feb 4, 2010 at 7:58 PM, Jeremy Shaw wrote: > Well, that's not good. > > I wonder how we are supposed to know that the client has disconnected... We > use withBinaryFile to open the file, so if an uncaught except is being > thrown then that should close the file handle.. > > If you look in Network.Socket.SendFile.Linux, you will see that when the C > sendfile() function returns -1, we throw an exception, unless it is the > EAGAIN error. So, that should cause us to close the files when an error > occurs. > > There is one possible odd case.. if sendfile returns 0, then we assume > nothing went wrong and keep trying to resend the data until everything is > sent. If it keeps returning 0 then we just keep trying even though nothing > is happening. (Or if we keep getting EAGAIN errors..). But I am not sure > that either of these cases would actually happen in practice. > > Another cause might be if threadWaitWrite is just never returning after the > client disconnects.. > > - jeremy > > > > On Thu, Feb 4, 2010 at 1:43 PM, Bardur Arantsson wrote: > >> Hi all, >> >> I've been using the sendfile package off Hackage, but it seems to be >> leaking file descriptors when using the Linux-native build. >> >> What's happening in my specific case is the following: >> >> 1) client requests a range of a file >> 2) server starts sending the range >> 3) client disconnects before receiving the whole file >> >> This happens over and over with the client requesting different ranges of >> the file (so the client does make progress). >> >> If I use the portable build of the sendfile package, everything works fine >> for hours and hours of this happening. >> >> If I use the Linux-native build of the sendfile package, the server >> will eventually run out of file descriptors. According to "lsof" the files >> that are being kept open are the data files being sent in 2) above. >> >> This is on GHC 6.10.x (Ubuntu). >> >> Is anyone else seeing this? Anyone got any idea what's going on? >> >> Cheers, >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100204/fd1b7234/attachment-0001.html From waldmann at imn.htwk-leipzig.de Fri Feb 5 02:04:51 2010 From: waldmann at imn.htwk-leipzig.de (Johannes Waldmann) Date: Fri Feb 5 01:36:19 2010 Subject: [Haskell-cafe] Re: programmatic DB interface? In-Reply-To: <29bf512f1002041127x74fbf370vf2fa7a81564f3fb2@mail.gmail.com> References: <4B6A70DD.8020503@imn.htwk-leipzig.de> <4B6A84C3.30701@web.de> <87zl3pfjin.fsf@gmail.com> <29bf512f1002041127x74fbf370vf2fa7a81564f3fb2@mail.gmail.com> Message-ID: <4B6BC313.6080200@imn.htwk-leipzig.de> > Johannes> Data.Time.LocalTime.LocalTime.LocalTime: Cannot parse > Johannes> using default format string "%Y-%m-%dT%T%Q" this actually comes from the default format string that is defined in old-locale:System.Locale? iso8601DateFormat :: Maybe String -> String iso8601DateFormat mTimeFmt = "%Y-%m-%d" ++ case mTimeFmt of Nothing -> "" Just fmt -> 'T' : fmt and this can't be right - the 'T' is invalid? J. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 260 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100205/e37967ca/signature.bin From magnus at therning.org Fri Feb 5 02:54:39 2010 From: magnus at therning.org (Magnus Therning) Date: Fri Feb 5 02:26:14 2010 Subject: [Haskell-cafe] Re: programmatic DB interface? In-Reply-To: <4B6BC313.6080200@imn.htwk-leipzig.de> References: <4B6A70DD.8020503@imn.htwk-leipzig.de> <4B6A84C3.30701@web.de> <87zl3pfjin.fsf@gmail.com> <29bf512f1002041127x74fbf370vf2fa7a81564f3fb2@mail.gmail.com> <4B6BC313.6080200@imn.htwk-leipzig.de> Message-ID: <4B6BCEBF.4040509@therning.org> On 05/02/10 07:04, Johannes Waldmann wrote: > >> Johannes> Data.Time.LocalTime.LocalTime.LocalTime: Cannot parse >> Johannes> using default format string "%Y-%m-%dT%T%Q" > > this actually comes from the default format string > that is defined in old-locale:System.Locale? > > iso8601DateFormat :: Maybe String -> String > iso8601DateFormat mTimeFmt = > "%Y-%m-%d" ++ case mTimeFmt of > Nothing -> "" > Just fmt -> 'T' : fmt > > and this can't be right - the 'T' is invalid? It's very much valid, see http://en.wikipedia.org/wiki/ISO_8601 /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100205/47ab1f23/signature.bin From mlesniak at uni-kassel.de Fri Feb 5 03:00:05 2010 From: mlesniak at uni-kassel.de (Michael Lesniak) Date: Fri Feb 5 02:31:30 2010 Subject: [Haskell-cafe] Sparks created, but not used (par/pseq, ST monad) In-Reply-To: <201002041951.29091.daniel.is.fischer@web.de> References: <5f8b37691002040850i5cbcdb9fo298631b7ec4369cc@mail.gmail.com> <201002041951.29091.daniel.is.fischer@web.de> Message-ID: <5f8b37691002050000l306e81cbk251a21903ace828d@mail.gmail.com> Hello Daniel, >> and running with >> >> ? ? ./st +RTS -N -s > You'd need to give a number of capacities, I think (-N2 e.g.). The runtime option -N chooses the maximum number of cores, according to GHC's documentation. > I think with the strict ST monad, when you have > ? ?a <- f n1 > ? ?b <- f n2 > they are already evaluated, so there's no point in sparking evaluation in > parallel. Very good point and probably the reason for my problems, thanks! Cheers, Michael -- Dipl.-Inf. Michael C. Lesniak University of Kassel Programming Languages / Methodologies Research Group Department of Computer Science and Electrical Engineering Wilhelmsh?her Allee 73 34121 Kassel Phone: +49-(0)561-804-6269 From nicolas.pouillard at gmail.com Fri Feb 5 04:02:44 2010 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Fri Feb 5 03:34:11 2010 Subject: [Haskell-cafe] safe lazy IO or Iteratee? In-Reply-To: <3283f7fe1002041251m75e83d6cxb82c3888487b2e2c@mail.gmail.com> References: <3e1162e61002040829p54dc9798rfc0919768e2a0292@mail.gmail.com> <3283f7fe1002041251m75e83d6cxb82c3888487b2e2c@mail.gmail.com> Message-ID: <4b6bdeb4.0e67f10a.250b.45ec@mx.google.com> On Thu, 4 Feb 2010 12:51:59 -0800, John Millikin wrote: > Both have advantages and disadvantages. The primary advantage of lazy > IO over iteratees is that it's much, *much* easier to understand -- > existing experience with monads can be used immediately. The downsides > of lazy IO, of course, are well documented[1][2][3]. > > Some are fixed by the safe/strict IO packages. However, safe lazy IO > is still "unpredictable" in that it's difficult to know how many > resources will be used, the order of some operations (eg, releasing > handles), or whether some particular expression will throw an > exception. I don't know if you include safe-lazy-io [1] here but its purpose is to cure these downsides. In particular file handles are properly released on time even when asking for a stream of a list of files. Moreover exceptions are not hidden and can be caught properly in the wrapping IO layer. Some restrictions are there though. For instance one cannot arbitrarily interleave different streams, one have to use one of the predefined interleaving scheme. Another limitation is that the client cannot react to errors without getting back to the non-lazy IO world, however this is a big selling point as well of lazy-IO: "reuse pure code". I don't want to claim that (safe-)lazy-IO should be used in all situations, this would be terribly wrong. However I recommend it for situations were the interleaving of input is standard and errors have not to be caught in the processing code. Best regards, [1]: http://www.haskell.org/pipermail/haskell/2009-March/021133.html -- Nicolas Pouillard http://nicolaspouillard.fr From tom at lokhorst.eu Fri Feb 5 05:37:51 2010 From: tom at lokhorst.eu (Tom Lokhorst) Date: Fri Feb 5 05:09:37 2010 Subject: [Haskell-cafe] Dutch HUG: meeting Monday 8th in Utrecht Message-ID: <317ca7671002050237x64eecf42h221f59f8f3113334@mail.gmail.com> I'd like to invite functional programmers in The Netherlands to the Dutch Haskell User Group [1, 2] meeting next Monday at 19:00. Two talks are scheduled: - Sebastiaan Visser and Tom Lokhorst will give a talk entitled "AwesomePrelude, Liberating Haskell from data types!" - Martijn van Steenbergen will talk about serializing monadic computations. In particular, he will describe a monadic EDSL to describe compass-and-straightedge constructions and how to serialize and deserialize such values. The meeting will be in the Booth Hall [3] of the Utrecht University Library. There's free car parking [4] at the library, and it's easily accessible by bike and bus [5]. After the talks we will move to The Basket [6] for drinks. See you next Monday! - Tom Lokhorst [1]: http://www.haskell.org/haskellwiki/Dutch_HUG [2]: http://groups.google.com/group/dutch-hug [3]: http://www.uu.nl/EN/library/contact/university_library/zaalverhuur/Pages/default.aspx#booth [4]: http://www.uu.nl/EN/library/contact/university_library/Parkeren/Pages/default.aspx [5]: http://www.uu.nl/EN/library/contact/university_library/plattegrondenrou/Pages/default.aspx [6]: http://utrecht.thebasket.nl/ From spam at scientician.net Fri Feb 5 02:56:12 2010 From: spam at scientician.net (Bardur Arantsson) Date: Fri Feb 5 05:28:16 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: References: Message-ID: Jeremy Shaw wrote: > Actually, > > We should start by testing if native sendfile leaks file descriptors even > when the whole file is sent. We have a test suite, but I am not sure if it > tests for file handle leaking... > I should have posted this earlier, but the exact message I'm seeing in the case where the Bad Client disconnects is this: hums: Network.Socket.SendFile.Linux: resource vanished (Broken pipe) Oddly, I haven't been able to reproduce this using a wget client with a ^C during transfer. When I "disconnect" wget with ^C or "pkill wget" or even "pkill -9 wget", I get this message: hums: Network.Socket.SendFile.Linux: resource vanished (Connection reset by peer) (and no leak, as observed by "lsof | grep hums"). So there appears to be some vital difference between the handling of the two cases. Another observation which may be useful: Before the sendfile' API change (Handle -> FilePath) in sendfile-0.6.x, my code used "withFile" to open the file and to ensure that it was closed. So it seems that withBinaryFile *should* also be fine. Unless the "Broken pipe" error somehow escapes the scope without causing a "close". I don't have time to dig more right now, but I'll try to see if I can find out more later. Cheers, From waldmann at imn.htwk-leipzig.de Fri Feb 5 03:55:02 2010 From: waldmann at imn.htwk-leipzig.de (Johannes Waldmann) Date: Fri Feb 5 05:28:54 2010 Subject: [Haskell-cafe] Re: programmatic DB interface? References: <4B6A70DD.8020503@imn.htwk-leipzig.de> <4B6A84C3.30701@web.de> <87zl3pfjin.fsf@gmail.com> <29bf512f1002041127x74fbf370vf2fa7a81564f3fb2@mail.gmail.com> Message-ID: > and then read with my own parse string:"%Y-%m-%d %T%Q" > This seems to work just fine. Thanks. - When I'm using that format string, I get: Convertible: error converting source data SqlLocalTime 2008-10-29 00:00:00 of type SqlValue to type Data.Time.LocalTime.LocalTime.ZonedTime: incompatible types I guess I need to find out who wants ZonedTime. In my DB description (generated by dbdirect), the only time-related type is CalendarTime. J. From ganesh.sittampalam at credit-suisse.com Fri Feb 5 06:20:41 2010 From: ganesh.sittampalam at credit-suisse.com (Sittampalam, Ganesh) Date: Fri Feb 5 05:52:15 2010 Subject: [Haskell-cafe] Anyone up for Google SoC 2010? In-Reply-To: References: <863507BC-FD78-49A0-9A77-C97B9431F7E7@cs.york.ac.uk><404396ef1002031434i1f0388fduef0eab93ee040c01@mail.gmail.com> Message-ID: <16442B752A06A74AB4D9F9A5FF076E4B08816DF8@ELON17P32001A.csfb.cs-group.com> Gwern Branwen wrote: > On Wed, Feb 3, 2010 at 8:14 PM, Henk-Jan van Tuyl > wrote: >> On Wed, 03 Feb 2010 23:34:34 +0100, Neil Mitchell >> >> wrote: >> >>> Hi Gwern, >>> >>> Please update: "haskell-src-exts -> haskell-src" **Unknown** >>> >>> This project was an unqualified success. ?haskell-src-exts is now >>> one >>> of the most commonly used Haskell libraries, achieved the goals in >>> the project proposal, and is an essential piece of Haskell >>> infrastructure. >> >> You can see this using Roel van Dijk's reversed dependencies >> overview [1]: 23 direct and 57 indirect dependencies on >> haskell-src-exts-1.8.0 >> >> Regards, >> Henk-Jan van Tuyl > > And how many of those used haskell-src-exts *before* the SoC project? > And would have used it regardless? You can't point to a popular > project which got a SoC student, and say look at how popular it is - > obviously the SoC student was hugely successful. Regardless of that, is there any reason to disregard Neil's summary and not update your page? Ganesh =============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html =============================================================================== From mightybyte at gmail.com Fri Feb 5 07:59:50 2010 From: mightybyte at gmail.com (MightyByte) Date: Fri Feb 5 07:31:13 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: References: Message-ID: I've been seeing a steady stream of similar resource vanished messages for as long as I've been running my happstack app. This message I get is this: : hClose: resource vanished (Broken pipe) I run my app from a shell script inside a "while true" loop, so it automatically gets restarted if it crashes. This incurs no more than a few seconds of down time. Since that is acceptable for my application, I've never put much effort into investigating the issue. But I don't think the resource vanished error results in program termination. When I have looked into it, I've had similar trouble reproducing it. Clients such as wget and firefox don't seem to cause the problem. If I remember correctly it only happens with IE. On Fri, Feb 5, 2010 at 2:56 AM, Bardur Arantsson wrote: > Jeremy Shaw wrote: >> >> Actually, >> >> We should start by testing if native sendfile leaks file descriptors even >> when the whole file is sent. We have a test suite, but I am not sure if it >> tests for file handle leaking... >> > > I should have posted this earlier, but the exact message I'm seeing in the > case where the Bad Client disconnects is this: > > ? hums: Network.Socket.SendFile.Linux: resource vanished (Broken pipe) > > Oddly, I haven't been able to reproduce this using a wget client with a ^C > during transfer. When I "disconnect" wget with ^C or "pkill wget" or even > "pkill -9 wget", I get this message: > > ?hums: Network.Socket.SendFile.Linux: resource vanished (Connection reset by > peer) > > (and no leak, as observed by "lsof | grep hums"). > > So there appears to be some vital difference between the handling of the two > cases. > > Another observation which may be useful: > > Before the sendfile' API change (Handle -> FilePath) in sendfile-0.6.x, my > code used "withFile" to open the file and to ensure that it was closed. So > it seems that withBinaryFile *should* also be fine. Unless the "Broken pipe" > error somehow escapes the scope without causing a "close". > > I don't have time to dig more right now, but I'll try to see if I can find > out more later. > > Cheers, > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From michael at snoyman.com Fri Feb 5 08:01:52 2010 From: michael at snoyman.com (Michael Snoyman) Date: Fri Feb 5 07:33:17 2010 Subject: [Haskell-cafe] Re: programmatic DB interface? In-Reply-To: References: <4B6A70DD.8020503@imn.htwk-leipzig.de> <4B6A84C3.30701@web.de> <87zl3pfjin.fsf@gmail.com> <29bf512f1002041127x74fbf370vf2fa7a81564f3fb2@mail.gmail.com> Message-ID: <29bf512f1002050501j647c4017vca8b8ee961c3bcc4@mail.gmail.com> On Fri, Feb 5, 2010 at 10:55 AM, Johannes Waldmann < waldmann@imn.htwk-leipzig.de> wrote: > > and then read with my own parse string:"%Y-%m-%d %T%Q" > > This seems to work just fine. > > Thanks. - When I'm using that format string, I get: > > Convertible: error converting source data SqlLocalTime 2008-10-29 00:00:00 > of type SqlValue to type Data.Time.LocalTime.LocalTime.ZonedTime: > incompatible types > > I guess I need to find out who wants ZonedTime. > > In my DB description (generated by dbdirect), > the only time-related type is CalendarTime. > > J. > > > Did you append an empty string in the SELECT statement? If you append the empty string (||''), HDBC treats the field as text and so returns a SqlByteString. However, if you do not append the empty string, it treats the field as a timestamp and tries to convert it before it even reaches your code. All of this is just speculation, of course, since I haven't actually looked at the code. But my "extensive" (ie, 5 minute) testing implies it to be true. Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100205/d37c4340/attachment.html From martijn at van.steenbergen.nl Fri Feb 5 08:19:38 2010 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Fri Feb 5 07:51:08 2010 Subject: [Haskell-cafe] Re: Generating repeatable arbitrary values with QuickCheck 2 In-Reply-To: <2f9b2d31002021404v6b3a86a7id0cf612e2f9573f7@mail.gmail.com> References: <3c6288ab1002011354j7909e2a4w6116ff685c081224@mail.gmail.com> <3c6288ab1002020434l496d0f41se869234ad0968de4@mail.gmail.com> <2f9b2d31002021048s3399622cyf3743531a3abfd64@mail.gmail.com> <49a77b7a1002021125k4f260adakdbcb187f873412e@mail.gmail.com> <2f9b2d31002021404v6b3a86a7id0cf612e2f9573f7@mail.gmail.com> Message-ID: <4B6C1AEA.3010400@van.steenbergen.nl> Ryan Ingram wrote: > Unfortunately, this makes things like >> infinite_xs <- sequence (repeat arbitrary) > no longer work, since the state never comes out the other side. You're asking to execute an infinite number of monadic actions. How can this ever terminate at all? Martijn. From itsme213 at hotmail.com Thu Feb 4 22:51:23 2010 From: itsme213 at hotmail.com (Sophie) Date: Fri Feb 5 08:06:29 2010 Subject: [Haskell-cafe] online Real World Haskell - tool used? Message-ID: Not a Haskell question, pardon me. I believe the online Real World Haskell book with commenting system was generated with an open-source tool (written by one of the authors?). Any idea where I might find this? [I think I had gotten the link long ago, lost it]. I am also curious what authoring tools were used to write the book. Thanks! Sophie From stefan at cs.uu.nl Fri Feb 5 08:39:55 2010 From: stefan at cs.uu.nl (Stefan Holdermans) Date: Fri Feb 5 08:11:20 2010 Subject: [Haskell-cafe] Re: Generating repeatable arbitrary values with QuickCheck 2 In-Reply-To: <4B6C1AEA.3010400@van.steenbergen.nl> References: <3c6288ab1002011354j7909e2a4w6116ff685c081224@mail.gmail.com> <3c6288ab1002020434l496d0f41se869234ad0968de4@mail.gmail.com> <2f9b2d31002021048s3399622cyf3743531a3abfd64@mail.gmail.com> <49a77b7a1002021125k4f260adakdbcb187f873412e@mail.gmail.com> <2f9b2d31002021404v6b3a86a7id0cf612e2f9573f7@mail.gmail.com> <4B6C1AEA.3010400@van.steenbergen.nl> Message-ID: <0AE2E5BE-577C-414B-BCB2-81B07B8802CA@cs.uu.nl> Martijn, Ryan wrote: >> Unfortunately, this makes things like >>> infinite_xs <- sequence (repeat arbitrary) >> no longer work, since the state never comes out the other side. You replied: > You're asking to execute an infinite number of monadic actions. How > can this ever terminate at all? There is this thing called lazy evaluation, you know. ;-) Try for yourself: import System.Random import Test.QuickCheck foo :: Gen [Int] foo = do ns <- sequence (repeat arbitrary) return (take 5 ns) main :: IO () main = do stdGen <- newStdGen print (generate 42 stdGen foo) Cheers, Stefan From keithshep at gmail.com Fri Feb 5 09:01:28 2010 From: keithshep at gmail.com (Keith Sheppard) Date: Fri Feb 5 08:32:56 2010 Subject: [Haskell-cafe] multMM :: Matrix -> Matrix -> Matrix --multiplies two matrices question (Homework) In-Reply-To: <98f46b31002022238m6b288c0w7a49d1ffc8c9ee2@mail.gmail.com> References: <98f46b31002022238m6b288c0w7a49d1ffc8c9ee2@mail.gmail.com> Message-ID: <92e42b741002050601o556a2d1ew9213432d9c0dc4f@mail.gmail.com> I did a blog post on basic matrix ops which may be useful to you http://blog.keithsheppard.name/2009/06/bird-tracks-through-math-land-basic.html It uses a 2D list representation for matrices which you would not do for any performance critical work. best keith On Wed, Feb 3, 2010 at 1:38 AM, ??? wrote: > hi i was trying to solve it but > > All i got is > type Matrix=[[Double]] > > multMM :: Matrix -> Matrix -> Matrix --multiplies two matrices > multMM m t = ???[[sum (zipWith (*) (head m)(a)) ] ]where? a = [head a | a<- > t] > > > Main> multMM [[2,1,-6],[1,-3,2]] [[1,0,-3],[0,4,20],[-2,1,1]] > [[14.0]] > > from this i could get only the first multiplication 14??? that is by? 2*1 + > 1*0 + -6*-2 = 14 > > how can i make this go throw all rows and colums to get multiple of matrixs? > > Thank you~ > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- keithsheppard.name From jwlato at gmail.com Fri Feb 5 09:04:38 2010 From: jwlato at gmail.com (John Lato) Date: Fri Feb 5 08:36:02 2010 Subject: [Haskell-cafe] safe lazy IO or Iteratee? Message-ID: <9979e72e1002050604k1668b9a9h39cf1cb305fe7b3b@mail.gmail.com> > Subject: Re: [Haskell-cafe] safe lazy IO or Iteratee? > > Downside: iteratees are very hard to understand. I wrote a > decently-sized article about them trying to figure out how to make > them useful, and some comments in one of Oleg's implementations > suggest that the "iteratee" package is subtly wrong. Oleg has written > at least three versions (non-monadic, monadic, monadic CPS) and I've > no idea why or whether their differences are important. Even dons says > he didn't understand them until after writing his own iteratee-based > IO layer. More significant than, and orthogonal to, the differences between non-monadic and monadic are the two primary implementations Oleg has written. They are[1]: Design 1: newtype Iteratee el m a = Iteratee{runIter:: Stream el -> m (IterV el m a)} data IterV el m a = IE_done a (Stream el) | IE_cont (Iteratee el m a) (Maybe ErrMsg) Design 2: newtype Iteratee el m a = Iteratee{runIter:: m (IterV el m a)} data IterV el m a = IE_done a (Stream el) | IE_cont (Stream el -> Iteratee el m a) (Maybe ErrMsg With the first design, it's impossible to get the state of an iteratee without feeding it a chunk. There are other consequences too. The second design seems to require some specialized combinators, that is (>>==) and ($$), which are not required for the first version. Neither situation is ideal. The CPS version appears to remedy both flaws, but at the expense of introducing CPS at a low level (this can be hidden from the end user in many cases). I already think of iteratees as holding continuations, so to me the so-called "CPS version" is to me a double CPS. Both designs appear to offer similar performance in aggregate, although there are differences for particular functions. I haven't yet had a chance to test the performance of the CPS variant, although Oleg has indicated he expects it will be higher. The monadic/non-monadic issue is related. Non-monadic iteratees are iteratees that can't perform monadic effects when they're running (although they can still be fed from a monadic enumerator). Essentially it's the difference between "fold" and "foldM". They are simpler and more efficient because of this, but also much less powerful. Any iteratee design can support both non-monadic and monadic, but *I* don't want to support both. At least, I don't want to have double modules for everything for nearly identical functions, and polymorphic code that can handle non-monadic and monadic iteratees is non-trivial[2]. Much of my recent work has been in the consequences of these various design considerations for the next version of the iteratee library. Currently undecided, although I'm leaning towards CPS. It seems to solve a lot of problems, and the implementation details are generally cleaner too. Cheers, John [1] Both taken from http://okmij.org/ftp/Haskell/Iteratee/IterateeM.hs. Design 1 is commented out on that page. [2] At least for me. Maybe others can provide a better solution. From waldmann at imn.htwk-leipzig.de Fri Feb 5 09:30:13 2010 From: waldmann at imn.htwk-leipzig.de (Johannes Waldmann) Date: Fri Feb 5 09:01:59 2010 Subject: [Haskell-cafe] Re: programmatic DB interface? References: <4B6A70DD.8020503@imn.htwk-leipzig.de> <4B6A84C3.30701@web.de> <87zl3pfjin.fsf@gmail.com> <29bf512f1002041127x74fbf370vf2fa7a81564f3fb2@mail.gmail.com> <29bf512f1002050501j647c4017vca8b8ee961c3bcc4@mail.gmail.com> Message-ID: Michael Snoyman snoyman.com> writes: > Did you append an empty string in the SELECT statement? I did not write a SELECT statement (see first post of this thread) ... SELECTs are generated by haskelldb(-hdbc-postgresql) I have a working version now, but only by 1. changing the format string computation to "%Y-%m-%d" ++ ' ' : fmt 2. adding a line in instance Convertible SqlValue ZonedTime for safeConvert y@(SqlLocalTime x) Magnus says 1. is wrong, but I don't see how the DB server could be convinced to send the ...T...Z format. In my application, the table definition contains 'timestamp without time zone' and I cannot change that. J. From colin at colina.demon.co.uk Fri Feb 5 09:34:50 2010 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Fri Feb 5 09:06:14 2010 Subject: [Haskell-cafe] Re: programmatic DB interface? In-Reply-To: (Johannes Waldmann's message of "Fri, 5 Feb 2010 14:30:13 +0000 (UTC)") References: <4B6A70DD.8020503@imn.htwk-leipzig.de> <4B6A84C3.30701@web.de> <87zl3pfjin.fsf@gmail.com> <29bf512f1002041127x74fbf370vf2fa7a81564f3fb2@mail.gmail.com> <29bf512f1002050501j647c4017vca8b8ee961c3bcc4@mail.gmail.com> Message-ID: >>>>> "Johannes" == Johannes Waldmann writes: Johannes> Michael Snoyman snoyman.com> writes: >> Did you append an empty string in the SELECT statement? Johannes> Magnus says 1. is wrong, but I don't see how the DB server Johannes> could be convinced to send the ...T...Z format. In my Johannes> application, the table definition contains 'timestamp Johannes> without time zone' and I cannot change that. That is exactly the problem - it is wrong for CalendarT. -- Colin Adams Preston Lancashire From waldmann at imn.htwk-leipzig.de Fri Feb 5 09:51:53 2010 From: waldmann at imn.htwk-leipzig.de (Johannes Waldmann) Date: Fri Feb 5 09:23:19 2010 Subject: [Haskell-cafe] Re: programmatic DB interface? In-Reply-To: References: <4B6A70DD.8020503@imn.htwk-leipzig.de> <4B6A84C3.30701@web.de> <87zl3pfjin.fsf@gmail.com> <29bf512f1002041127x74fbf370vf2fa7a81564f3fb2@mail.gmail.com> <29bf512f1002050501j647c4017vca8b8ee961c3bcc4@mail.gmail.com> Message-ID: <4B6C3089.3020204@imn.htwk-leipzig.de> > That is exactly the problem - it is wrong for CalendarT. what do you mean by "it" ... what package should be fixed (old-locale, haskelldb-hdbc-postgreqsl, ...)? Because obviously something seems broken here. J. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 260 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100205/d5102744/signature.bin From waldmann at imn.htwk-leipzig.de Fri Feb 5 10:05:59 2010 From: waldmann at imn.htwk-leipzig.de (Johannes Waldmann) Date: Fri Feb 5 09:37:24 2010 Subject: [Haskell-cafe] cabal fun (not) Message-ID: <4B6C33D7.70306@imn.htwk-leipzig.de> while trying to live with different versions of packages, I found cabal-install's behaviour strange because: you can "cabal install" a package without any complaint but the next "ghc-pkg list" is all red because of conflicts. and it's too late then - there's no way to get back. even if you re-install some package, it seems it is getting a different hashcode, so it's not recognized. if you were doing "cabal install --global" for some ghc package (e.g. old-locale), then ghc seems completely hosed and you've got to re-install the compiler. well that's not a big deal by itself but afterwards you have to re-install all packages ... so please please please have "cabal install" fail with some error message if (that is, before) the install would break anything. - J. $ ghc --version The Glorious Glasgow Haskell Compilation System, version 6.12.1 $ cabal --version cabal-install version 0.8.0 using version 1.8.0.2 of the Cabal library -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 260 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100205/0bf9cb89/signature.bin From colin at colina.demon.co.uk Fri Feb 5 10:10:26 2010 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Fri Feb 5 09:41:52 2010 Subject: [Haskell-cafe] Re: programmatic DB interface? In-Reply-To: <4B6C3089.3020204@imn.htwk-leipzig.de> (Johannes Waldmann's message of "Fri, 05 Feb 2010 15:51:53 +0100") References: <4B6A70DD.8020503@imn.htwk-leipzig.de> <4B6A84C3.30701@web.de> <87zl3pfjin.fsf@gmail.com> <29bf512f1002041127x74fbf370vf2fa7a81564f3fb2@mail.gmail.com> <29bf512f1002050501j647c4017vca8b8ee961c3bcc4@mail.gmail.com> <4B6C3089.3020204@imn.htwk-leipzig.de> Message-ID: >>>>> "Johannes" == Johannes Waldmann writes: >> That is exactly the problem - it is wrong for CalendarT. Johannes> what do you mean by "it" ... what package should be fixed Johannes> (old-locale, haskelldb-hdbc-postgreqsl, ...)? Because Johannes> obviously something seems broken here. "It" is the use of unzoned times. I sent the following patch to the haskelldb list several months ago. But there has not been a new release since then. Colin> It is just the code to generate the SQL for CREATE TABLE is Colin> presumably faulty. For CalendarTimeT columns it should Colin> generate a time of Colin> timestamp with time zone Colin> as CalendarTime is a zoned timestamp. here's my patch: --- Default.hs~ 2009-02-13 23:06:25.000000000 +0000 +++ Default.hs 2009-10-01 16:43:34.000000000 +0100 @@ -92,7 +92,7 @@ IntegerT -> SqlType "bigint" DoubleT -> SqlType "double precision" BoolT -> SqlType "bit" - CalendarTimeT -> SqlType "timestamp" + CalendarTimeT -> SqlType "timestamp with time zone" BStrT a -> SqlType1 "varchar" a -- Colin Adams Preston Lancashire From waldmann at imn.htwk-leipzig.de Fri Feb 5 10:17:25 2010 From: waldmann at imn.htwk-leipzig.de (Johannes Waldmann) Date: Fri Feb 5 09:48:51 2010 Subject: [Haskell-cafe] Re: programmatic DB interface? In-Reply-To: References: <4B6A70DD.8020503@imn.htwk-leipzig.de> <4B6A84C3.30701@web.de> <87zl3pfjin.fsf@gmail.com> <29bf512f1002041127x74fbf370vf2fa7a81564f3fb2@mail.gmail.com> <29bf512f1002050501j647c4017vca8b8ee961c3bcc4@mail.gmail.com> <4B6C3089.3020204@imn.htwk-leipzig.de> Message-ID: <4B6C3685.2080309@imn.htwk-leipzig.de> Colin Paul Adams wrote: > Colin> It is just the code to generate the SQL for CREATE TABLE is > Colin> presumably faulty. well this wouldn't help in my case since I did not CREATE TABLE from haskelldb. In my application, the DB is given externally, and I used Database.HaskellDB.DBDirect to create the Haskell interface. J. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 260 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100205/ea69967f/signature.bin From jmillikin at gmail.com Fri Feb 5 10:34:55 2010 From: jmillikin at gmail.com (John Millikin) Date: Fri Feb 5 10:06:39 2010 Subject: [Haskell-cafe] safe lazy IO or Iteratee? In-Reply-To: <9979e72e1002050604k1668b9a9h39cf1cb305fe7b3b@mail.gmail.com> References: <9979e72e1002050604k1668b9a9h39cf1cb305fe7b3b@mail.gmail.com> Message-ID: <3283f7fe1002050734v5e330e6co7361f2c09b01940b@mail.gmail.com> I didn't count the commented-out designs in Oleg's code, only those which are "live". > Both designs appear to offer similar performance in aggregate, > although there are differences for particular functions. I haven't > yet had a chance to test the performance of the CPS variant, although > Oleg has indicated he expects it will be higher. I wrote some criterion benchmarks for IterateeM vs IterateeCPS, and the CPS version was notably slower. I don't understand enough about CPS to diagnose why, but the additional runtime was present in even simple cases (reading from a file, writing back out). On Fri, Feb 5, 2010 at 06:04, John Lato wrote: >> Subject: Re: [Haskell-cafe] safe lazy IO or Iteratee? >> >> Downside: iteratees are very hard to understand. I wrote a >> decently-sized article about them trying to figure out how to make >> them useful, and some comments in one of Oleg's implementations >> suggest that the "iteratee" package is subtly wrong. Oleg has written >> at least three versions (non-monadic, monadic, monadic CPS) and I've >> no idea why or whether their differences are important. Even dons says >> he didn't understand them until after writing his own iteratee-based >> IO layer. > > More significant than, and orthogonal to, the differences between > non-monadic and monadic are the two primary implementations Oleg has > written. ?They are[1]: > > Design 1: > newtype Iteratee el m a = Iteratee{runIter:: Stream el -> m (IterV el m a)} > data IterV el m a = IE_done a (Stream el) > ? ? ? ? ? ? ? ? ?| IE_cont (Iteratee el m a) (Maybe ErrMsg) > > Design 2: > newtype Iteratee el m a = Iteratee{runIter:: m (IterV el m a)} > data IterV el m a = IE_done a (Stream el) > ? ? ? ? ? ? ? ? ?| IE_cont (Stream el -> Iteratee el m a) (Maybe ErrMsg > > With the first design, it's impossible to get the state of an iteratee > without feeding it a chunk. ?There are other consequences too. ?The > second design seems to require some specialized combinators, that is > (>>==) and ($$), which are not required for the first version. > Neither situation is ideal. ?The CPS version appears to remedy both > flaws, but at the expense of introducing CPS at a low level (this can > be hidden from the end user in many cases). ?I already think of > iteratees as holding continuations, so to me the so-called "CPS > version" is to me a double CPS. > > Both designs appear to offer similar performance in aggregate, > although there are differences for particular functions. ?I haven't > yet had a chance to test the performance of the CPS variant, although > Oleg has indicated he expects it will be higher. > > The monadic/non-monadic issue is related. ?Non-monadic iteratees are > iteratees that can't perform monadic effects when they're running > (although they can still be fed from a monadic enumerator). > Essentially it's the difference between "fold" and "foldM". ?They are > simpler and more efficient because of this, but also much less > powerful. ?Any iteratee design can support both non-monadic and > monadic, but *I* don't want to support both. ?At least, I don't want > to have double modules for everything for nearly identical functions, > and polymorphic code that can handle non-monadic and monadic iteratees > is non-trivial[2]. > > Much of my recent work has been in the consequences of these various > design considerations for the next version of the iteratee library. > Currently undecided, although I'm leaning towards CPS. ?It seems to > solve a lot of problems, and the implementation details are generally > cleaner too. > > Cheers, > John > > [1] Both taken from > http://okmij.org/ftp/Haskell/Iteratee/IterateeM.hs. ?Design 1 is > commented out on that page. > > [2] At least for me. ?Maybe others can provide a better solution. > From caseyh at istar.ca Fri Feb 5 10:36:40 2010 From: caseyh at istar.ca (Casey Hawthorne) Date: Fri Feb 5 10:08:09 2010 Subject: [Haskell-cafe] Stack ADT? In-Reply-To: <274886.22747.qm@web31101.mail.mud.yahoo.com> References: <274886.22747.qm@web31101.mail.mud.yahoo.com> Message-ID: You could also implement stacks with mutable data structures, e.g. STArray, etc. What do you want to use a stack ADT for? Usually stacks are discussed for pedagogical purposes but usually recursion is used if you need a stack like operation. -- Regards, Casey From colin at colina.demon.co.uk Fri Feb 5 10:40:34 2010 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Fri Feb 5 10:11:58 2010 Subject: [Haskell-cafe] Stack ADT? In-Reply-To: (Casey Hawthorne's message of "Fri, 05 Feb 2010 07:36:40 -0800") References: <274886.22747.qm@web31101.mail.mud.yahoo.com> Message-ID: >>>>> "Casey" == Casey Hawthorne writes: Casey> You could also implement stacks with mutable data structures, Casey> e.g. STArray, etc. Casey> What do you want to use a stack ADT for? BTW, There is a Myers stack in Edison. Disclaimer - I don't know what a Myers stack is. -- Colin Adams Preston Lancashire From nowgate at yahoo.com Fri Feb 5 10:56:57 2010 From: nowgate at yahoo.com (michael rice) Date: Fri Feb 5 10:28:22 2010 Subject: [Haskell-cafe] Stack ADT? In-Reply-To: Message-ID: <410077.28990.qm@web31101.mail.mud.yahoo.com> Not using Stack for anything, just trying to understand how things can be done in Haskell. To that end... What's going on here? I'm not even calling function POP. Michael ====================== module Data.Stack (Stack, emptyStack, isEmptyStack, push, pop, top) where newtype Stack a = Stack [a] emptyStack = Stack [] isEmptyStack (Stack xs) = null xs push x (Stack xs) = Stack (x:xs) pop (Stack (_:xs)) = Stack xs top (Stack (x:_)) = x ====================== [michael@localhost ~]$ ghci Stack.hs GHCi, version 6.10.4: http://www.haskell.org/ghc/? :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. [1 of 1] Compiling Data.Stack?????? ( Stack.hs, interpreted ) Ok, modules loaded: Data.Stack. *Data.Stack> let s1 = emptyStack *Data.Stack> top (push 1 s1) 1 *Data.Stack> top (push 2 s1) 2 *Data.Stack> top (push 3 s1) 3 *Data.Stack> let s2 = pop s1 *Data.Stack> top s2 *** Exception: Stack.hs:8:0-28: Non-exhaustive patterns in function pop *Data.Stack> --- On Fri, 2/5/10, Casey Hawthorne wrote: From: Casey Hawthorne Subject: Re: [Haskell-cafe] Stack ADT? To: haskell-cafe@haskell.org Date: Friday, February 5, 2010, 10:36 AM You could also implement stacks with mutable data structures, e.g. STArray, etc. What do you want to use a stack ADT for? Usually stacks are discussed for pedagogical purposes but usually recursion is used if you need a stack like operation. -- Regards, Casey _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100205/e999fb72/attachment.html From wagner.andrew at gmail.com Fri Feb 5 11:00:50 2010 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Fri Feb 5 10:32:15 2010 Subject: [Haskell-cafe] Stack ADT? In-Reply-To: <410077.28990.qm@web31101.mail.mud.yahoo.com> References: <410077.28990.qm@web31101.mail.mud.yahoo.com> Message-ID: What's "going on" is that data structures in Haskell are immutable. Thus, when you call "push" on a stack, you get a new stack with the new element pushed onto it, and the original stack is left un-touched. On Fri, Feb 5, 2010 at 10:56 AM, michael rice wrote: > Not using Stack for anything, just trying to understand how things can be > done in Haskell. > > To that end... > > What's going on here? I'm not even calling function POP. > > Michael > > ====================== > > module Data.Stack (Stack, emptyStack, isEmptyStack, push, pop, top) where > > newtype Stack a = Stack [a] > > emptyStack = Stack [] > isEmptyStack (Stack xs) = null xs > push x (Stack xs) = Stack (x:xs) > pop (Stack (_:xs)) = Stack xs > top (Stack (x:_)) = x > > ====================== > > [michael@localhost ~]$ ghci Stack.hs > GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help > Loading package ghc-prim ... linking ... done. > Loading package integer ... linking ... done. > Loading package base ... linking ... done. > [1 of 1] Compiling Data.Stack ( Stack.hs, interpreted ) > Ok, modules loaded: Data.Stack. > *Data.Stack> let s1 = emptyStack > *Data.Stack> top (push 1 s1) > 1 > *Data.Stack> top (push 2 s1) > 2 > *Data.Stack> top (push 3 s1) > 3 > *Data.Stack> let s2 = pop s1 > *Data.Stack> top s2 > *** Exception: Stack.hs:8:0-28: Non-exhaustive patterns in function pop > > *Data.Stack> > > > > > --- On *Fri, 2/5/10, Casey Hawthorne * wrote: > > > From: Casey Hawthorne > Subject: Re: [Haskell-cafe] Stack ADT? > To: haskell-cafe@haskell.org > Date: Friday, February 5, 2010, 10:36 AM > > You could also implement stacks with mutable data structures, e.g. > STArray, etc. > > What do you want to use a stack ADT for? > > Usually stacks are discussed for pedagogical purposes but usually > recursion is used if you need a stack like operation. > -- > Regards, > Casey > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100205/8de129da/attachment.html From rk at trie.org Fri Feb 5 11:02:08 2010 From: rk at trie.org (Rahul Kapoor) Date: Fri Feb 5 10:33:37 2010 Subject: [Haskell-cafe] Stack ADT? In-Reply-To: <410077.28990.qm@web31101.mail.mud.yahoo.com> References: <410077.28990.qm@web31101.mail.mud.yahoo.com> Message-ID: > What's going on here? I'm not even calling function POP. > *Data.Stack> let s2 = pop s1 > *Data.Stack> top s2 > *** Exception: Stack.hs:8:0-28: Non-exhaustive patterns in function pop Haskell being a non strict language, does not evaluate pop s1 when you define let s2 = pop s1. but when you try to use s2 by evaluating "top s2" "pop s1" needs to be evaluated leading to the error in "pop", since the definition of pop, does not deal with the case when the Stack is empty (Stack []). > pop (Stack (_:xs)) = Stack xs > top (Stack (x:_)) = x From noteed at gmail.com Fri Feb 5 11:04:54 2010 From: noteed at gmail.com (minh thu) Date: Fri Feb 5 10:36:38 2010 Subject: [Haskell-cafe] Stack ADT? In-Reply-To: <410077.28990.qm@web31101.mail.mud.yahoo.com> References: <410077.28990.qm@web31101.mail.mud.yahoo.com> Message-ID: <40a414c21002050804g3608c0d1r8f2d505ddc6a258d@mail.gmail.com> 2010/2/5 michael rice > > Not using Stack for anything, just trying to understand how things can be done in Haskell. > > To that end... > > What's going on here? I'm not even calling function POP. > > Michael > > ====================== > > module Data.Stack (Stack, emptyStack, isEmptyStack, push, pop, top) where > > newtype Stack a = Stack [a] > > emptyStack = Stack [] > isEmptyStack (Stack xs) = null xs > push x (Stack xs) = Stack (x:xs) > pop (Stack (_:xs)) = Stack xs > top (Stack (x:_)) = x > > ====================== > > [michael@localhost ~]$ ghci Stack.hs > GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help > Loading package ghc-prim ... linking ... done. > Loading package integer ... linking ... done. > Loading package base ... linking ... done. > [1 of 1] Compiling Data.Stack ( Stack.hs, interpreted ) > Ok, modules loaded: Data.Stack. > *Data.Stack> let s1 = emptyStack > *Data.Stack> top (push 1 s1) > 1 > *Data.Stack> top (push 2 s1) > 2 > *Data.Stack> top (push 3 s1) > 3 > *Data.Stack> let s2 = pop s1 > *Data.Stack> top s2 > *** Exception: Stack.hs:8:0-28: Non-exhaustive patterns in function pop When you write push 1 s1 you get a new stack value. you can view it by typing 'it' in ghci (provided you have an instance of Show for it). s1 is still s1, the empty stack. When you write let s2 = pop s1 Nothing happens yet, but if you want to evaluate s2, e.g. by typing it in ghci, pop will be applied to the empty stack, which is not taken care of in its definition. And you do want evaluate s2 when you eventually write top s2. HTH, Thu From valery.vv at gmail.com Fri Feb 5 11:31:45 2010 From: valery.vv at gmail.com (Valery V. Vorotyntsev) Date: Fri Feb 5 11:03:10 2010 Subject: [Haskell-cafe] safe lazy IO or Iteratee? In-Reply-To: <3283f7fe1002050734v5e330e6co7361f2c09b01940b@mail.gmail.com> References: <9979e72e1002050604k1668b9a9h39cf1cb305fe7b3b@mail.gmail.com> <3283f7fe1002050734v5e330e6co7361f2c09b01940b@mail.gmail.com> Message-ID: > John Lato wrote: > >> Both designs appear to offer similar performance in aggregate, >> although there are differences for particular functions. I haven't >> yet had a chance to test the performance of the CPS variant, although >> Oleg has indicated he expects it will be higher. @jwlato: Do you mind creating `IterateeCPS' tree in , so we can start writing CPS performance testing code? AFAICS, you have benchmarks for IterateeM-driven code already: http://inmachina.net/~jwlato/haskell/iteratee/tests/benchmarks.hs John Millikin wrote: > I wrote some criterion benchmarks for IterateeM vs IterateeCPS, and > the CPS version was notably slower. I don't understand enough about > CPS to diagnose why, but the additional runtime was present in even > simple cases (reading from a file, writing back out). @jmillikin: Could you please publish those benchmarks? Thanks. -- vvv From nowgate at yahoo.com Fri Feb 5 11:33:03 2010 From: nowgate at yahoo.com (michael rice) Date: Fri Feb 5 11:04:27 2010 Subject: [Haskell-cafe] Stack ADT? In-Reply-To: <40a414c21002050804g3608c0d1r8f2d505ddc6a258d@mail.gmail.com> Message-ID: <961445.32389.qm@web31106.mail.mud.yahoo.com> I see now that what I thought was happening wasn't happening at all. > top (push 1 s1)? gives me the top of the new Stack returned by PUSH. s1 remains unchanged. Thanks, Michael --- On Fri, 2/5/10, minh thu wrote: From: minh thu Subject: Re: [Haskell-cafe] Stack ADT? To: "michael rice" Cc: haskell-cafe@haskell.org, "Casey Hawthorne" Date: Friday, February 5, 2010, 11:04 AM 2010/2/5 michael rice > > Not using Stack for anything, just trying to understand how things can be done in Haskell. > > To that end... > > What's going on here? I'm not even calling function POP. > > Michael > > ====================== > > module Data.Stack (Stack, emptyStack, isEmptyStack, push, pop, top) where > > newtype Stack a = Stack [a] > > emptyStack = Stack [] > isEmptyStack (Stack xs) = null xs > push x (Stack xs) = Stack (x:xs) > pop (Stack (_:xs)) = Stack xs > top (Stack (x:_)) = x > > ====================== > > [michael@localhost ~]$ ghci Stack.hs > GHCi, version 6.10.4: http://www.haskell.org/ghc/? :? for help > Loading package ghc-prim ... linking ... done. > Loading package integer ... linking ... done. > Loading package base ... linking ... done. > [1 of 1] Compiling Data.Stack? ? ???( Stack.hs, interpreted ) > Ok, modules loaded: Data.Stack. > *Data.Stack> let s1 = emptyStack > *Data.Stack> top (push 1 s1) > 1 > *Data.Stack> top (push 2 s1) > 2 > *Data.Stack> top (push 3 s1) > 3 > *Data.Stack> let s2 = pop s1 > *Data.Stack> top s2 > *** Exception: Stack.hs:8:0-28: Non-exhaustive patterns in function pop When you write ? push 1 s1 you get a new stack value. you can view it by typing 'it' in ghci (provided you have an instance of Show for it). s1 is still s1, the empty stack. When you write ? let s2 = pop s1 Nothing happens yet, but if you want to evaluate s2, e.g. by typing it in ghci, pop will be applied to the empty stack, which is not taken care of in its definition. And you do want evaluate s2 when you eventually write ? top s2. HTH, Thu -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100205/8185a624/attachment.html From jwlato at gmail.com Fri Feb 5 11:56:06 2010 From: jwlato at gmail.com (John Lato) Date: Fri Feb 5 11:27:33 2010 Subject: [Haskell-cafe] safe lazy IO or Iteratee? In-Reply-To: References: <9979e72e1002050604k1668b9a9h39cf1cb305fe7b3b@mail.gmail.com> <3283f7fe1002050734v5e330e6co7361f2c09b01940b@mail.gmail.com> Message-ID: <9979e72e1002050856i39787fa0y9023f3fe533f0587@mail.gmail.com> On Fri, Feb 5, 2010 at 4:31 PM, Valery V. Vorotyntsev wrote: >> John Lato wrote: >> >>> Both designs appear to offer similar performance in aggregate, >>> although there are differences for particular functions. ?I haven't >>> yet had a chance to test the performance of the CPS variant, although >>> Oleg has indicated he expects it will be higher. > > @jwlato: > Do you mind creating `IterateeCPS' tree in > , so we can > start writing CPS performance testing code? I'm working on the CPS version and will make it public when it's done. It may take a week or so; this term started at 90 and has picked up. I have several benchmark sources that aren't public yet, but I can put them online for your perusal. > > AFAICS, you have benchmarks for IterateeM-driven code already: > http://inmachina.net/~jwlato/haskell/iteratee/tests/benchmarks.hs Those will make more sense when I've added the context of the codebases in use. There are several more sets of output that I simply haven't published yet, including bytestring-based variants. > > John Millikin wrote: > >> I wrote some criterion benchmarks for IterateeM vs IterateeCPS, and >> the CPS version was notably slower. I don't understand enough about >> CPS to diagnose why, but the additional runtime was present in even >> simple cases (reading from a file, writing back out). That's very interesting. I wonder if I'll see the same, and if I'd be able to figure it out myself... Did you benchmark any cases without doing IO? Sometimes the cost of the IO can overwhelm any other measurable differences, and also disk caching can affect results. Criterion should highlight any major outliers, but I still like to avoid IO when benchmarking unless strictly necessary. > > @jmillikin: > Could you please publish those benchmarks? +1 John From spam at scientician.net Fri Feb 5 12:09:02 2010 From: spam at scientician.net (Bardur Arantsson) Date: Fri Feb 5 11:40:52 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: <910ddf451002041744r363954a9ne42527d23bee6d2e@mail.gmail.com> References: <910ddf451002041744r363954a9ne42527d23bee6d2e@mail.gmail.com> Message-ID: Thomas Hartman wrote: > Do you have a test script to reproduce the behavior? > Unfortunately not, but the behavior *is* 100% reproducible with my PS3 client. The production of a leaked FD appears to require a particularly abrupt disconnect (see my other reply in this thread), so you're probably safe in most cases. Cheers, From jeremy at n-heptane.com Fri Feb 5 12:33:13 2010 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Fri Feb 5 12:04:39 2010 Subject: [Haskell-cafe] Re: could we get a Data instance for Data.Text.Text? In-Reply-To: References: <20100126175522.GA18671@kira.casa> Message-ID: Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: data-instance-for-text-2.dpatch Type: application/octet-stream Size: 3771 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100205/3d4e6488/data-instance-for-text-2.obj From aran.donohue at gmail.com Fri Feb 5 12:34:01 2010 From: aran.donohue at gmail.com (Aran Donohue) Date: Fri Feb 5 12:05:36 2010 Subject: [Haskell-cafe] a beginner question: decorate-op-undecorate Message-ID: Hi Haskell-Cafe, Consider a data type such as data Binding = Binding Var (Either Value [Value]) representing a variable bound either to a fixed value or that has a list of possible values. I'd like to perform an operation on say, the fixed-value members of a list of bindings. Data.Either has "partitionEithers"---I'd essentially like to use partitionEithers, but in a way that it "peeks" into the value field of the binding. For the sake of argument, let's say I can't or can't modify Binding to move the Either to the outside. What would be an idiomatic Haskell way to accomplish this? Currently I've got "liftedPartitionEithers :: [a] -> (a -> Either b c) -> ([a], [a])" which is my own version of partitionEithers that calls a selector first. Another option would be to map each Binding to a new datatype that has the Either on the outside, use partitionEithers, and map back. Thanks, Aran -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100205/781dffd5/attachment.html From gwern0 at gmail.com Fri Feb 5 12:48:36 2010 From: gwern0 at gmail.com (Gwern Branwen) Date: Fri Feb 5 12:20:01 2010 Subject: [Haskell-cafe] Anyone up for Google SoC 2010? In-Reply-To: <16442B752A06A74AB4D9F9A5FF076E4B08816DF8@ELON17P32001A.csfb.cs-group.com> References: <863507BC-FD78-49A0-9A77-C97B9431F7E7@cs.york.ac.uk> <404396ef1002031434i1f0388fduef0eab93ee040c01@mail.gmail.com> <16442B752A06A74AB4D9F9A5FF076E4B08816DF8@ELON17P32001A.csfb.cs-group.com> Message-ID: On Fri, Feb 5, 2010 at 6:20 AM, Sittampalam, Ganesh wrote: > Gwern Branwen wrote: >> On Wed, Feb 3, 2010 at 8:14 PM, Henk-Jan van Tuyl >> wrote: >>> On Wed, 03 Feb 2010 23:34:34 +0100, Neil Mitchell >>> >>> wrote: >>> >>>> Hi Gwern, >>>> >>>> Please update: "haskell-src-exts -> haskell-src" **Unknown** >>>> >>>> This project was an unqualified success. ?haskell-src-exts is now >>>> one >>>> of the most commonly used Haskell libraries, achieved the goals in >>>> the project proposal, and is an essential piece of Haskell >>>> infrastructure. >>> >>> You can see this using Roel van Dijk's reversed dependencies >>> overview [1]: 23 direct and 57 indirect dependencies on >>> haskell-src-exts-1.8.0 >>> >>> Regards, >>> Henk-Jan van Tuyl >> >> And how many of those used haskell-src-exts *before* the SoC project? >> And would have used it regardless? You can't point to a popular >> project which got a SoC student, and say look at how popular it is - >> obviously the SoC student was hugely successful. > > Regardless of that, is there any reason to disregard Neil's summary and not update your page? > > Ganesh I prefer to wait. haskell-src-exts was popular before, it was popular after. The question is not whether the patches were applied, or whether the mentor told Google it was successful, but whether it was the best possible use of the SoC slot. If features do not get used, then it wasn't a good SoC. If you know 3 or 4 uses of the new haskell-src-exts features in (relatively) major applications like hlint, then I'll concede the point and mark it a success. -- gwern From felipe.lessa at gmail.com Fri Feb 5 12:49:59 2010 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Fri Feb 5 12:21:29 2010 Subject: [Haskell-cafe] a beginner question: decorate-op-undecorate In-Reply-To: References: Message-ID: <20100205174959.GA11466@kira.casa> On Fri, Feb 05, 2010 at 12:34:01PM -0500, Aran Donohue wrote: > Hi Haskell-Cafe, > > Consider a data type such as > > data Binding = Binding Var (Either Value [Value]) > > representing a variable bound either to a fixed value or that has a list of > possible values. > > I'd like to perform an operation on say, the fixed-value members of a list > of bindings. Data.Either has "partitionEithers"---I'd essentially like to > use partitionEithers, but in a way that it "peeks" into the value field of > the binding. For the sake of argument, let's say I can't or can't modify > Binding to move the Either to the outside. > > What would be an idiomatic Haskell way to accomplish this? Currently I've > got "liftedPartitionEithers :: [a] -> (a -> Either b c) -> ([a], [a])" which > is my own version of partitionEithers that calls a selector first. Another > option would be to map each Binding to a new datatype that has the Either on > the outside, use partitionEithers, and map back. > > Thanks, > Aran > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe You could try using uniplate[1], something like transformBi (either doWhatYouLike id) I guess :). [1] http://hackage.haskell.org/package/uniplate -- Felipe. From chris at eidhof.nl Fri Feb 5 12:51:38 2010 From: chris at eidhof.nl (Chris Eidhof) Date: Fri Feb 5 12:23:06 2010 Subject: [Haskell-cafe] Two GET HTTP requests Message-ID: <1BE43023-80AC-464E-8972-65C842FBB476@eidhof.nl> Hi everyone, I'm trying to do a number of successive HTTP requests in one program. Here's what I tried: Approach 1: I used the 'download' package, which failed to install on OS X. It fails with "error: libio.h: No such file or directory". Approach 2: I installed the 'download-curl' package, and tried again. This seems to fail on the following example: > import Network.Curl.Download > > main = do x <- openURI "http://haskell.org" > y <- openURI "http://haskell.org/hoogle" > return () If I put a print statement around the second line of the do-statement it looks like openURI never returns. Approach 3: I used the simpleHTTP function from the HTTP package. This crashed, after I dug a little deeper into the code, it threw an error on calling the parseURI function (openFile: no such file exists). I installed the latest network package and upgraded my HTTP package, and the parseURI error went away. I felt like I was almost there, and tried the following: > simpleHTTP (getRequest "http://haskell.org") This failed with just the text "Bus error". I searched the HTTPBis git repository, but couldn't find the text "Bus error". I don't have a clue of how to fix this. I'm a bit stuck here, I would love to help fix the errors, but don't know what would be the best place to begin. If anyone can point me in the right direction, I will try to patch at least one of these packages. Thanks, -chris From andrewcoppin at btinternet.com Fri Feb 5 13:41:25 2010 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Feb 5 13:12:37 2010 Subject: [Haskell-cafe] Re: Trapping getChar before echo In-Reply-To: References: <3605445B-84F5-4CFF-A655-24060162FE5F@chariot.net.au><1264932763.2595.0.camel@cangaroo> <4B657E48.5040503@btinternet.com> Message-ID: <4B6C6655.1030705@btinternet.com> Tim Attwood wrote: >> Last time I tried something like this [on Windows], it didn't seem to >> work. I wanted to trap arrow keys and so forth, but they seem to be >> being used for input history. (I.e., pressing the up-arrow produces >> previously-entered lines of text, and none of this appears to be >> reaching the Haskell program itself.) Has this changed since I tried >> it last year? > > Doesn't work in windows, at least up till 6.10.1. There's a > work-around though. > > {-# LANGUAGE ForeignFunctionInterface #-} > > import Data.Char > import Control.Monad (liftM, forever) > import Foreign.C.Types > > getHiddenChar = liftM (chr.fromEnum) c_getch > foreign import ccall unsafe "conio.h getch" > c_getch :: IO CInt > > main = do > forever $ do > c <- getHiddenChar > putStrLn $ show (fromEnum c) Thanks for the info. Does anyone know how this is related to the "haskeline" package on Hackage? From mblazevic at stilo.com Fri Feb 5 13:54:23 2010 From: mblazevic at stilo.com (=?UTF-8?B?TWFyaW8gQmxhxb5ldmnEhw==?=) Date: Fri Feb 5 13:25:47 2010 Subject: [Haskell-cafe] GUI programming In-Reply-To: References: Message-ID: <4B6C695F.10205@stilo.com> Victor Nazarov wrote: > Hello, > > I've been writing some GUI application with Gtk2hs. It's an > interpreter for lambda-calculus and combinatory logic, it's GPL and if > you interested I can share it with cafe. > > The problem is that the GUI code has become very ugly and I'm tempted > to rewrite it totally. I've been looking forward to the FRP stuff, but > I've never seen a single definition of the term. Conal Eliot's > "denotational programming" is too general to be definition. I want to > try Grapefruit, but I got totally lost when I see arrow notation. > > I consider more lightweight and more imperative approach, something > closer to CSP (Communicating Secuential Processes) then FRP. I've just > crafted some sample program to illustrate my idea. > > The behaviour is a monad and it's IO monad so you can do any IO > (Gtk2hs) programming you wish. The differences is that you don't > attach static event handlers and tries to determine what to do > dependent on application state. You attach and detach handlers as much > as possible. Behaviour looks like a process that can stop execution > and wait for some GUI event. When event arrived it continues > execution. To summarize, the behaviour is a suspendable IO computation. It looks very much like a coroutine, in fact. I'm planning to extract the Control.Concurrent.Coroutine module [1] into a separate package soon. It implements a similar concept but generalized to transform any monad and any functorial suspension. [1] http://hackage.haskell.org/packages/archive/scc/0.4/doc/html/Control-Concurrent-Coroutine.html > Do you see this approach viable. There are steel some details to emerge: > * How to wait for several events > * How to handle IO exceptions I don't really know how applicable the idea is to GUI programming. That's not my area of expertise. I am surprised, though, that neither your code not your comments seem to address the issue of concurrency, as I expect that would be crucial in a GUI setting. Wouldn't you need different behaviours to run in different threads? > > Here is the code: > {-# LANGUAGE ExistentialQuantification #-} > ... I don't see the purpose of your BBind constructor. It seems to me that you could simply move the first three cases of runBehaviour implementation into your >>= and get rid of the constructor. Do you need that much laziness? > import Data.IORef > import System.Glib > import Graphics.UI.Gtk > import Control.Monad.Trans > > type Event obj = IO () -> IO (ConnectId obj) > > data Behaviour a = > forall b. BBind (Behaviour b) (b -> Behaviour a) > | BIO (IO a) > | forall obj. GObjectClass obj => BWaitEvent (Event obj) (Behaviour a) > > instance Monad Behaviour > where action >>= generator = BBind action generator > return a = BIO (return a) > > instance MonadIO Behaviour > where liftIO action = BIO action > > runBehaviour :: Behaviour a -> IO a > runBehaviour (BBind (BWaitEvent event after) f) = runBehaviour > (BWaitEvent event (after >>= f)) > runBehaviour (BBind (BIO a) f) = a >>= \x -> runBehaviour (f x) > runBehaviour (BBind (BBind a f) g) = runBehaviour (a >>= (\x -> f x >>= g)) > runBehaviour (BIO a) = a > runBehaviour (BWaitEvent event after) = > do sigIdRef <- newIORef (error "You can't access sigIdRef before > signal is connected") > sigId <- event $ > do sigId <- readIORef sigIdRef > signalDisconnect sigId > runBehaviour after > return () > writeIORef sigIdRef sigId > return (error "You can't expect result from behaviour") > > waitEvent :: GObjectClass obj => Event obj -> Behaviour () > waitEvent event = BWaitEvent event (return ()) > > main :: IO () > main = > do initGUI > window <- windowNew > onDestroy window mainQuit > set window [windowTitle := "Hello World"] > button <- buttonNew > let buttonB label = > do liftIO $ set button [buttonLabel := label] > waitEvent (onClicked button) > buttonB (label ++ "*") > runBehaviour (buttonB "*") > set window [containerChild := button] > widgetShowAll window > mainGUI > > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Mario Blazevic mblazevic@stilo.com Stilo International This message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure, copying, or distribution is strictly prohibited. If you are not the intended recipient(s) please contact the sender by reply email and destroy all copies of the original message and any attachments. From spam at scientician.net Fri Feb 5 14:06:51 2010 From: spam at scientician.net (Bardur Arantsson) Date: Fri Feb 5 13:38:48 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: References: Message-ID: I desperation, I've tried to instrument a couple of the functions in SendFile: > sendFile'' :: Socket -> Handle -> Integer -> Integer -> IO () > sendFile'' outs inp off count = > do let out_fd = Fd (fdSocket outs) > in_fd <- handleToFd inp > putStrLn ("in_fd=" ++ show in_fd) > finally (wrapSendFile' _sendFile out_fd in_fd off count) > (do > putStrLn ("SENDFILE DONE " ++ show in_fd) > ) > > sendFile' :: Socket -> FilePath -> Integer -> Integer -> IO () > sendFile' outs infp offset count = > bracket > (openBinaryFile infp ReadMode) > (\h -> do > putStrLn "CLOSING FILE!" > hClose h > putStrLn "FILE CLOSED!") > (\inp -> sendFile'' outs inp offset count) (Yes, this made me feel dirty.) Here's the resulting output from around when the file descriptor gets lost: --- Serving file 'X'... Sending 674465792 bytes... in_fd=7 SENDFILE DONE 7 CLOSING FILE! FILE CLOSED! hums: Network.Socket.SendFile.Linux: resource vanished (Broken pipe) Got request for CONTENT for objectId=1700000000000000,f215040000000000 Serving file 'X'... Sending 672892928 bytes... in_fd=7 SENDFILE DONE 7 CLOSING FILE! FILE CLOSED! hums: Network.Socket.SendFile.Linux: resource vanished (Broken pipe) Got request for CONTENT for objectId=1700000000000000,f215040000000000 Serving file 'X'... Sending 670140416 bytes... in_fd=7 <*----- What happened here? Got request for CONTENT for objectId=1700000000000000,f215040000000000 Serving file 'X'... Sending 667256832 bytes... in_fd=9 SENDFILE DONE 9 CLOSING FILE! FILE CLOSED! hums: Network.Socket.SendFile.Linux: resource vanished (Broken pipe) Got request for CONTENT for objectId=1700000000000000,f215040000000000 Serving file 'X'... Sending 665028608 bytes... in_fd=9 SENDFILE DONE 9 CLOSING FILE! FILE CLOSED! hums: Network.Socket.SendFile.Linux: resource vanished (Broken pipe) Got request for CONTENT for objectId=1700000000000000,f215040000000000 Serving file 'X'... --- Anyone got any clues as to what might cause the behavior show at the mark? The only idea I have is that *something* in the SendFile library kills the thread completely (or somehow evades "finally"), but I have no idea what it might be. Cheers, From rogerking915 at yahoo.com Fri Feb 5 14:49:44 2010 From: rogerking915 at yahoo.com (Roger King) Date: Fri Feb 5 14:21:08 2010 Subject: [Haskell-cafe] Simulation of interconnect network Message-ID: <775332.67358.qm@web57607.mail.re1.yahoo.com> I am building a simulator for an interconnect network for a multiprocessor computer. I would like to develop it in Haskell as an opportunity to learn Haskell. The network will have a number of routers with input ports and output ports and crossbars between them. I would like to simulate the protocol. This would be an event driven simulator. It would be at a high level, leaving out many details. I would like it to be fast and be able to run it on several processors. I would like to know if you have any advice. Has anyone done this before? Are there any discrete event simulators written in Haskell? R From ekmett at gmail.com Fri Feb 5 14:55:50 2010 From: ekmett at gmail.com (Edward Kmett) Date: Fri Feb 5 14:27:14 2010 Subject: [Haskell-cafe] Anyone up for Google SoC 2010? In-Reply-To: References: <863507BC-FD78-49A0-9A77-C97B9431F7E7@cs.york.ac.uk> <404396ef1002031434i1f0388fduef0eab93ee040c01@mail.gmail.com> <16442B752A06A74AB4D9F9A5FF076E4B08816DF8@ELON17P32001A.csfb.cs-group.com> Message-ID: <7fb8f82f1002051155u60ca768fg9d536f500e679c72@mail.gmail.com> You can add me to the list of voices that were unwilling to use it before the summer-of-code project due to the random incompatibilities caused by the huge supply of extensions it supported out of the box, but who were happy to switch to it after the changes were made to make them configurable. That said, I don't support a major public application. But keep in mind haskell-src-exts is used by almost every quasiquoter that wants antiquotation, so the improvements in mere compatibility with Haskell 98 as a baseline have had fairly wide-reaching impact, affecting almost every one of those 23 (or 57 depending how you count) dependencies on the haskell-src-exts library. One might argue that that well exceeds your 3 or 4 feature user guideline. =) The rest is just gravy that happens to permit a number of applications such as refactoring browsers that were impossible with the previous implementation. And, as I recall, the fairly radical exploratory "pretty print . parse = id" goal was explicitly listed merely as a secondary goal on the original application. It seems hardly appropriate to judge the impact of the entire SoC effort on the impact of that secondary exploratory component. -Edward Kmett On Fri, Feb 5, 2010 at 12:48 PM, Gwern Branwen wrote: > On Fri, Feb 5, 2010 at 6:20 AM, Sittampalam, Ganesh > wrote: > > Gwern Branwen wrote: > >> On Wed, Feb 3, 2010 at 8:14 PM, Henk-Jan van Tuyl > >> wrote: > >>> On Wed, 03 Feb 2010 23:34:34 +0100, Neil Mitchell > >>> > >>> wrote: > >>> > >>>> Hi Gwern, > >>>> > >>>> Please update: "haskell-src-exts -> haskell-src" **Unknown** > >>>> > >>>> This project was an unqualified success. haskell-src-exts is now > >>>> one > >>>> of the most commonly used Haskell libraries, achieved the goals in > >>>> the project proposal, and is an essential piece of Haskell > >>>> infrastructure. > >>> > >>> You can see this using Roel van Dijk's reversed dependencies > >>> overview [1]: 23 direct and 57 indirect dependencies on > >>> haskell-src-exts-1.8.0 > >>> > >>> Regards, > >>> Henk-Jan van Tuyl > >> > >> And how many of those used haskell-src-exts *before* the SoC project? > >> And would have used it regardless? You can't point to a popular > >> project which got a SoC student, and say look at how popular it is - > >> obviously the SoC student was hugely successful. > > > > Regardless of that, is there any reason to disregard Neil's summary and > not update your page? > > > > Ganesh > > I prefer to wait. haskell-src-exts was popular before, it was popular > after. The question is not whether the patches were applied, or > whether the mentor told Google it was successful, but whether it was > the best possible use of the SoC slot. If features do not get used, > then it wasn't a good SoC. If you know 3 or 4 uses of the new > haskell-src-exts features in (relatively) major applications like > hlint, then I'll concede the point and mark it a success. > > -- > gwern > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100205/18d07f0e/attachment.html From bos at serpentine.com Fri Feb 5 15:14:21 2010 From: bos at serpentine.com (Bryan O'Sullivan) Date: Fri Feb 5 14:45:46 2010 Subject: [Haskell-cafe] Re: could we get a Data instance for Data.Text.Text? In-Reply-To: References: <20100126175522.GA18671@kira.casa> Message-ID: On Fri, Feb 5, 2010 at 9:33 AM, Jeremy Shaw wrote: > I have attached a new version that should work with GHC 6.10, though I have > not tested it. > Thanks. I fixed the compilation warning, added a Data instance for lazy Text, and released 0.7.1.0. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100205/6220e81f/attachment.html From bos at serpentine.com Fri Feb 5 15:33:00 2010 From: bos at serpentine.com (Bryan O'Sullivan) Date: Fri Feb 5 15:04:24 2010 Subject: [Haskell-cafe] online Real World Haskell - tool used? In-Reply-To: References: Message-ID: On Thu, Feb 4, 2010 at 7:51 PM, Sophie wrote: > > I believe the online Real World Haskell book with commenting system was > generated with an open-source tool (written by one of the authors?). Any > idea where I might find this? See http://bitbucket.org/bos/hgbook for the code. > I am also curious what authoring tools were used to write the book. DocBook, emacs, and vi. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100205/b9f53173/attachment.html From niklas.broberg at gmail.com Fri Feb 5 15:38:13 2010 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Fri Feb 5 15:09:37 2010 Subject: [Haskell-cafe] Anyone up for Google SoC 2010? In-Reply-To: <7fb8f82f1002051155u60ca768fg9d536f500e679c72@mail.gmail.com> References: <863507BC-FD78-49A0-9A77-C97B9431F7E7@cs.york.ac.uk> <404396ef1002031434i1f0388fduef0eab93ee040c01@mail.gmail.com> <16442B752A06A74AB4D9F9A5FF076E4B08816DF8@ELON17P32001A.csfb.cs-group.com> <7fb8f82f1002051155u60ca768fg9d536f500e679c72@mail.gmail.com> Message-ID: On Fri, Feb 5, 2010 at 8:55 PM, Edward Kmett wrote: > You can add me to the list of voices that were unwilling to use it before > the summer-of-code project due to the random incompatibilities caused by the > huge supply of extensions it supported out of the box, but who were happy to > switch to it after the changes were made to make them configurable. This was indeed the main priority of the project, and the reason why even I would not have recommended anyone to use haskell-src-exts in production before the project. > The rest is just gravy that happens to permit a number of applications such > as refactoring browsers that were impossible with the previous > implementation. And, as I recall, the fairly radical exploratory "pretty > print . parse = id" goal was explicitly listed merely as a secondary goal on > the original application. Indeed it was, and I am not aware of any major applications that actually use the exact-print functionality yet (please, tell me if you have one!). I do know of several that make very good use of the new Annotated syntax tree, though, which was introduced as a step towards exact-printing. The benefits of that, together with the configurable extensions, is more than enough to now make me happily recommend haskell-src-exts to anyone working with Haskell source code in any application. The rest is, as you accurately put it, just gravy. I must admit I'm a bit sad to have the value of my project questioned in this way, a project that I myself was more than pleased with, both with the actual work achieved and the significant positive feedback I have received after its conclusion. If haskell-src-exts was indeed popular even before the project, that's all well and good to me. But it doesn't mean that the library offered to the users then was satisfactory, nor does it mean that the project failed to deliver something that those same users needed and/or could make good use of. Even if the number of direct users did not rise dramatically as a consequence of the project, why would it not be valid use of a project slot to greatly improve a library that was already popular? Browsing the numbers [1] posted by Don Stewart in September last year (the Haskell Symposium figures, which is the latest I could find) suggests a substantial increase of downloads of the package both before, during and after the project, but I can only speculate why. And since the project concluded late August, figures for September and onwards would have been more telling. I'm at a loss as to what criteria is actually used to judge success here. It seems to me a bit like the eternal discussion between "basic research" and "applied research". Just because something (research/library/project) doesn't have an immediate, palpable impact and/or delivers a visible tool, that certainly doesn't imply that it doesn't have merit or won't have as profound an impact on the domain, if more diffuse than a tool (or other palpable deliverable) would. /Niklas [1] http://www.galois.com/~dons/hackage/september-2009/total-downloads.html From ryani.spam at gmail.com Fri Feb 5 15:39:23 2010 From: ryani.spam at gmail.com (Ryan Ingram) Date: Fri Feb 5 15:10:46 2010 Subject: [Haskell-cafe] Re: Generating repeatable arbitrary values with QuickCheck 2 In-Reply-To: <4B6C1AEA.3010400@van.steenbergen.nl> References: <3c6288ab1002011354j7909e2a4w6116ff685c081224@mail.gmail.com> <3c6288ab1002020434l496d0f41se869234ad0968de4@mail.gmail.com> <2f9b2d31002021048s3399622cyf3743531a3abfd64@mail.gmail.com> <49a77b7a1002021125k4f260adakdbcb187f873412e@mail.gmail.com> <2f9b2d31002021404v6b3a86a7id0cf612e2f9573f7@mail.gmail.com> <4B6C1AEA.3010400@van.steenbergen.nl> Message-ID: <2f9b2d31002051239s5291b7b8i571ea240271f3787@mail.gmail.com> On Fri, Feb 5, 2010 at 5:19 AM, Martijn van Steenbergen wrote: > Ryan Ingram wrote: >> >> Unfortunately, this makes things like >>> >>> infinite_xs <- sequence (repeat arbitrary) >> >> no longer work, since the state never comes out the other side. > > You're asking to execute an infinite number of monadic actions. How can this > ever terminate at all? Stefan already gave an example, but to explain slightly further -- There's nothing "magical" about monadic actions. It's just another function call. In the case of QuickCheck, Gen is a reader monad with a "broken" >>= that changes the state of the generator passed to each side: > newtype Gen a = Gen (Int -> StdGen -> a) > generate n g (Gen f) = f n g > > return x = Gen (\_ _ -> x) > m >>= f = Gen mbindf where > mbindf n g = b where > (g1,g2) = split g > a = generate n g1 m > b = generate n g2 (f a) Now, to see how this generates data for an infinite list, just consider > sequence [arbitrary, ... which we can represent as > sequence (arbitrary:undefined) Recall the definition of sequence: > sequence [] = return [] > sequence (a:as) = do > x <- a > xs <- sequence as > return (x:xs) If we are ever required to evaluate the rest of the list, we'll get undefined and computation will fail. The goal is to get something out of the computation without needing to do so; if that works, then it will work for (arbitrary:arbitrary:undefined) and so on up to an infinite list of actions. Let's try it! generate 42 g $ sequence (aribtrary : undefined) = generate 42 sg $ do x <- arbitrary xs <- sequence undefined return (x:xs) = generate 42 sg ( arbitrary >>= \x -> sequence undefined >>= \xs -> return (x:xs) ) = let m = arbitrary f = \x -> sequence undefined >>= \xs -> return (x:xs) mbindf n g = b where (g1,g2) = split g a = generate n g m b = generate n g (f a) in generate 42 sg (Gen mbindf) = let ... in mbindf 42 sg = let m = arbitrary f = \x -> sequence undefined >>= \xs -> return (x:xs) n = 42 g = sg (g1,g2) = split g a = generate n g1 m b = generate n g2 (f a) in b = let ... in generate n g2 (f a) = let ... in generate n g2 (sequence undefined >>= \xs -> return (a:xs) = let m = arbitrary n = 42 g = sg (g1,g2) = split g a = generate n g1 m m1 = sequence undefined f = \xs -> return (a:xs) mbindf n1 g3 = b where (g4,g5) = split g3 a1 = generate n1 g4 m1 b = generate n1 g5 (f a1) in generate n g2 (Gen mbindf) = let ... in mbindf n g2 = let m = arbitrary n = 42 g = sg (g1,g2) = split g a = generate n g1 m m1 = sequence undefined f = \xs -> return (a:xs) (g4,g5) = split g2 a1 = generate n g4 m1 b = generate n g5 (f a1) in generate n g5 (f a1) = let ... in generate n g5 (return (a:a1)) = let ... in generate n g5 (Gen (\_ _ -> (a:a1))) = let ... in (\_ _ -> (a:a1)) n g5 = let ... in (a:a1) = let ... in (generate n g1 m : a1) = let ... in (generate n g1 arbitrary : a1) = let ... in ( : a1) We have now output a cons cell with an arbitrary value without even evaluating the rest of the input to sequence (which is undefined; could have been 'repeat aribtrary' or anything else) Lazy evaluation is pretty neat :) -- ryan From gwern0 at gmail.com Fri Feb 5 16:22:05 2010 From: gwern0 at gmail.com (Gwern Branwen) Date: Fri Feb 5 15:53:33 2010 Subject: [Haskell-cafe] Anyone up for Google SoC 2010? In-Reply-To: References: <863507BC-FD78-49A0-9A77-C97B9431F7E7@cs.york.ac.uk> <404396ef1002031434i1f0388fduef0eab93ee040c01@mail.gmail.com> <16442B752A06A74AB4D9F9A5FF076E4B08816DF8@ELON17P32001A.csfb.cs-group.com> <7fb8f82f1002051155u60ca768fg9d536f500e679c72@mail.gmail.com> Message-ID: On Fri, Feb 5, 2010 at 3:38 PM, Niklas Broberg wrote: > I'm at a loss as to what criteria is actually used to judge success > here. It seems to me a bit like the eternal discussion between "basic > research" and "applied research". Just because something > (research/library/project) doesn't have an immediate, palpable impact > and/or delivers a visible tool, that certainly doesn't imply that it > doesn't have merit or won't have as profound an impact on the domain, > if more diffuse than a tool (or other palpable deliverable) would. > > /Niklas There may be an eternal discussion on it, but it seems pretty clear to me which side SoC comes down on: http://code.google.com/soc/ "Through Google Summer of Code, accepted student applicants are paired with a mentor or mentors from the participating projects, thus gaining exposure to real-world software development scenarios and the opportunity for employment in areas related to their academic pursuits. In turn, the participating projects are able to more easily identify and bring in new developers. Best of all, more source code is created and released for the use and benefit of all." or http://socghop.appspot.com/document/show/program/google/gsoc2009/faqs#goals # Google Summer of Code has several goals: * Get more open source code created and released for the benefit of all * Inspire young developers to begin participating in open source development * Help open source projects identify and bring in new developers and committers * Provide students the opportunity to do work related to their academic pursuits during the summer (think "flip bits, not burgers") * Give students more exposure to real-world software development scenarios (e.g., distributed development, software licensing questions, mailing-list etiquette) -- gwern From niklas.broberg at gmail.com Fri Feb 5 16:33:19 2010 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Fri Feb 5 16:04:46 2010 Subject: [Haskell-cafe] Anyone up for Google SoC 2010? In-Reply-To: References: <863507BC-FD78-49A0-9A77-C97B9431F7E7@cs.york.ac.uk> <404396ef1002031434i1f0388fduef0eab93ee040c01@mail.gmail.com> <16442B752A06A74AB4D9F9A5FF076E4B08816DF8@ELON17P32001A.csfb.cs-group.com> <7fb8f82f1002051155u60ca768fg9d536f500e679c72@mail.gmail.com> Message-ID: > There may be an eternal discussion on it, but it seems pretty clear to > me which side SoC comes down on: http://code.google.com/soc/ I'm really not sure what you're getting at. How do the points you list not relate to my project? And how does my analogy contradict any of those points? If the goal is to have "more source code [..] created and released for the use and benefit of all", how does my project fail to achieve this? /Niklas From malcolm.wallace at cs.york.ac.uk Fri Feb 5 16:40:02 2010 From: malcolm.wallace at cs.york.ac.uk (Malcolm Wallace) Date: Fri Feb 5 16:11:26 2010 Subject: [Haskell-cafe] Anyone up for Google SoC 2010? In-Reply-To: References: <863507BC-FD78-49A0-9A77-C97B9431F7E7@cs.york.ac.uk> <404396ef1002031434i1f0388fduef0eab93ee040c01@mail.gmail.com> <16442B752A06A74AB4D9F9A5FF076E4B08816DF8@ELON17P32001A.csfb.cs-group.com> <7fb8f82f1002051155u60ca768fg9d536f500e679c72@mail.gmail.com> Message-ID: <164A8AF0-8668-469C-A991-53CC8345312B@cs.york.ac.uk> > If the goal is to have "more source code [..] created > and released for the use and benefit of all", how does my project fail > to achieve this? Also, it is worth pointing out that from Google's point of view, they are most interested in whether the programme yields students who stick around and continue to contribute to open source projects. I think Niklas and his HSE library very visibly pass on both criteria - quality code that is actively used, and a continuing contribution. Regards, Malcolm From dave at zednenem.com Fri Feb 5 17:13:47 2010 From: dave at zednenem.com (David Menendez) Date: Fri Feb 5 16:45:09 2010 Subject: [Haskell-cafe] Re: Generating repeatable arbitrary values with QuickCheck 2 In-Reply-To: <2f9b2d31002051239s5291b7b8i571ea240271f3787@mail.gmail.com> References: <3c6288ab1002011354j7909e2a4w6116ff685c081224@mail.gmail.com> <3c6288ab1002020434l496d0f41se869234ad0968de4@mail.gmail.com> <2f9b2d31002021048s3399622cyf3743531a3abfd64@mail.gmail.com> <49a77b7a1002021125k4f260adakdbcb187f873412e@mail.gmail.com> <2f9b2d31002021404v6b3a86a7id0cf612e2f9573f7@mail.gmail.com> <4B6C1AEA.3010400@van.steenbergen.nl> <2f9b2d31002051239s5291b7b8i571ea240271f3787@mail.gmail.com> Message-ID: <49a77b7a1002051413k325d569byda10fe4ac0c4577b@mail.gmail.com> On Fri, Feb 5, 2010 at 3:39 PM, Ryan Ingram wrote: > On Fri, Feb 5, 2010 at 5:19 AM, Martijn van Steenbergen > wrote: >> Ryan Ingram wrote: >>> >>> Unfortunately, this makes things like >>>> >>>> ?infinite_xs <- sequence (repeat arbitrary) >>> >>> no longer work, since the state never comes out the other side. >> >> You're asking to execute an infinite number of monadic actions. How can this >> ever terminate at all? > > Stefan already gave an example, but to explain slightly further -- > > There's nothing "magical" about monadic actions. ?It's just another > function call. > > In the case of QuickCheck, Gen is a reader monad with a "broken" >>= > that changes the state of the generator passed to each side: Incidentally, the alternative Gen I suggested also works for infinite lists. (It's equivalent to StateT StdGen (Reader Int), using the StateT from Control.Monad.State.Lazy.) The problem, as Ryan pointed out, is that you can't access the state after the infinite computation, so you can't create two infinite streams or an infinite tree, which the current definition of Gen allows. More concretely, this works fine: stream = do x <- arbitrary xs <- stream return (x:xs) but you can't call arbitrary after you call stream broken = do xs <- stream y <- arbitrary -- can't evaluate until stream is fully evaluated (i.e., never) The present definition of Gen avoids this by splitting the StdGen at every >>=, but that creates the situation where two expressions which should be equivalent produce different results in some contexts. It isn't clear to me which implementation is best. I lean towards the StateT-like implementation, on the theory that it's limitations are easier to explain, but I guess it comes down to whether we want to make life easier for (a) people creating infinite structures or (b) people who need reproducible results. -- Dave Menendez From judah.jacobson at gmail.com Fri Feb 5 18:38:52 2010 From: judah.jacobson at gmail.com (Judah Jacobson) Date: Fri Feb 5 18:10:36 2010 Subject: [Haskell-cafe] Re: Trapping getChar before echo In-Reply-To: <4B6C6655.1030705@btinternet.com> References: <3605445B-84F5-4CFF-A655-24060162FE5F@chariot.net.au> <1264932763.2595.0.camel@cangaroo> <4B657E48.5040503@btinternet.com> <4B6C6655.1030705@btinternet.com> Message-ID: <6d74b0d21002051538l92d1f9fq1e5abe5a84ea1bee@mail.gmail.com> On Fri, Feb 5, 2010 at 10:41 AM, Andrew Coppin wrote: > Tim Attwood wrote: >>> >>> Last time I tried something like this [on Windows], it didn't seem to >>> work. I wanted to trap arrow keys and so forth, but they seem to be being >>> used for input history. (I.e., pressing the up-arrow produces >>> previously-entered lines of text, and none of this appears to be reaching >>> the Haskell program itself.) Has this changed since I tried it last year? >> >> Doesn't work in windows, at least up till 6.10.1. There's a work-around >> though. >> >> {-# LANGUAGE ForeignFunctionInterface #-} >> >> import Data.Char >> import Control.Monad (liftM, forever) >> import Foreign.C.Types >> >> getHiddenChar = liftM (chr.fromEnum) c_getch >> foreign import ccall unsafe "conio.h getch" >> ?c_getch :: IO CInt >> >> main = do >> ?forever $ do >> ? ? c <- getHiddenChar >> ? ? putStrLn $ show (fromEnum c) > > Thanks for the info. > > Does anyone know how this is related to the "haskeline" package on Hackage? The haskeline package provides a readline-like library for reading in a line of input with arrow keys, tab completion, etc. It works on both Windows and unix platforms. Documentation and a full list of features can be found at http://trac.haskell.org/haskeline/ . On Windows, haskeline gets all user input by calling Win32 API functions such as ReadConsoleInputW: http://msdn.microsoft.com/en-us/library/ms684961%28VS.85%29.aspx That function returns an INPUT_RECORD struct with information about key press events (among others); those includes simple characters, arrow keys, page up/down, etc. AFAIK that's the only way to get at such events in the Windows console; there's no effective analogue to the unix setting, where e.g. pressing the up key causes stdin to receive the ANSI key sequence "\ESC[A". The source code of haskeline has examples of how to import and use those API functions: http://code.haskell.org/haskeline/System/Console/Haskeline/Backend/Win32.hsc Best, -Judah From allbery at ece.cmu.edu Fri Feb 5 19:13:28 2010 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Fri Feb 5 18:45:10 2010 Subject: [Haskell-cafe] a beginner question: decorate-op-undecorate In-Reply-To: References: Message-ID: <37091104-F280-436C-BD65-E5CEC5829158@ece.cmu.edu> Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100205/088372a6/PGP.bin From allbery at ece.cmu.edu Fri Feb 5 19:24:17 2010 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Fri Feb 5 18:56:07 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: References: Message-ID: <5679D446-9E50-4DFB-AFBD-E9532C3DCF0B@ece.cmu.edu> On Feb 5, 2010, at 02:56 , Bardur Arantsson wrote: > I should have posted this earlier, but the exact message I'm seeing > in the case where the Bad Client disconnects is this: > > hums: Network.Socket.SendFile.Linux: resource vanished (Broken pipe) > > Oddly, I haven't been able to reproduce this using a wget client > with a ^C during transfer. When I "disconnect" wget with ^C or > "pkill wget" or even "pkill -9 wget", I get this message: > > hums: Network.Socket.SendFile.Linux: resource vanished (Connection > reset by peer) > > (and no leak, as observed by "lsof | grep hums"). "Broken pipe" is normally handled as a signal, and is only mapped to an error if SIGPIPE is set to SIG_IGN. I can well imagine that the SIGPIPE signal handler isn't closing resources properly; a workaround would be to use the System.Posix.Signals API to ignore SIGPIPE, but I don't know if that would work as a general solution (it would depend on what other uses of pipes/sockets exist). -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100205/cc1a30d7/PGP.bin From lrpalmer at gmail.com Fri Feb 5 19:24:41 2010 From: lrpalmer at gmail.com (Luke Palmer) Date: Fri Feb 5 18:56:12 2010 Subject: [Haskell-cafe] a beginner question: decorate-op-undecorate In-Reply-To: References: Message-ID: <7ca3f0161002051624v27e3b389p10e77e0f72a7e10@mail.gmail.com> On Fri, Feb 5, 2010 at 10:34 AM, Aran Donohue wrote: > What would be an idiomatic Haskell way to accomplish this? Currently I've > got "liftedPartitionEithers :: [a] -> (a -> Either b c) -> ([a], [a])"?which > is my own version of partitionEithers that calls a selector first. Since you are not using b or c anywhere else, the only thing you care about in that Either is whether it is Left or Right. Which makes it seem much more like a Bool. After this conversion, I can hoogle for your signature. http://haskell.org/hoogle/?hoogle=[a]+-%3E+%28a+-%3E+Bool%29+-%3E+%28[a]%2C[a]%29 Which gives, among other things, Data.List.partition :: (a -> Bool) -> [a] -> ([a],[a]). Without more details about the precise thing you want to accomplish, I don't know what else to say. Many idioms are about the details of the problem, even down to argument order. Luke From allbery at ece.cmu.edu Fri Feb 5 19:40:24 2010 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Fri Feb 5 19:12:00 2010 Subject: [Haskell-cafe] a beginner question: decorate-op-undecorate In-Reply-To: <37091104-F280-436C-BD65-E5CEC5829158@ece.cmu.edu> References: <37091104-F280-436C-BD65-E5CEC5829158@ece.cmu.edu> Message-ID: <1C2F8FF0-F26C-44F0-8989-E3AB6D28DC06@ece.cmu.edu> Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100205/57192dfd/PGP.bin From aran.donohue at gmail.com Fri Feb 5 21:23:27 2010 From: aran.donohue at gmail.com (Aran Donohue) Date: Fri Feb 5 20:54:52 2010 Subject: [Haskell-cafe] a beginner question: decorate-op-undecorate In-Reply-To: <7ca3f0161002051624v27e3b389p10e77e0f72a7e10@mail.gmail.com> References: <7ca3f0161002051624v27e3b389p10e77e0f72a7e10@mail.gmail.com> Message-ID: Thanks for the helpful thoughts. I guess I was just reaching for a Haskell version of a programming pattern from other languages---dealing with baggage if you will. Thanks, Aran On Fri, Feb 5, 2010 at 7:24 PM, Luke Palmer wrote: > On Fri, Feb 5, 2010 at 10:34 AM, Aran Donohue > wrote: > > What would be an idiomatic Haskell way to accomplish this? Currently I've > > got "liftedPartitionEithers :: [a] -> (a -> Either b c) -> ([a], > [a])" which > > is my own version of partitionEithers that calls a selector first. > > Since you are not using b or c anywhere else, the only thing you care > about in that Either is whether it is Left or Right. Which makes it > seem much more like a Bool. After this conversion, I can hoogle for > your signature. > > > http://haskell.org/hoogle/?hoogle=[a]+-%3E+%28a+-%3E+Bool%29+-%3E+%28[a]%2C[a]%29 > > Which gives, among other things, Data.List.partition :: (a -> Bool) -> > [a] -> ([a],[a]). > > Without more details about the precise thing you want to accomplish, I > don't know what else to say. Many idioms are about the details of the > problem, even down to argument order. > > Luke > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100205/54d9c8eb/attachment.html From ivan.miljenovic at gmail.com Fri Feb 5 21:33:18 2010 From: ivan.miljenovic at gmail.com (Ivan Miljenovic) Date: Fri Feb 5 21:04:42 2010 Subject: [Haskell-cafe] cabal fun (not) In-Reply-To: <4B6C33D7.70306@imn.htwk-leipzig.de> References: <4B6C33D7.70306@imn.htwk-leipzig.de> Message-ID: On 6 February 2010 01:05, Johannes Waldmann wrote: > so please please please have "cabal install" fail with some error > message if (that is, before) the install would break anything. - J. If you upgrade a library, it will break all other libraries that depend upon it. "ghc-pkg list" will tell you which libraries are broken and need to be rebuilt. -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com Joan Crawford - "I, Joan Crawford, I believe in the dollar. Everything I earn, I spend." - http://www.brainyquote.com/quotes/authors/j/joan_crawford.html From jmillikin at gmail.com Fri Feb 5 23:25:43 2010 From: jmillikin at gmail.com (John Millikin) Date: Fri Feb 5 22:57:26 2010 Subject: [Haskell-cafe] safe lazy IO or Iteratee? In-Reply-To: <9979e72e1002050856i39787fa0y9023f3fe533f0587@mail.gmail.com> References: <9979e72e1002050604k1668b9a9h39cf1cb305fe7b3b@mail.gmail.com> <3283f7fe1002050734v5e330e6co7361f2c09b01940b@mail.gmail.com> <9979e72e1002050856i39787fa0y9023f3fe533f0587@mail.gmail.com> Message-ID: <3283f7fe1002052025t728421e4n44cd405ebcb1e147@mail.gmail.com> Benchmark attached. It just enumerates a list until EOF is reached. An interesting thing I've noticed is that IterateeMCPS performs better with no optimization, but -O2 gives IterateeM the advantage. Their relative performance depends heavily on the chunk size -- for example, CPS is much faster at chunk size 1, but slower with 100-element chunks. On Fri, Feb 5, 2010 at 08:56, John Lato wrote: > On Fri, Feb 5, 2010 at 4:31 PM, Valery V. Vorotyntsev > wrote: >>> John Lato wrote: >>> >>>> Both designs appear to offer similar performance in aggregate, >>>> although there are differences for particular functions. ?I haven't >>>> yet had a chance to test the performance of the CPS variant, although >>>> Oleg has indicated he expects it will be higher. >> >> @jwlato: >> Do you mind creating `IterateeCPS' tree in >> , so we can >> start writing CPS performance testing code? > > I'm working on the CPS version and will make it public when it's done. > ?It may take a week or so; this term started at 90 and has picked up. > I have several benchmark sources that aren't public yet, but I can put > them online for your perusal. > >> >> AFAICS, you have benchmarks for IterateeM-driven code already: >> http://inmachina.net/~jwlato/haskell/iteratee/tests/benchmarks.hs > > Those will make more sense when I've added the context of the > codebases in use. ?There are several more sets of output that I simply > haven't published yet, including bytestring-based variants. > >> >> John Millikin wrote: >> >>> I wrote some criterion benchmarks for IterateeM vs IterateeCPS, and >>> the CPS version was notably slower. I don't understand enough about >>> CPS to diagnose why, but the additional runtime was present in even >>> simple cases (reading from a file, writing back out). > > That's very interesting. ?I wonder if I'll see the same, and if I'd be > able to figure it out myself... > > Did you benchmark any cases without doing IO? ?Sometimes the cost of > the IO can overwhelm any other measurable differences, and also disk > caching can affect results. ?Criterion should highlight any major > outliers, but I still like to avoid IO when benchmarking unless > strictly necessary. > >> >> @jmillikin: >> Could you please publish those benchmarks? > > +1 > > John > -------------- next part -------------- A non-text attachment was scrubbed... Name: benchmark.hs Type: text/x-haskell Size: 1401 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100205/b0d3543a/benchmark.bin From magnus at therning.org Sat Feb 6 01:17:24 2010 From: magnus at therning.org (Magnus Therning) Date: Sat Feb 6 00:48:45 2010 Subject: [Haskell-cafe] Re: programmatic DB interface? In-Reply-To: <4B6BF519.3080708@imn.htwk-leipzig.de> References: <4B6A70DD.8020503@imn.htwk-leipzig.de> <29bf512f1002041127x74fbf370vf2fa7a81564f3fb2@mail.gmail.com> <4B6BC313.6080200@imn.htwk-leipzig.de> <4B6BCEBF.4040509@therning.org> <4B6BCF97.3050703@imn.htwk-leipzig.de> <4B6BEDDF.9020501@imn.htwk-leipzig.de> <4B6BF519.3080708@imn.htwk-leipzig.de> Message-ID: On Fri, Feb 5, 2010 at 10:38, Johannes Waldmann wrote: > >> As I posted earlier, using 'T' to separate date and time is correct >> ISO8601 according to wikipedia[1]. > > So you're saying ?"2009-12-20 16:55:57.297" > (returned by the psql server) is wrong, > and it should instead send "2009-12-20T16:55:57.297Z" ? Well, it isn't necessarily *wrong* ;-) "2009-12-20 16:55:57.297" is made up of two pieces, one for date and one for time. "2009-12-20T16:55:57.297Z" is made up of one piece, which specifies both date and time. This is why I believe that the function ISO8601DateFormat is correct when it provides a format for a combined date and time. > What would be the query to obtain this format? > > I don't see this mentioned anyplace on > http://www.postgresql.org/docs/8.3/interactive/functions-datetime.html Neither do I, I don't find anything relating to ISO8601 dates (they seem more concerned with ISO DOW and year). > Perhaps we take this back to haskell-cafe (or libraries?) as it might be > of general interest. Sure, why not. It was most likely a mistake on my side to drop haskell-cafe in the first place. /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From spam at scientician.net Sat Feb 6 03:16:35 2010 From: spam at scientician.net (Bardur Arantsson) Date: Sat Feb 6 02:48:18 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: <5679D446-9E50-4DFB-AFBD-E9532C3DCF0B@ece.cmu.edu> References: <5679D446-9E50-4DFB-AFBD-E9532C3DCF0B@ece.cmu.edu> Message-ID: Brandon S. Allbery KF8NH wrote: > On Feb 5, 2010, at 02:56 , Bardur Arantsson wrote: [--snip--] > > "Broken pipe" is normally handled as a signal, and is only mapped to an > error if SIGPIPE is set to SIG_IGN. I can well imagine that the SIGPIPE > signal handler isn't closing resources properly; a workaround would be > to use the System.Posix.Signals API to ignore SIGPIPE, but I don't know > if that would work as a general solution (it would depend on what other > uses of pipes/sockets exist). It was a good idea, but it doesn't seem to help to add installHandler sigPIPE Ignore (Just fullSignalSet) to the main function. (Given the package name I assume System.Posix.Signals works similarly to regular old signals, i.e. globally per-process.) This is really starting to drive me round the bend... One further thing I've noticed: When compiling on my 64-bit machine, ghc issues the following warnings: Linux.hsc:41: warning: format ?%d? expects type ?int?, but argument 3 has type ?long unsigned int? Linux.hsc:45: warning: format ?%d? expects type ?int?, but argument 3 has type ?long unsigned int? Linux.hsc:45: warning: format ?%d? expects type ?int?, but argument 3 has type ?long unsigned int? Linux.hsc:45: warning: format ?%d? expects type ?int?, but argument 3 has type ?long unsigned int? Those lines are: 39: -- max num of bytes in one send 40: maxBytes :: Int64 41: maxBytes = fromIntegral (maxBound :: (#type ssize_t)) and 44: foreign import ccall unsafe "sendfile64" c_sendfile 45: :: Fd -> Fd -> Ptr (#type off_t) -> (#type size_t) -> IO (#type ssize_t) This looks like a typical 32/64-bit problem, but normally I would expect any real run-time problems caused by a problematic conversion in the FFI to crash the whole process. Maybe I'm wrong about this... Cheers, From stephen.tetley at gmail.com Sat Feb 6 03:29:16 2010 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Sat Feb 6 03:00:37 2010 Subject: [Haskell-cafe] a beginner question: decorate-op-undecorate In-Reply-To: References: <7ca3f0161002051624v27e3b389p10e77e0f72a7e10@mail.gmail.com> Message-ID: <5fdc56d71002060029x3c9ea436u174ff6c31284b7c3@mail.gmail.com> Hello Aran Changing to an explicit sum type rather than using Either might subsequent functions that process a Binding cleaner: data Binding = BoundVar Var Value | PossiblyBound Var [Value] Naturally you might want to consider a better constructor name than 'PossiblyBound'. -- As an open question to the list - the above change can be seen as a 'denormalisation' of the data type (adding redundancy), does anyone know of a reference that covers such things? The only thing I can think of close is David S. Wile's "Abstract syntax from concrete syntax"... Thanks Stephen From thaldyron at gmail.com Sat Feb 6 04:23:19 2010 From: thaldyron at gmail.com (Peter Robinson) Date: Sat Feb 6 03:55:01 2010 Subject: [Haskell-cafe] cabal fun (not) In-Reply-To: References: <4B6C33D7.70306@imn.htwk-leipzig.de> Message-ID: On 6 February 2010 03:33, Ivan Miljenovic wrote: > If you upgrade a library, it will break all other libraries that > depend upon it. ?"ghc-pkg list" will tell you which libraries are > broken and need to be rebuilt. I think you mean "ghc-pkg check". Peter From ivan.miljenovic at gmail.com Sat Feb 6 04:54:50 2010 From: ivan.miljenovic at gmail.com (Ivan Miljenovic) Date: Sat Feb 6 04:26:12 2010 Subject: [Haskell-cafe] cabal fun (not) In-Reply-To: References: <4B6C33D7.70306@imn.htwk-leipzig.de> Message-ID: On 6 February 2010 19:23, Peter Robinson wrote: > I think you mean "ghc-pkg check". Yes, I do. Whoops :s -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com Charles de Gaulle - "The better I get to know men, the more I find myself loving dogs." - http://www.brainyquote.com/quotes/authors/c/charles_de_gaulle.html From sergueyz at gmail.com Sat Feb 6 05:01:11 2010 From: sergueyz at gmail.com (Serguey Zefirov) Date: Sat Feb 6 04:32:33 2010 Subject: [Haskell-cafe] Simulation of interconnect network In-Reply-To: <775332.67358.qm@web57607.mail.re1.yahoo.com> References: <775332.67358.qm@web57607.mail.re1.yahoo.com> Message-ID: <600376291002060201g5055c8f3nd65276f7a2069d0@mail.gmail.com> 2010/2/5 Roger King : > I am building a simulator for an interconnect network for a multiprocessor computer. ?I would like to develop it in Haskell as an opportunity to learn Haskell. > > The network will have a number of routers with input ports and output ports and crossbars between them. ?I would like to simulate the protocol. ?This would be an event driven simulator. ?It would be at a high level, leaving out many details. ?I would like it to be fast and be able to run it on several processors. Crossbar is certainly easier using lazy lists of events. Like those used in Hawk: http://eprints.kfupm.edu.sa/66296/1/66296.pdf Event-driven approach is good for asynchronous behaviour, like combinatorial logic etc. For single-clock clocked logic (and crossbar is certainly that kind of device) lazy lists are simpler to write and reason about. > I would like to know if you have any advice. ?Has anyone done this before? ?Are there any discrete event simulators written in Haskell? http://hackage.haskell.org/package/hasim From jwlato at gmail.com Sat Feb 6 06:09:18 2010 From: jwlato at gmail.com (John Lato) Date: Sat Feb 6 05:40:42 2010 Subject: [Haskell-cafe] safe lazy IO or Iteratee? In-Reply-To: <3283f7fe1002052025t728421e4n44cd405ebcb1e147@mail.gmail.com> References: <9979e72e1002050604k1668b9a9h39cf1cb305fe7b3b@mail.gmail.com> <3283f7fe1002050734v5e330e6co7361f2c09b01940b@mail.gmail.com> <9979e72e1002050856i39787fa0y9023f3fe533f0587@mail.gmail.com> <3283f7fe1002052025t728421e4n44cd405ebcb1e147@mail.gmail.com> Message-ID: <9979e72e1002060309q4624820ag7190c1d7d286d364@mail.gmail.com> I've put my benchmarking code online at: http://inmachina.net/~jwlato/haskell/research-iteratee.tar.bz2 unpack it so you have this directory structure: ./iteratee ./research-iteratee/ Also download my criterionProcessor programs. The darcs repo is at http://inmachina.net/~jwlato/haskell/criterionProcessor/ to use it, go into the criterionProcessor directory, edit the testrunner.hs script for your environment, and run it. This runs all the benchmarks. Then you can use the CritProc program (build with cabal) to generate pictures. I'm pretty sure you need Chart HEAD in order to build CritProc (I hacked my Chart install, but I think the only important change has been applied to HEAD). I make no guarantees that these will all build properly, it's basically a work-in-progress dump. John On Fri, Feb 5, 2010 at 10:25 PM, John Millikin wrote: > Benchmark attached. It just enumerates a list until EOF is reached. > > An interesting thing I've noticed is that IterateeMCPS performs better > with no optimization, but -O2 gives IterateeM the advantage. Their > relative performance depends heavily on the chunk size -- for example, > CPS is much faster at chunk size 1, but slower with 100-element > chunks. > > On Fri, Feb 5, 2010 at 08:56, John Lato wrote: >> On Fri, Feb 5, 2010 at 4:31 PM, Valery V. Vorotyntsev >> wrote: >>>> John Lato wrote: >>>> >>>>> Both designs appear to offer similar performance in aggregate, >>>>> although there are differences for particular functions. ?I haven't >>>>> yet had a chance to test the performance of the CPS variant, although >>>>> Oleg has indicated he expects it will be higher. >>> >>> @jwlato: >>> Do you mind creating `IterateeCPS' tree in >>> , so we can >>> start writing CPS performance testing code? >> >> I'm working on the CPS version and will make it public when it's done. >> ?It may take a week or so; this term started at 90 and has picked up. >> I have several benchmark sources that aren't public yet, but I can put >> them online for your perusal. >> >>> >>> AFAICS, you have benchmarks for IterateeM-driven code already: >>> http://inmachina.net/~jwlato/haskell/iteratee/tests/benchmarks.hs >> >> Those will make more sense when I've added the context of the >> codebases in use. ?There are several more sets of output that I simply >> haven't published yet, including bytestring-based variants. >> >>> >>> John Millikin wrote: >>> >>>> I wrote some criterion benchmarks for IterateeM vs IterateeCPS, and >>>> the CPS version was notably slower. I don't understand enough about >>>> CPS to diagnose why, but the additional runtime was present in even >>>> simple cases (reading from a file, writing back out). >> >> That's very interesting. ?I wonder if I'll see the same, and if I'd be >> able to figure it out myself... >> >> Did you benchmark any cases without doing IO? ?Sometimes the cost of >> the IO can overwhelm any other measurable differences, and also disk >> caching can affect results. ?Criterion should highlight any major >> outliers, but I still like to avoid IO when benchmarking unless >> strictly necessary. >> >>> >>> @jmillikin: >>> Could you please publish those benchmarks? >> >> +1 >> >> John >> > From felipe.lessa at gmail.com Sat Feb 6 06:14:15 2010 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sat Feb 6 05:45:40 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: References: <5679D446-9E50-4DFB-AFBD-E9532C3DCF0B@ece.cmu.edu> Message-ID: <20100206111415.GB29938@kira.casa> On Sat, Feb 06, 2010 at 09:16:35AM +0100, Bardur Arantsson wrote: > Brandon S. Allbery KF8NH wrote: > >On Feb 5, 2010, at 02:56 , Bardur Arantsson wrote: > [--snip--] > > > >"Broken pipe" is normally handled as a signal, and is only mapped > >to an error if SIGPIPE is set to SIG_IGN. I can well imagine that > >the SIGPIPE signal handler isn't closing resources properly; a > >workaround would be to use the System.Posix.Signals API to ignore > >SIGPIPE, but I don't know if that would work as a general solution > >(it would depend on what other uses of pipes/sockets exist). > > It was a good idea, but it doesn't seem to help to add > > installHandler sigPIPE Ignore (Just fullSignalSet) > > to the main function. (Given the package name I assume > System.Posix.Signals works similarly to regular old signals, i.e. > globally per-process.) > > This is really starting to drive me round the bend... Have you seen GHC ticket #1619? http://hackage.haskell.org/trac/ghc/ticket/1619 > One further thing I've noticed: When compiling on my 64-bit machine, > ghc issues the following warnings: > > Linux.hsc:41: warning: format ?%d? expects type ?int?, but argument > 3 has type ?long unsigned int? > Linux.hsc:45: warning: format ?%d? expects type ?int?, but argument > 3 has type ?long unsigned int? > Linux.hsc:45: warning: format ?%d? expects type ?int?, but argument > 3 has type ?long unsigned int? > Linux.hsc:45: warning: format ?%d? expects type ?int?, but argument > 3 has type ?long unsigned int? > > Those lines are: > > 39: -- max num of bytes in one send > 40: maxBytes :: Int64 > 41: maxBytes = fromIntegral (maxBound :: (#type ssize_t)) > > and > > 44: foreign import ccall unsafe "sendfile64" c_sendfile > 45: :: Fd -> Fd -> Ptr (#type off_t) -> (#type size_t) -> IO > (#type ssize_t) > > This looks like a typical 32/64-bit problem, but normally I would > expect any real run-time problems caused by a problematic conversion > in the FFI to crash the whole process. Maybe I'm wrong about this... To convert those '#' constants, hsc2hs preprocessor constructs a C file things like 'printf("%d", sizeof(ssize_t))' to use the system's C compiler and avoid having the encode the ABI of every platform (to be able to know the memory layout of the structures). So that message comes from that C file, not from your Haskell one. At runtime it really doesn't matter. -- Felipe. From mark.spezzano at chariot.net.au Sat Feb 6 07:42:40 2010 From: mark.spezzano at chariot.net.au (Mark Spezzano) Date: Sat Feb 6 07:14:06 2010 Subject: [Haskell-cafe] Using ShowS or Difference Lists Message-ID: Hi, Just wondering whether I can use ShowS or tupling or Difference Lists to speed up the following code? It's basic text processing. It takes in a list of Lines where each Line is a list of Words and intersperses " " between them then concatenates them into a longer String. Note that there is a recursive call and the ++ operator. Thanks Mark -- Function: joinLines -- Joins the Words within Lines together with whitespace and newline characters -- Argument: Lines to pad with whitespace and newlines -- Evaluate: The processed and concatenated String joinLines :: [Line] -> String joinLines (l:[]) = concat (intersperse " " l) joinLines (l:ls) = (concat (intersperse " " l)) ++ ('\n':joinLines ls) From jwlato at gmail.com Sat Feb 6 07:43:03 2010 From: jwlato at gmail.com (John Lato) Date: Sat Feb 6 07:14:30 2010 Subject: [Haskell-cafe] a beginner question: decorate-op-undecorate Message-ID: <9979e72e1002060443y6c32530cya1aa75d02d9cdd87@mail.gmail.com> > From: Aran Donohue > > Hi Haskell-Cafe, > > Consider a data type such as > > data Binding = Binding Var (Either Value [Value]) > > representing a variable bound either to a fixed value or that has a list of > possible values. > > I'd like to perform an operation on say, the fixed-value members of a list > of bindings. Data.Either has "partitionEithers"---I'd essentially like to > use partitionEithers, but in a way that it "peeks" into the value field of > the binding. For the sake of argument, let's say I can't or can't modify > Binding to move the Either to the outside. I think that partitionEithers is leading you down the wrong trail. If what you want to do is modify some values inside the binding, I would start with this: > mapVal :: (Either Value [Value] -> Either Value [Value]) -> Binding -> Binding > mapVal f (Binding v e) = Binding v (f e) > > mapLeft :: (a -> b) -> Either a c -> Either b c > mapLeft f = either (Left . f) Right > > -- mapRight is just fmap, but for symmetry > mapRight :: (b -> c) -> Either a b -> Either a c > mapRight = fmap > > modifyFixed :: (Value -> Value) -> Binding -> Binding > modifyFixed f b = mapVal (mapLeft f) b > > modifyList :: ([Value] -> [Value]) -> Binding -> Binding > modifyList f b = mapVal (mapRight f) b > > -- note that modifyFixed and modifyList have very nice point-free representations > -- modifyFixed = mapVal . mapLeft > -- modifyList = mapVal . mapRight Now to apply this to a list: > modifyFixedBindings :: (Value -> Value) -> [Binding] -> [Binding] > modifyFixedBindings f binds = map (modifyFixed f) binds > -- or point-free > modifyFixedBindings' = map . modifyFixed In my opinion, this would be more idiomatic if Binding were polymorphic: > data Binding' k v = Binding' k v > > instance Functor (Binding' k) where > fmap f (Binding' k v) = Binding' k (f v) > > type Binding2 = Binding' Var (Either Value [Value]) now mapVal is just fmap, and these functions are: > modifyFixed2 :: (Val -> Val) -> [Binding2] -> [Binding2] > modifyFixed2 = fmap . fmap . mapLeft > > modifyList2 :: ([Val] -> [Val]) -> [Binding2] -> [Binding2] > modifyList2 = fmap . fmap . mapRight I've typed out all the steps for clarity, but to be honest, I wouldn't bother with the Fixed and List variants, unless you're going to use them frequently. I would do just: > mapVals :: (Either Value [Value] -> Either Value [Value]) -> [Binding] -> [Binding] > mapVals f = map (\(Binding var val) -> Binding var (f val)) and leave it at that, using "mapVals" with the "either" function when necessary. I would consider making Binding polymorphic, though, so you can write the Functor instance. You may also want to look at Data.Traversable. Cheers, John From holgersiegel74 at yahoo.de Sat Feb 6 08:14:37 2010 From: holgersiegel74 at yahoo.de (Holger Siegel) Date: Sat Feb 6 07:46:01 2010 Subject: [Haskell-cafe] Using ShowS or Difference Lists In-Reply-To: References: Message-ID: <1265462077.19949.5.camel@cornfed> Am Samstag, den 06.02.2010, 23:12 +1030 schrieb Mark Spezzano: > Hi, > > Just wondering whether I can use ShowS or tupling or Difference Lists to speed up the following code? > > It's basic text processing. It takes in a list of Lines where each Line > is a list of Words and intersperses " " between them then concatenates > them into a longer String. Note that there is a recursive call and the > ++ operator. > > Thanks > > Mark > > > -- Function: joinLines > -- Joins the Words within Lines together with whitespace and newline characters > -- Argument: Lines to pad with whitespace and newlines > -- Evaluate: The processed and concatenated String > joinLines :: [Line] -> String > joinLines (l:[]) = concat (intersperse " " l) > joinLines (l:ls) = (concat (intersperse " " l)) ++ ('\n':joinLines ls) You should use the existing library functions and leave the optimisations to their implementor: import Data.List joinLines :: [[String]] -> String joinLines = intercalate "\n" . map (intercalate " ") Now you can easily switch to the faster ByteString library by simply changing the import statement. From felipe.lessa at gmail.com Sat Feb 6 08:17:28 2010 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sat Feb 6 07:48:54 2010 Subject: [Haskell-cafe] Using ShowS or Difference Lists In-Reply-To: References: Message-ID: <20100206131728.GA4709@kira.casa> On Sat, Feb 06, 2010 at 11:12:40PM +1030, Mark Spezzano wrote: > -- Function: joinLines > -- Joins the Words within Lines together with whitespace and newline characters > -- Argument: Lines to pad with whitespace and newlines > -- Evaluate: The processed and concatenated String > joinLines :: [Line] -> String > joinLines (l:[]) = concat (intersperse " " l) > joinLines (l:ls) = (concat (intersperse " " l)) ++ ('\n':joinLines ls) Why not just joinLines = unlines . map unwords This should be as fast as you may get using lists of lists of lists of Chars :). -- Felipe. From stephen.tetley at gmail.com Sat Feb 6 08:18:10 2010 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Sat Feb 6 07:49:30 2010 Subject: [Haskell-cafe] a beginner question: decorate-op-undecorate In-Reply-To: <9979e72e1002060443y6c32530cya1aa75d02d9cdd87@mail.gmail.com> References: <9979e72e1002060443y6c32530cya1aa75d02d9cdd87@mail.gmail.com> Message-ID: <5fdc56d71002060518t7fe09064w34a3c3beb3953e91@mail.gmail.com> Hi John I'm not sure about making Binding polymorphic to get Functor, Traversable, Foldable... While I think you're correct that partitionEithers might not be a useful example to draw from in this case, I'd assume that Binding would be part of a larger syntax-tree, thus there might not be a appropriate single leaf to make the tree polymorphic on. Felipe Lessa's point - to use Uniplate or one of the Generics packages - might be a better candidate for implementing traversals. Best wishes Stephen From daniel.is.fischer at web.de Sat Feb 6 08:25:56 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sat Feb 6 07:59:09 2010 Subject: [Haskell-cafe] Using ShowS or Difference Lists In-Reply-To: References: Message-ID: <201002061425.56419.daniel.is.fischer@web.de> Am Samstag 06 Februar 2010 13:42:40 schrieb Mark Spezzano: > Hi, > > Just wondering whether I can use ShowS or tupling or Difference Lists to > speed up the following code? > > It's basic text processing. It takes in a list of Lines where each Line > is a list of Words and intersperses " " between them then concatenates > them into a longer String. Note that there is a recursive call and the > ++ operator. > > Thanks > > Mark > > > -- Function: joinLines > -- Joins the Words within Lines together with whitespace and newline > characters -- Argument: Lines to pad with whitespace and newlines > -- Evaluate: The processed and concatenated String > joinLines :: [Line] -> String > joinLines (l:[]) = concat (intersperse " " l) > joinLines (l:ls) = (concat (intersperse " " l)) ++ ('\n':joinLines ls) > joinLines = init . unlines . map unwords joinLines = concat . intersperse "\n" . map unwords joinLines = intercalate "\n" . map unwords joinLines = intercalate "\n" . map (intercalate " ") it should be pretty good already, if that's a performance bottleneck, you might need to switch to (Lazy) ByteStrings. I don't think ShowS or difference lists would be any faster. From johann.hoechtl at gmail.com Sat Feb 6 10:36:54 2010 From: johann.hoechtl at gmail.com (=?ISO-8859-1?Q?Johann_H=F6chtl?=) Date: Sat Feb 6 10:08:14 2010 Subject: [Haskell-cafe] Re: cabal fun (not) In-Reply-To: References: <4B6C33D7.70306@imn.htwk-leipzig.de> Message-ID: <8a461b8d-4f89-4f49-9f67-9a1ecc212ef7@3g2000yqn.googlegroups.com> On Feb 6, 3:33?am, Ivan Miljenovic wrote: > On 6 February 2010 01:05, Johannes Waldmann > > wrote: > > so please please please have "cabal install" fail with some error > > message if (that is, before) the install would break anything. - J. > > If you upgrade a library, it will break all other libraries that > depend upon it. ?"ghc-pkg list" will tell you which libraries are > broken and need to be rebuilt. > Yes, I think that's the current behaviour what Johannes described yet he suggest this to be sub-optimal. A warning about breakage would be good before the breakage has happened. > -- > Ivan Lazar Miljenovic > Ivan.Miljeno...@gmail.com > IvanMiljenovic.wordpress.com > Joan Crawford ?- "I, Joan Crawford, I believe in the dollar. > Everything I earn, I spend." -http://www.brainyquote.com/quotes/authors/j/joan_crawford.html > _______________________________________________ > Haskell-Cafe mailing list > Haskell-C...@haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe From spam at scientician.net Sat Feb 6 11:18:09 2010 From: spam at scientician.net (Bardur Arantsson) Date: Sat Feb 6 10:49:52 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: <20100206111415.GB29938@kira.casa> References: <5679D446-9E50-4DFB-AFBD-E9532C3DCF0B@ece.cmu.edu> <20100206111415.GB29938@kira.casa> Message-ID: Felipe Lessa wrote: > On Sat, Feb 06, 2010 at 09:16:35AM +0100, Bardur Arantsson wrote: >> Brandon S. Allbery KF8NH wrote: >>> On Feb 5, 2010, at 02:56 , Bardur Arantsson wrote: >> [--snip--] >>> "Broken pipe" is normally handled as a signal, and is only mapped >>> to an error if SIGPIPE is set to SIG_IGN. I can well imagine that >>> the SIGPIPE signal handler isn't closing resources properly; a >>> workaround would be to use the System.Posix.Signals API to ignore >>> SIGPIPE, but I don't know if that would work as a general solution >>> (it would depend on what other uses of pipes/sockets exist). >> It was a good idea, but it doesn't seem to help to add >> >> installHandler sigPIPE Ignore (Just fullSignalSet) >> >> to the main function. (Given the package name I assume >> System.Posix.Signals works similarly to regular old signals, i.e. >> globally per-process.) >> >> This is really starting to drive me round the bend... > > Have you seen GHC ticket #1619? > > http://hackage.haskell.org/trac/ghc/ticket/1619 > > I hadn't. I guess the conclusion is that SIG_PIPE is ignored by default anyway. So much for that. During yet another bout of debugging, I've added even more "I am here" instrumentation code to the SendFile code, and the culprit seems to be threadWaitWrite. Here's the bit of code I've modified: > sendfile :: Fd -> Fd -> Ptr Int64 -> Int64 -> IO Int64 > sendfile out_fd in_fd poff bytes = do > putStrLn "PRE-threadWaitWrite" > threadWaitWrite out_fd > putStrLn "AFTER threadWaitWrite" > sbytes <- c_sendfile out_fd in_fd poff (fromIntegral bytes) > putStrLn $ "AFTER c_sendfile; result was: " ++ (show sbytes) > if sbytes <= -1 > then do errno <- getErrno > if errno == eAGAIN > then sendfile out_fd in_fd poff bytes > else throwErrno "Network.Socket.SendFile.Linux" > else return (fromIntegral sbytes) This is the output when a file descriptor is lost: --- AFTER sendfile: sbytes=27512 DIFFERENCE: 627264520 remaining=627264520, bytes=627264520 PRE-threadWaitWrite Got request for CONTENT for objectId=1700000000000000,f215040000000000 Serving file 'X'... Sending 625838080 bytes... in_fd=13 --- So I have to conclude that threadWaitWrite is doing *something* which causes the thread to die when the PS3 kills the connection. From DekuDekuplex at Yahoo.com Sat Feb 6 11:38:08 2010 From: DekuDekuplex at Yahoo.com (Benjamin L. Russell) Date: Sat Feb 6 11:09:49 2010 Subject: [Haskell-cafe] Re: Category Theory woes References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <814617241002020916o59f45a5cg622c150c363c4913@mail.gmail.com> Message-ID: On Tue, 02 Feb 2010 09:16:03 -0800, Creighton Hogg wrote: > 2010/2/2 ?lvaro Garc?a P?rez > >> You may try Pierce's "Basic Category Theory for Computer Scientists" or >> Awodey's "Category Theory", whose style is rather introductory. Both of them >> (I think) have a chapter about functors where they explain the Hom functor >> and related topics. >> > > I think Awodey's book is pretty fantastic, actually, but I'd avoid Pierce. > Unlike "Types and Programming Languages", I think "Basic Category > Theory..." is a bit eccentric in its presentation and doesn't help the > reader build intuition. I have written an overview of various category theory books, which you may find useful, at the following site: Learning Haskell through Category Theory, and Adventuring in Category Land: Like Flatterland, Only About Categories http://dekudekuplex.wordpress.com/2009/01/16/learning-haskell-through-category-theory-and-adventuring-in-category-land-like-flatterland-only-about-categories/ Hope this helps. -- Benjamin L. Russell -- Benjamin L. Russell / DekuDekuplex at Yahoo dot com http://dekudekuplex.wordpress.com/ Translator/Interpreter / Mobile: +011 81 80-3603-6725 "Furuike ya, kawazu tobikomu mizu no oto." -- Matsuo Basho^ From spam at scientician.net Sat Feb 6 11:44:29 2010 From: spam at scientician.net (Bardur Arantsson) Date: Sat Feb 6 11:16:14 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: References: <5679D446-9E50-4DFB-AFBD-E9532C3DCF0B@ece.cmu.edu> <20100206111415.GB29938@kira.casa> Message-ID: Bardur Arantsson wrote: (sorry about replying-to-self) > During yet another bout of debugging, I've added even more "I am here" > instrumentation code to the SendFile code, and the culprit seems to be > threadWaitWrite. I think I've pretty much confirmed this. I've changed the code again. This time to: > sendfile :: Fd -> Fd -> Ptr Int64 -> Int64 -> IO Int64 > sendfile out_fd in_fd poff bytes = do > putStrLn "PRE-threadWaitWrite" > -- threadWaitWrite out_fd > -- putStrLn "AFTER threadWaitWrite" > sbytes <- c_sendfile out_fd in_fd poff (fromIntegral bytes) > putStrLn $ "AFTER c_sendfile; result was: " ++ (show sbytes) > if sbytes <= -1 > then do errno <- getErrno > if errno == eAGAIN > then do > threadDelay 100 > sendfile out_fd in_fd poff bytes > else throwErrno "Network.Socket.SendFile.Linux" > else return (fromIntegral sbytes) That is, I removed the threadWaitWrite in favor of just adding a "threadDelay 100" when eAGAIN is encountered. With this code, I cannot provoke the leak. Unfortunately this isn't really a solution -- the CPU is pegged at ~50% when I do this and it's not exactly elegant to have a hardcoded 100 ms delay in there. :) I'm hoping that someone who understands the internals of GHC can chime in here with some kind of explanation as to if/why/how threadWaitWrite can fail in this way. Anyone? Cheers, From briand at aracnet.com Sat Feb 6 12:25:03 2010 From: briand at aracnet.com (briand@aracnet.com) Date: Sat Feb 6 11:56:25 2010 Subject: [Haskell-cafe] Re: Category Theory woes In-Reply-To: References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <814617241002020916o59f45a5cg622c150c363c4913@mail.gmail.com> Message-ID: <20100206092503.37fc6947@windy.deldotd.com> On Sun, 07 Feb 2010 01:38:08 +0900 "Benjamin L. Russell" wrote: > On Tue, 02 Feb 2010 09:16:03 -0800, Creighton Hogg wrote: > > > 2010/2/2 ?lvaro Garc?a P?rez > > > >> You may try Pierce's "Basic Category Theory for Computer > >> Scientists" or Awodey's "Category Theory", whose style is rather > >> introductory. Both of them (I think) have a chapter about functors > >> where they explain the Hom functor and related topics. > >> > > > > I think Awodey's book is pretty fantastic, actually, but I'd avoid > > Pierce. Unlike "Types and Programming Languages", I think "Basic > > Category Theory..." is a bit eccentric in its presentation and > > doesn't help the reader build intuition. > > I have written an overview of various category theory books, which > you may find useful, at the following site: > > Learning Haskell through Category Theory, and Adventuring in Category > Land: Like Flatterland, Only About Categories > http://dekudekuplex.wordpress.com/2009/01/16/learning-haskell-through-category-theory-and-adventuring-in-category-land-like-flatterland-only-about-categories/ > > Hope this helps. It does. Does anybody have any opinions on Pitt, "Category Theory and Computer Science" ? Brian From korpios at korpios.com Sat Feb 6 12:38:25 2010 From: korpios at korpios.com (Tom Tobin) Date: Sat Feb 6 12:09:46 2010 Subject: [Haskell-cafe] safe-lazy-io on GHC 6.12? Message-ID: After convincing myself the hard way that you can't be lazy across strict monadic results (by writing myself a "foldrM" -- yeah, I'm still a beginner), I noticed the recent discussion of safe-lazy-io vs. iteratee with interest. The safe-lazy-io package seems much easier to understand than iteratee, but it doesn't compile on GHC 6.12 (and I haven't had any luck in figuring out how to update it myself). The Hackage build log shows the same build result I'm getting [1]; is there any chance of it getting updated to work on 6.12? [1] http://hackage.haskell.org/packages/archive/safe-lazy-io/0.1/logs/failure/ghc-6.12 From nicolas.pouillard at gmail.com Sat Feb 6 13:12:17 2010 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Sat Feb 6 12:43:39 2010 Subject: [Haskell-cafe] safe-lazy-io on GHC 6.12? In-Reply-To: References: Message-ID: <4b6db101.0e67f10a.27f4.ffff9ed2@mx.google.com> On Sat, 6 Feb 2010 11:38:25 -0600, Tom Tobin wrote: > After convincing myself the hard way that you can't be lazy across > strict monadic results (by writing myself a "foldrM" -- yeah, I'm > still a beginner), I noticed the recent discussion of safe-lazy-io vs. > iteratee with interest. The safe-lazy-io package seems much easier to > understand than iteratee, but it doesn't compile on GHC 6.12 (and I > haven't had any luck in figuring out how to update it myself). The > Hackage build log shows the same build result I'm getting [1]; is > there any chance of it getting updated to work on 6.12? Right, updating it is on my todo list. However I have a little dilemma, safe-lazy-io has a local version of hGetContents because I needed a version which do not hide exceptions. However the latest version of hGetContents seems to no longer catch exceptions (am I right?), if so it might be preferable to just use the new hGetContents. Or not? -- Nicolas Pouillard http://nicolaspouillard.fr From ryani.spam at gmail.com Sat Feb 6 13:28:13 2010 From: ryani.spam at gmail.com (Ryan Ingram) Date: Sat Feb 6 12:59:32 2010 Subject: [Haskell-cafe] Using ShowS or Difference Lists In-Reply-To: References: Message-ID: <2f9b2d31002061028j62f78c90v922900baa0e93d37@mail.gmail.com> As other people have mentioned, you are duplicating library functionality. But nobody has actually talked about the performance characteristics of your code. Fortunately for you, the calls to (++) in your recursion are right-associative, so you don't have an asymptotic problem where your program gets slower and slower for large inputs; it should stay linear. But you are wasting some work. In particular, (concat (intersperse " " l)) produces a String, and then (++) duplicates all of the cons cells in that string as it rebuilds it so that the tail connects with the next string. So there is a potential benefit to using a difference list, albeit only by around a 2x factor. -- ryan On Sat, Feb 6, 2010 at 4:42 AM, Mark Spezzano wrote: > Hi, > > Just wondering whether I can use ShowS or tupling or Difference Lists to speed up the following code? > > It's basic text processing. It takes in a list of Lines where each Line is a list of Words and intersperses " " between them then concatenates them into a longer String. Note that there is a recursive call and the ++ operator. > > Thanks > > Mark > > > -- Function: joinLines > -- Joins the Words within Lines together with whitespace and newline characters > -- Argument: Lines to pad with whitespace and newlines > -- Evaluate: The processed and concatenated String > joinLines :: [Line] -> String > joinLines (l:[]) = concat (intersperse " " l) > joinLines (l:ls) = (concat (intersperse " " l)) ++ ('\n':joinLines ls) > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From aran.donohue at gmail.com Sat Feb 6 15:14:29 2010 From: aran.donohue at gmail.com (Aran Donohue) Date: Sat Feb 6 14:45:50 2010 Subject: [Haskell-cafe] a beginner question: decorate-op-undecorate In-Reply-To: <5fdc56d71002060518t7fe09064w34a3c3beb3953e91@mail.gmail.com> References: <9979e72e1002060443y6c32530cya1aa75d02d9cdd87@mail.gmail.com> <5fdc56d71002060518t7fe09064w34a3c3beb3953e91@mail.gmail.com> Message-ID: One way or the other, this has been a very productive question for getting good pointers on what to read about next... Thanks again. Aran On Sat, Feb 6, 2010 at 8:18 AM, Stephen Tetley wrote: > Hi John > > I'm not sure about making Binding polymorphic to get Functor, > Traversable, Foldable... > > While I think you're correct that partitionEithers might not be a > useful example to draw from in this case, I'd assume that Binding > would be part of a larger syntax-tree, thus there might not be a > appropriate single leaf to make the tree polymorphic on. Felipe > Lessa's point - to use Uniplate or one of the Generics packages - > might be a better candidate for implementing traversals. > > Best wishes > > Stephen > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100206/148c550e/attachment.html From tphyahoo at gmail.com Sat Feb 6 16:00:48 2010 From: tphyahoo at gmail.com (Thomas Hartman) Date: Sat Feb 6 15:32:07 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: References: Message-ID: <910ddf451002061300s5e209c52p694d3db416de624a@mail.gmail.com> me too. 2010/2/5 MightyByte : > I've been seeing a steady stream of similar resource vanished messages > for as long as I've been running my happstack app. ?This message I get > is this: > > : hClose: resource vanished (Broken pipe) > > I run my app from a shell script inside a "while true" loop, so it > automatically gets restarted if it crashes. ?This incurs no more than > a few seconds of down time. ?Since that is acceptable for my > application, I've never put much effort into investigating the issue. > But I don't think the resource vanished error results in program > termination. ?When I have looked into it, I've had similar trouble > reproducing it. ?Clients such as wget and firefox don't seem to cause > the problem. ?If I remember correctly it only happens with IE. > > On Fri, Feb 5, 2010 at 2:56 AM, Bardur Arantsson wrote: >> Jeremy Shaw wrote: >>> >>> Actually, >>> >>> We should start by testing if native sendfile leaks file descriptors even >>> when the whole file is sent. We have a test suite, but I am not sure if it >>> tests for file handle leaking... >>> >> >> I should have posted this earlier, but the exact message I'm seeing in the >> case where the Bad Client disconnects is this: >> >> ? hums: Network.Socket.SendFile.Linux: resource vanished (Broken pipe) >> >> Oddly, I haven't been able to reproduce this using a wget client with a ^C >> during transfer. When I "disconnect" wget with ^C or "pkill wget" or even >> "pkill -9 wget", I get this message: >> >> ?hums: Network.Socket.SendFile.Linux: resource vanished (Connection reset by >> peer) >> >> (and no leak, as observed by "lsof | grep hums"). >> >> So there appears to be some vital difference between the handling of the two >> cases. >> >> Another observation which may be useful: >> >> Before the sendfile' API change (Handle -> FilePath) in sendfile-0.6.x, my >> code used "withFile" to open the file and to ensure that it was closed. So >> it seems that withBinaryFile *should* also be fine. Unless the "Broken pipe" >> error somehow escapes the scope without causing a "close". >> >> I don't have time to dig more right now, but I'll try to see if I can find >> out more later. >> >> Cheers, >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From jao at gnu.org Sat Feb 6 16:39:52 2010 From: jao at gnu.org (Jose A. Ortega Ruiz) Date: Sat Feb 6 16:39:49 2010 Subject: [Haskell-cafe] cannot post to haskellmode-emacs@projects.haskell.org Message-ID: <877hqqf3h3.fsf@newton.homeunix.net> Hi, all my posts to the haskellmode-emacs list (using the address in the subject) are being rejected with the error: 451 451 Temporary local problem - please try later (state 18) (after several retries by the Google smtp server, which i use as a smarthost). Any idea of what could be causing this problem? Thanks! jao -- There are two ways to write error-free programs; only the third one works. - Alan Perlis, Epigrams in Programing From petersen at haskell.org Sun Feb 7 00:42:37 2010 From: petersen at haskell.org (Jens Petersen) Date: Sun Feb 7 00:13:57 2010 Subject: [Haskell-cafe] cannot post to haskellmode-emacs@projects.haskell.org In-Reply-To: <877hqqf3h3.fsf@newton.homeunix.net> References: <877hqqf3h3.fsf@newton.homeunix.net> Message-ID: <9436bffe1002062142t34388332t293279e32accee4e@mail.gmail.com> On 7 February 2010 07:39, Jose A. Ortega Ruiz wrote: > all my posts to the haskellmode-emacs list (using the address in the > subject) are being rejected with the error: > ?451 451 Temporary local problem - please try later (state 18) > (after several retries by the Google smtp server, which i use as a > smarthost). I have been experiencing this often too recently when trying to post to haskell-platform list. I wonder if some of the googlemail smtp servers got blacklisted on projects.haskell.org because of spam? Jens From leon.p.smith at gmail.com Sun Feb 7 01:29:20 2010 From: leon.p.smith at gmail.com (Leon Smith) Date: Sun Feb 7 01:00:40 2010 Subject: [Haskell-cafe] ANN: data-ordlist-0.2 Message-ID: I have released data-ordlist 0.2, with a number of changes: 1. The module name is now Data.List.Ordered, instead of Data.OrdList 2. Three bugfixes: (ack!) insertSet and insertBag assumed reverse-ordered lists, nub failed to remove duplicates. Thanks to Topi Karvonen for reporting the first problem. 3. One semantic change: old_nubBy f == new_nubBy (not . f). The new version is better keeping with the spirit of the rest of the library, and makes the old nub bug much more obvious. Now nubBy is the greedy algorithm that returns a sublist such that for all binary predicates: isSortedBy pred (nubBy pred xs) == True 4. Improved documentation, I hope! Please consider taking a look and letting me know what you think. http://hackage.haskell.org/package/data-ordlist Cheers, Leon -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100207/21bef6d8/attachment.html From spam at scientician.net Sun Feb 7 03:13:59 2010 From: spam at scientician.net (Bardur Arantsson) Date: Sun Feb 7 02:45:42 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: References: <5679D446-9E50-4DFB-AFBD-E9532C3DCF0B@ece.cmu.edu> <20100206111415.GB29938@kira.casa> Message-ID: Bardur Arantsson wrote: > Bardur Arantsson wrote: > > (sorry about replying-to-self) > >> During yet another bout of debugging, I've added even more "I am here" >> instrumentation code to the SendFile code, and the culprit seems to be > > threadWaitWrite. > As Jeremy Shaw pointed out off-list, the symptoms are also consistent with a thread that simply gets stuck in threadWaitWrite. I've tried a couple of different solutions to this based on starting a separate thread to enforce a timeout on threadWaitWrite (using throwTo). It seems to work to prevent the file descriptor leak, but causes GHC to segfault after a while. Probably some sort of other resource exhaustion since my code is just an evil hack: > killer :: MVar () -> ThreadId -> IO () > killer dontKill otherThread = do > threadDelay 5000 > x <- tryTakeMVar dontKill > case x of > Just _ -> putStrLn "Killer thread expired" > Nothing -> throwTo otherThread (Overflow) where the relevant bit of sendfile reads: > mtid <- myThreadId > dontKill <- newEmptyMVar > forkIO $ killer dontKill mtid > threadWaitWrite out_fd > putMVar dontKill () So I'm basically creating a thread for every single "threadWaitWrite" operation (which is a lot in this case). Anyone got any ideas on a simpler way to handle this? Maybe I should just report a bug for threadWaitWrite? IMO threadWaitWrite really should throw some sort of IOException if the FD goes dead while it's waiting. I suppose an alternative way to try to work around this would be by forcing the output socket into blocking (as opposed to non-blocking) mode, but I can't figure out how to do this on GHC 6.10.x -- I only see setNonBlockingFD which doesn't take a parameter unlike its 6.12.x counterpart. Cheers, From ross at soi.city.ac.uk Sun Feb 7 06:43:55 2010 From: ross at soi.city.ac.uk (Ross Paterson) Date: Sun Feb 7 06:15:45 2010 Subject: [Haskell-cafe] ANN: data-ordlist-0.2 In-Reply-To: References: Message-ID: <20100207114355.GA4269@soi.city.ac.uk> Why not wrap lists as Set and Bag abstract datatypes? An added bonus is that you could make them instances of Monoid. From jeremy at n-heptane.com Sun Feb 7 09:59:47 2010 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Sun Feb 7 09:31:06 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: References: <5679D446-9E50-4DFB-AFBD-E9532C3DCF0B@ece.cmu.edu> <20100206111415.GB29938@kira.casa> Message-ID: It's not clear to me that this is actually a bug in threadWaitWrite. I believe that under Linux, select() does not wakeup just because the file descriptor was closed. (Under Windows, and possibly solaris/BSD/etc it does). So this behavior might be consistent with normal Linux behavior. However, it is clearly annoying that (a) the expected behavior is not documented (b) the behavior might be different under Linux than other OSes. In some sense it is correct -- if the file descriptor is closed, then we certainly can't write more to it -- so threadWaitWrite need not wake up.. But that leaves us with the issue of needing someway to be notified that the file descriptor was closed so that we can clean up after ourselves.. - jeremy On Sun, Feb 7, 2010 at 2:13 AM, Bardur Arantsson wrote: > Bardur Arantsson wrote: > >> Bardur Arantsson wrote: >> >> (sorry about replying-to-self) >> >> During yet another bout of debugging, I've added even more "I am here" >>> instrumentation code to the SendFile code, and the culprit seems to be >>> >> > threadWaitWrite. >> >> > As Jeremy Shaw pointed out off-list, the symptoms are also consistent > with a thread that simply gets stuck in threadWaitWrite. > > I've tried a couple of different solutions to this based on starting a > separate thread to enforce a timeout on threadWaitWrite (using throwTo). > > It seems to work to prevent the file descriptor leak, but causes GHC > to segfault after a while. Probably some sort of other resource exhaustion > since my code is just an evil hack: > > > killer :: MVar () -> ThreadId -> IO () > > killer dontKill otherThread = do > > threadDelay 5000 > > x <- tryTakeMVar dontKill > > case x of > > Just _ -> putStrLn "Killer thread expired" > > Nothing -> throwTo otherThread (Overflow) > > where the relevant bit of sendfile reads: > > > mtid <- myThreadId > > dontKill <- newEmptyMVar > > forkIO $ killer dontKill mtid > > threadWaitWrite out_fd > > putMVar dontKill () > > So I'm basically creating a thread for every single "threadWaitWrite" > operation > (which is a lot in this case). > > Anyone got any ideas on a simpler way to handle this? Maybe I should just > report a bug for threadWaitWrite? IMO threadWaitWrite really should > throw some sort of IOException if the FD goes dead while it's waiting. > > I suppose an alternative way to try to work around this would be by forcing > the output > socket into blocking (as opposed to non-blocking) mode, but I can't figure > out how to > do this on GHC 6.10.x -- I only see setNonBlockingFD which doesn't take a > parameter > unlike its 6.12.x counterpart. > > > Cheers, > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100207/b6b7050c/attachment.html From nonowarn at gmail.com Sun Feb 7 10:07:54 2010 From: nonowarn at gmail.com (Yusaku Hashimoto) Date: Sun Feb 7 09:39:11 2010 Subject: [Haskell-cafe] Two GET HTTP requests In-Reply-To: <1BE43023-80AC-464E-8972-65C842FBB476@eidhof.nl> References: <1BE43023-80AC-464E-8972-65C842FBB476@eidhof.nl> Message-ID: Hello, On Sat, Feb 6, 2010 at 2:51 AM, Chris Eidhof wrote: > Approach 3: I used the simpleHTTP function from the HTTP package. This crashed, after I dug a little deeper into the code, it threw an error on calling the parseURI function (openFile: no such file exists). I installed the latest network package and upgraded my HTTP package, and the parseURI error went away. I felt like I was almost there, and tried the following: > >> simpleHTTP (getRequest "http://haskell.org") > > This failed with just the text "Bus error". I searched the HTTPBis git repository, but couldn't find the text "Bus error". I don't have a clue of how to fix this. Try reinstall network package with `cabal install --reinstall --hsc2hs-options="--cflag=-m32 --lflag=-m32"`. See also: http://hackage.haskell.org/trac/ghc/ticket/3681 Hope this helps. --nwn From spam at scientician.net Sun Feb 7 10:22:35 2010 From: spam at scientician.net (Bardur Arantsson) Date: Sun Feb 7 09:54:22 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: References: <5679D446-9E50-4DFB-AFBD-E9532C3DCF0B@ece.cmu.edu> <20100206111415.GB29938@kira.casa> Message-ID: Jeremy Shaw wrote: > It's not clear to me that this is actually a bug in threadWaitWrite. > > I believe that under Linux, select() does not wakeup just because the file > descriptor was closed. select() has the option of specifying an "exceptfds" FD_SET where I'd certainly _expect_ select() to flag an FD if it's closed. Annoyingly, the man page is not very specific about what an "exception" is, so it's hard to be sure. > (Under Windows, and possibly solaris/BSD/etc it > does). So this behavior might be consistent with normal Linux behavior. > However, it is clearly annoying that (a) the expected behavior is not > documented (b) the behavior might be different under Linux than other OSes. > > In some sense it is correct -- if the file descriptor is closed, then we > certainly can't write more to it -- so threadWaitWrite need not wake up.. > But that leaves us with the issue of needing someway to be notified that > the file descriptor was closed so that we can clean up after ourselves.. > True, it is perhaps technically not a bug, but it is certainly a misfeature since there is no easy way (at least AFAICT) to discover that something bad has happened for the file descriptor and act accordingly. AFAICT any solution would have to be based on a separate thread which either 1) "checks" the FD periodically somehow, or 2) simply lets the thread doing the threadWaitWrite time out after a set period of inactivity. Neither is very optimal. Either way, I'd certainly expect the sendfile library to work around this somehow such that this situation doesn't occur. I'm just having a hard time thinking up a good solution :). Cheers, From waldmann at imn.htwk-leipzig.de Sun Feb 7 10:44:32 2010 From: waldmann at imn.htwk-leipzig.de (Johannes Waldmann) Date: Sun Feb 7 10:15:56 2010 Subject: [Haskell-cafe] haskelldb in-memory driver? Message-ID: <4B6EDFE0.3080303@imn.htwk-leipzig.de> Is there a haskelldb-driver that works with a datasource that is in memory, as a Haskell object? (like LINQ can work on C# collections) - J. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 260 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100207/62d1cc1e/signature.bin From chris at eidhof.nl Sun Feb 7 10:50:30 2010 From: chris at eidhof.nl (Chris Eidhof) Date: Sun Feb 7 10:21:50 2010 Subject: [Haskell-cafe] Two GET HTTP requests In-Reply-To: References: <1BE43023-80AC-464E-8972-65C842FBB476@eidhof.nl> Message-ID: Thanks. Unfortunately, it didn't help. The thing that frustrates me is that it's quite hard to debug. I guess I'll upgrade my GHC to 6.12, hopefully that'll solve it. -chris On 7 feb 2010, at 16:07, Yusaku Hashimoto wrote: > Hello, > > On Sat, Feb 6, 2010 at 2:51 AM, Chris Eidhof wrote: >> Approach 3: I used the simpleHTTP function from the HTTP package. This crashed, after I dug a little deeper into the code, it threw an error on calling the parseURI function (openFile: no such file exists). I installed the latest network package and upgraded my HTTP package, and the parseURI error went away. I felt like I was almost there, and tried the following: >> >>> simpleHTTP (getRequest "http://haskell.org") >> >> This failed with just the text "Bus error". I searched the HTTPBis git repository, but couldn't find the text "Bus error". I don't have a clue of how to fix this. > > Try reinstall network package with `cabal install --reinstall > --hsc2hs-options="--cflag=-m32 --lflag=-m32"`. > > See also: http://hackage.haskell.org/trac/ghc/ticket/3681 > > Hope this helps. > --nwn From holgersiegel74 at yahoo.de Sun Feb 7 11:06:37 2010 From: holgersiegel74 at yahoo.de (Holger Siegel) Date: Sun Feb 7 10:37:59 2010 Subject: [Haskell-cafe] Using ShowS or Difference Lists In-Reply-To: <2f9b2d31002061028j62f78c90v922900baa0e93d37@mail.gmail.com> References: <2f9b2d31002061028j62f78c90v922900baa0e93d37@mail.gmail.com> Message-ID: <1265558797.3038.115.camel@cornfed> Am Samstag, den 06.02.2010, 10:28 -0800 schrieb Ryan Ingram: > As other people have mentioned, you are duplicating library > functionality. But nobody has actually talked about the performance > characteristics of your code. > > Fortunately for you, the calls to (++) in your recursion are > right-associative, so you don't have an asymptotic problem where your > program gets slower and slower for large inputs; it should stay > linear. > > But you are wasting some work. In particular, (concat (intersperse " > " l)) produces a String, and then (++) duplicates all of the cons > cells in that string as it rebuilds it so that the tail connects with > the next string. By applying rewrite rules from the standard libraries, GHC figures out that (concat xs ++ ys) == (foldr (++) ys xs) for every xs, ys. So, the rule joinLines (l:ls) = (concat (intersperse " " l)) ++ ('\n':joinLines ls) becomes joinLines (l:ls) = foldr (++) ('\n':joinLines ls) (intersperse " " l) However, the problem remains the same: For every line you have to construct a list (intersperse " " l) that is discarded immediately. But if you implement function intersperse as intersperse _ [] = [] intersperse sep (h:xs) = h : concatMap (\x -> [sep,x]) xs then you can derive the following implementation by applying the rules for list fusion: joinLines :: [[String]] -> String joinLines [[]] = "" joinLines [h:xs] = h ++ foldr (\x y -> ' ': x ++ y) "" xs joinLines ([]:ls) = '\n':jl ls joinLines ((h:xs):ls) = h ++ foldr (\x y -> ' ': x ++ y) ('\n' : joinLines ls) xs This version takes 10 seconds where the original version as well as the idiomatic (unlines . map unwords) takes 15 seconds. Unfortunately, you have to do that optimisation by hand; GHC doesn't figure it out by itself. > > So there is a potential benefit to using a difference list, albeit > only by around a 2x factor. > > -- ryan > > On Sat, Feb 6, 2010 at 4:42 AM, Mark Spezzano > wrote: > > Hi, > > > > Just wondering whether I can use ShowS or tupling or Difference Lists to speed up the following code? > > > > It's basic text processing. It takes in a list of Lines where each Line is a list of Words and intersperses " " between them then concatenates them into a longer String. Note that there is a recursive call and the ++ operator. > > > > Thanks > > > > Mark > > > > > > -- Function: joinLines > > -- Joins the Words within Lines together with whitespace and newline characters > > -- Argument: Lines to pad with whitespace and newlines > > -- Evaluate: The processed and concatenated String > > joinLines :: [Line] -> String > > joinLines (l:[]) = concat (intersperse " " l) > > joinLines (l:ls) = (concat (intersperse " " l)) ++ ('\n':joinLines ls) From haskell at benmachine.co.uk Sun Feb 7 12:12:23 2010 From: haskell at benmachine.co.uk (Ben Millwood) Date: Sun Feb 7 11:43:41 2010 Subject: [Haskell-cafe] Two GET HTTP requests In-Reply-To: <1BE43023-80AC-464E-8972-65C842FBB476@eidhof.nl> References: <1BE43023-80AC-464E-8972-65C842FBB476@eidhof.nl> Message-ID: On Fri, Feb 5, 2010 at 5:51 PM, Chris Eidhof wrote: > Approach 2: I installed the 'download-curl' package, and tried again. This seems to fail on the following example: > >> import Network.Curl.Download >> >> main = do x <- openURI "http://haskell.org" >> ? ? ? ? ? y <- openURI "http://haskell.org/hoogle" >> ? ? ? ? ? return () > > If I put a print statement around the second line of the do-statement it looks like openURI never returns. > I think you're supposed to use withCurlDo: http://hackage.haskell.org/packages/archive/curl/latest/doc/html/Network-Curl.html#v%3AwithCurlDo with the curl library. Could be wrong about that, haven't tried it myself. > Approach 3: I used the simpleHTTP function from the HTTP package. This crashed, after I dug a little deeper into the code, it threw an error on calling the parseURI function (openFile: no such file exists). I installed the latest network package and upgraded my HTTP package, and the parseURI error went away. I felt like I was almost there, and tried the following: > >> simpleHTTP (getRequest "http://haskell.org") > > This failed with just the text "Bus error". I searched the HTTPBis git repository, but couldn't find the text "Bus error". I don't have a clue of how to fix this. "Bus error" is a message generated by the operating system. On OS X, it can mean a null dereference, which is very unusual. I'm not sure how you'd debug it either - the most common cause when you're talking about C applications is programmer error, but Network.HTTP is specifically designed to be pure Haskell, and it's not easy to induce a null dereference from Haskell. > I'm a bit stuck here, I would love to help fix the errors, but don't know what would be the best place to begin. If anyone can point me in the right direction, I will try to patch at least one of these packages. I don't think anyone would blame you if you didn't manage it, none of those are particularly friendly errors. From zao at acc.umu.se Sun Feb 7 13:52:52 2010 From: zao at acc.umu.se (Lars Viklund) Date: Sun Feb 7 13:24:09 2010 Subject: [Haskell-cafe] Two GET HTTP requests In-Reply-To: References: <1BE43023-80AC-464E-8972-65C842FBB476@eidhof.nl> Message-ID: <20100207185252.GB14963@hatchepsut.acc.umu.se> On Sun, Feb 07, 2010 at 05:12:23PM +0000, Ben Millwood wrote: > > This failed with just the text "Bus error". I searched the HTTPBis git repository, but couldn't find the text "Bus error". I don't have a clue of how to fix this. > "Bus error" is a message generated by the operating system. On OS X, > it can mean a null dereference, which is very unusual. You did not mention whether the machine running your OS X was a PowerPC or an "Intel" machine. On non-x86 platforms, a bus error is usually caused by misaligned memory accesses. Unlike the x86 which silently and expensively fixes any misaligned accesses, sane processors kick and scream, resulting in a bus error. Such things tend to happen quite often when development of a software mainly takes place on x86 family chips, and are revealed when some poor soul on an UltraSparcIII tries to run them. -- Lars Viklund | zao@acc.umu.se From leon.p.smith at gmail.com Sun Feb 7 15:50:26 2010 From: leon.p.smith at gmail.com (Leon Smith) Date: Sun Feb 7 15:21:43 2010 Subject: [Haskell-cafe] ANN: data-ordlist-0.2 In-Reply-To: <20100207114355.GA4269@soi.city.ac.uk> References: <20100207114355.GA4269@soi.city.ac.uk> Message-ID: On Sun, Feb 7, 2010 at 6:43 AM, Ross Paterson wrote: > > Why not wrap lists as Set and Bag abstract datatypes? ?An added bonus > is that you could make them instances of Monoid. Well, my current thinking is that if you really want an abstract datatype for bags and sets, hackage (and the standard GHC distribution) offer a multitude of options. Previous versions of the code in data-ordlist dates back 9 years or more; I extracted and refurbished data-ordlist from a mess of miscellaneous list functions I use. Personally, I've never really used this code as an abstract datatype; my typical use cases break the set and bag abstractions to some extent. I use a few functions when I happen to know the lists I'm dealing with are ordered, and want a simple and efficient way to manipulate them. The functions I most often use are sortOn, sortOn', nubSort, and to a somewhat lesser extent, the set-like operators. I put this package on hackage as much for my own personal convenience as for others; but I do hope that other people will find it useful. I realize that others might use it in rather different ways than I do, and am open to suggestions and proposals. Cheers, Leon From kowey at darcs.net Mon Feb 8 03:44:07 2010 From: kowey at darcs.net (Eric Kow) Date: Mon Feb 8 03:15:27 2010 Subject: [Haskell-cafe] Darcs fundraising 2010 - send us to ZuriHac! ($792 more by 15 Feb) Message-ID: <20100208084405.GC242@dewdrop.local> Hi everybody, Only one more week of fundraising to go! We've raised $1208 so far, which gives us another $792 to go in our final push. Can we do it? I sure hope so. Even if we do not, we'll still have raised more than we did last year, so thanks to all! If you're still thinking of helping out, now is the perfect time :-) Otherwise, stay tuned at http://darcs.net/donations.html for our progress. Eric PS. If you send me an email telling me how much you donated, I can update the donations site immediately so that folks can watch our progress bar obsessively :-) Donating by Google Checkout ---------------------------------------------------------------------- Donating via Google Checkout puts more of your donation to work, since Google charges no Checkout fees to 501(c)(3) organizations. Please visit http://darcs.net/donations.html for more details. Donating by check (USA) ---------------------------------------------------------------------- The next best option is to donate by check if you have a US bank account. Checks should be made payable to "Software Freedom Conservancy, Inc.", with "Directed donation: Darcs" in the memo. They can be mailed to Software Freedom Conservancy 1995 BROADWAY FL 17 NEW YORK NY 10023-5882 USA Donating by Paypal ---------------------------------------------------------------------- Please visit http://darcs.net/donations.html for more details. -- Eric Kow PGP Key ID: 08AC04F9 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 195 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100208/5149e607/attachment-0001.bin From ivan.miljenovic at gmail.com Mon Feb 8 04:27:21 2010 From: ivan.miljenovic at gmail.com (Ivan Miljenovic) Date: Mon Feb 8 03:58:36 2010 Subject: [Haskell-cafe] Re: cabal fun (not) In-Reply-To: <8a461b8d-4f89-4f49-9f67-9a1ecc212ef7@3g2000yqn.googlegroups.com> References: <4B6C33D7.70306@imn.htwk-leipzig.de> <8a461b8d-4f89-4f49-9f67-9a1ecc212ef7@3g2000yqn.googlegroups.com> Message-ID: On 7 February 2010 02:36, Johann H?chtl wrote: > Yes, I think that's the current behaviour what Johannes described yet > he suggest this to be sub-optimal. A warning about breakage would be > good before the breakage has happened. As I said, almost any library upgrade will break packages; as far as I know this is one reason why "cabal upgrade" is disabled in newer versions of cabal-install (the main reason being that you shouldn't upgrade boot libraries). -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com Ted Turner - "Sports is like a war without the killing." - http://www.brainyquote.com/quotes/authors/t/ted_turner.html From chris at eidhof.nl Mon Feb 8 04:32:05 2010 From: chris at eidhof.nl (Chris Eidhof) Date: Mon Feb 8 04:04:36 2010 Subject: [Haskell-cafe] Two GET HTTP requests In-Reply-To: <20100207185252.GB14963@hatchepsut.acc.umu.se> References: <1BE43023-80AC-464E-8972-65C842FBB476@eidhof.nl> <20100207185252.GB14963@hatchepsut.acc.umu.se> Message-ID: <20DBE9FF-B673-4751-9D64-C68B2DBC3EAB@eidhof.nl> On 7 feb 2010, at 19:52, Lars Viklund wrote: > On Sun, Feb 07, 2010 at 05:12:23PM +0000, Ben Millwood wrote: >>> This failed with just the text "Bus error". I searched the HTTPBis git repository, but couldn't find the text "Bus error". I don't have a clue of how to fix this. >> "Bus error" is a message generated by the operating system. On OS X, >> it can mean a null dereference, which is very unusual. > > You did not mention whether the machine running your OS X was a PowerPC > or an "Intel" machine. > > On non-x86 platforms, a bus error is usually caused by misaligned memory > accesses. Unlike the x86 which silently and expensively fixes any > misaligned accesses, sane processors kick and scream, resulting in a bus > error. > > Such things tend to happen quite often when development of a software > mainly takes place on x86 family chips, and are revealed when some poor > soul on an UltraSparcIII tries to run them. I'm on X86, Snow Leopard. I'm running GHC 6.10.2. -chris From chris at eidhof.nl Mon Feb 8 04:35:23 2010 From: chris at eidhof.nl (Chris Eidhof) Date: Mon Feb 8 04:06:41 2010 Subject: [Haskell-cafe] Two GET HTTP requests In-Reply-To: References: <1BE43023-80AC-464E-8972-65C842FBB476@eidhof.nl> Message-ID: <08DE7837-6A8D-453D-A164-888DC88BC4BF@eidhof.nl> I should add that I was able to work around the issue by using Michael Snoyman's http-wget [1] package. It uses the command-line version of wget, which does work on my machine. -chris [1]: http://hackage.haskell.org/package/http-wget On 7 feb 2010, at 16:50, Chris Eidhof wrote: > Thanks. Unfortunately, it didn't help. The thing that frustrates me is that it's quite hard to debug. I guess I'll upgrade my GHC to 6.12, hopefully that'll solve it. > > -chris > > On 7 feb 2010, at 16:07, Yusaku Hashimoto wrote: > >> Hello, >> >> On Sat, Feb 6, 2010 at 2:51 AM, Chris Eidhof wrote: >>> Approach 3: I used the simpleHTTP function from the HTTP package. This crashed, after I dug a little deeper into the code, it threw an error on calling the parseURI function (openFile: no such file exists). I installed the latest network package and upgraded my HTTP package, and the parseURI error went away. I felt like I was almost there, and tried the following: >>> >>>> simpleHTTP (getRequest "http://haskell.org") >>> >>> This failed with just the text "Bus error". I searched the HTTPBis git repository, but couldn't find the text "Bus error". I don't have a clue of how to fix this. >> >> Try reinstall network package with `cabal install --reinstall >> --hsc2hs-options="--cflag=-m32 --lflag=-m32"`. >> >> See also: http://hackage.haskell.org/trac/ghc/ticket/3681 >> >> Hope this helps. >> --nwn > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From asviraspossible at gmail.com Mon Feb 8 04:54:03 2010 From: asviraspossible at gmail.com (Victor Nazarov) Date: Mon Feb 8 04:25:21 2010 Subject: [Haskell-cafe] GUI programming In-Reply-To: <4B6C695F.10205@stilo.com> References: <4B6C695F.10205@stilo.com> Message-ID: On Fri, Feb 5, 2010 at 9:54 PM, Mario Bla?evi? wrote: > Victor Nazarov wrote: >> >> Hello, >> >> I've been writing some GUI application with Gtk2hs. It's an >> interpreter for lambda-calculus and combinatory logic, it's GPL and if >> you interested I can share it with cafe. >> >> The problem is that the GUI code has become very ugly and I'm tempted >> to rewrite it totally. I've been looking forward to the FRP stuff, but >> I've never seen a single definition of the term. Conal Eliot's >> "denotational programming" is too general to be definition. I want to >> try Grapefruit, but I got totally lost when I see arrow notation. >> >> I consider more lightweight and more imperative approach, something >> closer to CSP (Communicating Secuential Processes) then FRP. I've just >> crafted some sample program to illustrate my idea. >> >> The behaviour is a monad and it's IO monad so you can do any IO >> (Gtk2hs) programming you wish. The differences is that you don't >> attach static event handlers and tries to determine what to do >> dependent on application state. You attach and detach handlers as much >> as possible. Behaviour looks like a process that can stop execution >> and wait for some GUI event. When event arrived it continues >> execution. > > ? ? ? ?To summarize, the behaviour is a suspendable IO computation. It looks > very much like a coroutine, in fact. I'm planning to extract the > Control.Concurrent.Coroutine module [1] into a separate package soon. It > implements a similar concept but generalized to transform any monad and any > functorial suspension. > > [1] > http://hackage.haskell.org/packages/archive/scc/0.4/doc/html/Control-Concurrent-Coroutine.html > > Yes, behaviour is exactly a coroutine. Your coroutine module seem cool, but I would like to have a DSL closer to GUI programming than to concurrent programming. >> Do you see this approach viable. There are steel some details to emerge: >> * How to wait for several events >> * How to handle IO exceptions > > ? ? ? ?I don't really know how applicable the idea is to GUI programming. > That's not my area of expertise. I am surprised, though, that neither your > code not your comments seem to address the issue of concurrency, as I expect > that would be crucial in a GUI setting. Wouldn't you need different > behaviours to run in different threads? > As I understand Gtk2hs still don't run in -threaded environment. And I've been trying to avoid multithreading as much as possible. I've already implemented exception handling through MonadError instance and multi-event waits. Now I'm trying to rewrite GUI code of my lambda-interpreter, and I'll publish it on hackage, when I am done. >> >> Here is the code: >> {-# LANGUAGE ExistentialQuantification #-} >> ... > > > ? ? ? ?I don't see the purpose of your BBind constructor. It seems to me > that you could simply move the first three cases of runBehaviour > implementation into your >>= and get rid of the constructor. Do you need > that much laziness? > I think, I need it, I can't see the way to rewrite it without intermediate data-structure. The problem is the third case: runBehaviour (BBind (BBind a f) g) = runBehaviour (a >>= (\x -> f x >>= g)) See Heinrich Apfelmus' entry in Monad.Reader to see operational view on monads. My implementation is very close to this idea. -- Victor Nazarov From felipe.lessa at gmail.com Mon Feb 8 05:10:07 2010 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Mon Feb 8 04:41:26 2010 Subject: [Haskell-cafe] GUI programming In-Reply-To: References: <4B6C695F.10205@stilo.com> Message-ID: <20100208101007.GB7273@kira.casa> On Mon, Feb 08, 2010 at 12:54:03PM +0300, Victor Nazarov wrote: > As I understand Gtk2hs still don't run in -threaded environment. It does run, just use unsafeInitGUIForThreadedRTS. -- Felipe. From bulat.ziganshin at gmail.com Mon Feb 8 05:12:03 2010 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Feb 8 04:52:14 2010 Subject: [Haskell-cafe] GUI programming In-Reply-To: <20100208101007.GB7273@kira.casa> References: <4B6C695F.10205@stilo.com> <20100208101007.GB7273@kira.casa> Message-ID: <618849078.20100208131203@gmail.com> Hello Felipe, Monday, February 8, 2010, 1:10:07 PM, you wrote: >> As I understand Gtk2hs still don't run in -threaded environment. > It does run, just use unsafeInitGUIForThreadedRTS. ... and run all GUI primitives via special wrapper or in GUI thread -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From gue.schmidt at web.de Mon Feb 8 05:58:12 2010 From: gue.schmidt at web.de (=?ISO-8859-15?Q?G=FCnther_Schmidt?=) Date: Mon Feb 8 05:29:55 2010 Subject: [Haskell-cafe] Number formatting Message-ID: <4B6FEE44.5010309@web.de> Hello, is there a function which will format a number with separators, something that will turn 14509.8674 into 14,509.86? G?nther From jwlato at gmail.com Mon Feb 8 06:16:03 2010 From: jwlato at gmail.com (John Lato) Date: Mon Feb 8 05:47:20 2010 Subject: [Haskell-cafe] a beginner question: decorate-op-undecorate Message-ID: <9979e72e1002080316j1bd55258idf4894bd971a00cc@mail.gmail.com> Hi Stephen, > From: Stephen Tetley > > Hi John > > I'm not sure about making Binding polymorphic to get Functor, > Traversable, Foldable... > > While I think you're correct that partitionEithers might not be a > useful example to draw from in this case, I'd assume that Binding > would be part of a larger syntax-tree, thus there might not be a > appropriate single leaf to make the tree polymorphic on. Felipe > Lessa's point - to use Uniplate or one of the Generics packages - > might be a better candidate for implementing traversals. I did not consider that, and hadn't seen any other replies when I first replied. If true, I would agree that one of the Generics packages would be the best option. Regardless, I think this is a valid approach. By thinking of data in terms of Functor, Traversable, etc., one can recognize these patterns. Even if Binding is part of a larger syntax tree and can't reasonably be made polymorphic, creating an fmap-like function to do what the OP requested is IMHO simple and idiomatic Haskell. Using Generics then simplifies the implementation. Cheers, John From anton at appsolutions.com Mon Feb 8 06:17:33 2010 From: anton at appsolutions.com (Anton van Straaten) Date: Mon Feb 8 05:48:49 2010 Subject: [Haskell-cafe] Number formatting In-Reply-To: <4B6FEE44.5010309@web.de> References: <4B6FEE44.5010309@web.de> Message-ID: <4B6FF2CD.6050300@appsolutions.com> G?nther Schmidt wrote: > is there a function which will format a number with separators, > something that will turn 14509.8674 into 14,509.86? There's a small function to do it here: http://bluebones.net/2007/02/formatting-decimals-in-haskell/ From stephen.tetley at gmail.com Mon Feb 8 08:09:23 2010 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Mon Feb 8 07:40:39 2010 Subject: [Haskell-cafe] Number formatting In-Reply-To: <4B6FF2CD.6050300@appsolutions.com> References: <4B6FEE44.5010309@web.de> <4B6FF2CD.6050300@appsolutions.com> Message-ID: <5fdc56d71002080509h290f6014g90b15cf4655888b8@mail.gmail.com> Hello All Alternatively, less dependencies and a bit less golf (but not much testing...): Best wishes Stephen import Data.List import Numeric formatDecimal :: RealFloat a => a -> String formatDecimal d = let s = showFFloat (Just 2) d "" (a,b) = break (=='.') s in (intersperseN 3 ',' a) ++ b intersperseN :: Int -> a -> [a] -> [a] intersperseN n a = snd . para phi (1,[]) where phi x ((_:_), (i,acc)) | i == n = (1, a : x : acc) phi x (_, (i,acc)) = (i+1, x : acc) -- paramorphism (generalizes fold) para :: (a -> ([a], b) -> b) -> b -> [a] -> b para phi b = step where step [] = b step (x:xs) = phi x (xs, step xs) On 8 February 2010 11:17, Anton van Straaten wrote: > There's a small function to do it here: > > http://bluebones.net/2007/02/formatting-decimals-in-haskell/ From stephen.tetley at gmail.com Mon Feb 8 08:40:37 2010 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Mon Feb 8 08:11:52 2010 Subject: [Haskell-cafe] Number formatting In-Reply-To: <5fdc56d71002080509h290f6014g90b15cf4655888b8@mail.gmail.com> References: <4B6FEE44.5010309@web.de> <4B6FF2CD.6050300@appsolutions.com> <5fdc56d71002080509h290f6014g90b15cf4655888b8@mail.gmail.com> Message-ID: <5fdc56d71002080540n2eb410f0t8e3a0588e60af345@mail.gmail.com> Hi G?nther Ahem... *FormatDecimal> formatDecimal (888.005) ",888.01" I'll post a revision shortly (that handles negatives as well) ... On 8 February 2010 13:09, Stephen Tetley wrote: > Hello All > > Alternatively, less dependencies and a bit less golf (but not much testing...): ^^^^^^^^^^^^^^^^^^^^ From stephen.tetley at gmail.com Mon Feb 8 09:16:35 2010 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Mon Feb 8 08:47:51 2010 Subject: [Haskell-cafe] Number formatting In-Reply-To: <5fdc56d71002080540n2eb410f0t8e3a0588e60af345@mail.gmail.com> References: <4B6FEE44.5010309@web.de> <4B6FF2CD.6050300@appsolutions.com> <5fdc56d71002080509h290f6014g90b15cf4655888b8@mail.gmail.com> <5fdc56d71002080540n2eb410f0t8e3a0588e60af345@mail.gmail.com> Message-ID: <5fdc56d71002080616jb4d737o10c73fc58e080578@mail.gmail.com> Hello I'd overlooked that the left-to-right behaviour of the paramorphism when I needed to go right-to-left, here's a version with a rather horrible right fold (different seeds for the counter, ho-hum, but easily testable): import Data.List import Numeric formatDecimal :: RealFloat a => a -> String formatDecimal d | d < 0 = '-' : fmt (negate d) | otherwise = fmt d where fmt x = let s = showFFloat (Just 2) x "" (a,b) = break (=='.') s in (intersperseN_rl 3 ',' a) ++ b intersperseN_rl :: Int -> a -> [a] -> [a] intersperseN_rl n sep xs = snd $ foldr phi (0,[]) xs where phi a (i,acc) | i == n = (1, a : sep : acc) | otherwise = (i+1, a : acc) test01 :: IO () test01 = mapM_ (print . (intersperseN_rl 3 ',')) $ inits "abcdefghijklmno" *FormatDecimal> test01 "" "a" "ab" "abc" "a,bcd" "ab,cde" "abc,def" "a,bcd,efg" "ab,cde,fgh" "abc,def,ghi" "a,bcd,efg,hij" "ab,cde,fgh,ijk" "abc,def,ghi,jkl" "a,bcd,efg,hij,klm" "ab,cde,fgh,ijk,lmn" "abc,def,ghi,jkl,mno" On 8 February 2010 13:40, Stephen Tetley wrote: > Ahem... > > *FormatDecimal> formatDecimal (888.005) > ",888.01" > > I'll post a revision shortly (that handles negatives as well) ... > From greg at gregorycollins.net Mon Feb 8 11:04:44 2010 From: greg at gregorycollins.net (Gregory Collins) Date: Mon Feb 8 10:35:57 2010 Subject: [Haskell-cafe] Interpreting profiling results Message-ID: <871vgvemsj.fsf@gregorycollins.net> Hello all, A friend and I are trying to benchmark some network server code which runs fine on my OSX laptop (~7500 req/s) but which is >10x slower on a much faster 8-core Xeon Linux box. The profiling run on Linux looks like this: individual inherited COST CENTRE MODULE no. entries %time %alloc %time %alloc MAIN MAIN 1 0 95.7 0.2 100.0 100.0 ... How should we interpret this result? MAIN doesn't seem to correspond to any user code so we're wondering where the time is going. G. -- Gregory Collins From stephen.tetley at gmail.com Mon Feb 8 11:26:01 2010 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Mon Feb 8 10:57:16 2010 Subject: [Haskell-cafe] a beginner question: decorate-op-undecorate In-Reply-To: <9979e72e1002080316j1bd55258idf4894bd971a00cc@mail.gmail.com> References: <9979e72e1002080316j1bd55258idf4894bd971a00cc@mail.gmail.com> Message-ID: <5fdc56d71002080826w712631b4x7e0e08d051b61684@mail.gmail.com> On 8 February 2010 11:16, John Lato wrote: > Regardless, I think this is a valid approach. ?By thinking of data in > terms of Functor, Traversable, etc., one can recognize these patterns. > ?Even if Binding is part of a larger syntax tree and can't reasonably > be made polymorphic, creating an fmap-like function to do what the OP > requested is IMHO simple and idiomatic Haskell. ?Using Generics then > simplifies the implementation. Hi John, Most definitely! - 'making a functor' is one of the strategies / patterns to consider when designing data types. It would be nice if there was a reference listing and defining such strategies. Phantom types are another strategy (well, maybe a family of strategies if you look closely), as is the de-normalisation by 'moving the sum' that I mentioned previously in the thread, albeit on a smaller scale. Best wishes Stephen From vanenkj at gmail.com Mon Feb 8 12:04:19 2010 From: vanenkj at gmail.com (John Van Enk) Date: Mon Feb 8 11:35:35 2010 Subject: [Haskell-cafe] Anyone up for Google SoC 2010? In-Reply-To: <863507BC-FD78-49A0-9A77-C97B9431F7E7@cs.york.ac.uk> References: <863507BC-FD78-49A0-9A77-C97B9431F7E7@cs.york.ac.uk> Message-ID: I'll just toss this idea out there: I want to be able to pick a runtime to compile against. Some Ada compilers allow me to specify a runtime to use with a --RTS flag. This, of course, also means we'd need to write more runtime variants. I dropped this on the haskell_proposals reddit for safe keeping/evaluation: http://www.reddit.com/r/haskell_proposals/comments/azjah/pluggable_rts_for_ghc_pickyourownruntime/ /jve On Sun, Jan 31, 2010 at 6:04 AM, Malcolm Wallace < malcolm.wallace@cs.york.ac.uk> wrote: > Google has announced that the Summer of Code programme will be running > again this year. If haskell.org people would like to take part again this > year, then we need volunteers: > > First, > * suggestions for suitable projects > (in the past this was organised using a reddit) > * an administrator to co-ordinate the application to Google > (I have done it for the last three years but am very willing > to hand on to someone else) > > Google will accept applications from organisations in the period 8th - 12th > March 2010, approx 1900UTC. > > If haskell.org is accepted again, students can apply between 29th March - > 9th April. > More volunteers will be required: > > * to review student applications and choose which to accept > * to supervise the accepted students > > Both of these roles are called "mentor" in the Google system. Putting > together a good team of mentors before applying as an organisation is > helpful towards us being accepted into the programme. > > Regards, > Malcolm > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100208/4d82b519/attachment.html From daniel.is.fischer at web.de Mon Feb 8 12:01:55 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Mon Feb 8 11:37:13 2010 Subject: [Haskell-cafe] Interpreting profiling results In-Reply-To: <871vgvemsj.fsf@gregorycollins.net> References: <871vgvemsj.fsf@gregorycollins.net> Message-ID: <201002081801.55932.daniel.is.fischer@web.de> Am Montag 08 Februar 2010 17:04:44 schrieb Gregory Collins: > Hello all, > > A friend and I are trying to benchmark some network server code which > runs fine on my OSX laptop (~7500 req/s) but which is >10x slower on a > much faster 8-core Xeon Linux box. > > The profiling run on Linux looks like this: > > individual inherited > COST CENTRE MODULE no. entries %time %alloc %time %alloc > > MAIN MAIN 1 0 95.7 0.2 100.0 100.0 > ... > > How should we interpret this result? MAIN doesn't seem to correspond to > any user code so we're wondering where the time is going. Insert lots of {-# SCC "foo" #-} pragmas (you did pass -auto-all on the command line when compiling?). You can't interpret a profile where almost everything is attributed to MAIN or main. > > G. From hjgtuyl at chello.nl Mon Feb 8 12:15:38 2010 From: hjgtuyl at chello.nl (Henk-Jan van Tuyl) Date: Mon Feb 8 11:46:38 2010 Subject: [Haskell-cafe] Links to darcs.haskel.org in the haskellwiki Message-ID: L.S., There are a lot of links in the haskellwiki that point to projects at darcs.haskel.org; I hope that anyone who moves a project, looks the links up and updates them. An example of a page with several obsolete links is http://www.haskell.org/haskellwiki/Applications_and_libraries/Web_programming Validity of links can automatically be checked with the linkchecker: http://validator.w3.org/checklink I have done quite a lot of updating of links in the past, I hope more people are willing to check and update pages that haven't been touched for a while. Regards, Henk-Jan van Tuyl -- http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html -- From greg at gregorycollins.net Mon Feb 8 12:15:30 2010 From: greg at gregorycollins.net (Gregory Collins) Date: Mon Feb 8 11:46:44 2010 Subject: [Haskell-cafe] Interpreting profiling results In-Reply-To: <201002081801.55932.daniel.is.fischer@web.de> (Daniel Fischer's message of "Mon, 8 Feb 2010 18:01:55 +0100") References: <871vgvemsj.fsf@gregorycollins.net> <201002081801.55932.daniel.is.fischer@web.de> Message-ID: <87wrynd4y5.fsf@gregorycollins.net> Daniel Fischer writes: >> The profiling run on Linux looks like this: >> >> individual inherited >> COST CENTRE MODULE no. entries %time %alloc %time %alloc >> >> MAIN MAIN 1 0 95.7 0.2 100.0 100.0 >> ... > > Insert lots of {-# SCC "foo" #-} pragmas (you did pass -auto-all on the > command line when compiling?). You can't interpret a profile where almost > everything is attributed to MAIN or main. The -auto-all flag is on. The actual "main" function only takes up 3.5% of the inherited time, and the program is only spending 2.4% of its time doing GC. Main itself is pretty trivial -- it creates an MVar, runs the server in a forkIO (to get the accept() loop out of the main thread, as suggested by http://haskell.org/haskellwiki/Simple_Servers), and blocks on the mvar until the accept loop is terminated. I'm just curious as to what the meaning of the MAIN cost centre is -- is it just a catch-all bucket? Are we measuring time spent in the runtime system? G -- Gregory Collins From hyangfji at gmail.com Mon Feb 8 12:25:13 2010 From: hyangfji at gmail.com (Hong Yang) Date: Mon Feb 8 11:56:30 2010 Subject: [Haskell-cafe] automatically exclude unused modules at compile time Message-ID: When I turned on "-Wall" knob at compile time, I got a message: Warning: Module `System.Cmd' is imported, but nothing from it is used, except perhaps instances visible in `System.Cmd' To suppress this warning, use: import System.Cmd() Then I did four experiments as follows at compile time: 1) import System.Environment 2) import System.Environment() 3) import System.Environment(only the functions I used) 4) -- import System.Environment It turned out that case 1-3) have the size after compilation, and that case 4) has smaller size than the others. Can we make GHC a little bit more intelligent to automatically exclude unused modules at compile time as in case 4)? (Am I just too lazy to add several dashes?) Thanks, Hong -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100208/ef87dd32/attachment.html From jfredett at gmail.com Mon Feb 8 12:47:48 2010 From: jfredett at gmail.com (jfredett@gmail.com) Date: Mon Feb 8 12:19:04 2010 Subject: [Haskell-cafe] Haskell Weekly News: Issue 149 - February 08, 2010 Message-ID: <4b704e44.aa15f10a.552c.ffffddd8@mx.google.com> --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20100208 Issue 149 - February 08, 2010 --------------------------------------------------------------------------- Welcome to issue 149 of HWN, a newsletter covering developments in the [1]Haskell community. Hello Haskellers, this week's HWN was delayed a bit in the hopes of making it a bit more substantial. I hate putting up thin HWNs, but of course this must occasionally happen. We have several new CFPs for workshops this week, a new benchmarking package, and some fun quotes. Till next week, Haskellers, your Haskell Weekly News! Announcements Call for Papers: Haskell Symposium 2010. Jeremy.Gibbons [2]announced a call for papers for the 2010 ACM SIGPLAN Haskell Symposium 2010 in Baltimore, Maryland; on 30th September. 2nd CfP: LOPSTR 2010. Temur Kutsia [3]announced a second call for papers for the 20th International Symposium on Logic-Based Program Synthesis and Transformation, being held in Hagenberg, Austria, July 23-25, 2010 (co-located with PPDP 2010). PAR 2010: First CFP. Koen Claessen [4]announced a first call for papers for PAR'10, the Workshop on Partiality and Recursion in Interactive Theorem Provers. data-ordlist-0.2. Leon Smith [5]announced a new release of ordlist, including a change to the module name and bug fixes. progression-0.1. Neil Brown [6]announced Progression, a metalibrary which consolidates various existing tools for Haskell optimization (notably Criterion). HList darcs repo. Oleg He who inhabits all types, but is not _|_, has [7]announced a new darcs repo for HList (and OOHaskell) on community.haskell.org. Discussion a beginner question: decorate-op-undecorate. Aran Donohue [8]asked about how to write a function which can 'inspect' inside a datatype. Translation of Haskell type classes. Enrique Martin [9]talked about some experiments he's done with type classes, and asked some questions regarding optimization related to them. Category Theory woes. Mark Spezzano [10]asked about resources for learning about category theory. Blog noise [11]Haskell news from the [12]blogosphere. Blog posts from people new to the Haskell community are marked with >>>, be sure to welcome them! * Dan Piponi (sigfpe): [13]The Categorification of the Naturals. * Roman Cheplyaka: [14]hledger. * Luke Palmer: [15]Associative Alpha Blending. * Neil Brown: [16]Progression: Supporting Optimisation in Haskell. * Holumbus: [17]Hayoo! Webservice API. * apfelmus: [18]The Operational Monad Tutorial. * Dan Piponi (sigfpe): [19]Tagging Monad Transformer Layers. * Darcs: [20]darcs weekly news #53. * JP Moresmau: [21]EclipseFP 1.110 released, with debugging support. Quotes of the Week * lispy|web: This curses binding appears to be terminally broken * lispy: I did, 'cabal install mage' and it complains about curses * lament: Just use fix to find the least funny joke * copumpkin: A monad is just a lax functor from a terminal bicategory, duh. fuck that monoid in category of endofunctors shit About the Haskell Weekly News New editions are posted to [22]the Haskell mailing list as well as to [23]the Haskell Sequence and [24]Planet Haskell. [25]RSS is also available, and headlines appear on [26]haskell.org. To help create new editions of this newsletter, please see the information on [27]how to contribute. Send stories to jfredett . at . gmail . dot . com. The darcs repository is available at darcs get [28]http://patch-tag.com/r/jfredett/HWN2/pullrepo HWN2 . References 1. http://haskell.org/ 2. http://article.gmane.org/gmane.comp.lang.haskell.general/17778 3. http://article.gmane.org/gmane.comp.lang.haskell.general/17770 4. http://article.gmane.org/gmane.comp.lang.haskell.general/17769 5. http://article.gmane.org/gmane.comp.lang.haskell.cafe/70035 6. http://article.gmane.org/gmane.comp.lang.haskell.cafe/69929 7. http://article.gmane.org/gmane.comp.lang.haskell.cafe/69898 8. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/69984 9. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/69914 10. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/69803 11. http://planet.haskell.org/ 12. http://haskell.org/haskellwiki/Blog_articles 13. http://blog.sigfpe.com/2010/02/decategorification-of-naturals.html 14. http://ro-che.blogspot.com/2010/02/hledger.html 15. http://lukepalmer.wordpress.com/2010/02/05/associative-alpha-blending/ 16. http://chplib.wordpress.com/2010/02/04/progression-supporting-optimisation-in-haskell/ 17. http://holumbus.fh-wedel.de/blog/?p=33 18. http://apfelmus.nfshost.com/articles/operational-monad.html 19. http://blog.sigfpe.com/2010/02/tagging-monad-transformer-layers.html 20. http://blog.darcs.net/2010/02/darcs-weekly-news-53.html 21. http://jpmoresmau.blogspot.com/2010/02/eclipsefp-1110-released-with-debugging.html 22. http://www.haskell.org/mailman/listinfo/haskell 23. http://sequence.complete.org/ 24. http://planet.haskell.org/ 25. http://sequence.complete.org/node/feed 26. http://haskell.org/ 27. http://haskell.org/haskellwiki/HWN 28. http://patch-tag.com/r/jfredett/HWN2/pullrepo%20HWN2 From felipe.lessa at gmail.com Mon Feb 8 12:57:52 2010 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Mon Feb 8 12:29:13 2010 Subject: [Haskell-cafe] automatically exclude unused modules at compile time In-Reply-To: References: Message-ID: <20100208175752.GA16281@kira.casa> On Mon, Feb 08, 2010 at 11:25:13AM -0600, Hong Yang wrote: > Can we make GHC a little bit more intelligent to automatically exclude > unused modules at compile time as in case 4)? (Am I just too lazy to add > several dashes?) Did you use -split-objs? Does it help? -- Felipe. From daniel.is.fischer at web.de Mon Feb 8 13:45:55 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Mon Feb 8 13:19:01 2010 Subject: [Haskell-cafe] Interpreting profiling results In-Reply-To: <87wrynd4y5.fsf@gregorycollins.net> References: <871vgvemsj.fsf@gregorycollins.net> <201002081801.55932.daniel.is.fischer@web.de> <87wrynd4y5.fsf@gregorycollins.net> Message-ID: <201002081945.55372.daniel.is.fischer@web.de> Am Montag 08 Februar 2010 18:15:30 schrieb Gregory Collins: > > I'm just curious as to what the meaning of the MAIN cost centre is -- is > it just a catch-all bucket? Are we measuring time spent in the runtime > system? > > G MAIN is always the root of the call-tree, so I think it's the cost-centre which subsumes all. That its inherited cost is 100% is natural, thus. But usually, its individual cost is 0%, so there's something strange going on. From korpios at korpios.com Mon Feb 8 14:21:59 2010 From: korpios at korpios.com (Tom Tobin) Date: Mon Feb 8 13:53:14 2010 Subject: [Haskell-cafe] Haskell Weekly News: Issue 149 - February 08, 2010 In-Reply-To: <4b704e44.aa15f10a.552c.ffffddd8@mx.google.com> References: <4b704e44.aa15f10a.552c.ffffddd8@mx.google.com> Message-ID: On Mon, Feb 8, 2010 at 11:47 AM, wrote: > --------------------------------------------------------------------------- > Haskell Weekly News > http://sequence.complete.org/hwn/20100208 > Issue 149 - February 08, 2010 > --------------------------------------------------------------------------- [snip] > ? [11]Haskell news from the [12]blogosphere. Blog posts from people new > ? to the Haskell community are marked with >>>, be sure to welcome them! I always enjoy catching the HWN; it's a good summary of stuff that I don't necessarily catch (particularly the blog posts), which is particularly useful when I'm still a beginner with the language. That said, I have a minor suggestion: I think the mention of the ">>>" marker for posts from "new" people should be omitted if there aren't any such posts in the current edition. It would help avoid confusion for those reading the HWN for the first time. From ozgurakgun at gmail.com Mon Feb 8 14:26:34 2010 From: ozgurakgun at gmail.com (Ozgur Akgun) Date: Mon Feb 8 13:57:49 2010 Subject: [Haskell-cafe] cabal install time Message-ID: <7be1feae1002081126k31a5d699oe8a299e065f6fd84@mail.gmail.com> I hate sending such messages to cafe, but... When I try to install "time" I get the following error: > sudo cabal install time ld: duplicate symbol ___hscore_d_name in /Users/username/.cabal/lib/unix-2.4.0.0/ghc-6.10.4/libHSunix-2.4.0.0.a(dirUtils.o) and /Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/base-4.1.0.0/libHSbase-4.1.0.0.a(PrelIOUtils.o) UsingSnow Leopard with the following versions of ghc and cabal > ghc --version The Glorious Glasgow Haskell Compilation System, version 6.10.4 > cabal --version cabal-install version 0.6.4 using version 1.6.0.3 of the Cabal library Thanks for any help. Best, -- Ozgur Akgun -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100208/ff1a4dc2/attachment.html From greg at gregorycollins.net Mon Feb 8 14:34:58 2010 From: greg at gregorycollins.net (Gregory Collins) Date: Mon Feb 8 14:06:12 2010 Subject: [Haskell-cafe] Interpreting profiling results In-Reply-To: <201002081945.55372.daniel.is.fischer@web.de> (Daniel Fischer's message of "Mon, 8 Feb 2010 19:45:55 +0100") References: <871vgvemsj.fsf@gregorycollins.net> <201002081801.55932.daniel.is.fischer@web.de> <87wrynd4y5.fsf@gregorycollins.net> <201002081945.55372.daniel.is.fischer@web.de> Message-ID: <87r5ovcyhp.fsf@gregorycollins.net> Daniel Fischer writes: > Am Montag 08 Februar 2010 18:15:30 schrieb Gregory Collins: >> >> I'm just curious as to what the meaning of the MAIN cost centre is -- is >> it just a catch-all bucket? Are we measuring time spent in the runtime >> system? >> >> G > > MAIN is always the root of the call-tree, so I think it's the cost-centre > which subsumes all. That its inherited cost is 100% is natural, thus. But > usually, its individual cost is 0%, so there's something strange going on. We've been thinking it might be http://hackage.haskell.org/trac/ghc/ticket/3758 (my laptop is 6.10 and the linux box is 6.12) but removing -threaded doesn't improve the situation. G -- Gregory Collins From ketil at malde.org Mon Feb 8 15:37:41 2010 From: ketil at malde.org (Ketil Malde) Date: Mon Feb 8 15:08:52 2010 Subject: [Haskell-cafe] Links to darcs.haskel.org in the haskellwiki In-Reply-To: (Henk-Jan van Tuyl's message of "Mon, 08 Feb 2010 18:15:38 +0100") References: Message-ID: <87d40fihuy.fsf@malde.org> "Henk-Jan van Tuyl" writes: > There are a lot of links in the haskellwiki that point to projects at > darcs.haskel.org; I hope that anyone who moves a project, looks the > links up and updates them. An example of a page with several obsolete > links is I check my own pages once in a while with Google webmaster tools, which tells me about these things (and provides other useful information as well). Perhaps this is useful for the Haskell wiki as well? -k -- If I haven't seen further, it is by standing in the footprints of giants From mattphil at gmail.com Mon Feb 8 16:58:03 2010 From: mattphil at gmail.com (Matthew Phillips) Date: Mon Feb 8 16:29:30 2010 Subject: [Haskell-cafe] Spelling checker exercise In-Reply-To: <201001250820.00307.daniel.is.fischer@web.de> References: <83757D35-C8ED-49B9-9EAA-FED2098C52F9@gmail.com> <201001241252.10357.daniel.is.fischer@web.de> <201001250820.00307.daniel.is.fischer@web.de> Message-ID: <513408EC-D125-4467-8E05-A2EBCE77F2BD@gmail.com> Just wanted to follow up on this, after getting distracted by less important things. Thanks to Daniel's suggestions re the ByteString variant, the fairly-faithful Haskell translation of Norvig's Python clocks in at about 1.7 times slower than spelling.py, most of which is down to the fact that "train" doesn't have a O(1) hashmap to use. I tried using Data.Trie rather than Data.Map, but that made it slightly slower. A counting Bloom filter might be better, but that's going further than I have time for right now. So, in "real" usage this simple version would probably be usable, since train would be done once. Of course there are far cleverer algorithms, but the version I have so far I think retains the value that Norvig's has as a learning example. The latest version I came up with is here: http://github.com/scramjet/spelling/blob/master/spelling.hs Cheers, and thanks again, Matthew. P.S. > Daniel: > [*] classic example: why will > > average xs = sum / len > where > (sum,len) = foldl' accum (0,0) xs > accum (sm,ln) x = (sm+x,ln+1) > > cause a stack overflow for long lists? You gave a strong hint before this, so I'd guess it's due to the lazy tuple creation in "accum"? On 25/01/2010, at 5:49 PM, Daniel Fischer wrote: > Am Montag 25 Januar 2010 05:34:50 schrieb Matthew Phillips: >> On 24/01/2010, at 10:22 PM, Daniel Fischer wrote: >> >> <...> >> >>> I think I know what happened here: >>> >>> $ ghc -fforce-recomp --make matthew -o matthew0 >> >> <...> >> >>> I habitually compile all code with -O2, unless I have a specific >>> reason not to. I tend to forget that some compile without >>> optimisations. For some kinds of code that makes hardly any >>> difference, for others it makes a big difference. >> >> I used the flags "-funbox-strict-fields -fvia-C -optc-O2", but *not* >> -O2. Whoops! I could kick myself: I blindly assumed that -optc-O2 would >> turn on optimisation, but of course that's just the flag for GCC. > > By the way, compiling via C nowadays hardly ever produces faster code than > the native code generator (most times I tried since 6.10, if there was a > difference, native was faster). > >> >> $ time ./spelling becuase >> becuase -> because >> >> real 0m4.467s >> user 0m3.865s >> sys 0m0.280s >> >> $ time ./spelling_df becuase >> becuase -> because >> >> real 0m2.422s >> user 0m2.198s >> sys 0m0.081s >> >> Your previous version is close to twice as fast, and now only 2.5 times >> slower than Python. >> >> >> >> With your suggested changes, your latest version on my machine: >> >> $ time ./spelling_df becuase >> becuase -> because >> >> real 0m1.731s >> user 0m1.572s >> sys 0m0.056s >> >> Now, we're getting close: 4.7s -> 2.3s -> 1.7s. >> >>>>> But once you start needing two edits (try korrekt), correct and >>>>> edits1 start to show up. That shows that Norvig's algorithm isn't >>>>> really good. With two edit steps, you create a _lot_ of strings you >>>>> need to look up, far more than there are in the map. That takes >>>>> time. It'll be better to scan the map for entries with an edit >>>>> distance (< 3) if you have a good method to check that >>> >>> Indeed: >>> $ time ./nLDBSWSpelling becuase >>> becuase -> because >>> 2.84user 0.02system 0:02.86elapsed 100%CPU >>> $ time ./nLDBSWSpelling korrekt >>> korrekt -> correct >>> 2.83user 0.05system 0:02.88elapsed 100%CPU >> >> Not sure if I see what you're saying here: do you mean to point out the >> 2.86 vs 2.88 elapsed? > > Well, above the code, I had the times for Norvig's algorithm (creating all > two-step edits and checking which are known): > >>> And, without profiling: >>> $ time ./spellingBSW becuase >>> becuase -> because >>> 2.84user 0.03system 0:02.88elapsed 99%CPU >>> >>> Finally, building the set of two-step edits takes longer than the >>> additional lookups: >>> >>> $ time ./spellingBSW becuase >>> becuase -> because >>> 2.84user 0.03system 0:02.88elapsed 99%CPU >>> $ time ./spellingBSW korrekt >>> korrekt -> correct >>> 3.50user 0.02system 0:03.52elapsed 100%CPU >>> >>> vs. >>> >>> $ time ./spellingBSWL becuase >>> becuase -> because >>> 2.79user 0.04system 0:02.83elapsed 100%CPU >>> $ time ./spellingBSWL3 korrekt >>> korrekt -> correct >>> 3.20user 0.02system 0:03.23elapsed 99%CPU > > For "becuase", which is a one-step edit, all take the same time (within > normal fluctuation), 2.8x seconds. > For the two-step edit "korrekt", the version building Sets takes 3.5 > seconds, the version which doesn't build a Set of two-step edits takes 3.2 > seconds, *and the version scanning the Map of known words for entries with > a Levenshtein distance [modified to account for transpositions] less than > 3, takes 2.8y seconds, practically the same time as for the one-step edit*. > > It becomes more obvious, perhaps, if we test a couple of two-steppers: > > Lazy Levenshtein: > > time ./nLDBSWSpelling becrase korrekt halmos territoir gutzenperg > becrase -> because > korrekt -> correct > halmos -> holmes > territoir -> territory > gutzenperg -> gutenberg > 2.94user 0.03system 0:02.97elapsed 100%CPU > > just something like 0.1 - 0.15 seconds more than for "becuase", that makes > 0.02 - 0.04 seconds per two-edit correction. > > Sets: > > $ time ./spellingBSW becrase korrekt halmos territoir gutzenperg > becrase -> because > korrekt -> correct > halmos -> holmes > territoir -> territory > gutzenperg -> gutenberg > 7.48user 0.03system 0:07.55elapsed 99%CPU > > Gewalt geschrien! That takes almost a second per two-edit correction. > > List: > > $ time ./spellingBSWL3 becrase korrekt halmos territoir gutzenperg > becrase -> because > korrekt -> correct > halmos -> holmes > territoir -> territory > gutzenperg -> gutenberg > 5.54user 0.04system 0:05.58elapsed 99%CPU > > Better, but still bad, roughly half a second per correction. > > Python without psyco: > > $ time python ./norvig.py becrase korrekt halmos territoir gutzenperg > Trained in 1.46993017197 seconds > because > correct > holmes > territory > gutenberg > 3.00user 0.08system 0:03.09elapsed 99%CPU > $ time python ./norvig.py becuase > Trained in 1.49027395248 seconds > because > 1.46user 0.08system 0:01.55elapsed 100%CPU > > about 0.3 seconds per correction > > and with: > > $ time python ./norvig.py becrase korrekt halmos territoir gutzenperg > Trained in 1.22417902946 seconds > because > correct > holmes > territory > gutenberg > 2.12user 0.09system 0:02.21elapsed 100%CPU > $ time python ./norvig.py becuase > Trained in 1.17486715317 seconds > because > 1.14user 0.08system 0:01.23elapsed 99%CPU > > about 0.2 seconds per correction. > > (Just for the record, I found out what Python did in the half second I > couldn't account for: it looked for matches for "./norvig.py", I forgot > that Python passes the name of the script in argv[0] - d'oh) > >> >>>>> Another thing is >>>>> >>>>> allWords = keysSet wordCounts >>>>> >>>>> Ouch. For each correction, you construct that set anew. Just use >>>>> member from Data.Map instead of Data.Set.member and look up the >>>>> words in the map. >>>> >>>> Whoops! Just to be clear though: Haskell will memoise the result of >>>> "allWords" for a given invocation of "correct"? >>> >>> Yes. But not across different invocations. >>> >>>> So this would only make a large difference for multiple corrections? >>> >>> Right. But that's the interesting use case, isn't it? >> >> It will be when I get the the rest of it working, yes :) >> >>>>>> I will look at using Bloom Filters or >>>>>> Trie?s instead of Data.Map, but I wonder if readFile should be >>>>>> taking nearly %30 of the run time, even for a 6MB file? >>>>> >>>>> No way. But it doesn't seem to, from my GHC's point of view. >>>> >>>> Just to be sure I wasn't using the SCC incorrectly, I split out the >>>> readFile call into "myReadFile". The prof line comes out as: >>>> >>>> myReadFile Main 210 1 35.8 8.6 >>>> 35.8 8.6 >>>> >>>> i.e. 35.8% of runtime. >>> >>> Can I see the exact code which gives that profile? >>> Somehow, things which shouldn't must be attributed to readFile. >> >> The version at this link has myReadFile split out. >> >> http://github.com/scramjet/spelling/blob/31071edb2166b2bc4d350358900d975 >> 228fd43b9/spelling.hs >> >> Doing the same to your version has the same result: >> >> myReadFile Main 210 1 45.7 9.6 45.7 >> 9.6 >> >> It does seem that the profiler is wrong or misleading somehow. > > Strange. Doing that here has no such effect. The only line in the profile > (ByteString) where myReadFile occurs is > > myReadFile Main 260 1 0.0 0.9 0.0 0.9 0 6507348 > > (snipped whitespace), entered once, allocated 6.5 million bytes, took not > measurable time. > > Both, compiled via C and with the native code generator. > > With String IO, it costs 4.6% time and 8.1% allocation. > >> >> Two other quick questions: >> >> (1) you added parentheses to "candidates": >> >> candidates = known [word] `or` ((known e1) `or` known_edits2) >> >> The "or"'s should short circuit so that if "known [word]" is non-empty, >> the others shouldn't be evaluated. I read the above as forcing >> evaluation of the second "or" first: am I wrong? > > Au contraire, > "Any operator lacking a fixity declaration is assumed to be infixl 9" > says the report, so without parentheses, it's parsed as > > (known [word] `or` known e1) `or` known_edits2 > > and both 'or's must be evaluated even if word is known. Since 'or' is lazy > in its second argument, if we associate it > > known [word] `or` (known e1 `or` known_edits2) > > , in case of a known word, we needn't look at the parenthesis at all (it > will probably not make a measurable difference in running time unless you > check a couple of million known words, but still, it feels lazier). For a > local definition, I thought an explicit fixity declaration was overkill. > >> >> (2) you eliminated the "fold" in "correct" in favour of a tail-recursive >> search in "maxCount": was this for style or performance reasons (or both >> :)? > > Performance, kind of. Since the lists we fold over are in fact short, it > doesn't really matter, but if they were long, there'd be the risk of > unnecessarily allocating lots of pairs. I'm rather confident that with -O2, > GHC will eliminate the pairs anyway, but without looking at the core, I'm > not entirely sure. > However, in fact it was an unthought-through rewrite because I just had > someone with a stack overflow in spite of foldl' due to the laziness of the > data constructors[*]. So I made sure that that couldn't happen, without > looking at the folded function to see if that already prevents it. And in > fact, it does, so using a foldl' if you use lists instead of Sets is fine, > with respect to style, even preferable. > > [*] classic example: why will > > average xs = sum / len > where > (sum,len) = foldl' accum (0,0) xs > accum (sm,ln) x = (sm+x,ln+1) > > cause a stack overflow for long lists? > >> >> Cheers, >> >> Matthew. > From svein.ove at aas.no Mon Feb 8 17:16:07 2010 From: svein.ove at aas.no (Svein Ove Aas) Date: Mon Feb 8 16:47:22 2010 Subject: [Haskell-cafe] cannot post to haskellmode-emacs@projects.haskell.org In-Reply-To: <9436bffe1002062142t34388332t293279e32accee4e@mail.gmail.com> References: <877hqqf3h3.fsf@newton.homeunix.net> <9436bffe1002062142t34388332t293279e32accee4e@mail.gmail.com> Message-ID: <221b53ab1002081416j1f17a8c1t96fb72f7df44a03@mail.gmail.com> On Sun, Feb 7, 2010 at 6:42 AM, Jens Petersen wrote: > On 7 February 2010 07:39, Jose A. Ortega Ruiz wrote: >> all my posts to the haskellmode-emacs list (using the address in the >> subject) are being rejected with the error: >> ?451 451 Temporary local problem - please try later (state 18) >> (after several retries by the Google smtp server, which i use as a >> smarthost). > > I have been experiencing this often too recently when trying to > post to haskell-platform list. ?I wonder if some of the googlemail > smtp servers got blacklisted on projects.haskell.org because of > spam? > I see the same thing, also posting from gmail - email is a no-go. Hm. There's nothing blacklisted in the administrative interface. -- Svein Ove Aas From daniel.is.fischer at web.de Mon Feb 8 17:30:07 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Mon Feb 8 17:03:14 2010 Subject: [Haskell-cafe] Spelling checker exercise In-Reply-To: <513408EC-D125-4467-8E05-A2EBCE77F2BD@gmail.com> References: <83757D35-C8ED-49B9-9EAA-FED2098C52F9@gmail.com> <201001250820.00307.daniel.is.fischer@web.de> <513408EC-D125-4467-8E05-A2EBCE77F2BD@gmail.com> Message-ID: <201002082330.07334.daniel.is.fischer@web.de> Am Montag 08 Februar 2010 22:58:03 schrieb Matthew Phillips: > P.S. > > > Daniel: > > > > [*] classic example: why will > > > > average xs = sum / len > > ? where > > ? ? ?(sum,len) = foldl' accum (0,0) xs > > ? ? ?accum (sm,ln) x = (sm+x,ln+1) > > > > cause a stack overflow for long lists? > > You gave a strong hint before this, so I'd guess it's due to the lazy > tuple creation in "accum"? Well, the tuples are forced, so in that sense, tuple creation is not lazy. But the components of the tuple are *not* forced, so they become large thunks and in that sense, tuple creation is lazy and that's indeed the cause of the stack overflow. I think you get full marks for this :) From schlepptop at henning-thielemann.de Mon Feb 8 17:35:32 2010 From: schlepptop at henning-thielemann.de (Henning Thielemann) Date: Mon Feb 8 17:07:14 2010 Subject: [Haskell-cafe] Links to darcs.haskel.org in the haskellwiki In-Reply-To: <87d40fihuy.fsf@malde.org> References: <87d40fihuy.fsf@malde.org> Message-ID: <4B7091B4.8070303@henning-thielemann.de> Ketil Malde schrieb: > "Henk-Jan van Tuyl" writes: > > >> There are a lot of links in the haskellwiki that point to projects at >> darcs.haskel.org; I hope that anyone who moves a project, looks the >> links up and updates them. An example of a page with several obsolete >> links is >> > > I check my own pages once in a while with Google webmaster tools, which > tells me about these things (and provides other useful information as > well). Perhaps this is useful for the Haskell wiki as well? > Bulk updates in Wikis are not very funny. I have also searched for links to my darcs.haskell.org repositories in HaskellWiki and I hope I have updated them all, which is very cumbersome. It would be cool if there would be a way to access the Wiki contents like a file system, such that I can use 'grep' and friends for such tasks. From gwern0 at gmail.com Mon Feb 8 18:00:53 2010 From: gwern0 at gmail.com (Gwern Branwen) Date: Mon Feb 8 17:32:17 2010 Subject: [Haskell-cafe] Links to darcs.haskel.org in the haskellwiki In-Reply-To: <4B7091B4.8070303@henning-thielemann.de> References: <87d40fihuy.fsf@malde.org> <4B7091B4.8070303@henning-thielemann.de> Message-ID: On Mon, Feb 8, 2010 at 5:35 PM, Henning Thielemann wrote: > Ketil Malde schrieb: >> >> "Henk-Jan van Tuyl" writes: >> >> >>> >>> There are a lot of links in the haskellwiki that point to projects at >>> darcs.haskel.org; I hope that anyone who moves a project, looks the >>> links ?up and updates them. An example of a page with several obsolete >>> links is >>> >> >> I check my own pages once in a while with Google webmaster tools, which >> tells me about these things (and provides other useful information as >> well). ?Perhaps this is useful for the Haskell wiki as well? >> > > Bulk updates in Wikis are not very funny. I have also searched for links to > my darcs.haskell.org repositories in HaskellWiki and I hope I have updated > them all, which is very cumbersome. It would be cool if there would be a way > to access the Wiki contents like a file system, such that I can use 'grep' > and friends for such tasks. http://en.wikipedia.org/wiki/Wikipedia:WikipediaFS It was working when I last tried it a year or 3 ago; no idea whether it still does or would work with Hawiki. Also, it's 'on demand' loading. -- gwern From v.dijk.bas at gmail.com Mon Feb 8 18:45:47 2010 From: v.dijk.bas at gmail.com (Bas van Dijk) Date: Mon Feb 8 18:17:20 2010 Subject: [Haskell-cafe] Using ShowS or Difference Lists In-Reply-To: References: Message-ID: On Sat, Feb 6, 2010 at 1:42 PM, Mark Spezzano wrote: > Just wondering whether I can use ShowS or tupling or Difference Lists to speed up the following code?... In case you do want to use a difference list, you could also use a DString[1]. A DString is just a newtype wrapper around a difference list. It has an instance for IsString[2] so you can create them by writing string literals. regards, Bas [1] http://hackage.haskell.org/package/dstring [2] http://hackage.haskell.org/packages/archive/base/4.2.0.0/doc/html/Data-String.html From tonymorris at gmail.com Mon Feb 8 19:42:26 2010 From: tonymorris at gmail.com (Tony Morris) Date: Mon Feb 8 19:16:56 2010 Subject: [Haskell-cafe] Lazy language on JVM/CLR Message-ID: <4B70AF72.1070601@gmail.com> I have hypothesised a pure, lazy language on the JVM and perhaps the .NET CLR with FFI to .NET/Java libraries. I foresee various problems but none that are catastrophic; just often requiring a compromises, sometimes very unattractive compromises. I have authored several libraries in the same vain as pure, lazy programming to run on the JVM in Java and Scala programming languages. I expect others have forethought and perhaps even experimented with such a language. Are there any dangers to be wary of that undo the entire endeavour? Thanks for any insights. -- Tony Morris http://tmorris.net/ From greg at gregorycollins.net Mon Feb 8 19:50:34 2010 From: greg at gregorycollins.net (Gregory Collins) Date: Mon Feb 8 19:21:46 2010 Subject: [Haskell-cafe] cannot post to haskellmode-emacs@projects.haskell.org In-Reply-To: <221b53ab1002081416j1f17a8c1t96fb72f7df44a03@mail.gmail.com> (Svein Ove Aas's message of "Mon, 8 Feb 2010 23:16:07 +0100") References: <877hqqf3h3.fsf@newton.homeunix.net> <9436bffe1002062142t34388332t293279e32accee4e@mail.gmail.com> <221b53ab1002081416j1f17a8c1t96fb72f7df44a03@mail.gmail.com> Message-ID: <87pr4fgrl1.fsf@gregorycollins.net> Svein Ove Aas writes: > I see the same thing, also posting from gmail - email is a no-go. > > Hm. There's nothing blacklisted in the administrative interface. I reported the same issue about a month ago, and I'm not on gmail, so it isn't a gmail-specific thing. G -- Gregory Collins From gue.schmidt at web.de Mon Feb 8 20:03:48 2010 From: gue.schmidt at web.de (=?ISO-8859-15?Q?G=FCnther_Schmidt?=) Date: Mon Feb 8 19:35:23 2010 Subject: [Haskell-cafe] Compiling on Windows - using a particular Manifest file Message-ID: <4B70B474.20303@web.de> Hi, how can I make ghc use a particular manifest file for embedding? (on Windows) G?nther From john at repetae.net Mon Feb 8 20:16:59 2010 From: john at repetae.net (John Meacham) Date: Mon Feb 8 19:48:12 2010 Subject: [Haskell-cafe] Lazy language on JVM/CLR In-Reply-To: <4B70AF72.1070601@gmail.com> References: <4B70AF72.1070601@gmail.com> Message-ID: <20100209011659.GD16245@sliver.repetae.net> On Tue, Feb 09, 2010 at 10:42:26AM +1000, Tony Morris wrote: > I have hypothesised a pure, lazy language on the JVM and perhaps the > .NET CLR with FFI to .NET/Java libraries. I foresee various problems but > none that are catastrophic; just often requiring a compromises, > sometimes very unattractive compromises. I have authored several > libraries in the same vain as pure, lazy programming to run on the JVM > in Java and Scala programming languages. Yes, I have done some design work on a JVM back end for JHC, which seems quite doable and has been on my todo list for a while. > I expect others have forethought and perhaps even experimented with such > a language. Are there any dangers to be wary of that undo the entire > endeavour? There have been a couple papers published on it, the main sticking point seems to be tail call elimination. When targeting real hardware you always had the option of dropping to assembly to do a direct jump, but there isn't an equivalent in the JVM. If you look up tail call + jvm you will probably get a few hits. I believe there are even a couple haskell specific papers on the issue. If you just want something that works and isn't necessarily the most efficient, you can do something like implement the G-machine in java, you would then have a VM on a VM though.. but it would work and be straightforward. John -- John Meacham - ?repetae.net?john? - http://notanumber.net/ From nonowarn at gmail.com Tue Feb 9 00:41:53 2010 From: nonowarn at gmail.com (Yusaku Hashimoto) Date: Tue Feb 9 00:13:05 2010 Subject: [Haskell-cafe] Two GET HTTP requests In-Reply-To: References: <1BE43023-80AC-464E-8972-65C842FBB476@eidhof.nl> Message-ID: Try to reinstall HTTP package also. I think your HTTP package is still linked with old broken network package. HTTP depends on network. And network is a binding for network API of OS. These API is for C-language. When ghc builds such binding packages, It runs gcc for some purpose. gcc thinks you need 64bit binary (from SL, I believe.) and works for 64bit environment. But ghc on Mac can only build 32bit binaries. So it causes the problem. You can check if network package was correctly built by running this. This takes a host name, and gets the root document of the host via HTTP using a socket. Build and try `./this_program haskell.org` import Network.Socket import System.IO import System.Environment getAddr :: HostName -> IO AddrInfo getAddr host = head `fmap` (getAddrInfo (Just defaultHints { addrSocketType = Stream }) (Just host) (Just "http")) connected :: HostName -> IO Socket connected host = do addrinfo <- getAddr host sock <- socket (addrFamily addrinfo) (addrSocketType addrinfo) (addrProtocol addrinfo) connect sock (addrAddress addrinfo) return sock httpGet :: HostName -> IO String httpGet host = do h <- flip socketToHandle ReadWriteMode =<< connected host hSetBuffering h NoBuffering hPutStr h "GET / HTTP/1.0\r\n\r\n" hGetContents h main = fmap head getArgs >>= httpGet >>= putStr I should have mentioned them in my last mail. Sorry. By the way, ghc-6.12 on Mac still can not build 64bit binaries. So upgrading ghc won't solve it. --nwn On Mon, Feb 8, 2010 at 12:50 AM, Chris Eidhof wrote: > Thanks. Unfortunately, it didn't help. The thing that frustrates me is that it's quite hard to debug. I guess I'll upgrade my GHC to 6.12, hopefully that'll solve it. > > -chris > > On 7 feb 2010, at 16:07, Yusaku Hashimoto wrote: > >> Hello, >> >> On Sat, Feb 6, 2010 at 2:51 AM, Chris Eidhof wrote: >>> Approach 3: I used the simpleHTTP function from the HTTP package. This crashed, after I dug a little deeper into the code, it threw an error on calling the parseURI function (openFile: no such file exists). I installed the latest network package and upgraded my HTTP package, and the parseURI error went away. I felt like I was almost there, and tried the following: >>> >>>> simpleHTTP (getRequest "http://haskell.org") >>> >>> This failed with just the text "Bus error". I searched the HTTPBis git repository, but couldn't find the text "Bus error". I don't have a clue of how to fix this. >> >> Try reinstall network package with `cabal install --reinstall >> --hsc2hs-options="--cflag=-m32 --lflag=-m32"`. >> >> See also: http://hackage.haskell.org/trac/ghc/ticket/3681 >> >> Hope this helps. >> --nwn > > From marcin.kosiba at gmail.com Tue Feb 9 02:19:30 2010 From: marcin.kosiba at gmail.com (Marcin Kosiba) Date: Tue Feb 9 01:50:42 2010 Subject: [Haskell-cafe] Lazy language on JVM/CLR In-Reply-To: <20100209011659.GD16245@sliver.repetae.net> References: <4B70AF72.1070601@gmail.com> <20100209011659.GD16245@sliver.repetae.net> Message-ID: On Mon, Feb 8, 2010 at 5:16 PM, John Meacham wrote: > On Tue, Feb 09, 2010 at 10:42:26AM +1000, Tony Morris wrote: >> I expect others have forethought and perhaps even experimented with such >> a language. Are there any dangers to be wary of that undo the entire >> endeavour? > > There have been a couple papers published on it, the main sticking point > seems to be tail call elimination. When targeting real hardware you > always had the option of dropping to assembly to do a direct jump, but > there isn't an equivalent in the JVM. If you look up tail call + jvm you > will probably get a few hits. I believe there are even a couple haskell > specific papers on the issue. > I think .NET 4.0 has tail-call optimization built in because I remember reading that F# relies on such a mechanism. AFAIK you just need to mark the bytecode as "to be optimized" and the runtime does that for you. From uzytkownik2 at gmail.com Tue Feb 9 04:03:46 2010 From: uzytkownik2 at gmail.com (Maciej Piechotka) Date: Tue Feb 9 03:35:20 2010 Subject: [Haskell-cafe] Iteratee, parsec & co. Message-ID: <1265706225.5700.20.camel@picard> I read a lot about iteratee IO and it seemed very interesting (Unfortunately it lacks tutorial). Especially features like 'no input yet' in network programming (with lazy IO + parsec I run into problems as it tried to evaluate the first response character before sending output). I decided first write a simple program and then attempt write a Stream implementation for parsec. > {-# LANGUAGE FlexibleInstances #-} > {-# LANGUAGE MultiParamTypeClasses #-} > import Data.Iteratee > import Text.Parse > > data Buffer a = Buffer > instance Monad m => Stream (Buffer a) (IterateeG [] a m) a where > uncons Buffer = IterateeG loop > where loop (Chunk []) = > return $! Cont (IterateeG loop) Nothing > loop (Chunk (x:xs)) = > return $! Done (Just (x, Buffer)) > (Chunk xs) > loop (EOF Nothing) = > return $! Done Nothing (EOF Nothing) > loop (EOF (Just e)) = > return $! throwErr e 1. I'm not quite sure what Cursor was suppose to do from A Parsing Trifecta presentation. 2. Is there any package which contains this stream definition? 3. Why Seek FileOffset is error message? Regards PS. I guess iteratee does qualify as cafe but if beginner would be more appropriate group then I'm sorry - I'll remember next time. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100209/23b30f9e/attachment.bin From thomas at 0xc29.net Tue Feb 9 05:40:24 2010 From: thomas at 0xc29.net (Thomas Girod) Date: Tue Feb 9 05:19:24 2010 Subject: [Haskell-cafe] various dependencies breakages Message-ID: <20100209104024.GA32487@fairlight.lan> Hi there. I'm trying to reinstall gitit after updating to ghc 6.12 and it's driving me crazy. I hope you will be able to help me troubleshoot this mess ... I'm starting from scratch again, using cabal. I will post more problems as they appears. $ cabal install gitit Resolving dependencies... cabal: cannot configure datetime-0.2. It requires QuickCheck ==2.* For the dependency on QuickCheck ==2.* there are these packages: QuickCheck-2.1, QuickCheck-2.1.0.1, QuickCheck-2.1.0.2 and QuickCheck-2.1.0.3. However none of them are available. QuickCheck-2.1 was excluded because happstack-util-0.4.1 requires QuickCheck <2 QuickCheck-2.1.0.1 was excluded because happstack-util-0.4.1 requires QuickCheck <2 QuickCheck-2.1.0.2 was excluded because happstack-util-0.4.1 requires QuickCheck <2 QuickCheck-2.1.0.3 was excluded because happstack-util-0.4.1 requires QuickCheck <2 Can't cabal handle several versions of the same library in parallel ? If not, how can I solve this problem ? cheers tom From batterseapower at hotmail.com Tue Feb 9 06:11:57 2010 From: batterseapower at hotmail.com (Max Bolingbroke) Date: Tue Feb 9 05:43:10 2010 Subject: [Haskell-cafe] various dependencies breakages In-Reply-To: <20100209104024.GA32487@fairlight.lan> References: <20100209104024.GA32487@fairlight.lan> Message-ID: <9d4d38821002090311j4ef25b3ch6b625a8e7a0acbea@mail.gmail.com> Cabal can handle multiple versions of libraries, but you need to find a consistent set of libraries when building any one executable, since they are all going to be linked together. In this case Cabal has apparently failed to find such a set. You might be able to get this to work with cabal instal gitit --constraint='datetime==0.1', since that version only demands QuickCheck > 1.2, and gitit doesn't specify a datetime version. I haven't tried this though. Happstack-util should probably not depend on QuickCheck at all if the "tests" flag is False -- this appears to be an omission in their Cabal file (http://hackage.haskell.org/packages/archive/happstack-util/0.4.1/happstack-util.cabal). The datetime package doesn't appear to make this a configurable dependency at all... Cheers, Max On 9 February 2010 10:40, Thomas Girod wrote: > Hi there. > > I'm trying to reinstall gitit after updating to ghc 6.12 and it's > driving me crazy. I hope you will be able to help me troubleshoot this > mess ... ?I'm starting from scratch again, using cabal. I will > post more problems as they appears. > > $ cabal install gitit > Resolving dependencies... > cabal: cannot configure datetime-0.2. It requires QuickCheck ==2.* > For the dependency on QuickCheck ==2.* there are these packages: > QuickCheck-2.1, QuickCheck-2.1.0.1, QuickCheck-2.1.0.2 and > QuickCheck-2.1.0.3. > However none of them are available. > QuickCheck-2.1 was excluded because happstack-util-0.4.1 requires > QuickCheck > <2 > QuickCheck-2.1.0.1 was excluded because happstack-util-0.4.1 requires > QuickCheck <2 > QuickCheck-2.1.0.2 was excluded because happstack-util-0.4.1 requires > QuickCheck <2 > QuickCheck-2.1.0.3 was excluded because happstack-util-0.4.1 requires > QuickCheck <2 > > Can't cabal handle several versions of the same library in parallel ? If > not, how can I solve this problem ? > > cheers > > tom > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From bulat.ziganshin at gmail.com Tue Feb 9 06:41:23 2010 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Feb 9 06:12:49 2010 Subject: [Haskell-cafe] Compiling on Windows - using a particular Manifest file In-Reply-To: <4B70B474.20303@web.de> References: <4B70B474.20303@web.de> Message-ID: <1999100359.20100209144123@gmail.com> Hello G?nther, Tuesday, February 9, 2010, 4:03:48 AM, you wrote: > how can I make ghc use a particular manifest file for embedding? (on > Windows) compile.cmd: windres.exe -I. Register.rc res.o g++.exe Register.cpp res.o Register.rc: 1 24 "Register.exe.manifest" windres is standard mingw tool alternatively: mt.exe -manifest Register64.exe.manifest -outputresource:Register64.exe where mt.exe is MSVS tool (probably available in free MSVS Express) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From daniel.is.fischer at web.de Tue Feb 9 06:55:45 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Feb 9 06:28:50 2010 Subject: [Haskell-cafe] Iteratee, parsec & co. In-Reply-To: <1265706225.5700.20.camel@picard> References: <1265706225.5700.20.camel@picard> Message-ID: <201002091255.45772.daniel.is.fischer@web.de> Am Dienstag 09 Februar 2010 10:03:46 schrieb Maciej Piechotka: Sorry, I haven't looked at iteratees at all, so I can't answer your questions. > PS. I guess iteratee does qualify as cafe but if beginner would be more > appropriate group then I'm sorry - I'll remember next time. It's not that one kind of question is for the beginners list and only more advanced questions are to be posted in the cafe, the distinction is - the beginners list is lower traffic, so your questions are less likely to be overlooked there (though it's unlikely to be overlooked in the cafe either) - questions on beginners are less likely to get answers involving terms like "zygohistomorphic prepromorphism" So it's more a decision of "what kind of answer do you want" where to post your question. Another aspect is that your question and the answers are more visible on beginners (especially to beginners), so if you think your question is something many beginners would wrestle with, that's a reason to post it on beginners (or both lists), so other beginners may profit more from it. From vasyl.pasternak at gmail.com Tue Feb 9 07:18:23 2010 From: vasyl.pasternak at gmail.com (Vasyl Pasternak) Date: Tue Feb 9 06:49:38 2010 Subject: [Haskell-cafe] Generate random UArray in constant memory space. Message-ID: <8feb08f71002090418g6674453dp8af8f71fd6327011@mail.gmail.com> Hello Cafe, I tried to generate memory-efficient list of random numbers, so I've used uvector library for this task. But it doesn't work, it still allocates more than 6Gb of memory for the random list of 10 million elements. Here is the code: > import Text.Printf > import System.Random > import Control.Applicative > import System.Environment > import Data.Array.Vector > randomListU :: (Int, Int) -> StdGen -> Int -> (UArr Int) > randomListU b g size = unfoldU size gen g > where gen g = let (x, g') = randomR b g > in JustS (x :*: g') > main = do > [size] <- map read <$> getArgs > let ints = randomListU (-10, 10) (mkStdGen 1) size > printf "%d\n" (sumU ints) Could someone give a hint, how to implement this function in constant memory space? Thank you in advance. Best regards, Vasyl Pasternak From thomas at 0xc29.net Tue Feb 9 07:13:06 2010 From: thomas at 0xc29.net (Thomas Girod) Date: Tue Feb 9 06:52:05 2010 Subject: [Haskell-cafe] various dependencies breakages In-Reply-To: <9d4d38821002090311j4ef25b3ch6b625a8e7a0acbea@mail.gmail.com> References: <20100209104024.GA32487@fairlight.lan> <9d4d38821002090311j4ef25b3ch6b625a8e7a0acbea@mail.gmail.com> Message-ID: <20100209121306.GA32614@fairlight.lan> thanks Lars and Max. It did the trick, except for one small detail : MissingH needs the "testpack -any" dependency, but cabal does not install it automatically. tom From tom at lokhorst.eu Tue Feb 9 07:59:07 2010 From: tom at lokhorst.eu (Tom Lokhorst) Date: Tue Feb 9 07:30:41 2010 Subject: [Haskell-cafe] Lazy language on JVM/CLR In-Reply-To: <4B70AF72.1070601@gmail.com> References: <4B70AF72.1070601@gmail.com> Message-ID: <317ca7671002090459n61f20a9aj9daf8e85d6d42772@mail.gmail.com> About a year ago, Jeroen Leeuwenstein and I worked on CLR backend for the Utrecht Haskell Compiler (UHC) [1]. That was a one-month project for a seminar at Utrecht University, and the backend is far from being complete. But we did make some interesting observations. A particular caveat of the UHC is that it does whole program analysis, so we had access to the entire program and all libraries at compile time. A benefit of using the CLR was that it does support tail calls. So a mutual recursive function definition can loop a million times without creating a stack overflow. Our main problem (in efficiency) was lazy evaluation, not knowing the difference between an evaluated `int` and a possible thunk `Lazy`. That meant we had to wrap _everything_ in a layer of indirection, e.g.: > add :: Int -> Int -> Int > add x y = x + y > add 2 4 Becomes something equivalent to: > public int add(Lazy x, Lazy y) > { > return x.Force() + y.Force(); > } > add(new Lazy(() => 2), new Lazy(() => 4)); Having a strictness analyser would have helped tremendously. Also, I wonder if there is some efficient way of implementing the Lazy class, perhaps by having the Force method using runtime code generation to override itself. I don't know if this is possible, but I vaguely remember the Dynamic Language Runtime on .NET doing something like that. I find this an interesting topic, so when you do have something more, please let us know on this list. - Tom Lokhorst [1]: http://tom.lokhorst.eu/ehc/clr/ehc-clr-handout.pdf On Tue, Feb 9, 2010 at 1:42 AM, Tony Morris wrote: > I have hypothesised a pure, lazy language on the JVM and perhaps the > .NET CLR with FFI to .NET/Java libraries. I foresee various problems but > none that are catastrophic; just often requiring a compromises, > sometimes very unattractive compromises. I have authored several > libraries in the same vain as pure, lazy programming to run on the JVM > in Java and Scala programming languages. > > I expect others have forethought and perhaps even experimented with such > a language. Are there any dangers to be wary of that undo the entire > endeavour? > > Thanks for any insights. > > -- > Tony Morris > http://tmorris.net/ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From daniel.is.fischer at web.de Tue Feb 9 07:57:35 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Feb 9 07:30:43 2010 Subject: [Haskell-cafe] Generate random UArray in constant memory space. In-Reply-To: <8feb08f71002090418g6674453dp8af8f71fd6327011@mail.gmail.com> References: <8feb08f71002090418g6674453dp8af8f71fd6327011@mail.gmail.com> Message-ID: <201002091357.35867.daniel.is.fischer@web.de> Am Dienstag 09 Februar 2010 13:18:23 schrieb Vasyl Pasternak: > Hello Cafe, > > I tried to generate memory-efficient list of random numbers, so I've > used uvector library for this task. But it doesn't work, > it still allocates more than 6Gb of memory for the random list of 10 > > million elements. Here is the code: Hmm, $ ghc -O2 --make ranVec [1 of 1] Compiling Main ( ranVec.hs, ranVec.o ) Linking ranVec ... $ ./ranVec 10000000 +RTS -sstderr 5130 4,919,912,080 bytes allocated in the heap 883,256 bytes copied during GC 26,896 bytes maximum residency (1 sample(s)) 25,620 bytes maximum slop 1 MB total memory in use (0 MB lost due to fragmentation) maximum residency is just eight bytes more than for 100,000 or 1,000,000 numbers. I think that is constant space. The ~5 GB total allocation is sequential, ten million new StdGens are produced and allocated, then immediately garbage collected. I see no problem (except that StdGen is slow, e.g. the Mersenne twister is much faster [and allocates less, but still linear in size]). > > import Text.Printf > > import System.Random > > import Control.Applicative > > import System.Environment > > import Data.Array.Vector > > > > randomListU :: (Int, Int) -> StdGen -> Int -> (UArr Int) > > randomListU b g size = unfoldU size gen g > > where gen g = let (x, g') = randomR b g > > in JustS (x :*: g') > > > > main = do > > [size] <- map read <$> getArgs > > let ints = randomListU (-10, 10) (mkStdGen 1) size > > printf "%d\n" (sumU ints) > > Could someone give a hint, how to implement this function in constant > memory space? > > Thank you in advance. > > Best regards, > Vasyl Pasternak From gue.schmidt at web.de Tue Feb 9 08:20:46 2010 From: gue.schmidt at web.de (=?ISO-8859-1?Q?G=FCnther_Schmidt?=) Date: Tue Feb 9 07:52:26 2010 Subject: [Haskell-cafe] Re: haskelldb in-memory driver? In-Reply-To: <4B6EDFE0.3080303@imn.htwk-leipzig.de> References: <4B6EDFE0.3080303@imn.htwk-leipzig.de> Message-ID: <4B71612E.8030101@web.de> Hello Johannes, no, sorry, HaskellDB is only meant for RDBM back ends, it eventually generates SQL (Strings). I tried to create an EDSL for relational algebra in the finally tagless style. This would theoretically allow to create entirely abstract expressions which could then be evaluated to either SQL or in-memory code or whatever. Of course I don't even know how to get started and at the moment it's on the very top of my wish-list because I really need it badly. All my code eventually turned into spaghetti code and without being able to express the algorithm abstractly(but correctly) and decide on implementation later I don't think will even try to untangle my mess, because at least it works. G?nther Am 07.02.10 16:44, schrieb Johannes Waldmann: > Is there a haskelldb-driver that works with a datasource > that is in memory, as a Haskell object? > (like LINQ can work on C# collections) - J. > > > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From colin at colina.demon.co.uk Tue Feb 9 08:33:15 2010 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Tue Feb 9 08:04:28 2010 Subject: [Haskell-cafe] Re: haskelldb in-memory driver? In-Reply-To: <4B71612E.8030101@web.de> (=?utf-8?Q?=22G=C3=BCnther?= Schmidt"'s message of "Tue, 09 Feb 2010 14:20:46 +0100") References: <4B6EDFE0.3080303@imn.htwk-leipzig.de> <4B71612E.8030101@web.de> Message-ID: >>>>> "G?nther" == G?nther Schmidt writes: G?nther> Hello Johannes, no, sorry, HaskellDB is only meant for RDBM G?nther> back ends, it eventually generates SQL (Strings). I recall that there WAS an experimental in-memory backend. -- Colin Adams Preston Lancashire From ganesh.sittampalam at credit-suisse.com Tue Feb 9 08:44:50 2010 From: ganesh.sittampalam at credit-suisse.com (Sittampalam, Ganesh) Date: Tue Feb 9 08:16:09 2010 Subject: [Haskell-cafe] Lazy language on JVM/CLR In-Reply-To: <317ca7671002090459n61f20a9aj9daf8e85d6d42772@mail.gmail.com> References: <4B70AF72.1070601@gmail.com> <317ca7671002090459n61f20a9aj9daf8e85d6d42772@mail.gmail.com> Message-ID: <16442B752A06A74AB4D9F9A5FF076E4B08816E06@ELON17P32001A.csfb.cs-group.com> Tom Lokhorst wrote: > Also, I wonder if there is some efficient way of implementing the > Lazy class, perhaps by having the Force method using runtime code > generation to override itself. I don't know if this is possible, but > I vaguely remember the Dynamic Language Runtime on .NET doing > something like that. .NET 4 (final release due in the next few months) will have a built-in lazy type. Ganesh =============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html =============================================================================== From limestrael at gmail.com Tue Feb 9 08:48:21 2010 From: limestrael at gmail.com (=?UTF-8?Q?Limestra=C3=ABl?=) Date: Tue Feb 9 08:19:32 2010 Subject: [Haskell-cafe] Using Cabal during development Message-ID: <27515446.post@talk.nabble.com> Cabal/cabal-install are good tools for distribution and installation, but I was wondering -- as I was starting to learn how to use Cabal -- how do usually Haskell developpers build their softwares (and especially medium or big libraries) while they are still developping them ? With cabal-install, by doing one 'cabal configure' once and 'cabal build' each time they have altered their code ? With only Cabal, through some 'runhaskell Setup.hs build's ? The point is that I am currently writing a binding for an SDL-like library called SFML. My project is now 55-file wide (and I will have to add some more), uses hsc2hs and has a little executable (for testing purposes) in which I add some code each time I add functionnalities to my binding. What I mean is that it would be a pain to have to compile it by hand whenever I add something to my code. Currently, I compile it by using a simple shell script, but it's a little bit lousy, I think. -- View this message in context: http://old.nabble.com/Using-Cabal-during-development-tp27515446p27515446.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100209/f39ed050/attachment.html From miguelimo38 at yandex.ru Tue Feb 9 08:46:38 2010 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Tue Feb 9 08:21:29 2010 Subject: [Haskell-cafe] Using Cabal during development In-Reply-To: <27515446.post@talk.nabble.com> References: <27515446.post@talk.nabble.com> Message-ID: <4B71673E.2000302@yandex.ru> With cabal-install, usually. Limestra?l wrote: > Cabal/cabal-install are good tools for distribution and installation, > but I was wondering -- as I was starting to learn how to use Cabal -- > how do usually Haskell developpers build their softwares (and especially > medium or big libraries) while they are *still developping them* ? With > cabal-install, by doing one 'cabal configure' once and 'cabal build' > each time they have altered their code ? With only Cabal, through some > 'runhaskell Setup.hs build's ? The point is that I am currently writing > a binding for an SDL-like library called SFML. My project is now 55-file > wide (and I will have to add some more), uses hsc2hs and has a little > executable (for testing purposes) in which I add some code each time I > add functionnalities to my binding. What I mean is that it would be a > pain to have to compile it by hand whenever I add something to my code. > Currently, I compile it by using a simple shell script, but it's a > little bit lousy, I think. > ------------------------------------------------------------------------ > View this message in context: Using Cabal during development > > Sent from the Haskell - Haskell-Cafe mailing list archive > at Nabble.com. > > > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From limestrael at gmail.com Tue Feb 9 08:51:19 2010 From: limestrael at gmail.com (=?UTF-8?Q?Limestra=C3=ABl?=) Date: Tue Feb 9 08:22:30 2010 Subject: [Haskell-cafe] Using Cabal during development In-Reply-To: <27515446.post@talk.nabble.com> References: <27515446.post@talk.nabble.com> Message-ID: <27515487.post@talk.nabble.com> (This is a same message, but with newlines. Sorry for the double post) Cabal/cabal-install are good tools for distribution and installation, but I was wondering -- as I was starting to learn how to use Cabal -- how do usually Haskell developpers build their softwares (and especially medium or big libraries) while they are still developping them ? With cabal-install, by doing one 'cabal configure' once and 'cabal build' each time they have altered their code ? With only Cabal, through some 'runhaskell Setup.hs build's ? The point is that I am currently writing a binding for an SDL-like library called SFML. My project is now 55-file wide (and I will have to add some more), uses hsc2hs and has a little executable (for testing purposes) in which I add some code each time I add functionnalities to my binding. What I mean is that it would be a pain to have to compile it by hand whenever I add something to my code. Currently, I compile it by using a simple shell script, but it's a little bit lousy, I think. -- View this message in context: http://old.nabble.com/Using-Cabal-during-development-tp27515446p27515487.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From ekmett at gmail.com Tue Feb 9 08:51:23 2010 From: ekmett at gmail.com (Edward Kmett) Date: Tue Feb 9 08:22:40 2010 Subject: [Haskell-cafe] Iteratee, parsec & co. In-Reply-To: <1265706225.5700.20.camel@picard> References: <1265706225.5700.20.camel@picard> Message-ID: <7fb8f82f1002090551y653b8b09m8fe22773405430c8@mail.gmail.com> On Tue, Feb 9, 2010 at 4:03 AM, Maciej Piechotka wrote: > I read a lot about iteratee IO and it seemed very interesting > (Unfortunately it lacks tutorial). Especially features like 'no input > yet' in network programming (with lazy IO + parsec I run into problems > as it tried to evaluate the first response character before sending > output). > > I decided first write a simple program and then attempt write a Stream > implementation for parsec. > > > {-# LANGUAGE FlexibleInstances #-} > > {-# LANGUAGE MultiParamTypeClasses #-} > > import Data.Iteratee > > import Text.Parse > > > > data Buffer a = Buffer > > instance Monad m => Stream (Buffer a) (IterateeG [] a m) a where > > uncons Buffer = IterateeG loop > > where loop (Chunk []) = > > return $! Cont (IterateeG loop) Nothing > > loop (Chunk (x:xs)) = > > return $! Done (Just (x, Buffer)) > > (Chunk xs) > > loop (EOF Nothing) = > > return $! Done Nothing (EOF Nothing) > > loop (EOF (Just e)) = > > return $! throwErr e > > 1. I'm not quite sure what Cursor was suppose to do from A Parsing > Trifecta presentation. > Note that my parsing trifecta Iteratee differs from the iteratees defined by Oleg et al; it has access to the entire input so far (accumulated in a fingertree). The Cursor is the index into that finger tree, and is tracked as the 'remaining input' by Parsec, allowing backtracking. The presentation up to that point centers on the changes necessary to Iteratee to make this possible. 2. Is there any package which contains this stream definition? > Not that I'm aware of, but I hardly qualify as an expert in the mainline Iteratee implementation. 3. Why Seek FileOffset is error message? > I'm not quite sure what you're asking here. -Edward Kmett -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100209/758dbdc4/attachment.html From vasyl.pasternak at gmail.com Tue Feb 9 08:51:31 2010 From: vasyl.pasternak at gmail.com (Vasyl Pasternak) Date: Tue Feb 9 08:22:51 2010 Subject: [Haskell-cafe] Generate random UArray in constant memory space. In-Reply-To: <201002091357.35867.daniel.is.fischer@web.de> References: <8feb08f71002090418g6674453dp8af8f71fd6327011@mail.gmail.com> <201002091357.35867.daniel.is.fischer@web.de> Message-ID: <8feb08f71002090551x235c975dwd25cfa8c650e4b19@mail.gmail.com> Sorry, maybe I should ask more clearer. I've looked at dons article "Haskell as fast as C"[1], and tried to implement similar algorithm but for list of random numbers. Please look at code: > import Text.Printf > import Control.Applicative > import System.Environment > import Data.Array.Vector > main = do > [size] <- map read <$> getArgs > let ints = enumFromToU 0 size :: UArr Int > printf "%d\n" (sumU ints) This code runs in constant space (on my pc ~25kb allocates on the heap) regardless of array size. So I tried to achieve similar with random list, just to replace `enumFromToU` with my own list generator. So the question - is it possible to implement random list similary to enumFromToU? [1]http://donsbot.wordpress.com/2008/06/04/haskell-as-fast-as-c-working-at-a-high-altitude-for-low-level-performance/ Thank you, Vasyl Pasternak 2010/2/9 Daniel Fischer : > Am Dienstag 09 Februar 2010 13:18:23 schrieb Vasyl Pasternak: >> Hello Cafe, >> >> I tried to generate memory-efficient list of random numbers, so I've >> used uvector library for this task. But it doesn't work, >> it still allocates more than 6Gb of memory for the random list of 10 >> >> million elements. Here is the code: > > Hmm, > > $ ghc -O2 --make ranVec > [1 of 1] Compiling Main ? ? ? ? ? ? ( ranVec.hs, ranVec.o ) > Linking ranVec ... > $ ./ranVec 10000000 +RTS -sstderr > 5130 > ? 4,919,912,080 bytes allocated in the heap > ? ? ? ? 883,256 bytes copied during GC > ? ? ? ? ?26,896 bytes maximum residency (1 sample(s)) > ? ? ? ? ?25,620 bytes maximum slop > ? ? ? ? ? ? ? 1 MB total memory in use (0 MB lost due to fragmentation) > > maximum residency is just eight bytes more than for 100,000 or 1,000,000 > numbers. I think that is constant space. > > The ~5 GB total allocation is sequential, ten million new StdGens are > produced and allocated, then immediately garbage collected. I see no > problem (except that StdGen is slow, e.g. the Mersenne twister is much > faster [and allocates less, but still linear in size]). > >> > import Text.Printf >> > import System.Random >> > import Control.Applicative >> > import System.Environment >> > import Data.Array.Vector >> > >> > randomListU :: (Int, Int) -> StdGen -> Int -> (UArr Int) >> > randomListU b g size = unfoldU size gen g >> > ? where gen g = let (x, g') = randomR b g >> > ? ? ? ? ? ? ? ? in JustS (x :*: g') >> > >> > main = do >> > ? [size] <- map read <$> getArgs >> > ? let ints = randomListU (-10, 10) (mkStdGen 1) size >> > ? printf "%d\n" ?(sumU ints) >> >> Could someone give a hint, how to implement this function in constant >> memory space? >> >> Thank you in advance. >> >> Best regards, >> Vasyl Pasternak > > From gue.schmidt at web.de Tue Feb 9 09:04:00 2010 From: gue.schmidt at web.de (=?UTF-8?B?R8O8bnRoZXIgU2NobWlkdA==?=) Date: Tue Feb 9 08:35:38 2010 Subject: [Haskell-cafe] Re: haskelldb in-memory driver? In-Reply-To: References: <4B6EDFE0.3080303@imn.htwk-leipzig.de> <4B71612E.8030101@web.de> Message-ID: <4B716B50.9030305@web.de> Hello, for completeness there is also CoddFish, which is not based on HaskellDB, but rather on Oleg's HList. G?nther Am 09.02.10 14:33, schrieb Colin Paul Adams: >>>>>> "G?nther" == G?nther Schmidt writes: > > G?nther> Hello Johannes, no, sorry, HaskellDB is only meant for RDBM > G?nther> back ends, it eventually generates SQL (Strings). > > I recall that there WAS an experimental in-memory backend. From ivan.panachev at gmail.com Tue Feb 9 09:06:58 2010 From: ivan.panachev at gmail.com (Ivan Panachev) Date: Tue Feb 9 08:38:09 2010 Subject: [Haskell-cafe] haskelldb in-memory driver? In-Reply-To: <4B6EDFE0.3080303@imn.htwk-leipzig.de> References: <4B6EDFE0.3080303@imn.htwk-leipzig.de> Message-ID: On Sun, Feb 7, 2010 at 6:44 PM, Johannes Waldmann < waldmann@imn.htwk-leipzig.de> wrote: > Is there a haskelldb-driver that works with a datasource > that is in memory, as a Haskell object? > (like LINQ can work on C# collections) - J. > > SQLite could make it, take a look at http://www.sqlite.org/inmemorydb.html -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100209/4ba3b2a2/attachment.html From ketil at malde.org Tue Feb 9 09:10:56 2010 From: ketil at malde.org (Ketil Malde) Date: Tue Feb 9 08:42:03 2010 Subject: [Haskell-cafe] Using Cabal during development In-Reply-To: <27515446.post@talk.nabble.com> (=?utf-8?Q?=22Limestra=C3=ABl?= =?utf-8?Q?=22's?= message of "Tue, 9 Feb 2010 05:48:21 -0800 (PST)") References: <27515446.post@talk.nabble.com> Message-ID: <87r5ouebyn.fsf@malde.org> Limestra?l writes: > how do usually Haskell developpers build their softwares (and > especially medium or big libraries) while they are still developping them ? > With cabal-install, by doing one 'cabal configure' once and 'cabal build' > each time they have altered their code ? > With only Cabal, through some 'runhaskell Setup.hs build's ? Generally, the first thing I do is hit C-c C-l in Emacs to load the current file into a haskell process. Then back to fix the type errors (click on the error to jump to the code), and iterate until it loads correctly. Then I can play with expressions in the Haskell buffer until I'm satisfied things work as expected. Now I can use darcsum to record the changes. For libraries, I switch to an xterm to do the "./Setup.hs build; sudo ./Setup.hs install" routine. I guess I could be using cabal-install for this, but I haven't really gotten around to installing it everywhere yet. For binaries, I sometimes build executables using ghc --make in the shell, using -optl-static -oplt-pthread to build static executables for distribution to different machines. This process could probably be improved, but that's how it stands at the moment. -k -- If I haven't seen further, it is by standing in the footprints of giants From limestrael at gmail.com Tue Feb 9 09:14:31 2010 From: limestrael at gmail.com (=?UTF-8?Q?Limestra=C3=ABl?=) Date: Tue Feb 9 08:45:42 2010 Subject: [Haskell-cafe] Using Cabal during development In-Reply-To: <4B71673E.2000302@yandex.ru> References: <27515446.post@talk.nabble.com> <4B71673E.2000302@yandex.ru> Message-ID: <27515830.post@talk.nabble.com> Okay, so then I have so troubles regarding the compilation of my executable: First, what do you think is the simpler : (1) build only the library through cabal-install and then the executable with ghc (it isn't to be distributed with the lib), or (2) add both to my http://old.nabble.com/file/p27515830/HSFML.cabal .cabal file and build them in the same time with a 'cabal build' ? Because I've tried both methods, and have had issues with both : (1) after a 'cabal build', ghc doesn't know where to find my library -- whereas cabal-install displays 'Registering HSFL-1.5...' at the end of the build -- when I do 'ghc --make main.hs'. I'm not gonna do a 'cabal install' whenever I alter my code, am I? (2) well, then, when building, if I don't specify that my executable depends on my lib, I got: SFML/Direct/Graphics.hs:51:7: Could not find module `SFML.Direct.Types.Enums': It is a member of the hidden package `HSFML-1.5'. Perhaps you need to add `HSFML' to the build-depends in your .cabal file. it is a hidden module in the package `HSFML-1.5' Use -v to see a list of the files searched for. and if I do what I asks me to add (I add the line 'Build-Depends: HSFML' in the 'Executable' section of my .cabal file), I'm told when 'cabal build'ing: cabal: internal error: could not construct a valid install plan. The proposed (invalid) plan contained the following problems: The following packages are involved in a dependency cycle HSFML-1.5 Miguel Mitrofanov wrote: > > With cabal-install, usually. > -- View this message in context: http://old.nabble.com/Using-Cabal-during-development-tp27515446p27515830.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From inforichland at gmail.com Tue Feb 9 09:31:42 2010 From: inforichland at gmail.com (Tim Wawrzynczak) Date: Tue Feb 9 09:02:54 2010 Subject: [Haskell-cafe] Lazy language on JVM/CLR In-Reply-To: <4B70AF72.1070601@gmail.com> References: <4B70AF72.1070601@gmail.com> Message-ID: <4335a3261002090631s20e8dc48g9cc375ff6197009d@mail.gmail.com> Perhaps this is similar to what you're looking for. http://openquark.org/Open_Quark/Welcome.html It's a pure, lazy language for the JVM. I haven't used it myself, but I would imagine that it would have a Java FFI. Cheers, - Tim On Mon, Feb 8, 2010 at 6:42 PM, Tony Morris wrote: > I have hypothesised a pure, lazy language on the JVM and perhaps the > .NET CLR with FFI to .NET/Java libraries. I foresee various problems but > none that are catastrophic; just often requiring a compromises, > sometimes very unattractive compromises. I have authored several > libraries in the same vain as pure, lazy programming to run on the JVM > in Java and Scala programming languages. > > I expect others have forethought and perhaps even experimented with such > a language. Are there any dangers to be wary of that undo the entire > endeavour? > > Thanks for any insights. > > -- > Tony Morris > http://tmorris.net/ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100209/4170a6a2/attachment.html From ekmett at gmail.com Tue Feb 9 09:36:21 2010 From: ekmett at gmail.com (Edward Kmett) Date: Tue Feb 9 09:07:31 2010 Subject: [Haskell-cafe] Lazy language on JVM/CLR In-Reply-To: <20100209011659.GD16245@sliver.repetae.net> References: <4B70AF72.1070601@gmail.com> <20100209011659.GD16245@sliver.repetae.net> Message-ID: <7fb8f82f1002090636w4f7df5c5xde11fb6ea9898061@mail.gmail.com> On Mon, Feb 8, 2010 at 8:16 PM, John Meacham wrote: > > > I expect others have forethought and perhaps even experimented with such > > a language. Are there any dangers to be wary of that undo the entire > > endeavour? > > There have been a couple papers published on it, the main sticking point > seems to be tail call elimination. When targeting real hardware you > always had the option of dropping to assembly to do a direct jump, but > there isn't an equivalent in the JVM. If you look up tail call + jvm you > will probably get a few hits. I believe there are even a couple haskell > specific papers on the issue. > One of the easiest approaches to this comes from the scheme folks and I've been able to employ it fairly effectively in toy compilers. It doesn't require anything from the host language except exceptions and you can use it to evaluate spineless tagless g-machine frames mostly on the native/VM stack fairly easily. The biggest problem is the generated code bloat factor of about 2-3x. http://www.ccs.neu.edu/scheme/pubs/stackhack4.html http://www.cs.brown.edu/~sk/Publications/Papers/Published/pcmkf-cont-from-gen-stack-insp/ -Edward Kmett -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100209/b653c879/attachment.html From limestrael at gmail.com Tue Feb 9 10:03:20 2010 From: limestrael at gmail.com (=?UTF-8?Q?Limestra=C3=ABl?=) Date: Tue Feb 9 09:34:31 2010 Subject: [Haskell-cafe] Using Cabal during development In-Reply-To: <27515830.post@talk.nabble.com> References: <27515446.post@talk.nabble.com> <4B71673E.2000302@yandex.ru> <27515830.post@talk.nabble.com> Message-ID: <27516610.post@talk.nabble.com> Okay, I juste solved issue (1) : The package compiled through Cabal has its information stored in the dist/package.conf.inplace file. I can then compile my main by doing : ghc --make -package-conf dist/package.conf.inplace main.hs I just don't know if it's really the way I'm supposed to do this. Nevertheless, issue (2) remains... Limestra?l wrote: > > Okay, so then I have some troubles regarding the compilation of my > executable: > > First, what do you think is the simpler : (1) build only the library > through cabal-install and then the executable with ghc (it isn't to be > distributed with the lib), or (2) add both to my > http://old.nabble.com/file/p27515830/HSFML.cabal .cabal file and build > them in the same time with a 'cabal build' ? > > Because I've tried both methods, and have had issues with both : > (1) after a 'cabal build', ghc doesn't know where to find my library -- > whereas cabal-install displays 'Registering HSFL-1.5...' at the end of the > build -- when I do 'ghc --make main.hs'. I'm not gonna do a 'cabal > install' whenever I alter my code, am I? > > (2) well, then, when building, if I don't specify that my executable > depends on my lib, I got: > SFML/Direct/Graphics.hs:51:7: > Could not find module `SFML.Direct.Types.Enums': > It is a member of the hidden package `HSFML-1.5'. > Perhaps you need to add `HSFML' to the build-depends in your .cabal > file. > it is a hidden module in the package `HSFML-1.5' > Use -v to see a list of the files searched for. > > and if I do what it asks me to do (to add the line 'Build-Depends: HSFML' > in the 'Executable' section of my .cabal file), I'm told when 'cabal > build'ing: > cabal: internal error: could not construct a valid install plan. > The proposed (invalid) plan contained the following problems: > The following packages are involved in a dependency cycle HSFML-1.5 > > > > Miguel Mitrofanov wrote: >> >> With cabal-install, usually. >> > > -- View this message in context: http://old.nabble.com/Using-Cabal-during-development-tp27515446p27516610.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From valery.vv at gmail.com Tue Feb 9 10:08:48 2010 From: valery.vv at gmail.com (Valery V. Vorotyntsev) Date: Tue Feb 9 09:40:00 2010 Subject: [Haskell-cafe] Iteratee, parsec & co. In-Reply-To: <1265706225.5700.20.camel@picard> References: <1265706225.5700.20.camel@picard> Message-ID: | 3. Why Seek FileOffset is error message? Are you talking about John Lato's implementation [1]? Well, `Seek' is not an error message. It is one of constructors for ErrMsg, and ErrMsg is [2] > -- -- a message to the stream producer (e.g., to rewind the stream) > -- or an error indication. You know the overall idea behind Seek, don't you? It is an instrument to implement random IO [3]. Compare Oleg's code [4] > data SeekException = SeekException FileOffset > deriving Show > > instance Typeable SeekException where > typeOf _ = mkTyConApp (mkTyCon "SeekException") [] > > instance Exception SeekException and [2] > type ErrMsg = SomeException > data Stream el = EOF (Maybe ErrMsg) | Chunk [el] deriving Show with John Lato's implementation [1]: > data StreamG c el = > EOF (Maybe ErrMsg) > | Chunk (c el) > data ErrMsg = Err String > | Seek FileOffset > deriving (Show, Eq) John makes Err and Seek to be the distinct constructors of ErrMsg. Errors (Err) in `iteratee' package are always Strings. Oleg's ErrMsg is SomeException. One of its instances (SeekException) is a ``rewind the stream'' message to the stream producer. And the user is free to have as many different ErrMsg'es as he needs to do the job. [1] http://inmachina.net/~jwlato/haskell/iteratee/src/Data/Iteratee/Base.hs [2] http://okmij.org/ftp/Haskell/Iteratee/IterateeM.hs [3] http://okmij.org/ftp/Streams.html#random-bin-IO [4] http://okmij.org/ftp/Haskell/Iteratee/RandomIO.hs -- vvv From daniel.is.fischer at web.de Tue Feb 9 10:30:45 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Feb 9 10:03:50 2010 Subject: [Haskell-cafe] Generate random UArray in constant memory space. In-Reply-To: <8feb08f71002090551x235c975dwd25cfa8c650e4b19@mail.gmail.com> References: <8feb08f71002090418g6674453dp8af8f71fd6327011@mail.gmail.com> <201002091357.35867.daniel.is.fischer@web.de> <8feb08f71002090551x235c975dwd25cfa8c650e4b19@mail.gmail.com> Message-ID: <201002091630.45467.daniel.is.fischer@web.de> Am Dienstag 09 Februar 2010 14:51:31 schrieb Vasyl Pasternak: > Sorry, maybe I should ask more clearer. > > I've looked at dons article "Haskell as fast as C"[1], and tried to > implement similar algorithm but for list of random numbers. > > Please look at code: > > import Text.Printf > > import Control.Applicative > > import System.Environment > > import Data.Array.Vector > > > > main = do > > [size] <- map read <$> getArgs > > let ints = enumFromToU 0 size :: UArr Int > > printf "%d\n" (sumU ints) > > This code runs in constant space (on my pc ~25kb allocates on the > heap) regardless of array size. The random number thing runs in constant space, too. The difference is that the enumFromToU produces a tight loop with variables which never leave the registers, while in the random number thing at least the StdGens are allocated in the heap (the produced Ints may stay in the registers, too, I don't know). But enumFromToU and friends were written for that to happen, there are a ton of rewrite rules to help the compiler create tight loops. StdGen has no such thing, randomR has no {-# INLINE #-} pragma, so you have a call to randomR (well, to randomIValInteger, actually) for each element. Maybe if you had the source for the PRNG in the same file, it could be inlined to give an allocation-free loop. > So I tried to achieve similar with > random list, just to replace `enumFromToU` with my own list generator. > > So the question - is it possible to implement random list similary to > enumFromToU? > > > [1]http://donsbot.wordpress.com/2008/06/04/haskell-as-fast-as-c-working- >at-a-high-altitude-for-low-level-performance/ > > Thank you, > Vasyl Pasternak > > 2010/2/9 Daniel Fischer : > > Am Dienstag 09 Februar 2010 13:18:23 schrieb Vasyl Pasternak: > >> Hello Cafe, > >> > >> I tried to generate memory-efficient list of random numbers, so I've > >> used uvector library for this task. But it doesn't work, > >> it still allocates more than 6Gb of memory for the random list of 10 > >> > >> million elements. Here is the code: > > > > Hmm, > > > > $ ghc -O2 --make ranVec > > [1 of 1] Compiling Main ? ? ? ? ? ? ( ranVec.hs, ranVec.o ) > > Linking ranVec ... > > $ ./ranVec 10000000 +RTS -sstderr > > 5130 > > ? 4,919,912,080 bytes allocated in the heap > > ? ? ? ? 883,256 bytes copied during GC > > ? ? ? ? ?26,896 bytes maximum residency (1 sample(s)) > > ? ? ? ? ?25,620 bytes maximum slop > > ? ? ? ? ? ? ? 1 MB total memory in use (0 MB lost due to > > fragmentation) > > > > maximum residency is just eight bytes more than for 100,000 or > > 1,000,000 numbers. I think that is constant space. > > > > The ~5 GB total allocation is sequential, ten million new StdGens are > > produced and allocated, then immediately garbage collected. I see no > > problem (except that StdGen is slow, e.g. the Mersenne twister is much > > faster [and allocates less, but still linear in size]). > > > >> > import Text.Printf > >> > import System.Random > >> > import Control.Applicative > >> > import System.Environment > >> > import Data.Array.Vector > >> > > >> > randomListU :: (Int, Int) -> StdGen -> Int -> (UArr Int) > >> > randomListU b g size = unfoldU size gen g > >> > ? where gen g = let (x, g') = randomR b g > >> > ? ? ? ? ? ? ? ? in JustS (x :*: g') > >> > > >> > main = do > >> > ? [size] <- map read <$> getArgs > >> > ? let ints = randomListU (-10, 10) (mkStdGen 1) size > >> > ? printf "%d\n" ?(sumU ints) > >> > >> Could someone give a hint, how to implement this function in constant > >> memory space? > >> > >> Thank you in advance. > >> > >> Best regards, > >> Vasyl Pasternak From chris at eidhof.nl Tue Feb 9 10:44:59 2010 From: chris at eidhof.nl (Chris Eidhof) Date: Tue Feb 9 10:16:18 2010 Subject: [Haskell-cafe] Lazy language on JVM/CLR In-Reply-To: <4335a3261002090631s20e8dc48g9cc375ff6197009d@mail.gmail.com> References: <4B70AF72.1070601@gmail.com> <4335a3261002090631s20e8dc48g9cc375ff6197009d@mail.gmail.com> Message-ID: <4C1B19C2-534D-4664-AE4C-07570AF1B71C@eidhof.nl> I don't think it's pure. I would definitely use a pure language on the JVM, but IIRC Open Quark / Cal is an impure language. For example, from the library documentation: "printLine :: String -> ()". -chris On 9 feb 2010, at 15:31, Tim Wawrzynczak wrote: > Perhaps this is similar to what you're looking for. > > http://openquark.org/Open_Quark/Welcome.html > > It's a pure, lazy language for the JVM. I haven't used it myself, but I would imagine that > it would have a Java FFI. > > Cheers, > - Tim > > On Mon, Feb 8, 2010 at 6:42 PM, Tony Morris wrote: > I have hypothesised a pure, lazy language on the JVM and perhaps the > .NET CLR with FFI to .NET/Java libraries. I foresee various problems but > none that are catastrophic; just often requiring a compromises, > sometimes very unattractive compromises. I have authored several > libraries in the same vain as pure, lazy programming to run on the JVM > in Java and Scala programming languages. > > I expect others have forethought and perhaps even experimented with such > a language. Are there any dangers to be wary of that undo the entire > endeavour? > > Thanks for any insights. > > -- > Tony Morris > http://tmorris.net/ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From inforichland at gmail.com Tue Feb 9 10:52:35 2010 From: inforichland at gmail.com (Tim Wawrzynczak) Date: Tue Feb 9 10:23:48 2010 Subject: [Haskell-cafe] Lazy language on JVM/CLR In-Reply-To: <4C1B19C2-534D-4664-AE4C-07570AF1B71C@eidhof.nl> References: <4B70AF72.1070601@gmail.com> <4335a3261002090631s20e8dc48g9cc375ff6197009d@mail.gmail.com> <4C1B19C2-534D-4664-AE4C-07570AF1B71C@eidhof.nl> Message-ID: <4335a3261002090752j4ead5c25g3b6bb627f8815873@mail.gmail.com> Oops, you're right. It's not pure. Mea cupla for not reading more closely. I wonder how it deals with I/O, then? I don't see anything like Haskell's monads or Clean's uniqueness typing... but at a closer look it does appear to have an excellent Java FFI. On Tue, Feb 9, 2010 at 9:44 AM, Chris Eidhof wrote: > I don't think it's pure. I would definitely use a pure language on the JVM, > but IIRC Open Quark / Cal is an impure language. For example, from the > library documentation: "printLine :: String -> ()". > > -chris > > On 9 feb 2010, at 15:31, Tim Wawrzynczak wrote: > > > Perhaps this is similar to what you're looking for. > > > > http://openquark.org/Open_Quark/Welcome.html > > > > It's a pure, lazy language for the JVM. I haven't used it myself, but I > would imagine that > > it would have a Java FFI. > > > > Cheers, > > - Tim > > > > On Mon, Feb 8, 2010 at 6:42 PM, Tony Morris > wrote: > > I have hypothesised a pure, lazy language on the JVM and perhaps the > > .NET CLR with FFI to .NET/Java libraries. I foresee various problems but > > none that are catastrophic; just often requiring a compromises, > > sometimes very unattractive compromises. I have authored several > > libraries in the same vain as pure, lazy programming to run on the JVM > > in Java and Scala programming languages. > > > > I expect others have forethought and perhaps even experimented with such > > a language. Are there any dangers to be wary of that undo the entire > > endeavour? > > > > Thanks for any insights. > > > > -- > > Tony Morris > > http://tmorris.net/ > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100209/f5231c05/attachment.html From johan.tibell at gmail.com Tue Feb 9 11:03:15 2010 From: johan.tibell at gmail.com (Johan Tibell) Date: Tue Feb 9 10:34:47 2010 Subject: [Haskell-cafe] Using Cabal during development In-Reply-To: <87r5ouebyn.fsf@malde.org> References: <27515446.post@talk.nabble.com> <87r5ouebyn.fsf@malde.org> Message-ID: <90889fe71002090803p78d1be5bo34a97175d8d22d0d@mail.gmail.com> On Tue, Feb 9, 2010 at 6:10 AM, Ketil Malde wrote: > Limestra?l writes: > > > how do usually Haskell developpers build their softwares (and > > especially medium or big libraries) while they are still developping them > ? > > With cabal-install, by doing one 'cabal configure' once and 'cabal build' > > each time they have altered their code ? > > With only Cabal, through some 'runhaskell Setup.hs build's ? > > Generally, the first thing I do is hit C-c C-l in Emacs to load the > current file into a haskell process. Then back to fix the type errors > (click on the error to jump to the code), and iterate until it loads > correctly. > > It's really unfortunate that this approach doesn't work for .hsc files. When writing low level libraries I often have a couple of these which forces me out of my nice Emacs workflow into an Emacs + terminal + Cabal workflow. -- Johan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100209/e169902e/attachment.html From leather at cs.uu.nl Tue Feb 9 11:40:47 2010 From: leather at cs.uu.nl (Sean Leather) Date: Tue Feb 9 11:12:19 2010 Subject: [Haskell-cafe] Strange Haddock output Message-ID: <3c6288ab1002090840h6e25fdc1g7eaec5f7cd573366@mail.gmail.com> I was browsing Hackage pointlessly and came across what appears to be strange Haddock formatting here: http://hackage.haskell.org/packages/archive/pointless-haskell/0.0.3/doc/html/Generics-Pointless-Functors.html#v%3Afmap The following source -- | Polytypic 'Prelude.Functor' class for functor representations class Functor (f :: * -> *) where ? fmap :: Fix f ? ? ? ? ? ? ? ? ? ? ? ? ?-- ^ For desambiguation purposes, the type of the functor must be passed as an explicit paramaeter to 'fmap' ? ? ? ?-> (x -> y) -> Rep f x -> Rep f y -- ^ The mapping over representations produces the following view from the browser class Functor f where ?Polytypic Prelude.Functor class for functor representations ?Methods ? ?fmap ? ? ?:: ? ? ?=> Fix f ? ? ?-> x -> y ? ? ?-> Rep f x The mapping over representations ? ? ?-> Rep f y with the Haddock 2.6.0 on Hackage. There seems to be an extraneous => in the signature of fmap, and the comment on Fix f does not show up. Sean From jwlato at gmail.com Tue Feb 9 11:41:31 2010 From: jwlato at gmail.com (John Lato) Date: Tue Feb 9 11:12:44 2010 Subject: [Haskell-cafe] Re: Haskell-Cafe Digest, Vol 78, Issue 14 In-Reply-To: <20100209133545.82064324655@www.haskell.org> References: <20100209133545.82064324655@www.haskell.org> Message-ID: <9979e72e1002090841x4916e029qf32fad7abc8854d3@mail.gmail.com> Edward's reply was quite good. I'll just try to fill in a few items he didn't address. > From: Maciej Piechotka > > I read a lot about iteratee IO and it seemed very interesting > (Unfortunately it lacks tutorial). Especially features like 'no input > yet' in network programming (with lazy IO + parsec I run into problems > as it tried to evaluate the first response character before sending > output). > > I decided first write a simple program and then attempt write a Stream > implementation for parsec. > >> {-# LANGUAGE FlexibleInstances #-} >> {-# LANGUAGE MultiParamTypeClasses #-} >> import Data.Iteratee >> import Text.Parse >> >> data Buffer a = Buffer >> instance Monad m => Stream (Buffer a) (IterateeG [] a m) a where >> ? ? uncons Buffer = IterateeG loop >> ? ? ? ? ? ? ? ? ? ? where loop (Chunk []) ? ? = >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? return $! Cont (IterateeG loop) Nothing >> ? ? ? ? ? ? ? ? ? ? ? ? ? loop (Chunk (x:xs)) = >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? return $! Done (Just (x, Buffer)) >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?(Chunk xs) >> ? ? ? ? ? ? ? ? ? ? ? ? ? loop (EOF Nothing) ?= >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? return $! Done Nothing (EOF Nothing) >> ? ? ? ? ? ? ? ? ? ? ? ? ? loop (EOF (Just e)) = >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? return $! throwErr e > > > 2. Is there any package which contains this stream definition? I believe this Stream instance is incorrect. According to the parsec-3.0.1 docs, "A Stream instance is responsible for maintaining the 'position within the stream' in the stream state s. This is trivial unless you are using the monad in a non-trivial way." This is necessary for referential integrity. That is, "uncons s" needs to always evaluate to the same result for the same 's'. Your Stream instance doesn't preserve this. As an example, > testIter = let b = Buffer in uncons b >> uncons b should be an iteratee that returns a "Maybe (t, buffer)" where t is the first element in the enumeration, but with your instance it will return the second. See http://inmachina.net/~jwlato/haskell/ParsecIteratee.hs for a valid Stream instance using iteratee. Also Gregory Collins recently posted an iteratee wrapper for Attoparsec to haskell-cafe. To my knowledge these are not yet in any packages, but hackage is vast. > > 3. Why Seek FileOffset is error message? Version 3 of iteratee is somewhat experimental, one of the ideas on trial is that of resumable exceptions. This framework is perfectly suited to handle control messages as well, which is why Seek is included as an error message. I don't want to make a major release just to fix this, but both error handling and control messages will undergo a substantial cleanup in the next major version. Included in this will be a proper separation between control messages and true exceptions, most likely based upon the extensible-exceptions framework. Cheers, John From mightybyte at gmail.com Tue Feb 9 11:43:29 2010 From: mightybyte at gmail.com (MightyByte) Date: Tue Feb 9 11:14:40 2010 Subject: [Haskell-cafe] various dependencies breakages In-Reply-To: <20100209121306.GA32614@fairlight.lan> References: <20100209104024.GA32487@fairlight.lan> <9d4d38821002090311j4ef25b3ch6b625a8e7a0acbea@mail.gmail.com> <20100209121306.GA32614@fairlight.lan> Message-ID: The latest darcs head for happstack has changed the quickcheck dependency to > 2. You might try that. On Tue, Feb 9, 2010 at 7:13 AM, Thomas Girod wrote: > thanks Lars and Max. It did the trick, except for one small detail : > > MissingH needs the "testpack -any" dependency, but cabal does not > install it automatically. > > tom > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From jwlato at gmail.com Tue Feb 9 11:50:52 2010 From: jwlato at gmail.com (John Lato) Date: Tue Feb 9 11:22:06 2010 Subject: [Haskell-cafe] Iteratee, parsec & co. Message-ID: <9979e72e1002090850t2a3f24c0ic49ac2f1fcd8c7f9@mail.gmail.com> > From: Edward Kmett > > 3. Why Seek FileOffset is error message? >> > > I'm not quite sure what you're asking here. One of the infelicities of iteratee-0.3 is that it defines a data type: > data ErrMsg = Err String > | Seek FileOffset > deriving (Show, Eq) I believe this is what the OP is referring to. Oleg originally implemented seek using IORefs; I wanted to try this and didn't know if it would work so I used a minimal implementation. I've decided this is the correct approach, but the details need to be tweaked a bit. Cheers, John From daniel.is.fischer at web.de Tue Feb 9 12:13:51 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Feb 9 11:46:56 2010 Subject: [Haskell-cafe] Generate random UArray in constant memory space. In-Reply-To: <8feb08f71002090643r54f5ac94kffd49838783dfe66@mail.gmail.com> References: <8feb08f71002090418g6674453dp8af8f71fd6327011@mail.gmail.com> <8feb08f71002090551x235c975dwd25cfa8c650e4b19@mail.gmail.com> <8feb08f71002090643r54f5ac94kffd49838783dfe66@mail.gmail.com> Message-ID: <201002091813.51750.daniel.is.fischer@web.de> Am Tuesday 09 February 2010 15:43:13 schrieben Sie: > Update: > > I've implemented `enumFromToU` through `unfoldU`: > > enumFromToU' from to = unfoldU (to - from) f from > > where f i = let i' = i + 1 in JustS (i' :*: i') > > This code behaves similarly to `enumFromToU` (i.e. constantly uses ~25 > kb of memory, runs in the same time as above). Wait, $ cat venum2.hs module Main (main) where import Text.Printf import Control.Applicative import System.Environment import Data.Array.Vector main = do ? [size] <- map read <$> getArgs ? let ints = enumFromToU' 0 size :: UArr Int ? printf "%d\n" ?(sumU ints) enumFromToU' from to = unfoldU (to - from) f from ? ?where f i = let i' = i + 1 in JustS (i' :*: i') $ ghc -O2 --make venum2 [1 of 1] Compiling Main ( venum2.hs, venum2.o ) Linking venum2 ... $ ./venum2 +RTS -sstderr -RTS 1000000 ./venum2 1000000 +RTS -sstderr 1784293664 48,256,384 bytes allocated in the heap 6,256 bytes copied during GC 26,804 bytes maximum residency (1 sample(s)) 25,524 bytes maximum slop 1 MB total memory in use (0 MB lost due to fragmentation) $ ./venum2 +RTS -sstderr -RTS 10000000 ./venum2 10000000 +RTS -sstderr -2004260032 481,937,552 bytes allocated in the heap 19,516 bytes copied during GC 26,804 bytes maximum residency (1 sample(s)) 25,512 bytes maximum slop 1 MB total memory in use (0 MB lost due to fragmentation) So we have constant memory, but linear allocation, just like with the random numbers. With enumFromToU, also the allocation is constant, so unfoldU allocates, enumFromToU not. > > So the question is why random number list generator eats O(n) memory ? It doesn't, not here, at least. Using System.Random, the allocation figures are about ten times as high, but the residency is about the same. Putting the PRNG code in the same file and tweaking things a bit (eliminating all intermediate Integers, e.g.), I get $ cat ran2Vec.hs {-# LANGUAGE BangPatterns #-} module Main (main) where import Text.Printf import Control.Applicative import System.Environment import Data.Array.Vector randomListU :: (Int, Int) -> StdGen -> Int -> (UArr Int) randomListU b@(l,h) g size = unfoldU size gen g ? where !k = h-l+1 !b' = 2147483561 `rem` k gen !g = let (!x, !g') = stdNext g in JustS ((l+ (x+b') `rem` k) :*: g') main = do ? [size] <- map read <$> getArgs ? let ints = randomListU (-10, 10) (mkStdGen 1) size ? printf "%d\n" ?(sumU ints) data StdGen = StdGen {-# UNPACK #-} !Int {-# UNPACK #-} !Int mkStdGen :: Int -> StdGen mkStdGen s | s < 0 = mkStdGen (-s) | otherwise = StdGen (s1+1) (s2+1) where (q, s1) = s `divMod` 2147483562 s2 = q `mod` 2147483398 {-# INLINE stdNext #-} stdNext :: StdGen -> (Int, StdGen) -- Returns values in the range stdRange stdNext (StdGen s1 s2) = z' `seq` g' `seq` (z', g') where !g' = StdGen s1'' s2'' !z' = if z < 1 then z + 2147483562 else z !z = s1'' - s2'' !k = s1 `quot` 53668 !s1' = 40014 * (s1 - k * 53668) - k * 12211 !s1'' = if s1' < 0 then s1' + 2147483563 else s1' !k' = s2 `quot` 52774 !s2' = 40692 * (s2 - k' * 52774) - k' * 3791 !s2'' = if s2' < 0 then s2' + 2147483399 else s2' $ ghc -O2 -funbox-strict-fields -funfolding-use-threshold=16 --make ran2Vec -o ran2AVec5 Linking ran2AVec5 ... $ ./ran2AVec5 +RTS -sstderr -RTS 10000000 ./ran2AVec5 10000000 +RTS -sstderr 5130 521,828,888 bytes allocated in the heap 8,664 bytes copied during GC 26,788 bytes maximum residency (1 sample(s)) 25,636 bytes maximum slop 1 MB total memory in use (0 MB lost due to fragmentation) nearly the same allocation figures as for the *much* simpler enumFromToU', and it's about ten times as fast as System.Random. > > Regards, > Vasyl Pasternak > > 2010/2/9 Vasyl Pasternak : > > Sorry, maybe I should ask more clearer. > > > > I've looked at dons article "Haskell as fast as C"[1], and tried to > > implement similar algorithm but for list of random numbers. > > > > Please look at code: > >> import Text.Printf > >> import Control.Applicative > >> import System.Environment > >> import Data.Array.Vector > >> > >> main = do > >> ? [size] <- map read <$> getArgs > >> ? let ints = enumFromToU 0 size :: UArr Int > >> ? printf "%d\n" ?(sumU ints) > > > > This code runs in constant space (on my pc ~25kb allocates on the > > heap) regardless of array size. So I tried to achieve similar with > > random list, just to replace `enumFromToU` with my own list generator. > > > > So the question - is it possible to implement random list similary to > > enumFromToU? > > > > > > [1]http://donsbot.wordpress.com/2008/06/04/haskell-as-fast-as-c-workin > >g-at-a-high-altitude-for-low-level-performance/ > > > > Thank you, > > Vasyl Pasternak > > > > 2010/2/9 Daniel Fischer : > >> Am Dienstag 09 Februar 2010 13:18:23 schrieb Vasyl Pasternak: > >>> Hello Cafe, > >>> > >>> I tried to generate memory-efficient list of random numbers, so I've > >>> used uvector library for this task. But it doesn't work, > >>> it still allocates more than 6Gb of memory for the random list of 10 > >>> > >>> million elements. Here is the code: > >> > >> Hmm, > >> > >> $ ghc -O2 --make ranVec > >> [1 of 1] Compiling Main ? ? ? ? ? ? ( ranVec.hs, ranVec.o ) > >> Linking ranVec ... > >> $ ./ranVec 10000000 +RTS -sstderr > >> 5130 > >> ? 4,919,912,080 bytes allocated in the heap > >> ? ? ? ? 883,256 bytes copied during GC > >> ? ? ? ? ?26,896 bytes maximum residency (1 sample(s)) > >> ? ? ? ? ?25,620 bytes maximum slop > >> ? ? ? ? ? ? ? 1 MB total memory in use (0 MB lost due to > >> fragmentation) > >> > >> maximum residency is just eight bytes more than for 100,000 or > >> 1,000,000 numbers. I think that is constant space. > >> > >> The ~5 GB total allocation is sequential, ten million new StdGens are > >> produced and allocated, then immediately garbage collected. I see no > >> problem (except that StdGen is slow, e.g. the Mersenne twister is > >> much faster [and allocates less, but still linear in size]). > >> > >>> > import Text.Printf > >>> > import System.Random > >>> > import Control.Applicative > >>> > import System.Environment > >>> > import Data.Array.Vector > >>> > > >>> > randomListU :: (Int, Int) -> StdGen -> Int -> (UArr Int) > >>> > randomListU b g size = unfoldU size gen g > >>> > ? where gen g = let (x, g') = randomR b g > >>> > ? ? ? ? ? ? ? ? in JustS (x :*: g') > >>> > > >>> > main = do > >>> > ? [size] <- map read <$> getArgs > >>> > ? let ints = randomListU (-10, 10) (mkStdGen 1) size > >>> > ? printf "%d\n" ?(sumU ints) > >>> > >>> Could someone give a hint, how to implement this function in > >>> constant memory space? > >>> > >>> Thank you in advance. > >>> > >>> Best regards, > >>> Vasyl Pasternak From jason.dusek at gmail.com Tue Feb 9 12:19:26 2010 From: jason.dusek at gmail.com (Jason Dusek) Date: Tue Feb 9 11:50:37 2010 Subject: [Haskell-cafe] Using Cabal during development In-Reply-To: <27515446.post@talk.nabble.com> References: <27515446.post@talk.nabble.com> Message-ID: <42784f261002090919p4ef604bap84272320f6a6e230@mail.gmail.com> My development environment is a Screen with Bash, Vim and GHCi running. If I can just load the files in GHCi or compile them with GHC without specifying many options or extensions, then I just do it that way. As soon as I feel a need to write a Makefile or a little build script, I write a Cabal file instead and switch to using `cabal-install'. When I say "many" options or extensions, I nearly mean "any". Most projects of mine get a Cabal file at the point where I feel the need for the first `LANGUAGE' pragma. (I usually omit `LANGUAGE' pragmas, delegating to Cabal for that. I'm not sure whether this is good or bad practice.) -- Jason Dusek From limestrael at gmail.com Tue Feb 9 12:35:48 2010 From: limestrael at gmail.com (=?UTF-8?Q?Limestra=C3=ABl?=) Date: Tue Feb 9 12:07:01 2010 Subject: [Haskell-cafe] Using Cabal during development In-Reply-To: <42784f261002090919p4ef604bap84272320f6a6e230@mail.gmail.com> References: <27515446.post@talk.nabble.com> <42784f261002090919p4ef604bap84272320f6a6e230@mail.gmail.com> Message-ID: <27518960.post@talk.nabble.com> Okay, but have you ever felt the need to make in the same project a library and an executable which depends on this library (even just like me, for testing purpose)? How would you do it? Jason Dusek wrote: > > My development environment is a Screen with Bash, Vim and GHCi > running. > > If I can just load the files in GHCi or compile them with GHC > without specifying many options or extensions, then I just do > it that way. As soon as I feel a need to write a Makefile or a > little build script, I write a Cabal file instead and switch > to using `cabal-install'. > > When I say "many" options or extensions, I nearly mean "any". > Most projects of mine get a Cabal file at the point where I > feel the need for the first `LANGUAGE' pragma. (I usually omit > `LANGUAGE' pragmas, delegating to Cabal for that. I'm not sure > whether this is good or bad practice.) > > -- > Jason Dusek > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- View this message in context: http://old.nabble.com/Using-Cabal-during-development-tp27515446p27518960.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From hyangfji at gmail.com Tue Feb 9 12:44:50 2010 From: hyangfji at gmail.com (Hong Yang) Date: Tue Feb 9 12:16:10 2010 Subject: [Haskell-cafe] automatically exclude unused modules at compile time In-Reply-To: <20100208175752.GA16281@kira.casa> References: <20100208175752.GA16281@kira.casa> Message-ID: I did not use -split-objs. This option did help after I tried it. Thanks. Hong On Mon, Feb 8, 2010 at 11:57 AM, Felipe Lessa wrote: > On Mon, Feb 08, 2010 at 11:25:13AM -0600, Hong Yang wrote: > > Can we make GHC a little bit more intelligent to automatically exclude > > unused modules at compile time as in case 4)? (Am I just too lazy to add > > several dashes?) > > Did you use -split-objs? Does it help? > > -- > Felipe. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100209/23879e41/attachment.html From drcygnus at gmail.com Tue Feb 9 12:59:01 2010 From: drcygnus at gmail.com (Jonathan Daugherty) Date: Tue Feb 9 12:30:22 2010 Subject: [Haskell-cafe] Using Cabal during development In-Reply-To: <27515446.post@talk.nabble.com> References: <27515446.post@talk.nabble.com> Message-ID: <20100209175900.GA10972@pickle> > Cabal/cabal-install are good tools for distribution and > installation, but I was wondering -- as I was starting to learn how > to use Cabal -- how do usually Haskell developpers build their > softwares (and especially medium or big libraries) while they are > still developping them ? The first thing I always do is create a skeletal cabal file for my project and add Library and Executable sections to it. The executable might be a test/demo program, or it might be a real app. I usually try to put whatever I can into a library to keep my executable source lightweight. My development flow relies heavily on some emacs integration with darcs that I wrote, which allows me to press C-c C-t to run the darcs test hook preference in am emacs buffer, which happens to be bound to something like "cabal build && some_test_command" in most of my Haskell repositories. That way I don't usually have to leave my editor to see the build failures and address them. -- Jonathan Daugherty From bos at serpentine.com Tue Feb 9 13:27:58 2010 From: bos at serpentine.com (Bryan O'Sullivan) Date: Tue Feb 9 12:59:11 2010 Subject: [Haskell-cafe] Generate random UArray in constant memory space. In-Reply-To: <8feb08f71002090418g6674453dp8af8f71fd6327011@mail.gmail.com> References: <8feb08f71002090418g6674453dp8af8f71fd6327011@mail.gmail.com> Message-ID: On Tue, Feb 9, 2010 at 4:18 AM, Vasyl Pasternak wrote: > > I tried to generate memory-efficient list of random numbers, so I've > used uvector library for this task. Use the mwc-random package. It provides a function that does exactly this, and produces better quality random numbers with much higher performance (1000x faster) than System.Random or even mersenne-random. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100209/50cc8b80/attachment.html From rk at trie.org Tue Feb 9 13:44:44 2010 From: rk at trie.org (Rahul Kapoor) Date: Tue Feb 9 13:15:54 2010 Subject: [Haskell-cafe] Using Cabal during development In-Reply-To: <27518960.post@talk.nabble.com> References: <27515446.post@talk.nabble.com> <42784f261002090919p4ef604bap84272320f6a6e230@mail.gmail.com> <27518960.post@talk.nabble.com> Message-ID: > Okay, but have you ever felt the need to make in the same project a library > and an executable which depends on this library (even just like me, for > testing purpose)? How would you do it? Specifying the modules under test in other-modules section for the executable does the trick for me. I can email you a suitable elided cabal file for one of my projects if you want. Also another really helpful thing for testing is adding a .ghci file in your project I usually check in the .ghci with my source. Standard commands that I define in .ghci usually include :test to run the Test Suite. I also use .ghci set up the correct source paths and to start up with the test module loaded. So recompiles are usually just as simple as :reload. I still run the complete "cabal configure -ftest && cabal configure build && ./dist/..../test before commits. Rahul From limestrael at gmail.com Tue Feb 9 13:46:51 2010 From: limestrael at gmail.com (=?UTF-8?Q?Limestra=C3=ABl?=) Date: Tue Feb 9 13:18:01 2010 Subject: [Haskell-cafe] Using Cabal during development In-Reply-To: <20100209175900.GA10972@pickle> References: <27515446.post@talk.nabble.com> <20100209175900.GA10972@pickle> Message-ID: <27520110.post@talk.nabble.com> Then how does the 'Executable' section of your .cabal look like? That's what I can't get working. Jonathan Daugherty-4 wrote: > The first thing I always do is create a skeletal cabal file for my > project and add Library and Executable sections to it. The executable > might be a test/demo program, or it might be a real app. I usually > try to put whatever I can into a library to keep my executable source > lightweight. -- View this message in context: http://old.nabble.com/Using-Cabal-during-development-tp27515446p27520110.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From rk at trie.org Tue Feb 9 13:49:35 2010 From: rk at trie.org (Rahul Kapoor) Date: Tue Feb 9 13:20:47 2010 Subject: [Haskell-cafe] Using Cabal during development In-Reply-To: <27520110.post@talk.nabble.com> References: <27515446.post@talk.nabble.com> <20100209175900.GA10972@pickle> <27520110.post@talk.nabble.com> Message-ID: > Then how does the 'Executable' section of your .cabal look like? That's what > I can't get working. Suitably elided. Executable test hs-source-dirs: src, tests other-modules: Text.Yaml.Yay, Text.Yaml.Yay.Syck main-is: Main.hs build-depends: base, HsSyck, syb if flag(test) build-depends: QuickCheck >= 2.1 && < 2.2, test-framework-quickcheck2 >= 0.2 && < 0.3, test-framework >= 0.2 && < 0.3 else buildable: False Library Hs-Source-Dirs: src Exposed-Modules: Text.Yaml.Yay, Text.Yaml.Yay.Syck Other-Modules: Text.Yaml.Yay.Internal.Utils, Text.Yaml.Yay.Syck.Encoder, Text.Yaml.Yay.Syck.Decoder Build-Depends: base, HsSyck, syb if flag(test) -- Faster builds ghc-options: -O0 else -- Optimized builds ghc-options: -O2 if flag(nolib) buildable: False From drcygnus at gmail.com Tue Feb 9 13:51:36 2010 From: drcygnus at gmail.com (Jonathan Daugherty) Date: Tue Feb 9 13:22:55 2010 Subject: [Haskell-cafe] Using Cabal during development In-Reply-To: <27520110.post@talk.nabble.com> References: <27515446.post@talk.nabble.com> <20100209175900.GA10972@pickle> <27520110.post@talk.nabble.com> Message-ID: <20100209185135.GA11684@pickle> > Then how does the 'Executable' section of your .cabal look like? > That's what I can't get working. Executable vty-ui-demo Hs-Source-Dirs: src Main-is: Demo.hs Build-Depends: mtl >= 1.1 && < 1.2 The Main-is refers to src/Demo.hs. This example is from: http://hackage.haskell.org/packages/archive/vty-ui/0.2/vty-ui.cabal The "package description" link on any Hackage package page will link to the release's cabal file, so you can see how other folks have written their Executable sections. Hope that helps, -- Jonathan Daugherty From drcygnus at gmail.com Tue Feb 9 13:54:35 2010 From: drcygnus at gmail.com (Jonathan Daugherty) Date: Tue Feb 9 13:25:53 2010 Subject: [Haskell-cafe] Using Cabal during development In-Reply-To: References: <27515446.post@talk.nabble.com> <20100209175900.GA10972@pickle> <27520110.post@talk.nabble.com> Message-ID: <20100209185434.GB11684@pickle> > Executable test > hs-source-dirs: src, tests > other-modules: Text.Yaml.Yay, Text.Yaml.Yay.Syck > ... In general, it's not advisable to name your test executable "test" due to a naming collision with the typical "test" utility. You might consider naming it $package_name-test. (This is also more cabal-install-friendly.) -- Jonathan Daugherty From jao at gnu.org Tue Feb 9 13:41:47 2010 From: jao at gnu.org (Jose A. Ortega Ruiz) Date: Tue Feb 9 13:39:36 2010 Subject: [Haskell-cafe] Re: Using Cabal during development References: <27515446.post@talk.nabble.com> <87r5ouebyn.fsf@malde.org> <90889fe71002090803p78d1be5bo34a97175d8d22d0d@mail.gmail.com> Message-ID: <87wrymckus.fsf@newton.homeunix.net> Johan Tibell writes: > It's really unfortunate that this approach doesn't work for .hsc > files. When writing low level libraries I often have a couple of these > which forces me out of my nice Emacs workflow into an Emacs + terminal > + Cabal workflow. I use the elisp code below to run cabal without leaving emacs, with its output going into a compilation buffer (so that one can jump to the errors). C-c c will find the cabal file nearest to the current buffer and invoke cabal. HTH, jao --8<---------------cut here---------------start------------->8--- (defun jao-locate-dominating-files (regexp &optional file) "Look up the directory hierarchy from FILE for a file matching REGEXP. Stop at the first parent where a matching file is found and return the list of files that that match in this directory." (catch 'found (let ((dir (file-name-as-directory (or file (buffer-file-name)))) files) (while (and dir (not (string-match locate-dominating-stop-dir-regexp dir))) (if (setq files (condition-case nil (directory-files dir 'full regexp 'nosort) (error nil))) (throw 'found files) (if (equal dir (setq dir (file-name-directory (directory-file-name dir)))) (setq dir nil)))) nil))) (defun jao-haskell-locate-cabal-file () "Find the cabal file associated with current buffer." (car (jao-locate-dominating-files ".+\\.cabal"))) (eval-after-load 'haskell-mode '(add-hook 'haskell-mode-hook (lambda () (set (make-local-variable 'compile-command) "cabal build")))) (defun jao-haskell-cabal-build () "Run, in a compilation buffer, a cabal command, after finding the cabal file associated with this buffer." (interactive) (let ((cabal-file (jao-haskell-locate-cabal-file))) (unless cabal-file (error "Couldn't find associated cabal file")) (let ((default-directory (file-name-directory cabal-file))) (call-interactively 'compile)))) (eval-after-load 'haskell-mode '(define-key haskell-mode-map [?\C-c ?c] 'jao-haskell-cabal-build)) --8<---------------cut here---------------end--------------->8--- From david.waern at gmail.com Tue Feb 9 14:17:58 2010 From: david.waern at gmail.com (David Waern) Date: Tue Feb 9 13:49:10 2010 Subject: [Haskell-cafe] Re: Strange Haddock output In-Reply-To: <3c6288ab1002090840h6e25fdc1g7eaec5f7cd573366@mail.gmail.com> References: <3c6288ab1002090840h6e25fdc1g7eaec5f7cd573366@mail.gmail.com> Message-ID: 2010/2/9 Sean Leather : > I was browsing Hackage pointlessly and came across what appears to be > strange Haddock formatting here: > > http://hackage.haskell.org/packages/archive/pointless-haskell/0.0.3/doc/html/Generics-Pointless-Functors.html#v%3Afmap > > The following source > > -- | Polytypic 'Prelude.Functor' class for functor representations > class Functor (f :: * -> *) where > fmap :: Fix f -- ^ For desambiguation > purposes, the type of the functor must be passed as an explicit > paramaeter to 'fmap' > -> (x -> y) -> Rep f x -> Rep f y -- ^ The mapping over representations > > produces the following view from the browser > > class Functor f where > Polytypic Prelude.Functor class for functor representations > Methods > fmap > :: > => Fix f > -> x -> y > -> Rep f x The mapping over representations > -> Rep f y > > with the Haddock 2.6.0 on Hackage. There seems to be an extraneous => > in the signature of fmap, and the comment on Fix f does not show up. I think this is an instance of a bug introduced when implementing cross-package documentation. It has been fixed already and will be in the next minor release. David From david.waern at gmail.com Tue Feb 9 14:20:00 2010 From: david.waern at gmail.com (David Waern) Date: Tue Feb 9 13:51:12 2010 Subject: [Haskell-cafe] Re: Strange Haddock output In-Reply-To: References: <3c6288ab1002090840h6e25fdc1g7eaec5f7cd573366@mail.gmail.com> Message-ID: > I think this is an instance of a bug introduced when implementing > cross-package documentation. It has been fixed already and will be in > the next minor release. Sorry, I should have said that the /fix/ will be in the next minor release, and not the bug, of course :-) David From daniel.is.fischer at web.de Tue Feb 9 14:38:46 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Feb 9 14:11:51 2010 Subject: [Haskell-cafe] Generate random UArray in constant memory space. In-Reply-To: <8feb08f71002091019s6df82076h1f4327889036fdd2@mail.gmail.com> References: <8feb08f71002090418g6674453dp8af8f71fd6327011@mail.gmail.com> <201002091813.51750.daniel.is.fischer@web.de> <8feb08f71002091019s6df82076h1f4327889036fdd2@mail.gmail.com> Message-ID: <201002092038.47054.daniel.is.fischer@web.de> Am Tuesday 09 February 2010 19:19:18 schrieben Sie: > Daniel, > > I've just run venum2 program locally and here is my results: > > $ ./venum2 10000000 +RTS -s > ./venum2 10000000 +RTS -s > 50000005000000 > 22,736 bytes allocated in the heap > 688 bytes copied during GC > 17,184 bytes maximum residency (1 sample(s)) > 19,680 bytes maximum slop > 1 MB total memory in use (0 MB lost due to fragmentation) > > $ ./venum2 1000000000 +RTS -s > ./venum2 1000000000 +RTS -s > 500000000500000000 > 24,152 bytes allocated in the heap > 688 bytes copied during GC > 17,184 bytes maximum residency (1 sample(s)) > 19,680 bytes maximum slop > 1 MB total memory in use (0 MB lost due to fragmentation) > > So my PC shows that there is constant memory allocation. Maybe I'm > doing something wrong ? Unlikely. However, I notice that you seem to have a 64-bit system. I don't know the details, but usually those have more registers than a 32- bit system, so you can get more complicated loops to run completely in the registers. I think that's what happens here, enumFromToU' is just complicated enough to not run in the registers on my 32-bit system, but still runs in the registers on your 64-bit system. The PRNG code is too complicated (too many temporary variables) to run in the registers on either system (BTW, have you tried it with the specialised PRNG code in the source file? I'm not sure whether that might be just small enough to run in the registers on a 64-bit system.). > > 2010/2/9 Daniel Fischer : > > Am Tuesday 09 February 2010 15:43:13 schrieben Sie: > >> Update: > >> > >> I've implemented `enumFromToU` through `unfoldU`: > >> > enumFromToU' from to = unfoldU (to - from) f from > >> > ? ?where f i = let i' = i + 1 in JustS (i' :*: i') > >> > >> This code behaves similarly to `enumFromToU` (i.e. constantly uses > >> ~25 kb of memory, runs in the same time as above). > > > > Wait, > > > > $ cat venum2.hs > > module Main (main) where > > > > import Text.Printf > > import Control.Applicative > > import System.Environment > > import Data.Array.Vector > > > > main = do > > ? [size] <- map read <$> getArgs > > ? let ints = enumFromToU' 0 size :: UArr Int > > ? printf "%d\n" ?(sumU ints) > > > > enumFromToU' from to = unfoldU (to - from) f from > > ? ?where f i = let i' = i + 1 in JustS (i' :*: i') > > > > $ ghc -O2 --make venum2 > > [1 of 1] Compiling Main ? ? ? ? ? ? ( venum2.hs, venum2.o ) > > Linking venum2 ... > > $ ./venum2 +RTS -sstderr -RTS 1000000 > > ./venum2 1000000 +RTS -sstderr > > 1784293664 > > ? ? ?48,256,384 bytes allocated in the heap > > ? ? ? ? ? 6,256 bytes copied during GC > > ? ? ? ? ?26,804 bytes maximum residency (1 sample(s)) > > ? ? ? ? ?25,524 bytes maximum slop > > ? ? ? ? ? ? ? 1 MB total memory in use (0 MB lost due to > > fragmentation) > > > > $ ./venum2 +RTS -sstderr -RTS 10000000 > > ./venum2 10000000 +RTS -sstderr > > -2004260032 > > ? ? 481,937,552 bytes allocated in the heap > > ? ? ? ? ?19,516 bytes copied during GC > > ? ? ? ? ?26,804 bytes maximum residency (1 sample(s)) > > ? ? ? ? ?25,512 bytes maximum slop > > ? ? ? ? ? ? ? 1 MB total memory in use (0 MB lost due to > > fragmentation) > > > > So we have constant memory, but linear allocation, just like with the > > random numbers. > > > > With enumFromToU, also the allocation is constant, so unfoldU > > allocates, enumFromToU not. > > > >> So the question is why random number list generator eats O(n) memory > >> ? > > > > It doesn't, not here, at least. Using System.Random, the allocation > > figures are about ten times as high, but the residency is about the > > same. Putting the PRNG code in the same file and tweaking things a bit > > (eliminating all intermediate Integers, e.g.), I get > > > > $ cat ran2Vec.hs > > {-# LANGUAGE BangPatterns #-} > > module Main (main) where > > > > import Text.Printf > > import Control.Applicative > > import System.Environment > > import Data.Array.Vector > > > > randomListU :: (Int, Int) -> StdGen -> Int -> (UArr Int) > > randomListU b@(l,h) g size = unfoldU size gen g > > ? where > > ? ?!k = h-l+1 > > ? ?!b' = 2147483561 `rem` k > > ? ?gen !g = let (!x, !g') = stdNext g > > ? ? ? ? ? ? in JustS ((l+ (x+b') `rem` k) :*: g') > > > > main = do > > ? [size] <- map read <$> getArgs > > ? let ints = randomListU (-10, 10) (mkStdGen 1) size > > ? printf "%d\n" ?(sumU ints) > > > > data StdGen = StdGen {-# UNPACK #-} !Int {-# UNPACK #-} !Int > > > > mkStdGen :: Int -> StdGen > > mkStdGen s > > ?| s < 0 ? ? = mkStdGen (-s) > > ?| otherwise = StdGen (s1+1) (s2+1) > > ? ? ?where > > ? ?(q, s1) = s `divMod` 2147483562 > > ? ?s2 ? ? ?= q `mod` 2147483398 > > > > {-# INLINE stdNext #-} > > stdNext :: StdGen -> (Int, StdGen) > > -- Returns values in the range stdRange > > stdNext (StdGen s1 s2) = z' `seq` g' `seq` (z', g') > > ? ?where > > ? ? ? ?!g' ? = StdGen s1'' s2'' > > ? ? ? ?!z' ? = if z < 1 then z + 2147483562 else z > > ? ? ? ?!z ? ?= s1'' - s2'' > > > > ? ? ? ?!k ? ?= s1 `quot` 53668 > > ? ? ? ?!s1' ?= 40014 * (s1 - k * 53668) - k * 12211 > > ? ? ? ?!s1'' = if s1' < 0 then s1' + 2147483563 else s1' > > > > ? ? ? ?!k' ? = s2 `quot` 52774 > > ? ? ? ?!s2' ?= 40692 * (s2 - k' * 52774) - k' * 3791 > > ? ? ? ?!s2'' = if s2' < 0 then s2' + 2147483399 else s2' > > $ ghc -O2 -funbox-strict-fields -funfolding-use-threshold=16 ?--make > > ran2Vec -o ran2AVec5 > > Linking ran2AVec5 ... > > $ ./ran2AVec5 +RTS -sstderr -RTS 10000000 > > ./ran2AVec5 10000000 +RTS -sstderr > > 5130 > > ? ? 521,828,888 bytes allocated in the heap > > ? ? ? ? ? 8,664 bytes copied during GC > > ? ? ? ? ?26,788 bytes maximum residency (1 sample(s)) > > ? ? ? ? ?25,636 bytes maximum slop > > ? ? ? ? ? ? ? 1 MB total memory in use (0 MB lost due to > > fragmentation) > > > > nearly the same allocation figures as for the *much* simpler > > enumFromToU', and it's about ten times as fast as System.Random. > > From daniel.is.fischer at web.de Tue Feb 9 15:08:21 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Feb 9 14:41:31 2010 Subject: [Haskell-cafe] Generate random UArray in constant memory space. In-Reply-To: References: <8feb08f71002090418g6674453dp8af8f71fd6327011@mail.gmail.com> Message-ID: <201002092108.23035.daniel.is.fischer@web.de> Am Dienstag 09 Februar 2010 19:27:58 schrieb Bryan O'Sullivan: > On Tue, Feb 9, 2010 at 4:18 AM, Vasyl Pasternak > > wrote: > > I tried to generate memory-efficient list of random numbers, so I've > > used uvector library for this task. > > Use the mwc-random package. It provides a function that does exactly > this, and produces better quality random numbers with much higher > performance (1000x faster) than System.Random or even mersenne-random. Not here. I may be doing it wrong, but ======================================== {-# LANGUAGE BangPatterns #-} module Main (main) where import Text.Printf import System.Random.MWC import Control.Applicative import System.Environment import Data.Array.Vector import Control.Monad.ST randomListU :: (Int, Int) -> Int -> Int -- (UArr Int) randomListU b@(l,h) size = runST $ do let !k = h-l+1 f !m = m `mod` k + l sg <- create sumU . mapU f <$> uniformArray sg size main = do ? [size] <- map read <$> getArgs ? let int = randomListU (-10, 10) size ? printf "%d\n" int ======================================== gives $ ghc -O2 -funfolding-use-threshold=32 -fforce-recomp --make mwcRanVec.hs - o mwcRanVec3 [1 of 1] Compiling Main ( mwcRanVec.hs, mwcRanVec.o ) Linking mwcRanVec3 ... $ ./mwcRanVec3 +RTS -s -RTS 10000000 ./mwcRanVec3 10000000 +RTS -s 22784 40,966,820 bytes allocated in the heap 3,696 bytes copied during GC 27,128 bytes maximum residency (1 sample(s)) 26,940 bytes maximum slop 40 MB total memory in use (0 MB lost due to fragmentation) Generation 0: 1 collections, 0 parallel, 0.00s, 0.00s elapsed Generation 1: 1 collections, 0 parallel, 0.00s, 0.00s elapsed INIT time 0.00s ( 0.00s elapsed) MUT time 1.09s ( 1.15s elapsed) GC time 0.00s ( 0.00s elapsed) EXIT time 0.00s ( 0.00s elapsed) Total time 1.10s ( 1.15s elapsed) %GC time 0.0% (0.0% elapsed) Alloc rate 37,376,166 bytes per MUT second Productivity 99.6% of total user, 95.2% of total elapsed , System.Random.Mersenne $ ./mtRanVec +RTS -s -RTS 10000000 ./mtRanVec 10000000 +RTS -s -24541 280,609,188 bytes allocated in the heap 17,404 bytes copied during GC 26,776 bytes maximum residency (1 sample(s)) 25,724 bytes maximum slop 1 MB total memory in use (0 MB lost due to fragmentation) Generation 0: 535 collections, 0 parallel, 0.00s, 0.00s elapsed Generation 1: 1 collections, 0 parallel, 0.00s, 0.00s elapsed INIT time 0.00s ( 0.00s elapsed) MUT time 1.10s ( 1.10s elapsed) GC time 0.00s ( 0.00s elapsed) EXIT time 0.00s ( 0.00s elapsed) Total time 1.10s ( 1.10s elapsed) %GC time 0.4% (0.4% elapsed) Alloc rate 255,083,261 bytes per MUT second Productivity 99.3% of total user, 99.5% of total elapsed more or less the same, the System.Random code gives $ ./uRanVec +RTS -s -RTS 10000000./uRanVec 10000000 +RTS -s 5130 4,515,826,700 bytes allocated in the heap 803,132 bytes copied during GC 26,852 bytes maximum residency (1 sample(s)) 25,716 bytes maximum slop 1 MB total memory in use (0 MB lost due to fragmentation) Generation 0: 8680 collections, 0 parallel, 0.10s, 0.10s elapsed Generation 1: 1 collections, 0 parallel, 0.00s, 0.00s elapsed INIT time 0.00s ( 0.00s elapsed) MUT time 9.12s ( 9.17s elapsed) GC time 0.10s ( 0.10s elapsed) EXIT time 0.00s ( 0.00s elapsed) Total time 9.22s ( 9.27s elapsed) %GC time 1.1% (1.1% elapsed) Alloc rate 495,342,570 bytes per MUT second Productivity 98.9% of total user, 98.3% of total elapsed (so a factor of a little above 8), and the specialised System.Random code in the source file, ==================================================== {-# LANGUAGE BangPatterns #-} module Main (main) where import Text.Printf import Control.Applicative import System.Environment import Data.Array.Vector randomListU :: (Int, Int) -> StdGen -> Int -> (UArr Int) randomListU b@(l,h) g size = unfoldU size gen g ? where !k = h-l+1 !b' = 2147483561 `rem` k gen !g = let (!x, !g') = stdNext g in JustS ((l+ (x+b') `rem` k) :*: g') main = do ? [size] <- map read <$> getArgs ? let ints = randomListU (-10, 10) (mkStdGen 1) size ? printf "%d\n" ?(sumU ints) data StdGen = StdGen {-# UNPACK #-} !Int {-# UNPACK #-} !Int mkStdGen :: Int -> StdGen mkStdGen s | s < 0 = mkStdGen (-s) | otherwise = StdGen (s1+1) (s2+1) where (q, s1) = s `divMod` 2147483562 s2 = q `mod` 2147483398 {-# INLINE stdNext #-} stdNext :: StdGen -> (Int, StdGen) -- Returns values in the range stdRange stdNext (StdGen s1 s2) = z' `seq` g' `seq` (z', g') where !g' = StdGen s1'' s2'' !z' = if z < 1 then z + 2147483562 else z !z = s1'' - s2'' !k = s1 `quot` 53668 !s1' = 40014 * (s1 - k * 53668) - k * 12211 !s1'' = if s1' < 0 then s1' + 2147483563 else s1' !k' = s2 `quot` 52774 !s2' = 40692 * (s2 - k' * 52774) - k' * 3791 !s2'' = if s2' < 0 then s2' + 2147483399 else s2' ==================================================== comes in fastest at $ ./ran2AVec5 +RTS -sstderr -RTS 10000000./ran2AVec5 10000000 +RTS -sstderr 5130 521,828,888 bytes allocated in the heap 8,664 bytes copied during GC 26,788 bytes maximum residency (1 sample(s)) 25,636 bytes maximum slop 1 MB total memory in use (0 MB lost due to fragmentation) Generation 0: 995 collections, 0 parallel, 0.00s, 0.01s elapsed Generation 1: 1 collections, 0 parallel, 0.00s, 0.00s elapsed INIT time 0.00s ( 0.00s elapsed) MUT time 0.94s ( 0.94s elapsed) GC time 0.00s ( 0.01s elapsed) EXIT time 0.00s ( 0.00s elapsed) Total time 0.94s ( 0.95s elapsed) %GC time 0.4% (1.0% elapsed) Alloc rate 557,474,951 bytes per MUT second Productivity 99.6% of total user, 98.8% of total elapsed From vasyl.pasternak at gmail.com Tue Feb 9 15:31:24 2010 From: vasyl.pasternak at gmail.com (Vasyl Pasternak) Date: Tue Feb 9 15:02:36 2010 Subject: [Haskell-cafe] Generate random UArray in constant memory space. In-Reply-To: <201002092038.47054.daniel.is.fischer@web.de> References: <8feb08f71002090418g6674453dp8af8f71fd6327011@mail.gmail.com> <201002091813.51750.daniel.is.fischer@web.de> <8feb08f71002091019s6df82076h1f4327889036fdd2@mail.gmail.com> <201002092038.47054.daniel.is.fischer@web.de> Message-ID: <8feb08f71002091231s38f52221va481d6dcec7e829@mail.gmail.com> Daniel, Yes, I have 64 bit system. Maybe you're right. The PRNG code with the same vector size allocates two times more memory at my PC. (~ 1 Gb) Thank you, Vasyl 2010/2/9 Daniel Fischer : > Am Tuesday 09 February 2010 19:19:18 schrieben Sie: >> Daniel, >> >> I've just run venum2 program locally and here is my results: >> >> $ ./venum2 10000000 +RTS -s >> ./venum2 10000000 +RTS -s >> 50000005000000 >> ? ? ? ? ? 22,736 bytes allocated in the heap >> ? ? ? ? ? ? ?688 bytes copied during GC >> ? ? ? ? ? 17,184 bytes maximum residency (1 sample(s)) >> ? ? ? ? ? 19,680 bytes maximum slop >> ? ? ? ? ? ? ? ?1 MB total memory in use (0 MB lost due to fragmentation) >> >> $ ./venum2 1000000000 +RTS -s >> ./venum2 1000000000 +RTS -s >> 500000000500000000 >> ? ? ? ? ? 24,152 bytes allocated in the heap >> ? ? ? ? ? ? ?688 bytes copied during GC >> ? ? ? ? ? 17,184 bytes maximum residency (1 sample(s)) >> ? ? ? ? ? 19,680 bytes maximum slop >> ? ? ? ? ? ? ? ?1 MB total memory in use (0 MB lost due to fragmentation) >> >> So my PC shows that there is constant memory allocation. Maybe I'm >> doing something wrong ? > > Unlikely. > However, I notice that you seem to have a 64-bit system. > I don't know the details, but usually those have more registers than a 32- > bit system, so you can get more complicated loops to run completely in the > registers. > I think that's what happens here, enumFromToU' is just complicated enough > to not run in the registers on my 32-bit system, but still runs in the > registers on your 64-bit system. > > The PRNG code is too complicated (too many temporary variables) to run in > the registers on either system (BTW, have you tried it with the specialised > PRNG code in the source file? I'm not sure whether that might be just small > enough to run in the registers on a 64-bit system.). > >> >> 2010/2/9 Daniel Fischer : >> > Am Tuesday 09 February 2010 15:43:13 schrieben Sie: >> >> Update: >> >> >> >> I've implemented `enumFromToU` through `unfoldU`: >> >> > enumFromToU' from to = unfoldU (to - from) f from >> >> > ? ?where f i = let i' = i + 1 in JustS (i' :*: i') >> >> >> >> This code behaves similarly to `enumFromToU` (i.e. constantly uses >> >> ~25 kb of memory, runs in the same time as above). >> > >> > Wait, >> > >> > $ cat venum2.hs >> > module Main (main) where >> > >> > import Text.Printf >> > import Control.Applicative >> > import System.Environment >> > import Data.Array.Vector >> > >> > main = do >> > ? [size] <- map read <$> getArgs >> > ? let ints = enumFromToU' 0 size :: UArr Int >> > ? printf "%d\n" ?(sumU ints) >> > >> > enumFromToU' from to = unfoldU (to - from) f from >> > ? ?where f i = let i' = i + 1 in JustS (i' :*: i') >> > >> > $ ghc -O2 --make venum2 >> > [1 of 1] Compiling Main ? ? ? ? ? ? ( venum2.hs, venum2.o ) >> > Linking venum2 ... >> > $ ./venum2 +RTS -sstderr -RTS 1000000 >> > ./venum2 1000000 +RTS -sstderr >> > 1784293664 >> > ? ? ?48,256,384 bytes allocated in the heap >> > ? ? ? ? ? 6,256 bytes copied during GC >> > ? ? ? ? ?26,804 bytes maximum residency (1 sample(s)) >> > ? ? ? ? ?25,524 bytes maximum slop >> > ? ? ? ? ? ? ? 1 MB total memory in use (0 MB lost due to >> > fragmentation) >> > >> > $ ./venum2 +RTS -sstderr -RTS 10000000 >> > ./venum2 10000000 +RTS -sstderr >> > -2004260032 >> > ? ? 481,937,552 bytes allocated in the heap >> > ? ? ? ? ?19,516 bytes copied during GC >> > ? ? ? ? ?26,804 bytes maximum residency (1 sample(s)) >> > ? ? ? ? ?25,512 bytes maximum slop >> > ? ? ? ? ? ? ? 1 MB total memory in use (0 MB lost due to >> > fragmentation) >> > >> > So we have constant memory, but linear allocation, just like with the >> > random numbers. >> > >> > With enumFromToU, also the allocation is constant, so unfoldU >> > allocates, enumFromToU not. >> > >> >> So the question is why random number list generator eats O(n) memory >> >> ? >> > >> > It doesn't, not here, at least. Using System.Random, the allocation >> > figures are about ten times as high, but the residency is about the >> > same. Putting the PRNG code in the same file and tweaking things a bit >> > (eliminating all intermediate Integers, e.g.), I get >> > >> > $ cat ran2Vec.hs >> > {-# LANGUAGE BangPatterns #-} >> > module Main (main) where >> > >> > import Text.Printf >> > import Control.Applicative >> > import System.Environment >> > import Data.Array.Vector >> > >> > randomListU :: (Int, Int) -> StdGen -> Int -> (UArr Int) >> > randomListU b@(l,h) g size = unfoldU size gen g >> > ? where >> > ? ?!k = h-l+1 >> > ? ?!b' = 2147483561 `rem` k >> > ? ?gen !g = let (!x, !g') = stdNext g >> > ? ? ? ? ? ? in JustS ((l+ (x+b') `rem` k) :*: g') >> > >> > main = do >> > ? [size] <- map read <$> getArgs >> > ? let ints = randomListU (-10, 10) (mkStdGen 1) size >> > ? printf "%d\n" ?(sumU ints) >> > >> > data StdGen = StdGen {-# UNPACK #-} !Int {-# UNPACK #-} !Int >> > >> > mkStdGen :: Int -> StdGen >> > mkStdGen s >> > ?| s < 0 ? ? = mkStdGen (-s) >> > ?| otherwise = StdGen (s1+1) (s2+1) >> > ? ? ?where >> > ? ?(q, s1) = s `divMod` 2147483562 >> > ? ?s2 ? ? ?= q `mod` 2147483398 >> > >> > {-# INLINE stdNext #-} >> > stdNext :: StdGen -> (Int, StdGen) >> > -- Returns values in the range stdRange >> > stdNext (StdGen s1 s2) = z' `seq` g' `seq` (z', g') >> > ? ?where >> > ? ? ? ?!g' ? = StdGen s1'' s2'' >> > ? ? ? ?!z' ? = if z < 1 then z + 2147483562 else z >> > ? ? ? ?!z ? ?= s1'' - s2'' >> > >> > ? ? ? ?!k ? ?= s1 `quot` 53668 >> > ? ? ? ?!s1' ?= 40014 * (s1 - k * 53668) - k * 12211 >> > ? ? ? ?!s1'' = if s1' < 0 then s1' + 2147483563 else s1' >> > >> > ? ? ? ?!k' ? = s2 `quot` 52774 >> > ? ? ? ?!s2' ?= 40692 * (s2 - k' * 52774) - k' * 3791 >> > ? ? ? ?!s2'' = if s2' < 0 then s2' + 2147483399 else s2' >> > $ ghc -O2 -funbox-strict-fields -funfolding-use-threshold=16 ?--make >> > ran2Vec -o ran2AVec5 >> > Linking ran2AVec5 ... >> > $ ./ran2AVec5 +RTS -sstderr -RTS 10000000 >> > ./ran2AVec5 10000000 +RTS -sstderr >> > 5130 >> > ? ? 521,828,888 bytes allocated in the heap >> > ? ? ? ? ? 8,664 bytes copied during GC >> > ? ? ? ? ?26,788 bytes maximum residency (1 sample(s)) >> > ? ? ? ? ?25,636 bytes maximum slop >> > ? ? ? ? ? ? ? 1 MB total memory in use (0 MB lost due to >> > fragmentation) >> > >> > nearly the same allocation figures as for the *much* simpler >> > enumFromToU', and it's about ten times as fast as System.Random. >> > > From caseyh at istar.ca Tue Feb 9 16:04:24 2010 From: caseyh at istar.ca (caseyh@istar.ca) Date: Tue Feb 9 15:35:35 2010 Subject: [Haskell-cafe] If monads are single/linearly threaded, doesn't that reduce parallelism? Message-ID: <20100209160424.1269769xclnbk89k@webmail.uniserve.com> From ekirpichov at gmail.com Tue Feb 9 16:10:03 2010 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Tue Feb 9 15:41:14 2010 Subject: [Haskell-cafe] If monads are single/linearly threaded, doesn't that reduce parallelism? In-Reply-To: <20100209160424.1269769xclnbk89k@webmail.uniserve.com> References: <20100209160424.1269769xclnbk89k@webmail.uniserve.com> Message-ID: <5e0214851002091310m45d758e8xab084a40310c3ef1@mail.gmail.com> In what exact sense are monads "single threaded", and of which exactly parallelism are you talking about? 2010/2/10 : > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Eugene Kirpichov Web IR developer, market.yandex.ru From limestrael at gmail.com Tue Feb 9 16:49:16 2010 From: limestrael at gmail.com (=?UTF-8?Q?Limestra=C3=ABl?=) Date: Tue Feb 9 16:20:26 2010 Subject: [Haskell-cafe] Using Cabal during development In-Reply-To: <20100209185135.GA11684@pickle> References: <27515446.post@talk.nabble.com> <20100209175900.GA10972@pickle> <27520110.post@talk.nabble.com> <20100209185135.GA11684@pickle> Message-ID: <27522604.post@talk.nabble.com> I think I must be dumb or something. I did my SFML.cabal exactly the way the packager of vty-ui did vty-ui.cabal, and I still have got the error when building: hs_src/SFML/Direct/Graphics.hs:51:7: Could not find module `SFML.Direct.Types.Enums': It is a member of the hidden package `SFML-1.5'. Perhaps you need to add `SFML' to the build-depends in your .cabal file. it is a hidden module in the package `SFML-1.5' Use -v to see a list of the files searched for. My cabal file is http://old.nabble.com/file/p27522604/SFML.cabal here . Il you get to know why it doesn't work, please tell me, because I'm lost... I have a hs_src directory, which contains an SFML directory (the lib) and a demo.hs file. (the simple main) It's the way vty-ui package is done. Jonathan Daugherty-4 wrote: > >> Then how does the 'Executable' section of your .cabal look like? >> That's what I can't get working. > > Executable vty-ui-demo > Hs-Source-Dirs: src > Main-is: Demo.hs > Build-Depends: > mtl >= 1.1 && < 1.2 > > The Main-is refers to src/Demo.hs. This example is from: > > http://hackage.haskell.org/packages/archive/vty-ui/0.2/vty-ui.cabal > > The "package description" link on any Hackage package page will link > to the release's cabal file, so you can see how other folks have > written their Executable sections. > > Hope that helps, > > -- > Jonathan Daugherty > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- View this message in context: http://old.nabble.com/Using-Cabal-during-development-tp27515446p27522604.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From matthias.goergens at googlemail.com Tue Feb 9 16:56:49 2010 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Tue Feb 9 16:28:22 2010 Subject: [Haskell-cafe] If monads are single/linearly threaded, doesn't that reduce parallelism? In-Reply-To: <5e0214851002091310m45d758e8xab084a40310c3ef1@mail.gmail.com> References: <20100209160424.1269769xclnbk89k@webmail.uniserve.com> <5e0214851002091310m45d758e8xab084a40310c3ef1@mail.gmail.com> Message-ID: Monads are not commutative. A structure that would tell the compiler that it's commutative, would give it more leeway for optimization (and parallel execution). From matthias.goergens at googlemail.com Tue Feb 9 16:57:32 2010 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Tue Feb 9 16:29:02 2010 Subject: [Haskell-cafe] Navigating Graphs Message-ID: Using something like zippers it is easy to navigate an acyclic graph in O(1) operations per arc you follow. Inspired by Chris Okasaki's work on queues I wondered if there is a similar approach to navigating cyclic graphs. If the graph you are navigating is static (i.e. does not have to support addition or removal of vertices in any reasonable amount of time), I guess you can get away with "Tying the know" (http://www.haskell.org/haskellwiki/Tying_the_Knot). But is there a technique that allows navigation, insertion and removal at focus in (at least amortised) O(1) operations each? As a generalisation being able to have multiple points of focus (in an acyclic graph for a start) would also be interesting. Any thoughts? From jeremy at n-heptane.com Tue Feb 9 17:50:49 2010 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Tue Feb 9 17:22:03 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: References: <5679D446-9E50-4DFB-AFBD-E9532C3DCF0B@ece.cmu.edu> <20100206111415.GB29938@kira.casa> Message-ID: On Sun, Feb 7, 2010 at 9:22 AM, Bardur Arantsson wrote: True, it is perhaps technically not a bug, but it is certainly a misfeature > since there is no easy way (at least AFAICT) to discover that something bad > has happened for the file descriptor and act accordingly. AFAICT any > solution would have to be based on a separate thread which either 1) > "checks" the FD periodically somehow, or 2) simply lets the thread doing the > threadWaitWrite time out after a set period of inactivity. Neither is very > optimal. > > Either way, I'd certainly expect the sendfile library to work around this > somehow such that this situation doesn't occur. I'm just having a hard time > thinking up a good solution :). > > Well, it is certainly a bug in sendfile that needs to be fixed. I'm not sure how to fix it either. If we can simplify the test case, we can ask Simon Marlow.. - jeremy -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100209/bdae3f6e/attachment.html From vasyl.pasternak at gmail.com Tue Feb 9 18:48:26 2010 From: vasyl.pasternak at gmail.com (Vasyl Pasternak) Date: Tue Feb 9 18:19:37 2010 Subject: [Haskell-cafe] Generate random UArray in constant memory space. In-Reply-To: References: <8feb08f71002090418g6674453dp8af8f71fd6327011@mail.gmail.com> Message-ID: <8feb08f71002091548k1100d93wcdc7ba8c886d7a14@mail.gmail.com> Bryan, mwc-random is really fast. But it eats to much memory. My previous attempts were to reduce total number of allocations. This package made this possible, but it increases total memory usage. Here is the code: import Text.Printf import System.Random.MWC import Control.Applicative import System.Environment import Data.Array.Vector import Control.Monad.ST randomListU size = runST $ flip uniformArray size =<< create main = do [size] <- map read <$> getArgs printf "%d\n" $ (sumU (randomListU size) :: Int) And sample tests: ./mwcvec 10000000 +RTS -s -9198901858466039191 165,312 bytes allocated in the heap 688 bytes copied during GC 17,184 bytes maximum residency (1 sample(s)) 19,680 bytes maximum slop 78 MB total memory in use (1 MB lost due to fragmentation) ./mwcvec 100000000 +RTS -s 2242701120799374676 165,704 bytes allocated in the heap 688 bytes copied during GC 17,184 bytes maximum residency (1 sample(s)) 19,680 bytes maximum slop 764 MB total memory in use (12 MB lost due to fragmentation) ./mwcvec 1000000000 +RTS -s mwcvec: out of memory (requested 8000634880 bytes) I don't know exactly, but is this a normal behavior ? Thank you, Vasyl 2010/2/9 Bryan O'Sullivan : > On Tue, Feb 9, 2010 at 4:18 AM, Vasyl Pasternak > wrote: >> >> I tried to generate memory-efficient list of random numbers, so I've >> used uvector library for this task. > > Use the mwc-random package. It provides a function that does exactly this, > and produces better quality random numbers with much higher performance > (1000x faster) than System.Random or even mersenne-random. From bos at serpentine.com Tue Feb 9 19:27:57 2010 From: bos at serpentine.com (Bryan O'Sullivan) Date: Tue Feb 9 18:59:08 2010 Subject: [Haskell-cafe] Generate random UArray in constant memory space. In-Reply-To: <8feb08f71002091548k1100d93wcdc7ba8c886d7a14@mail.gmail.com> References: <8feb08f71002090418g6674453dp8af8f71fd6327011@mail.gmail.com> <8feb08f71002091548k1100d93wcdc7ba8c886d7a14@mail.gmail.com> Message-ID: On Tue, Feb 9, 2010 at 3:48 PM, Vasyl Pasternak wrote: > > mwc-random is really fast. But it eats to much memory. It creates and returns a vector, so if you ask it to give you a billion items, it's going to require north of 8 gigabytes of memory. This should not come as a surprise, I'd hope :-) Assuming that's not what you actually want, you should look at other entry points in the API, which you can use to generate a single value at a time in constant space. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100209/677ddffd/attachment.html From tphyahoo at gmail.com Tue Feb 9 19:47:53 2010 From: tphyahoo at gmail.com (Thomas Hartman) Date: Tue Feb 9 19:19:03 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: References: <5679D446-9E50-4DFB-AFBD-E9532C3DCF0B@ece.cmu.edu> <20100206111415.GB29938@kira.casa> Message-ID: <910ddf451002091647m4b7e12a5y5a680d7d356fb3d6@mail.gmail.com> Matt, have you seen this thread? Jeremy, are you saying this a bug in the sendfile library on hackage, or something underlying? thomas. 2010/2/9 Jeremy Shaw : > On Sun, Feb 7, 2010 at 9:22 AM, Bardur Arantsson > wrote: >> >> True, it is perhaps technically not a bug, but it is certainly a >> misfeature since there is no easy way (at least AFAICT) to discover that >> something bad has happened for the file descriptor and act accordingly. >> AFAICT any solution would have to be based on a separate thread which either >> 1) "checks" the FD periodically somehow, or 2) simply lets the thread doing >> the threadWaitWrite time out after a set period of inactivity. Neither is >> very optimal. >> >> Either way, I'd certainly expect the sendfile library to work around this >> somehow such that this situation doesn't occur. I'm just having a hard time >> thinking up a good solution :). > > Well, it is certainly a bug in sendfile that needs to be fixed. I'm not sure > how to fix it either. If we can simplify the test case, we can ask Simon > Marlow.. > - jeremy > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From felipe.lessa at gmail.com Tue Feb 9 20:04:01 2010 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Tue Feb 9 19:35:16 2010 Subject: [Haskell-cafe] Generate random UArray in constant memory space. In-Reply-To: References: <8feb08f71002090418g6674453dp8af8f71fd6327011@mail.gmail.com> <8feb08f71002091548k1100d93wcdc7ba8c886d7a14@mail.gmail.com> Message-ID: <20100210010401.GA1618@kira.casa> On Tue, Feb 09, 2010 at 04:27:57PM -0800, Bryan O'Sullivan wrote: > It creates and returns a vector, so if you ask it to give you a billion > items, it's going to require north of 8 gigabytes of memory. This should not > come as a surprise, I'd hope :-) Assuming that's not what you actually > want, you should look at other entry points in the API, which you can use to > generate a single value at a time in constant space. He thought the vector would be fused away by the library, which is one of the selling points of uvector. Sadly the implementation of uniformArray wasn't done with this purpose in mind. -- Felipe. From developer at live.com Tue Feb 9 20:22:16 2010 From: developer at live.com (Roderick Ford) Date: Tue Feb 9 19:53:28 2010 Subject: [Haskell-cafe] Jobs Message-ID: We need two developers at the company I work for; that is, I am NOT a recruiter. My boss is asking me to search for developers for me to work with ... like minded, haskell loving, driven, c/c++ (c# if we have to) for an INITIALLY c# full-time salaried position in Arizona (or FL or UT). He is open to starting new projects using Haskell, where applicable. So, he is involving me in the interview process, and I've been less than pleased with candidate selection so far. I told him we need to find people that see the beauty of mathematics and Haskell. If you have a resume you want me to forward on, reply to me directly and I will forward on through the review process. Here is a clip from posting 1 (don't take too literally): Software Engineer with strong 'Design, Programming, Debugging' experience Required Experience 3+yrs MS C# *AND* C++ MS SQL Server MS ASP.NET MS SQL Applicants must have at least 3 years practical work experience designing and building commercial software products that have shipped on the Windows OS platform. Requires proven experience building Web GUI on Windows platform, familiarity with distributed programming and networking. Must also be able to write and debug SQL Stored Procedures. Developer will be required to take ownership of the assigned modules through design, code & unit test. Past team lead experience would be valuable. Familiarity with gcc and Linux / Unix programming would be a plus. 4 year degree in a Computer Science related field with at least 5-7 years of experience in a software development environment or similar combination of education/work experience. This position is available in the following offices: Scottsdale, Arizona Provo, Utah Melbourne, Florida Here is a clip from posting 2: Job Description As a Senior C# - Asp.net Software Engineer in this position you will operate within a group of engineers, engaged in product design and implementation of enterprise applications. This role has a very high level of technical and product knowledge spanning multiple development technologies and target platforms. The Senior Software Engineer operates unsupervised and is a self-starter. Essential Duties and Responsibilities: Performs OOD, implementation and maintenance for products composed with a variety of technologies, mostly for Windows platforms but also Linux and other platforms Provides expertise for multiple software layers and levels of abstraction: UI, business layer, database, and distributed operations. Builds a tactical consensus with the development team whilst demonstrating strong technical leadership skills Experience working in a scrum agile environment a plus Performs highly complex product design activities which may require extensive research and analysis Performs complex bug verification, release testing and beta support for assigned products Researches problems discovered by QA or product support and identifies solutions to the problems Conducts unit testing and integration testing for functionality and performance limits In absence of product architects, may serve as a product architect Researches and understands non-functional requirements beyond the marketing requirements for a product Researches new technology or development tools to remain informed of current technology Required Skills Advanced technical knowledge in software development methodologies, design and implementation in C#. Expert analytical and design skills at multi-product/multi-environment level. Understands cross-platform and/or internationalisation development. In-depth experience in research and analysis, project planning and implementation. Excellent understanding of entire development process, including specification, documentation and quality assurance. Aware of business issues as they impact overall project plans. Recognised reference and central point for technical issues across groups and products. Strong communications and interpersonal skills. Advanced PC skills. Required Experience A university degree in computer science or software engineering, preferably a masters or higher, is desireable. Requires 10 to 15 years of experience in product design Good knowledge of .Net, and ASP.NET, for C# developers. Minimum 5 Years Experience of C# language and Asp.net -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100209/548773ce/attachment.html From tgdavies at gmail.com Tue Feb 9 23:24:37 2010 From: tgdavies at gmail.com (Tom Davies) Date: Tue Feb 9 22:55:57 2010 Subject: [Haskell-cafe] Lazy language on JVM/CLR In-Reply-To: <4335a3261002090752j4ead5c25g3b6bb627f8815873@mail.gmail.com> References: <4B70AF72.1070601@gmail.com> <4335a3261002090631s20e8dc48g9cc375ff6197009d@mail.gmail.com> <4C1B19C2-534D-4664-AE4C-07570AF1B71C@eidhof.nl> <4335a3261002090752j4ead5c25g3b6bb627f8815873@mail.gmail.com> Message-ID: On 10/02/2010, at 2:52 AM, Tim Wawrzynczak wrote: > Oops, you're right. It's not pure. Mea cupla for not reading more closely. I wonder how it deals with I/O, then? I don't see anything like Haskell's monads or Clean's uniqueness typing... but at a closer look it does appear to have an excellent Java FFI. > > On Tue, Feb 9, 2010 at 9:44 AM, Chris Eidhof wrote: > I don't think it's pure. I would definitely use a pure language on the JVM, but IIRC Open Quark / Cal is an impure language. For example, from the library documentation: "printLine :: String -> ()". CAL is pure as long as you don't call Java functions with side effects, or functions like printLine -- rather like avoiding unsafePerformIO in Haskell. For my experimentation I use my own IO monad implementation, but you can generally use `seq` to control when IO happens. The Java FFI is good, although arguably verbose. Tom From HaskellJade.5.JadeNB at spamgourmet.com Wed Feb 10 00:13:54 2010 From: HaskellJade.5.JadeNB at spamgourmet.com (L Spice) Date: Wed Feb 10 00:06:19 2010 Subject: [Haskell-cafe] Re: Category Theory woes References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> Message-ID: Mark Spezzano chariot.net.au> writes: > Does anyone know what Hom stands for? 'Hom' stands for 'homomorphism' --a way of changing (morphism) between two structures while keeping some information the same (homo-). Any algebra text will define morphisms aplenty --homomorphisms, epimorphisms, monomorphisms, and the like. These are maps on groups that preserve group operations (or on rings that preserve ring operations, etc.) In a topology text, you will find information on what are called continuous functions; they're morphisms too, in disguise. You can find a thinner disguise when you look at continuously invertible continuous functions, which are called homeomorphisms. If you proceed to differential geometry, you'll see smooth maps --they're morphisms too, and the invertible ones are called diffeomorphisms. This-morphisms, that-morphisms --if you're trying to come up with a general theory that describes all of them, it's natural just to call them 'morphisms'; but, as with the word 'colonel', the word and the symbol come to us via different routes, so that 'Hom(omorphism)' survives instead as the abbreviation. The crucial point in learning category theory is the realisation that, despite all the fancy terminology, it is at heart nothing but a way of talking about groups, rings, topological spaces, partial orders, etc. --all at once, so no wonder it seems abstract! From chris at eidhof.nl Wed Feb 10 04:52:57 2010 From: chris at eidhof.nl (Chris Eidhof) Date: Wed Feb 10 04:24:20 2010 Subject: [Haskell-cafe] Two GET HTTP requests In-Reply-To: References: <1BE43023-80AC-464E-8972-65C842FBB476@eidhof.nl> Message-ID: <21053867-0272-4379-919E-BC283B8DD3AB@eidhof.nl> Hi nwn, I had the following error: Run: Network/Socket/Internal.hsc:(298,2)-(314,60): Non-exhaustive patterns in case. The code for those lines look like this: > peekSockAddr p = do > family <- (#peek struct sockaddr, sa_family) p > case family :: CSaFamily of > #if defined(DOMAIN_SOCKET_SUPPORT) > (#const AF_UNIX) -> do > str <- peekCString ((#ptr struct sockaddr_un, sun_path) p) > return (SockAddrUnix str) > #endif > (#const AF_INET) -> do > addr <- (#peek struct sockaddr_in, sin_addr) p > port <- (#peek struct sockaddr_in, sin_port) p > return (SockAddrInet (PortNum port) addr) > #if defined(IPV6_SOCKET_SUPPORT) > (#const AF_INET6) -> do > port <- (#peek struct sockaddr_in6, sin6_port) p > flow <- (#peek struct sockaddr_in6, sin6_flowinfo) p > addr <- (#peek struct sockaddr_in6, sin6_addr) p > scope <- (#peek struct sockaddr_in6, sin6_scope_id) p > return (SockAddrInet6 (PortNum port) flow addr scope) > #endif Thanks for all your help. I'll first upgrade to a new GHC and then try again. -chris On 9 feb 2010, at 06:41, Yusaku Hashimoto wrote: > Try to reinstall HTTP package also. I think your HTTP package is still > linked with old broken network package. > > HTTP depends on network. And network is a binding for network API of > OS. These API is for C-language. When ghc builds such binding > packages, It runs gcc for some purpose. gcc thinks you need 64bit > binary (from SL, I believe.) and works for 64bit environment. But ghc > on Mac can only build 32bit binaries. So it causes the problem. > > You can check if network package was correctly built by running this. > This takes a host name, and gets the root document of the host via > HTTP using a socket. Build and try `./this_program haskell.org` > > import Network.Socket > import System.IO > import System.Environment > > getAddr :: HostName -> IO AddrInfo > getAddr host = head `fmap` > (getAddrInfo (Just defaultHints { addrSocketType = Stream }) > (Just host) > (Just "http")) > > connected :: HostName -> IO Socket > connected host = do > addrinfo <- getAddr host > sock <- socket (addrFamily addrinfo) > (addrSocketType addrinfo) > (addrProtocol addrinfo) > connect sock (addrAddress addrinfo) > return sock > > httpGet :: HostName -> IO String > httpGet host = do > h <- flip socketToHandle ReadWriteMode =<< connected host > hSetBuffering h NoBuffering > hPutStr h "GET / HTTP/1.0\r\n\r\n" > hGetContents h > > main = fmap head getArgs >>= httpGet >>= putStr > > I should have mentioned them in my last mail. Sorry. > > By the way, ghc-6.12 on Mac still can not build 64bit binaries. So > upgrading ghc won't solve it. > > --nwn > > On Mon, Feb 8, 2010 at 12:50 AM, Chris Eidhof wrote: >> Thanks. Unfortunately, it didn't help. The thing that frustrates me is that it's quite hard to debug. I guess I'll upgrade my GHC to 6.12, hopefully that'll solve it. >> >> -chris >> >> On 7 feb 2010, at 16:07, Yusaku Hashimoto wrote: >> >>> Hello, >>> >>> On Sat, Feb 6, 2010 at 2:51 AM, Chris Eidhof wrote: >>>> Approach 3: I used the simpleHTTP function from the HTTP package. This crashed, after I dug a little deeper into the code, it threw an error on calling the parseURI function (openFile: no such file exists). I installed the latest network package and upgraded my HTTP package, and the parseURI error went away. I felt like I was almost there, and tried the following: >>>> >>>>> simpleHTTP (getRequest "http://haskell.org") >>>> >>>> This failed with just the text "Bus error". I searched the HTTPBis git repository, but couldn't find the text "Bus error". I don't have a clue of how to fix this. >>> >>> Try reinstall network package with `cabal install --reinstall >>> --hsc2hs-options="--cflag=-m32 --lflag=-m32"`. >>> >>> See also: http://hackage.haskell.org/trac/ghc/ticket/3681 >>> >>> Hope this helps. >>> --nwn >> >> From vasyl.pasternak at gmail.com Wed Feb 10 08:29:59 2010 From: vasyl.pasternak at gmail.com (Vasyl Pasternak) Date: Wed Feb 10 08:01:08 2010 Subject: [Haskell-cafe] Generate random UArray in constant memory space. In-Reply-To: <20100210010401.GA1618@kira.casa> References: <8feb08f71002090418g6674453dp8af8f71fd6327011@mail.gmail.com> <8feb08f71002091548k1100d93wcdc7ba8c886d7a14@mail.gmail.com> <20100210010401.GA1618@kira.casa> Message-ID: <8feb08f71002100529k58514f9g74002eca55ee5333@mail.gmail.com> Hi all, To summarize everything in this thread I've tested mwc-random, System.Random and mersenne random numbers (mersenne-random-pure64). Here the score table: [THIRD PLACE] Generic Random Number Generator. Is the slowest and allocates too much memory in the heap. The total memory usage is constant and very low. [SECOND PLACE] MWC-RANDOM. The fastest random number generator ever. But it uses O(n) memory for generate random numbers. Thought it isn't possible to calculate a really large set of random numbers (my PC stuck with calculating 500 millions random numbers with memory usage above 3,5Gb). The memory usage for me is more important than time, because I can easily wait additional 5-10-15 mins, but I cant so easily put additional memory to my PC. Thus this is only second place. [FIRST PLACE] Mercenne Random number generator. Approx 10 times faster than generic and two times slower than mwc. But it works in constant memory space, so theoretically it could generate infinite list of numbers. It also uses 6 time less total allocations, than generic RNG. NOTE: These tests didn't test the quality of the random sequences, only speed/memory. Thanks to everyone, who helped me with this code, it seems, that now I understand optimizations much better, than a day ago. Best regards, Vasyl 2010/2/10 Felipe Lessa : > On Tue, Feb 09, 2010 at 04:27:57PM -0800, Bryan O'Sullivan wrote: >> It creates and returns a vector, so if you ask it to give you a billion >> items, it's going to require north of 8 gigabytes of memory. This should not >> come as a surprise, I'd hope :-) ?Assuming that's not what you actually >> want, you should look at other entry points in the API, which you can use to >> generate a single value at a time in constant space. > > He thought the vector would be fused away by the library, which > is one of the selling points of uvector. ?Sadly the > implementation of uniformArray wasn't done with this purpose in > mind. > > -- > Felipe. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From nccb2 at kent.ac.uk Wed Feb 10 09:11:19 2010 From: nccb2 at kent.ac.uk (Neil Brown) Date: Wed Feb 10 08:43:13 2010 Subject: [Haskell-cafe] Using Cabal during development In-Reply-To: <27522604.post@talk.nabble.com> References: <27515446.post@talk.nabble.com> <20100209175900.GA10972@pickle> <27520110.post@talk.nabble.com> <20100209185135.GA11684@pickle> <27522604.post@talk.nabble.com> Message-ID: <4B72BE87.9020404@kent.ac.uk> Don't you simply need to do what the error message says, and add (*in the Executable section*, at the end of the file): build-depends: SFML ? Limestra?l wrote: > I think I must be dumb or something. > I did my SFML.cabal exactly the way the packager of vty-ui did vty-ui.cabal, > and I still have got the error when building: > hs_src/SFML/Direct/Graphics.hs:51:7: > Could not find module `SFML.Direct.Types.Enums': > It is a member of the hidden package `SFML-1.5'. > Perhaps you need to add `SFML' to the build-depends in your .cabal > file. > it is a hidden module in the package `SFML-1.5' > Use -v to see a list of the files searched for. > > My cabal file is http://old.nabble.com/file/p27522604/SFML.cabal here . Il > you get to know why it doesn't work, please tell me, because I'm lost... > I have a hs_src directory, which contains an SFML directory (the lib) and a > demo.hs file. (the simple main) > It's the way vty-ui package is done. > > > Jonathan Daugherty-4 wrote: > >>> Then how does the 'Executable' section of your .cabal look like? >>> That's what I can't get working. >>> >> Executable vty-ui-demo >> Hs-Source-Dirs: src >> Main-is: Demo.hs >> Build-Depends: >> mtl >= 1.1 && < 1.2 >> >> The Main-is refers to src/Demo.hs. This example is from: >> >> http://hackage.haskell.org/packages/archive/vty-ui/0.2/vty-ui.cabal >> >> The "package description" link on any Hackage package page will link >> to the release's cabal file, so you can see how other folks have >> written their Executable sections. >> >> Hope that helps, >> >> -- >> Jonathan Daugherty >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> >> > > From jeremy at n-heptane.com Wed Feb 10 10:52:45 2010 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Wed Feb 10 10:24:02 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: <910ddf451002091647m4b7e12a5y5a680d7d356fb3d6@mail.gmail.com> References: <5679D446-9E50-4DFB-AFBD-E9532C3DCF0B@ece.cmu.edu> <20100206111415.GB29938@kira.casa> <910ddf451002091647m4b7e12a5y5a680d7d356fb3d6@mail.gmail.com> Message-ID: <94E8A4F7-E54B-4885-8D6A-6AA4777F6FC1@n-heptane.com> On Feb 9, 2010, at 6:47 PM, Thomas Hartman wrote: > Matt, have you seen this thread? > > Jeremy, are you saying this a bug in the sendfile library on hackage, > or something underlying? I'm saying that the behavior of the sendfile library is buggy. But it could be due to something underlying.. Either threadWaitWrite is buggy and should be fixed. Or threadWaitWrite is doing the right thing, and sendfile needs to be modified some how to account for the behavior. But I don't know which is the case or how to implement a solution to either option. - jeremy From jason.dusek at gmail.com Wed Feb 10 10:59:42 2010 From: jason.dusek at gmail.com (Jason Dusek) Date: Wed Feb 10 10:30:50 2010 Subject: [Haskell-cafe] How many "Haskell Engineer I/II/III"s are there? Message-ID: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> Although I'm fond of Haskell, in practice I am not a Haskell programmer -- I'm paid for Ruby and Bourne shell programming. Many of the jobs posted on this list end up being jobs for people who appreciate Haskell but will work in C# or O'Caml or some-such. I wonder how many people actually write Haskell, principally or exclusively, at work? -- Jason Dusek From perikov at gmail.com Wed Feb 10 11:05:45 2010 From: perikov at gmail.com (Pavel Perikov) Date: Wed Feb 10 10:37:12 2010 Subject: [Haskell-cafe] How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> Message-ID: I do. On Feb 10, 2010, at 6:59 PM, Jason Dusek wrote: > Although I'm fond of Haskell, in practice I am not a > Haskell programmer -- I'm paid for Ruby and Bourne shell > programming. > > Many of the jobs posted on this list end up being jobs > for people who appreciate Haskell but will work in C# or > O'Caml or some-such. > > I wonder how many people actually write Haskell, > principally or exclusively, at work? > > -- > Jason Dusek > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From korpios at korpios.com Wed Feb 10 11:06:29 2010 From: korpios at korpios.com (Tom Tobin) Date: Wed Feb 10 10:37:41 2010 Subject: [Haskell-cafe] How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> Message-ID: On Wed, Feb 10, 2010 at 9:59 AM, Jason Dusek wrote: > ?I wonder how many people actually write Haskell, > ?principally or exclusively, at work? While I don't suspect the number is large at the moment, the same thing could have been said several years ago of the language I use at my current job and used at my last job: Python. I get the same "industrial incubation period vibe" (for lack of a better term) from Haskell that I once got from Python -- although perhaps I'm biased in that I simply *like* these languages, too. :p From matthias.goergens at googlemail.com Wed Feb 10 11:07:35 2010 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Wed Feb 10 10:39:04 2010 Subject: [Haskell-cafe] How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> Message-ID: I used Haskell for some Research & Development work at Deutsche Bahn, earlier. (But my program was not integrated with their other systems.) From vanenkj at gmail.com Wed Feb 10 11:22:56 2010 From: vanenkj at gmail.com (John Van Enk) Date: Wed Feb 10 10:54:05 2010 Subject: [Haskell-cafe] How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> Message-ID: Not using it yet, but there's been a large amount of interest and willingness to work with it from management. We're contractors, so it depends on us finding some one who will allow us to use the language or asks for it explicitly. On Wed, Feb 10, 2010 at 10:59 AM, Jason Dusek wrote: > Although I'm fond of Haskell, in practice I am not a > Haskell programmer -- I'm paid for Ruby and Bourne shell > programming. > > Many of the jobs posted on this list end up being jobs > for people who appreciate Haskell but will work in C# or > O'Caml or some-such. > > I wonder how many people actually write Haskell, > principally or exclusively, at work? > > -- > Jason Dusek > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100210/7e01a32e/attachment.html From leimy2k at gmail.com Wed Feb 10 11:24:29 2010 From: leimy2k at gmail.com (David Leimbach) Date: Wed Feb 10 10:55:39 2010 Subject: [Haskell-cafe] How many "Haskell Engineer I/II/III"s are there? In-Reply-To: References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> Message-ID: <3e1162e61002100824n598d6b56xac35669bf9a0f44c@mail.gmail.com> Using it at the day job currently... like I need to get back to it. On Wed, Feb 10, 2010 at 8:22 AM, John Van Enk wrote: > Not using it yet, but there's been a large amount of interest and > willingness to work with it from management. We're contractors, so it > depends on us finding some one who will allow us to use the language or asks > for it explicitly. > > > On Wed, Feb 10, 2010 at 10:59 AM, Jason Dusek wrote: > >> Although I'm fond of Haskell, in practice I am not a >> Haskell programmer -- I'm paid for Ruby and Bourne shell >> programming. >> >> Many of the jobs posted on this list end up being jobs >> for people who appreciate Haskell but will work in C# or >> O'Caml or some-such. >> >> I wonder how many people actually write Haskell, >> principally or exclusively, at work? >> >> -- >> Jason Dusek >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100210/a437e4bc/attachment.html From leather at cs.uu.nl Wed Feb 10 11:26:29 2010 From: leather at cs.uu.nl (Sean Leather) Date: Wed Feb 10 10:57:57 2010 Subject: [Haskell-cafe] How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> Message-ID: <3c6288ab1002100826x2034c079n789d3b392944208a@mail.gmail.com> > I wonder how many people actually write Haskell, > principally or exclusively, at work? > I suppose you're implying non-academic jobs by that statement, but most of the people in my research group develop programs in Haskell on a daily basis. You'll find a number of libraries on Hackage from us. http://www.cs.uu.nl/staff/cur/IDX/sds.html As a shameless plug, I will also add that we have a great master's program in which you can get your fill of Haskell and compilers, among other things. http://www.cs.uu.nl/wiki/Master/ As second (but related) shameless plug, we also have a two-week-long summer school which is an excellent way to jump-start the above master's program or to get quickly up to speed on Haskell for business or pleasure. The course is in August, and the deadline is May 1. http://www.utrechtsummerschool.nl/index.php?type=courses&code=H9 Regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100210/e2ee39d4/attachment.html From limestrael at gmail.com Wed Feb 10 12:16:42 2010 From: limestrael at gmail.com (=?UTF-8?Q?Limestra=C3=ABl?=) Date: Wed Feb 10 11:47:50 2010 Subject: [Haskell-cafe] Using Cabal during development In-Reply-To: <4B72BE87.9020404@kent.ac.uk> References: <27515446.post@talk.nabble.com> <20100209175900.GA10972@pickle> <27520110.post@talk.nabble.com> <20100209185135.GA11684@pickle> <27522604.post@talk.nabble.com> <4B72BE87.9020404@kent.ac.uk> Message-ID: <27534455.post@talk.nabble.com> Neil Brown-7 wrote: > > Don't you simply need to do what the error message says, and add (*in > the Executable section*, at the end of the file): > Nope, just check my previous message (my issue (2)): Limestrael wrote: > > (2) well, then, when building, if I don't specify that my executable > depends on my lib, I got: > SFML/Direct/Graphics.hs:51:7: > Could not find module `SFML.Direct.Types.Enums': > It is a member of the hidden package `HSFML-1.5'. > Perhaps you need to add `HSFML' to the build-depends in your .cabal > file. > it is a hidden module in the package `HSFML-1.5' > Use -v to see a list of the files searched for. > > and if I do what it asks me to do (to add the line 'Build-Depends: HSFML' > in the 'Executable' section of my .cabal file), I'm told when 'cabal > build'ing: > cabal: internal error: could not construct a valid install plan. > The proposed (invalid) plan contained the following problems: > The following packages are involved in a dependency cycle HSFML-1.5 > -- View this message in context: http://old.nabble.com/Using-Cabal-during-development-tp27515446p27534455.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From sk at k-hornz.de Wed Feb 10 12:59:18 2010 From: sk at k-hornz.de (stefan kersten) Date: Wed Feb 10 12:30:34 2010 Subject: [Haskell-cafe] vector to uvector and back again Message-ID: <4B72F3F6.3050506@k-hornz.de> hi, i've been using the vector [1] library for implementing some signal processing algorithms, but now i'd like to use the statistics [2] package on my data, which is based on the uvector [3] library. is there a (straightforward) way of converting between vectors and uvectors, preferrably O(1)? thanks, [1] http://hackage.haskell.org/package/vector [2] http://hackage.haskell.org/package/statistics [3] http://hackage.haskell.org/package/uvector From bos at serpentine.com Wed Feb 10 13:03:43 2010 From: bos at serpentine.com (Bryan O'Sullivan) Date: Wed Feb 10 12:34:52 2010 Subject: [Haskell-cafe] vector to uvector and back again In-Reply-To: <4B72F3F6.3050506@k-hornz.de> References: <4B72F3F6.3050506@k-hornz.de> Message-ID: I'm thinking of switching the statistics library over to using vector. uvector is pretty bit-rotted in comparison to vector at this point, and it's really seeing no development, while vector is The Shiny Future. Roman, would you call the vector library good enough to use in production at the moment? On Wed, Feb 10, 2010 at 9:59 AM, stefan kersten wrote: > hi, > > i've been using the vector [1] library for implementing some signal > processing > algorithms, but now i'd like to use the statistics [2] package on my data, > which > is based on the uvector [3] library. is there a (straightforward) way of > converting between vectors and uvectors, preferrably O(1)? > > thanks, > > > [1] http://hackage.haskell.org/package/vector > [2] http://hackage.haskell.org/package/statistics > [3] http://hackage.haskell.org/package/uvector > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100210/ea1c6b9c/attachment.html From bulat.ziganshin at gmail.com Wed Feb 10 13:07:28 2010 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Feb 10 12:38:48 2010 Subject: [Haskell-cafe] How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> Message-ID: <8510087284.20100210210728@gmail.com> Hello Jason, Wednesday, February 10, 2010, 6:59:42 PM, you wrote: > I wonder how many people actually write Haskell, > principally or exclusively, at work? i work on commercial program. once it will start selling, i will publish here the story -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From daniel.is.fischer at web.de Wed Feb 10 13:11:37 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Feb 10 12:46:46 2010 Subject: [Haskell-cafe] Using Cabal during development In-Reply-To: <27534455.post@talk.nabble.com> References: <27515446.post@talk.nabble.com> <4B72BE87.9020404@kent.ac.uk> <27534455.post@talk.nabble.com> Message-ID: <201002101911.37931.daniel.is.fischer@web.de> Am Mittwoch 10 Februar 2010 18:16:42 schrieb Limestra?l: > Neil Brown-7 wrote: > > Don't you simply need to do what the error message says, and add (*in > > the Executable section*, at the end of the file): > > Nope, just check my previous message (my issue (2)): I think http://www.haskell.org/ghc/docs/latest/html/Cabal/authors.html might help, example 3, a package containing a library and executable programs Name: TestPackage Version: 0.0 Cabal-Version: >= 1.2 License: BSD3 Author: Angela Author Synopsis: Package with library and two programs Build-Type: Simple Library Build-Depends: HUnit Exposed-Modules: A, B, C Executable program1 Main-Is: Main.hs Hs-Source-Dirs: prog1 Other-Modules: A, B Executable program2 Main-Is: Main.hs Hs-Source-Dirs: prog2 Other-Modules: A, C, Utils For the executable, you have to specify the source dirs and the modules *from the library you are developing* it needs. A little inconvenient, admittedly. > > Limestrael wrote: > > (2) well, then, when building, if I don't specify that my executable > > depends on my lib, I got: > > SFML/Direct/Graphics.hs:51:7: > > Could not find module `SFML.Direct.Types.Enums': > > It is a member of the hidden package `HSFML-1.5'. > > Perhaps you need to add `HSFML' to the build-depends in your > > .cabal file. > > it is a hidden module in the package `HSFML-1.5' > > Use -v to see a list of the files searched for. > > > > and if I do what it asks me to do (to add the line 'Build-Depends: > > HSFML' in the 'Executable' section of my .cabal file), I'm told when > > 'cabal build'ing: > > cabal: internal error: could not construct a valid install plan. > > The proposed (invalid) plan contained the following problems: > > The following packages are involved in a dependency cycle HSFML-1.5 From jason.dusek at gmail.com Wed Feb 10 13:30:23 2010 From: jason.dusek at gmail.com (Jason Dusek) Date: Wed Feb 10 13:01:31 2010 Subject: [Haskell-cafe] How many "Haskell Engineer I/II/III"s are there? In-Reply-To: References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> Message-ID: <42784f261002101030r2dd23fb6xf04811265fccff96@mail.gmail.com> 2010/02/10 Tom Tobin : > On Wed, Feb 10, 2010 at 9:59 AM, Jason Dusek wrote: > >?I wonder how many people actually write Haskell, > > principally or exclusively, at work? > > While I don't suspect the number is large at the moment, the > same thing could have been said several years ago of the > language I use at my current job and used at my last job: > Python. ?I get the same "industrial incubation period vibe" > (for lack of a better term) from Haskell that I once got from > Python -- although perhaps I'm biased in that I simply *like* > these languages, too. ?:p I completely agree. I'm just trying to figure out where on the growth curve we are :) I am also interested in what industries tend to aggregate Haskell programmers. Within the Bay Area webosphere, Haskell is not much liked though Scala is gaining some traction. I think this has a lot to do with the fact that web programming is very much a "let's go shopping" kind of discipline -- no point in troubling oneself over correctness when the users haven't weighed in on the worth of your site. Of course this attitude leads to a long maintenance phase of Crazy Stuff?, like writing a PHP compiler; but by then you have piles of money to throw at the problem! Such is the theory, anyways. -- Jason Dusek From matthias.goergens at googlemail.com Wed Feb 10 13:39:28 2010 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Wed Feb 10 13:10:58 2010 Subject: [Haskell-cafe] How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <42784f261002101030r2dd23fb6xf04811265fccff96@mail.gmail.com> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <42784f261002101030r2dd23fb6xf04811265fccff96@mail.gmail.com> Message-ID: > I think this has a lot to do with the fact that > ?web programming is very much a "let's go shopping" kind of > ?discipline -- no point in troubling oneself over correctness > ?when the users haven't weighed in on the worth of your site. > ?Of course this attitude leads to a long maintenance phase of > ?Crazy Stuff?, like writing a PHP compiler; but by then you > ?have piles of money to throw at the problem! Such is the > ?theory, anyways. Or have sold your startup to some other company. Matthias. From spam at scientician.net Wed Feb 10 14:15:23 2010 From: spam at scientician.net (Bardur Arantsson) Date: Wed Feb 10 13:46:58 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: <94E8A4F7-E54B-4885-8D6A-6AA4777F6FC1@n-heptane.com> References: <5679D446-9E50-4DFB-AFBD-E9532C3DCF0B@ece.cmu.edu> <20100206111415.GB29938@kira.casa> <910ddf451002091647m4b7e12a5y5a680d7d356fb3d6@mail.gmail.com> <94E8A4F7-E54B-4885-8D6A-6AA4777F6FC1@n-heptane.com> Message-ID: Jeremy Shaw wrote: > On Feb 9, 2010, at 6:47 PM, Thomas Hartman wrote: > >> Matt, have you seen this thread? >> >> Jeremy, are you saying this a bug in the sendfile library on hackage, >> or something underlying? > > I'm saying that the behavior of the sendfile library is buggy. But it > could be due to something underlying.. > > Either threadWaitWrite is buggy and should be fixed. Or threadWaitWrite > is doing the right thing, and sendfile needs to be modified some how to > account for the behavior. But I don't know which is the case or how to > implement a solution to either option. IMO, in the interests of "correctness over speed", an interim release of sendfile which simply uses the "portable" code on Linux should be put out. The CPU overhead of the "portable" method doesn't matter that much for servers which aren't extremely busy. I've also been contemplating some solutions, but I cannot see any solutions to this problem which could reasonably be implemented outside of GHC itself. GHC lacks a "threadWaitError", so there's no way to detect the problem except by timeout or polling. Solutions involving timeouts and polling are bad in this case because they arbitrarily restrict the client connection rate. Cheers, From johan.tibell at gmail.com Wed Feb 10 14:19:59 2010 From: johan.tibell at gmail.com (Johan Tibell) Date: Wed Feb 10 13:51:27 2010 Subject: [Haskell-cafe] vector to uvector and back again In-Reply-To: References: <4B72F3F6.3050506@k-hornz.de> Message-ID: <90889fe71002101119nea45386lecf904f3dee533c6@mail.gmail.com> On Wed, Feb 10, 2010 at 10:03 AM, Bryan O'Sullivan wrote: > I'm thinking of switching the statistics library over to using vector. > uvector is pretty bit-rotted in comparison to vector at this point, and it's > really seeing no development, while vector is The Shiny Future. Roman, would > you call the vector library good enough to use in production at the moment? > I like the vector API much better than the uvector one. * no "U" suffixes on functions (go namespaces!) and * no cryptic names (what's an UAE?). Cheers, Johan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100210/9334c438/attachment.html From andrewcoppin at btinternet.com Wed Feb 10 14:26:22 2010 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Wed Feb 10 13:57:22 2010 Subject: [Haskell-cafe] How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> Message-ID: <4B73085E.4060109@btinternet.com> Jason Dusek wrote: > Although I'm fond of Haskell, in practice I am not a > Haskell programmer -- I'm paid for Ruby and Bourne shell > programming. > > Many of the jobs posted on this list end up being jobs > for people who appreciate Haskell but will work in C# or > O'Caml or some-such. > > I wonder how many people actually write Haskell, > principally or exclusively, at work? > I usually estimate the answer to this question by looking up how many employees WellTyped.com and Galois.com have between them, under the simplifying assumption that the number of other people using Haskell is probably so utterly insignificant that it doesn't matter. I'd love to see Haskell become popular, but it doesn't seem to be in any rush to happen just yet. (Then again, I gather 10 years ago things were far, far worse than they are today...) Some people (especially C programmers) have tried to tell me that Haskell is too slow. Others have claimed it's too incomprehensible. "People inherantly thing sequentially, not set-theoretically" they say. (Last time I checked, nobody's complaining about SQL being unintuitive...) "People don't think recursively" is another commonly-sited objection. Still others point out that Haskell is a *pure* functional language, and all the most popular languages are hybrids. Eiffel is a pure-OO language, but the hybrids like Java and C++ far vastly more popular. I myself might point out the comparative immaturity of things on Windows (the single biggest target platform on the market), and the rough edges on tools like Darcs, Haddock and Cabal. If enough people become interested, all these things could (and hopefully would) be fixed. It's a question of whether we reach the necessary critical mass or not... From andrewcoppin at btinternet.com Wed Feb 10 14:29:57 2010 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Wed Feb 10 14:00:57 2010 Subject: [Haskell-cafe] Type arithmetic with ATs Message-ID: <4B730935.6030901@btinternet.com> OK, so I sat down today and tried this, but I can't figure out how. There are various examples of type-level arithmetic around the place. For example, http://www.haskell.org/haskellwiki/Type_arithmetic (This is THE first hit on Google, by the way. Haskell is apparently THAT popular!) But this does type arithmetic using functional dependencies; what I'm trying to figure out is how to do that with associated types. Any hints? (I know for a fact that other people have done this - rule 34 requires it.) From sebf at informatik.uni-kiel.de Wed Feb 10 14:35:22 2010 From: sebf at informatik.uni-kiel.de (Sebastian Fischer) Date: Wed Feb 10 14:06:31 2010 Subject: [Haskell-cafe] lazy'foldl Message-ID: Hello, I have implemented the following function: lazy'foldl :: (a -> b -> Maybe a) -> Maybe a -> [b] -> Maybe a lazy'foldl _ Nothing _ = Nothing lazy'foldl _ m [] = m lazy'foldl f (Just y) (x:xs) = lazy'foldl f (f y x) xs After hoogling its type, I found that Control.Monad.foldM :: (a -> b -> Maybe a) -> a -> [b] -> Maybe a seems like a perfect replacement because lazy'foldl f (Just x) xs == foldM f x xs holds for all finite lists xs. Here is an inductive proof: lazy'foldl f (Just x) [] == Just x == foldM f x [] lazy'foldl f (Just x) (y:ys) == lazy'foldl f (f x y) ys (if f x y == Nothing) == lazy'foldl f Nothing ys == Nothing == Nothing >>= \z -> foldM f z ys == f x y >>= \z -> foldM f z ys == foldM f x (y:ys) lazy'foldl f (Just x) (y:ys) == lazy'foldl f (f x y) ys (if f x y == Just z) == lazy'foldl f (Just z) ys (induction) == foldM f z ys == Just z >>= \z -> foldM f z ys == f x y >>= \z -> foldM f z ys == foldM f x (y:ys) I think the above equation holds even for infinite lists xs. Both functions terminate on infinite lists, if the accumulator is eventually Nothing. Do you see any differences in terms of strictness, i.e., a counter example to the above equation that involves bottom? I don't. Sebastian -- Underestimating the novelty of the future is a time-honored tradition. (D.G.) From v.dijk.bas at gmail.com Wed Feb 10 14:46:54 2010 From: v.dijk.bas at gmail.com (Bas van Dijk) Date: Wed Feb 10 14:18:23 2010 Subject: [Haskell-cafe] How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> Message-ID: On Wed, Feb 10, 2010 at 4:59 PM, Jason Dusek wrote: > ?I wonder how many people actually write Haskell, > ?principally or exclusively, at work? Roel and I use Haskell at work. We develop embedded software in Haskell (not real-time) that controls a scientific instrument. We will probably write something more detailed about this project some time from now. regards, Roel and Bas van Dijk From miguelimo38 at yandex.ru Wed Feb 10 15:17:29 2010 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Wed Feb 10 14:48:48 2010 Subject: [Haskell-cafe] lazy'foldl In-Reply-To: References: Message-ID: <887AE0FA-ED0B-4975-85FB-48C0A031065A@yandex.ru> For the reference: foldM is defined as foldM :: Monad m => (a -> b -> m a) -> a -> [b] -> ma foldM _ a [] = return a foldM f a (x:xs) = f a x >>= \fax -> foldM f fax xs Let's define foldM' f x xs = lazy'foldl f (Just x) xs We can check that foldM' satisfies the same equations as foldM: foldM' f a [] = lazy'foldl f (Just a) [] = Just a = return a f a x >>= \fax -> foldM' f fax xs = case f a x of {Nothing -> Nothing; Just fax -> foldM' f fax xs} = case f a x of {Nothing -> Nothing; Just fax -> lazy'foldl f (Just fax) xs} = case f a x of {Nothing -> lazy'foldl f Nothing xs; Just fax -> lazy'foldl f (Just fax) xs} = (*) lazy'foldl f (f a x) xs = lazy'foldl f (Just a) (x:xs) = foldM' f a (x:xs) (*) this holds, because lazy'foldl actually does pattern match on it's second argument This means, that foldM' as at least as defined as foldM (meaning, roughly, that if foldM gives a meaningful, non-undefined value, foldM' produces the same value; if foldM gives (_|_), foldM' is free to produce anything). Therefore, lazy'foldl f (Just x) xs is at least as defined as foldM f x xs. On the other hand, let's define lazyf f mx xs = case mx of {Nothing -> Nothing, Just x -> foldM f x xs} lazyf satisfies the same equations as lazy'foldl: lazyf f Nothing xs = Nothing lazyf f (Just y) (x:xs) = foldM f y (x:xs) = f y x >>= \fyx -> foldM f fyx xs = f y x >>= \fyx -> lazyf f (Just fyx) xs = case f y x of {Nothing -> Nothing; Just fyx -> lazyf f (Just fyx) xs} = case f y x of {Nothing -> lazyf f Nothing xs; Just fyx -> lazyf f (Just fyx) xs} = (*) lazyf f (f y x) xs (*) again, lazyf does pattern-match on it's second argument, so this is valid lazyf f mx [] = case mx of {Nothing -> Nothing, Just x -> foldM f x []} = case mx of {Nothing -> Nothing, Just x -> return x} = case mx of {Nothing -> Nothing, Just x -> Just x} = mx The last equality holds because there are only three kinds of values mx can have: Nothing, Just x, or (_|_); in all three cases pattern- matching produces the same value. That means, that lazyf is at least as defined as lasy'foldl, so foldM f x xs = lazyf f (Just x) xs is at least as defined as lazyfoldl' f (Just x) xs. All this means that lazy'foldl f (Just x) xs coincides with foldM f x xs exactly, for all possible f, x, and xs. On 10 Feb 2010, at 22:35, Sebastian Fischer wrote: > Hello, > > I have implemented the following function: > > lazy'foldl :: (a -> b -> Maybe a) -> Maybe a -> [b] -> Maybe a > lazy'foldl _ Nothing _ = Nothing > lazy'foldl _ m [] = m > lazy'foldl f (Just y) (x:xs) = lazy'foldl f (f y x) xs > > After hoogling its type, I found that > > Control.Monad.foldM :: (a -> b -> Maybe a) -> a -> [b] -> Maybe a > > seems like a perfect replacement because > > lazy'foldl f (Just x) xs == foldM f x xs > > holds for all finite lists xs. Here is an inductive proof: > > lazy'foldl f (Just x) [] == Just x > == foldM f x [] > > lazy'foldl f (Just x) (y:ys) == lazy'foldl f (f x y) ys > (if f x y == Nothing) == lazy'foldl f Nothing ys > == Nothing > == Nothing >>= \z -> foldM f z ys > == f x y >>= \z -> foldM f z ys > == foldM f x (y:ys) > > lazy'foldl f (Just x) (y:ys) == lazy'foldl f (f x y) ys > (if f x y == Just z) == lazy'foldl f (Just z) ys > (induction) == foldM f z ys > == Just z >>= \z -> foldM f z ys > == f x y >>= \z -> foldM f z ys > == foldM f x (y:ys) > > I think the above equation holds even for infinite lists xs. Both > functions terminate on infinite lists, if the accumulator is > eventually Nothing. > > Do you see any differences in terms of strictness, i.e., a counter > example to the above equation that involves bottom? I don't. > > Sebastian > > > > > > -- > Underestimating the novelty of the future is a time-honored tradition. > (D.G.) > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From j.russell at alum.mit.edu Wed Feb 10 15:27:31 2010 From: j.russell at alum.mit.edu (James Russell) Date: Wed Feb 10 14:58:59 2010 Subject: [Haskell-cafe] How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> Message-ID: <58925be01002101227k181bbd56y26cd17d657b19108@mail.gmail.com> In my previous job, which recently ended, we used Haskell for at least half of our code, and most of our core stuff. I ended up writing a lot of Java, too, but you take the good, you take the bad. -James On Wed, Feb 10, 2010 at 10:59 AM, Jason Dusek wrote: > ?Although I'm fond of Haskell, in practice I am not a > ?Haskell programmer -- I'm paid for Ruby and Bourne shell > ?programming. > > ?Many of the jobs posted on this list end up being jobs > ?for people who appreciate Haskell but will work in C# or > ?O'Caml or some-such. > > ?I wonder how many people actually write Haskell, > ?principally or exclusively, at work? > > -- > Jason Dusek > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From robgreayer at gmail.com Wed Feb 10 15:30:37 2010 From: robgreayer at gmail.com (Robert Greayer) Date: Wed Feb 10 15:01:49 2010 Subject: [Haskell-cafe] Type arithmetic with ATs In-Reply-To: <4B730935.6030901@btinternet.com> References: <4B730935.6030901@btinternet.com> Message-ID: <4ec472cb1002101230v1a8fd910j3710b07095a25417@mail.gmail.com> On Wed, Feb 10, 2010 at 2:29 PM, Andrew Coppin wrote: > OK, so I sat down today and tried this, but I can't figure out how. > > There are various examples of type-level arithmetic around the place. For > example, > > http://www.haskell.org/haskellwiki/Type_arithmetic > > (This is THE first hit on Google, by the way. Haskell is apparently THAT > popular!) But this does type arithmetic using functional dependencies; what > I'm trying to figure out is how to do that with associated types. > > Any hints? > > (I know for a fact that other people have done this - rule 34 requires it.) > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > With type families, something like: type family Add m n type instance Add (Succ n) (Succ m) = Succ (Succ (Add n m)) type instance Add Zero (Succ m) = (Succ m) type instance Add (Succ m) Zero = (Succ m) type instance Add Zero Zero = Zero is this what you are after? There's also the tfp library on hackage which has much more type level arithmetic, using type families. From dons at galois.com Wed Feb 10 15:46:42 2010 From: dons at galois.com (Don Stewart) Date: Wed Feb 10 15:17:57 2010 Subject: [Haskell-cafe] How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> Message-ID: <20100210204642.GA12377@whirlpool.galois.com> jason.dusek: > Although I'm fond of Haskell, in practice I am not a > Haskell programmer -- I'm paid for Ruby and Bourne shell > programming. > > Many of the jobs posted on this list end up being jobs > for people who appreciate Haskell but will work in C# or > O'Caml or some-such. > > I wonder how many people actually write Haskell, > principally or exclusively, at work? Galois is a 100% Haskell shop, and we're around 40 people now - not all are engineers though. At the Commercial Users of FP workshop this year, when asked to raise their hands what FP languages people used at work, the majority of the room (60 people? / 120 in the room -- check the video) said they'd used Haskell at work. More than any of the other FP langs present (we also asked about Erlang, OCaml, Scheme, F#). -- Don From dons at galois.com Wed Feb 10 15:50:49 2010 From: dons at galois.com (Don Stewart) Date: Wed Feb 10 15:21:59 2010 Subject: [Haskell-cafe] How many "Haskell Engineer I/II/III"s are there? In-Reply-To: References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> Message-ID: <20100210205049.GB12377@whirlpool.galois.com> v.dijk.bas: > On Wed, Feb 10, 2010 at 4:59 PM, Jason Dusek wrote: > > ?I wonder how many people actually write Haskell, > > ?principally or exclusively, at work? > > Roel and I use Haskell at work. > > We develop embedded software in Haskell (not real-time) that controls > a scientific instrument. > > We will probably write something more detailed about this project some > time from now. > This is a great thread. Perhaps more users could add their details to http://haskell.org/haskellwiki/Haskell_in_industry and consider presenting at CUFP this year. http://cufp.galois.com (new website to be launched soon!) -- Don From v.dijk.bas at gmail.com Wed Feb 10 16:01:58 2010 From: v.dijk.bas at gmail.com (Bas van Dijk) Date: Wed Feb 10 15:33:26 2010 Subject: [Haskell-cafe] How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <20100210205049.GB12377@whirlpool.galois.com> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <20100210205049.GB12377@whirlpool.galois.com> Message-ID: On Wed, Feb 10, 2010 at 9:50 PM, Don Stewart wrote: > ... Perhaps more users could add their details to > http://haskell.org/haskellwiki/Haskell_in_industry ... done From developer at live.com Wed Feb 10 16:05:18 2010 From: developer at live.com (Roderick Ford) Date: Wed Feb 10 15:36:26 2010 Subject: [Haskell-cafe] How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <4B73085E.4060109@btinternet.com> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com>, <4B73085E.4060109@btinternet.com> Message-ID: We could/should probably all just start our own collective (corporate) entity to produce software, based on the premises that 1) software built with Haskell will be more robust, and 2) software built by developers who have an affinity and aptitude for this language will tend to write better software. When the products themselves gain a positive reputation with the general public, then the corporation itself and those invested will benefit. .... cheers heard across the world .... A U.S. president would probably subsidize such a job-creating endeavor too! Nay-sayers are probably predominately composed of those who do not understand it or its benefits. > Date: Wed, 10 Feb 2010 19:26:22 +0000 > From: andrewcoppin@btinternet.com > To: haskell-cafe@haskell.org > Subject: Re: [Haskell-cafe] How many "Haskell Engineer I/II/III"s are there? > > Jason Dusek wrote: > > Although I'm fond of Haskell, in practice I am not a > > Haskell programmer -- I'm paid for Ruby and Bourne shell > > programming. > > > > Many of the jobs posted on this list end up being jobs > > for people who appreciate Haskell but will work in C# or > > O'Caml or some-such. > > > > I wonder how many people actually write Haskell, > > principally or exclusively, at work? > > > > I usually estimate the answer to this question by looking up how many > employees WellTyped.com and Galois.com have between them, under the > simplifying assumption that the number of other people using Haskell is > probably so utterly insignificant that it doesn't matter. > > I'd love to see Haskell become popular, but it doesn't seem to be in any > rush to happen just yet. (Then again, I gather 10 years ago things were > far, far worse than they are today...) > > Some people (especially C programmers) have tried to tell me that > Haskell is too slow. Others have claimed it's too incomprehensible. > "People inherantly thing sequentially, not set-theoretically" they say. > (Last time I checked, nobody's complaining about SQL being > unintuitive...) "People don't think recursively" is another > commonly-sited objection. Still others point out that Haskell is a > *pure* functional language, and all the most popular languages are > hybrids. Eiffel is a pure-OO language, but the hybrids like Java and C++ > far vastly more popular. I myself might point out the comparative > immaturity of things on Windows (the single biggest target platform on > the market), and the rough edges on tools like Darcs, Haddock and Cabal. > If enough people become interested, all these things could (and > hopefully would) be fixed. It's a question of whether we reach the > necessary critical mass or not... > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100210/fc4a80d4/attachment.html From vanenkj at gmail.com Wed Feb 10 16:19:14 2010 From: vanenkj at gmail.com (John Van Enk) Date: Wed Feb 10 15:50:24 2010 Subject: [Haskell-cafe] How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <20100210205049.GB12377@whirlpool.galois.com> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <20100210205049.GB12377@whirlpool.galois.com> Message-ID: > consider presenting at CUFP this year Any word on when this will be? On Wed, Feb 10, 2010 at 3:50 PM, Don Stewart wrote: > v.dijk.bas: > > On Wed, Feb 10, 2010 at 4:59 PM, Jason Dusek > wrote: > > > I wonder how many people actually write Haskell, > > > principally or exclusively, at work? > > > > Roel and I use Haskell at work. > > > > We develop embedded software in Haskell (not real-time) that controls > > a scientific instrument. > > > > We will probably write something more detailed about this project some > > time from now. > > > > This is a great thread. Perhaps more users could add their details to > > http://haskell.org/haskellwiki/Haskell_in_industry > > and consider presenting at CUFP this year. http://cufp.galois.com > (new website to be launched soon!) > > -- Don > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100210/a015b5e6/attachment.html From caseyh at istar.ca Wed Feb 10 17:08:57 2010 From: caseyh at istar.ca (Casey Hawthorne) Date: Wed Feb 10 16:40:30 2010 Subject: [Haskell-cafe] If monads are single/linearly threaded, doesn't that reduce parallelism? In-Reply-To: References: <20100209160424.1269769xclnbk89k@webmail.uniserve.com> <5e0214851002091310m45d758e8xab084a40310c3ef1@mail.gmail.com> Message-ID: On Tue, 9 Feb 2010 21:56:49 +0000, you wrote: >Monads are not commutative. A structure that would tell the compiler >that it's commutative, would give it more leeway for optimization (and >parallel execution). Thank you. "Not commutative" was the phrase I was looking for. -- Regards, Casey From rl at cse.unsw.edu.au Wed Feb 10 17:42:46 2010 From: rl at cse.unsw.edu.au (Roman Leshchinskiy) Date: Wed Feb 10 17:14:04 2010 Subject: [Haskell-cafe] vector to uvector and back again In-Reply-To: References: <4B72F3F6.3050506@k-hornz.de> Message-ID: On 11/02/2010, at 05:03, Bryan O'Sullivan wrote: > I'm thinking of switching the statistics library over to using vector. uvector is pretty bit-rotted in comparison to vector at this point, and it's really seeing no development, while vector is The Shiny Future. Roman, would you call the vector library good enough to use in production at the moment? Yes, with the caveat that I haven't really used it in production code (I have tested and benchmarked it, though). BTW, I'll release version 0.5 as soon as get a code.haskell.org account and move the repo there. Roman > > > On Wed, Feb 10, 2010 at 9:59 AM, stefan kersten wrote: > hi, > > i've been using the vector [1] library for implementing some signal processing > algorithms, but now i'd like to use the statistics [2] package on my data, which > is based on the uvector [3] library. is there a (straightforward) way of > converting between vectors and uvectors, preferrably O(1)? > > thanks, > > > [1] http://hackage.haskell.org/package/vector > [2] http://hackage.haskell.org/package/statistics > [3] http://hackage.haskell.org/package/uvector > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ramsdell0 at gmail.com Wed Feb 10 18:07:19 2010 From: ramsdell0 at gmail.com (John D. Ramsdell) Date: Wed Feb 10 17:38:26 2010 Subject: [Haskell-cafe] Using Cabal during development In-Reply-To: <27515446.post@talk.nabble.com> References: <27515446.post@talk.nabble.com> Message-ID: <7687290b1002101507m607555e8m71f788f59447d612@mail.gmail.com> On Tue, Feb 9, 2010 at 8:48 AM, Limestra?l wrote: > Cabal/cabal-install are good tools for distribution and installation, but I > was wondering -- as I was starting to learn how to use Cabal -- how do > usually Haskell developpers build their softwares I add the enclosed Makefile to the directory that contains the .cabal file, and then in emacs, run M-x compile. To move to location of an error, type C-x `. I bind compile to M-C-y in my .emacs.el file with: (global-set-key "\M-\C-y" 'compile) --------------- Makefile ---------------- # Haskell/Cabal Makefile # Requires GNU Make # The all target creates a default configuration if need be. PACKAGE := $(wildcard *.cabal) CONFIG = dist/setup-config SETUP = runhaskell Setup.hs all: $(CONFIG) $(SETUP) build Makefile: @echo make $@ $(PACKAGE): @echo make $@ $(CONFIG): $(PACKAGE) $(SETUP) configure --ghc --user --prefix="${HOME}" %: force $(SETUP) $@ .PHONY: all force From jason.dusek at gmail.com Wed Feb 10 18:11:10 2010 From: jason.dusek at gmail.com (Jason Dusek) Date: Wed Feb 10 17:42:19 2010 Subject: [Haskell-cafe] How many "Haskell Engineer I/II/III"s are there? In-Reply-To: References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <4B73085E.4060109@btinternet.com> Message-ID: <42784f261002101511v1eea1955md37b090aa783f207@mail.gmail.com> 2010/02/10 Roderick Ford : > A U.S. president?would probably subsidize such a job-creating endeavor too! The US government generally subsidizes these kinds of things through DoD spending (and a few NSF grants). That is probably hard to get into. -- Jason Dusek From chak at cse.unsw.edu.au Wed Feb 10 19:34:01 2010 From: chak at cse.unsw.edu.au (Manuel M T Chakravarty) Date: Wed Feb 10 19:05:19 2010 Subject: [Haskell-cafe] How many "Haskell Engineer I/II/III"s are there? In-Reply-To: References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <20100210205049.GB12377@whirlpool.galois.com> Message-ID: <88BE9A56-88B4-483A-9051-274E1B8E239E@cse.unsw.edu.au> John Van Enk: > > consider presenting at CUFP this year > > Any word on when this will be? It'll be before or after (I suspect the later) ICFP , which is September 27-29 in Baltimore, Maryland. Manuel -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100210/3f255ccd/attachment.html From simon at joyful.com Wed Feb 10 20:21:31 2010 From: simon at joyful.com (Simon Michael) Date: Wed Feb 10 19:53:06 2010 Subject: [Haskell-cafe] Re: Using Cabal during development In-Reply-To: <27515446.post@talk.nabble.com> References: <27515446.post@talk.nabble.com> Message-ID: Another great thread. I'm another who uses both make and cabal. I try to automate a lot of things and find a makefile easier for quick scripting. Perhaps at some point I'll get by with just cabal. Here's an example: http://joyful.com/repos/hledger/Makefile An unusual feature, I think, is the use of the little-known sp tool for auto-recompiling (see "ci" rule). Typically I leave make ci running in an emacs shell window, where I can watch the errors as I edit and save source. I don't have clickable errors currently, I get by with linum-mode. When I need to explore I'll run ghci in another shell window. After reading this thread, I'm going to try using C-c C-l more. From markl at glyphic.com Wed Feb 10 21:49:38 2010 From: markl at glyphic.com (Mark Lentczner) Date: Wed Feb 10 21:20:46 2010 Subject: [Haskell-cafe] trouble with HDBC-mysql on Mac OS X Message-ID: I'm having trouble with HDBC-mysql on Mac OS X (10.6, Snow Leopard). It compiles and builds fine, but when loaded (into ghci), the dynamic loader complains about not being able to find libmygcc.dylib. The issue is, MySQL's libmygcc is a static lib, not a dynamic one, so of course it won't find it. I've checked the build sequence that HDBC-mysql uses, and it calls upon mysql_config to generate the lib options. I've checked those and they are correct, expressly listing libmygcc statically (!). I've tried building against both the 64bit and 32bit versions of MySQL libs. (Suspect that only the 32bit should work.) Anyone have HDBC-mysql running on 10.6? Any ideas for me to try would be appreciated. - Mark Mark Lentczner http://www.ozonehouse.com/mark/ IRC: mtnviewmark From hesselink at gmail.com Thu Feb 11 03:20:20 2010 From: hesselink at gmail.com (Erik Hesselink) Date: Thu Feb 11 02:51:48 2010 Subject: [Haskell-cafe] How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> Message-ID: <7f9d6b531002110020i4d801a44x74e0e560eaf4a6ce@mail.gmail.com> On Wed, Feb 10, 2010 at 16:59, Jason Dusek wrote: > ?I wonder how many people actually write Haskell, > ?principally or exclusively, at work? We (typLAB) use Haskell. There's four of us, but only two actually program Haskell, and not exclusively. We also use Javascript in the browser (though we use functional programming techniques there as well). Erik From patai_gergely at fastmail.fm Thu Feb 11 03:35:35 2010 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Thu Feb 11 03:06:41 2010 Subject: [Haskell-cafe] ANN: Dungeons of Wor - a largish FRP example and a fun game, all in one! Message-ID: <1265877335.18142.1359423573@webmail.messagingengine.com> Hello all, I just uploaded the first public version of Dungeons of Wor [1], a homage to the renowned three-decade-old arcade game, Wizard of Wor. While it makes a fine time killer if you have a few minutes to spare, it might be of special interest to the lost souls who are trying to figure out FRP. The game was programmed using the Simple version of the experimental branch of Elerea [2], which provides first-class discrete streams to describe time-varying quantities, and the main game logic is described as a composition of streams instead of a world state transformer. Developing in this manner was an interesting experience, and I'll write about it in more detail over the weekend. All the best, Gergely [1] http://hackage.haskell.org/package/dow [2] http://hackage.haskell.org/packages/archive/elerea/1.2.3/doc/html/FRP-Elerea-Experimental-Simple.html -- http://www.fastmail.fm - The professional email service From johann.hoechtl at gmail.com Thu Feb 11 03:41:20 2010 From: johann.hoechtl at gmail.com (=?ISO-8859-1?Q?Johann_H=F6chtl?=) Date: Thu Feb 11 03:12:26 2010 Subject: [Haskell-cafe] Seen on reddit: or, foldl and foldr considered slightly harmful Message-ID: <555dc06a-b80d-4067-a803-d8a43059dc0f@g28g2000yqh.googlegroups.com> In a presentation of Guy Steele for ICFP 2009 in Edinburgh: http://www.vimeo.com/6624203 he "considers foldl and foldr" harmful as they hinder parallelism because of "Process first element, then the rest" Instead he proposes a divide and merge aproach, especially in the light of going parallel. The slides at http://docs.google.com/viewer?url=http%3A%2F%2Fresearch.sun.com%2Fprojects%2Fplrg%2FPublications%2FICFPAugust2009Steele.pdf [Bware: Google docs] are somewhat geared towards Fortress, but I wonder what Haskellers have to say about his position. Greetings, Johann From muell_om at gmx.net Thu Feb 11 04:39:26 2010 From: muell_om at gmx.net (Michael Oswald) Date: Thu Feb 11 04:16:39 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> Message-ID: On 02/10/2010 04:59 PM, Jason Dusek wrote: > I wonder how many people actually write Haskell, > principally or exclusively, at work? Well, my main language at work in the moment is C++, we also use Java, a lot of Tcl and Python. I use Haskell for my own programs and test utilities / converters. The biggest achievement at work was an Installer program, which was quite complicated and had to be safe and of course we had time pressure, so I quickly coded it in Haskell. It is now used in the installation procedure of a part from a big mission control system for satellites. lg, Michael From iainspeed at gmail.com Thu Feb 11 04:55:20 2010 From: iainspeed at gmail.com (Iain Barnett) Date: Thu Feb 11 04:27:11 2010 Subject: [Haskell-cafe] HDBC convert [SqlValue] without muchos boilerplate Message-ID: <1EA33878-F2E1-4F18-B770-B3D46A67D0D8@gmail.com> Hi, I'm trying to get to grips with HDBC and have the following problem. When I run a query that returns a result set, each row comes back as a [SqlValue]. Naively, I thought the following function would convert a [SqlValue] into a string, but instead I get the error below. convrow2 :: [SqlValue] -> String convrow2 (x:xs) = foldl (\i j -> i ++ " | " ++ show j ) (show (fromSql x)) xs Prelude> :l TasksSimple.lhs [1 of 1] Compiling Main ( TasksSimple.lhs, interpreted ) TasksSimple.lhs:126:65: No instance for (convertible-1.0.5:Data.Convertible.Base.Convertible SqlValue a) arising from a use of `fromSql' at TasksSimple.lhs:126:65-73 Possible fix: add an instance declaration for (convertible-1.0.5:Data.Convertible.Base.Convertible SqlValue a) In the first argument of `show', namely `(fromSql x)' In the second argument of `foldl', namely `(show (fromSql x))' In the expression: foldl (\ i j -> i ++ " | " ++ show j) (show (fromSql x)) xs Failed, modules loaded: none. I tried looking at how to add an instance declaration for convertible, but was stumped. This code, however, works in GHCi. Would anyone know how to convert from [SqlValue] in a straightforward way without having to specify every field "by hand" ? I don't fancy doing this for each sql statement I need to run. convrow1 :: [SqlValue] -> String convrow1 [tasksid,title,added] = show ( (fromSql tasksid)::Integer ) ++ " | " ++ fromSql title ++ " | " ++ show ((fromSql added)::LocalTime) Any help is much appreciated, especially as I haven't looked at any Haskell in a while and wasn't any good with it before! Regards, Iain This is my set up: GHC is 6.10.4 HDBC is HDBC-2.1.1, HDBC-2.2.2, HDBC-postgresql-2.1.0.0,HDBC-postgresql-2.2.0.0 Convertible is convertible-1.0.5, convertible-1.0.8 OSX 10.6 From ketil at malde.org Thu Feb 11 05:00:51 2010 From: ketil at malde.org (Ketil Malde) Date: Thu Feb 11 04:32:08 2010 Subject: [Haskell-cafe] Seen on reddit: or, foldl and foldr considered slightly harmful In-Reply-To: <555dc06a-b80d-4067-a803-d8a43059dc0f@g28g2000yqh.googlegroups.com> ("Johann =?utf-8?Q?H=C3=B6chtl=22's?= message of "Thu, 11 Feb 2010 00:41:20 -0800 (PST)") References: <555dc06a-b80d-4067-a803-d8a43059dc0f@g28g2000yqh.googlegroups.com> Message-ID: <87r5osnlbg.fsf@malde.org> Johann H?chtl writes: > In a presentation of Guy Steele for ICFP 2009 in Edinburgh: > http://www.vimeo.com/6624203 > he "considers foldl and foldr" harmful as they hinder parallelism > because of "Process first element, then the rest" Instead he proposes > a divide and merge aproach, especially in the light of going parallel. In Haskell foldl/foldr apply to linked lists (or lazy streams, if you prefer) which are already inherently sequential, and gets a rather harsh treatment. I notice he points to finger trees, which I though was implemented in Data.Sequence. > are somewhat geared towards Fortress, but I wonder what Haskellers > have to say about his position. Can we (easily) parallelize operations on Data.Sequence? Often, the devil is in the details, and there's a lot of ground to cover between 'trees are easier to parallelize' to an efficient and effective high level interface. (E.g. non-strict semantics allowing speculative evalutaion - you still need to insert manual `par`s, right?) -k -- If I haven't seen further, it is by standing in the footprints of giants From thomas at 0xc29.net Thu Feb 11 05:09:45 2010 From: thomas at 0xc29.net (Thomas Girod) Date: Thu Feb 11 04:48:46 2010 Subject: [Haskell-cafe] Seen on reddit: or, foldl and foldr considered slightly harmful In-Reply-To: <87r5osnlbg.fsf@malde.org> References: <555dc06a-b80d-4067-a803-d8a43059dc0f@g28g2000yqh.googlegroups.com> <87r5osnlbg.fsf@malde.org> Message-ID: <20100211100945.GA7736@fairlight.lan> Isn't it the kind of things Data Parallel Haskell is achieving ? I'm in no way an expert of the field, but from what I've read on the subject it looked like : I have a list of N elements and I want to map the function F on it. technically, I could spawn N processes and build the result from that, but it would be highly inefficient. So the really hard part is to guess how I should split my data to get the best performances. Well, I guess it's pretty easy for a flat structure if you have access to it's length, but for a recursive one it is complicated as you don't know if a branch of the tree will lead to a leaf or a huge subtree ... the "evil detail" ! Tom On Thu, Feb 11, 2010 at 11:00:51AM +0100, Ketil Malde wrote: > Johann H?chtl writes: > > > In a presentation of Guy Steele for ICFP 2009 in Edinburgh: > > http://www.vimeo.com/6624203 > > he "considers foldl and foldr" harmful as they hinder parallelism > > because of "Process first element, then the rest" Instead he proposes > > a divide and merge aproach, especially in the light of going parallel. > > In Haskell foldl/foldr apply to linked lists (or lazy streams, if you > prefer) which are already inherently sequential, and gets a rather harsh > treatment. I notice he points to finger trees, which I though was > implemented in Data.Sequence. > > > are somewhat geared towards Fortress, but I wonder what Haskellers > > have to say about his position. > > Can we (easily) parallelize operations on Data.Sequence? Often, the > devil is in the details, and there's a lot of ground to cover between > 'trees are easier to parallelize' to an efficient and effective high > level interface. (E.g. non-strict semantics allowing speculative > evalutaion - you still need to insert manual `par`s, right?) > > -k > -- > If I haven't seen further, it is by standing in the footprints of giants > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From miguelimo38 at yandex.ru Thu Feb 11 05:06:09 2010 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Thu Feb 11 04:49:48 2010 Subject: [Haskell-cafe] HDBC convert [SqlValue] without muchos boilerplate In-Reply-To: <1EA33878-F2E1-4F18-B770-B3D46A67D0D8@gmail.com> References: <1EA33878-F2E1-4F18-B770-B3D46A67D0D8@gmail.com> Message-ID: <4B73D691.3070005@yandex.ru> The problem is, "fromSql x" doesn't know that type it should return. It's sure that it has to be of class "Convertible SqlValue", but nothing more. Could be String, or Int32, or something else. What if you just omit the "show" function? fromSql seems to be able to convert almost anything to String. Iain Barnett wrote: > Hi, > > I'm trying to get to grips with HDBC and have the following problem. When I run a query that returns a result set, each row comes back as a [SqlValue]. Naively, I thought the following function would convert a [SqlValue] into a string, but instead I get the error below. > > convrow2 :: [SqlValue] -> String > convrow2 (x:xs) = foldl (\i j -> i ++ " | " ++ show j ) (show (fromSql x)) xs > > > Prelude> :l TasksSimple.lhs > [1 of 1] Compiling Main ( TasksSimple.lhs, interpreted ) > > TasksSimple.lhs:126:65: > No instance for (convertible-1.0.5:Data.Convertible.Base.Convertible > SqlValue a) > arising from a use of `fromSql' at TasksSimple.lhs:126:65-73 > Possible fix: > add an instance declaration for > (convertible-1.0.5:Data.Convertible.Base.Convertible SqlValue a) > In the first argument of `show', namely `(fromSql x)' > In the second argument of `foldl', namely `(show (fromSql x))' > In the expression: > foldl (\ i j -> i ++ " | " ++ show j) (show (fromSql x)) xs > Failed, modules loaded: none. > > > I tried looking at how to add an instance declaration for convertible, but was stumped. > > > This code, however, works in GHCi. Would anyone know how to convert from [SqlValue] in a straightforward way without having to specify every field "by hand" ? I don't fancy doing this for each sql statement I need to run. > > convrow1 :: [SqlValue] -> String > convrow1 [tasksid,title,added] = > show ( (fromSql tasksid)::Integer ) > ++ " | " ++ > fromSql title > ++ " | " ++ > show ((fromSql added)::LocalTime) > > > Any help is much appreciated, especially as I haven't looked at any Haskell in a while and wasn't any good with it before! > > Regards, > Iain > > This is my set up: > GHC is 6.10.4 > HDBC is HDBC-2.1.1, HDBC-2.2.2, HDBC-postgresql-2.1.0.0,HDBC-postgresql-2.2.0.0 > Convertible is convertible-1.0.5, convertible-1.0.8 > OSX 10.6_______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From uzytkownik2 at gmail.com Thu Feb 11 05:21:41 2010 From: uzytkownik2 at gmail.com (Maciej Piechotka) Date: Thu Feb 11 04:52:45 2010 Subject: [Haskell-cafe] Re: Haskell-Cafe Digest, Vol 78, Issue 14 In-Reply-To: <9979e72e1002090841x4916e029qf32fad7abc8854d3@mail.gmail.com> References: <20100209133545.82064324655@www.haskell.org> <9979e72e1002090841x4916e029qf32fad7abc8854d3@mail.gmail.com> Message-ID: <1265883701.5700.55.camel@picard> Skipped content of type multipart/mixed-------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100211/6c872060/attachment.bin From limestrael at gmail.com Thu Feb 11 05:28:41 2010 From: limestrael at gmail.com (=?UTF-8?Q?Limestra=C3=ABl?=) Date: Thu Feb 11 04:59:46 2010 Subject: [Haskell-cafe] Using Cabal during development In-Reply-To: References: <27515446.post@talk.nabble.com> Message-ID: <27544307.post@talk.nabble.com> Eventually, I think using cabal during development may be convenient. The only drawback is that you have to specify each dependency and -- above all -- every module each time you add one. Nevertheless, I'm not convinced regarding the use of Makefiles with Cabal. I happen to think it's a bit outsize. A shell script is enough. By the way, I've found another way to develop simultaneously a (or many) library(ies) and an executable. It would be to use a local ghc package database. In my project directory, I do: ghc-pky init pkg.conf.d It create a directory pkg.conf.d which will contain my local database. Then all the libs must be configured with: cabal configure --package-db pkg.conf.d (or 'runhaskell Setup.hs configure --package-db pkg.conf.d' if you don't use cabal-install) Then build normally ('cabal build') Then, the little trouble is that you have to register you newly-built manually with a: cabal register --inplace (Anyone knows how to tell cabal to register automatically to the local pkg database?) Then, to compile you executable with ghc (because Cabal is definitely not convient when you have a lib and an executable in the same package): ghc --make --package-conf pkg.conf.d main.hs Again, should you have better/simpler ways to achieve this, I would be glad to know them. Simon Michael wrote: > > Another great thread. I'm another who uses both make and cabal. I try to > automate a lot of things and find a makefile > easier for quick scripting. Perhaps at some point I'll get by with just > cabal. Here's an example: > > http://joyful.com/repos/hledger/Makefile > > An unusual feature, I think, is the use of the little-known sp tool for > auto-recompiling (see "ci" rule). Typically I > leave make ci running in an emacs shell window, where I can watch the > errors as I edit and save source. I don't have > clickable errors currently, I get by with linum-mode. When I need to > explore I'll run ghci in another shell window. > After reading this thread, I'm going to try using C-c C-l more. > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- View this message in context: http://old.nabble.com/Using-Cabal-during-development-tp27515446p27544307.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From mauricio.antunes at gmail.com Thu Feb 11 06:19:41 2010 From: mauricio.antunes at gmail.com (=?ISO-8859-1?Q?Maur=ED=ADcio_CA?=) Date: Thu Feb 11 05:51:12 2010 Subject: [Haskell-cafe] Re: Using Cabal during development In-Reply-To: <27544307.post@talk.nabble.com> References: <27515446.post@talk.nabble.com> <27544307.post@talk.nabble.com> Message-ID: > Eventually, I think using cabal during development may be > convenient. The only drawback is that you have to specify each > dependency and -- above all -- every module each time you add > one. When writing bindings-posix, bindings-glib etc., which have lots of modules, I used a shell script to take all modules under ./src to .cabal. What it did was: 1) for each subdirectory, create a .hs file that reimport all modules under that subdirectory; 2) list all .hs (and, in my case, also .hsc) under ./src and insert then into .cabal. I've found that scripts of this kind have been very usefull. They require you to follow some rules (like, say, all modules with name mapping to directories are always a reimport of submodules). > Then, to compile you executable with ghc (because Cabal is > definitely not convient when you have a lib and an executable in > the same package): ghc --make --package-conf pkg.conf.d main.hs > > Again, should you have better/simpler ways to achieve this, I > would be glad to know them. I usually find useful, at first, to build only the executable and leave the library. When modules get stable enough, I separate both. Other scripts have been also usefull: one to check uncommited changes in all packages I'm working in, other to sync all my local packages with their repos. You could have a single 'b' script you could run like: b l # build and install your library in local database b t # build and run your test package executable b m # update module list in .cabal file for all your packages etc. Best, Maur?cio From ross at soi.city.ac.uk Thu Feb 11 08:06:33 2010 From: ross at soi.city.ac.uk (Ross Paterson) Date: Thu Feb 11 07:38:11 2010 Subject: [Haskell-cafe] Seen on reddit: or, foldl and foldr considered slightly harmful In-Reply-To: <87r5osnlbg.fsf@malde.org> References: <555dc06a-b80d-4067-a803-d8a43059dc0f@g28g2000yqh.googlegroups.com> <87r5osnlbg.fsf@malde.org> Message-ID: <20100211130633.GA9231@soi.city.ac.uk> On Thu, Feb 11, 2010 at 11:00:51AM +0100, Ketil Malde wrote: > Johann H?chtl writes: > > In a presentation of Guy Steele for ICFP 2009 in Edinburgh: > > http://www.vimeo.com/6624203 > > he "considers foldl and foldr" harmful as they hinder parallelism > > because of "Process first element, then the rest" Instead he proposes > > a divide and merge aproach, especially in the light of going parallel. > > In Haskell foldl/foldr apply to linked lists (or lazy streams, if you > prefer) which are already inherently sequential, and gets a rather harsh > treatment. I notice he points to finger trees, which I though was > implemented in Data.Sequence. Direct URL for the slides: http://research.sun.com/projects/plrg/Publications/ICFPAugust2009Steele.pdf As he says, associativity is the key to parallelism -- an old observation, but still underappreciated. Even without parallelism, associativity also gives us greater freedom in structuring our solutions. The moral is that our datatypes need associative binary operations more than asymmetric ones. We use lists too much (because they're so convenient) and apart from the loss of parallelism it constrains our thinking to the sequential style criticised by Backus back in 1978. Regarding finger trees, he's just referring to the idea of caching the results of monoidal folds in nodes of a tree. That's crucial to the applications of finger trees, but it can be applied to any kind of tree. As he mentions, it's related to the Ladner-Fischer parallel prefix algorithm, which has an upward pass accumulating sums for each subtree followed by a downward accumulation passing each sum into the subtree to the right. But it's not just for parallelism: when you have these cached values in a balanced tree, you can compute the sum of any prefix in O(log n) steps. From matthias.goergens at googlemail.com Thu Feb 11 08:40:45 2010 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Thu Feb 11 08:12:11 2010 Subject: [Haskell-cafe] If monads are single/linearly threaded, doesn't that reduce parallelism? In-Reply-To: References: <20100209160424.1269769xclnbk89k@webmail.uniserve.com> <5e0214851002091310m45d758e8xab084a40310c3ef1@mail.gmail.com> Message-ID: Perhaps if you search for Abelian Monad or so, you will find interesting things in the category theory literature. Some of them may be transplantable to Haskell --- but you probably don't want a completely commutative structure. Arrows seem to express the dependencies between operations more fine-grained than the sequencing that Monads require. (I meant to look into arrows for ages..) Matthias. From mightybyte at gmail.com Thu Feb 11 09:02:43 2010 From: mightybyte at gmail.com (MightyByte) Date: Thu Feb 11 08:33:49 2010 Subject: [Haskell-cafe] Using Cabal during development In-Reply-To: <27544307.post@talk.nabble.com> References: <27515446.post@talk.nabble.com> <27544307.post@talk.nabble.com> Message-ID: On Thu, Feb 11, 2010 at 5:28 AM, Limestra?l wrote: > Eventually, I think using cabal during development may be convenient. The > only drawback is that you have to specify each dependency... I actually think this is a benefit, not a drawback. In one of my projects where I used makefiles, I was depending on a variety of hackage projects. I was using development code from one of these that had not yet made it onto hackage. There was a period of time where I didn't do much development, and when I came back, I updated to the most recent development code and discovered that it broke my build. Since I didn't have all my dependencies specified and didn't know which devel version I had been using, I was unable to build the project until I fixed all the places where the update to the other package broke my code. If you are on a tight time schedule, this could be very problematic, whereas if you had specified the dependencies, cabal would easily be able to get the right versions for you. From praki.prakash at gmail.com Thu Feb 11 10:02:45 2010 From: praki.prakash at gmail.com (Praki Prakash) Date: Thu Feb 11 09:33:56 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> Message-ID: I am working on an analytics server with a web front end. Being a personal endeavor at this time, I can choose any language that I fancy. I love Haskell and have achieved a modicum of proficiency with many years of following along. I spent a few weeks of serious Haskell prototyping and came to the realization that Haskell has a very steep learning curve to become truly proficient in it. The basics are easy, the various typeclasses can be understood with some study. But, there are thousands of packages on Hackage and not much documentation on most them. Another issue for me is the lack of a cohesive infrastructure for working with web services. Now my work has shifted to Clojure. I like it so far but I miss the elegance of Haskell. Whether Haskell becomes an easy choice for commercial work or remains a boutique language depends on how easy it is to build today's applications. But, I still love Haskell :) Praki On Thu, Feb 11, 2010 at 1:39 AM, Michael Oswald wrote: > On 02/10/2010 04:59 PM, Jason Dusek wrote: >> ? I wonder how many people actually write Haskell, >> ? principally or exclusively, at work? > > Well, my main language at work in the moment is C++, we also use Java, a > lot of Tcl and Python. > > I use Haskell for my own programs and test utilities / converters. The > biggest achievement at work was an Installer program, which was quite > complicated and had to be safe and of course we had time pressure, so I > quickly coded it in Haskell. It is now used in the installation > procedure of a part from a big mission control system for satellites. > > > lg, > Michael > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- http://www.google.com/profiles/praki.prakash From mlesniak at uni-kassel.de Thu Feb 11 10:12:53 2010 From: mlesniak at uni-kassel.de (Michael Lesniak) Date: Thu Feb 11 09:43:58 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> Message-ID: <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> Hello, > elegance of Haskell. Whether Haskell becomes an easy choice for > commercial work or remains a boutique language depends on how easy it > is to build today's applications. Do you (or anyone reading this thread) know of some kind of wishlist of missing features and/or libraries? Would be nice to see what's still "missing". - Michael From jmaessen at alum.mit.edu Thu Feb 11 10:21:42 2010 From: jmaessen at alum.mit.edu (Jan-Willem Maessen) Date: Thu Feb 11 09:52:50 2010 Subject: [Haskell-cafe] Seen on reddit: or, foldl and foldr considered slightly harmful In-Reply-To: <555dc06a-b80d-4067-a803-d8a43059dc0f@g28g2000yqh.googlegroups.com> References: <555dc06a-b80d-4067-a803-d8a43059dc0f@g28g2000yqh.googlegroups.com> Message-ID: <41BD3A9C-5A6D-4FCE-BA8A-F5CD66C84C1E@alum.mit.edu> On Feb 11, 2010, at 3:41 AM, Johann H?chtl wrote: > In a presentation of Guy Steele for ICFP 2009 in Edinburgh: > http://www.vimeo.com/6624203 > he "considers foldl and foldr" harmful as they hinder parallelism > because of "Process first element, then the rest" Instead he proposes > a divide and merge aproach, especially in the light of going parallel. > > The slides at > http://docs.google.com/viewer?url=http%3A%2F%2Fresearch.sun.com%2Fprojects%2Fplrg%2FPublications%2FICFPAugust2009Steele.pdf > [Bware: Google docs] There's no need to use Google docs. A direct url for the pdf: http://research.sun.com/projects/plrg/Publications/ICFPAugust2009Steele.pdf I recently gave a followup talk at Portland State, arguing that notation matters, and that even with better notation programmer mindset is also going to be hard to change: http://research.sun.com/projects/plrg/Publications/PSUJan2010-Maessen.pdf The key thing here isn't *just* the handedness of lists, but the handedness of foldl/foldr *irrespective of the underlying data structure*. So switching to tree-structured data a la fingertrees is a necessary step, but not a sufficient one. The use of monoidal reductions has always been an important part of parallel programming. > are somewhat geared towards Fortress, but I wonder what Haskellers > have to say about his position. Now, what if list comprehensions were really shorthand for construction of Applicative or Monoid structures by traversing a mixture of data types with a common interface (something like this one)? class Generator t e | t -> e mapReduce :: (Monoid m) => t -> (e -> m) -> m -Jan-Willem Maessen Another Fortress/Haskell crossover > Greetings, > > Johann > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From vanenkj at gmail.com Thu Feb 11 10:30:33 2010 From: vanenkj at gmail.com (John Van Enk) Date: Thu Feb 11 10:01:41 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> Message-ID: I need to be able to swap out the RTS. The place I want to stick Haskell absolutely needs its own custom RTS, and currently, I don't think it's all that easy or clean to do that. Am I wrong? Are there resources describing how to do this already? /jve On Thu, Feb 11, 2010 at 10:12 AM, Michael Lesniak wrote: > Hello, > > > > elegance of Haskell. Whether Haskell becomes an easy choice for > > commercial work or remains a boutique language depends on how easy it > > is to build today's applications. > > Do you (or anyone reading this thread) know of some kind of wishlist > of missing features and/or libraries? Would be nice to see what's > still "missing". > > - Michael > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100211/20c0f397/attachment.html From greg at gregorycollins.net Thu Feb 11 11:00:09 2010 From: greg at gregorycollins.net (Gregory Collins) Date: Thu Feb 11 10:31:14 2010 Subject: [Haskell-cafe] Re: Haskell-Cafe Digest, Vol 78, Issue 14 In-Reply-To: <1265883701.5700.55.camel@picard> (Maciej Piechotka's message of "Thu, 11 Feb 2010 10:21:41 +0000") References: <20100209133545.82064324655@www.haskell.org> <9979e72e1002090841x4916e029qf32fad7abc8854d3@mail.gmail.com> <1265883701.5700.55.camel@picard> Message-ID: <87y6izhieu.fsf@gregorycollins.net> Maciej Piechotka writes: > On Tue, 2010-02-09 at 16:41 +0000, John Lato wrote: >> >> See http://inmachina.net/~jwlato/haskell/ParsecIteratee.hs for a valid >> Stream instance using iteratee. Also Gregory Collins recently posted >> an iteratee wrapper for Attoparsec to haskell-cafe. To my knowledge >> these are not yet in any packages, but hackage is vast. > > Hmm. Am I correct that his implementation caches everything? The one that John posted (iteratees on top of parsec) has to keep a copy of the entire input, because parsec wants to be able to do arbitrary backtracking on the stream. Attoparsec provides an *incremental* parser. You feed it bite-sized chunks of an input stream, and it either says "ok, I'm done, here's your value, and the rest of the stream I didn't use" or "I couldn't finish, here's a parser continuation you can feed more chunks to." This, of course, is a perfect conceptual match for iteratees -- with a little bit of plumbing you should be able to parse a stream in O(1) space. > I tried to rewrite the implementation using... well imperative linked > list. For trivial benchmark it have large improvement (althought it may > be due to error in test such as using ByteString) and, I believe, that > it allows to free memory before finish. > > Results of test on Core 2 Duo 2.8 GHz: > 10: 0.000455s 0.000181s > 100: 0.000669s 0.001104s > 1000: 0.005209s 0.023704s > 10000: 0.053292s 1.423443s > 100000: 0.508093s 132.208597s Which column corresponds to which module here, and which module are you benchmarking against, John's or mine? G -- Gregory Collins From ivan.panachev at gmail.com Thu Feb 11 11:10:40 2010 From: ivan.panachev at gmail.com (Ivan Panachev) Date: Thu Feb 11 10:41:47 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> Message-ID: On Thu, Feb 11, 2010 at 6:30 PM, John Van Enk wrote: > I need to be able to swap out the RTS. The place I want to stick Haskell > absolutely needs its own custom RTS, and currently, I don't think it's all > that easy or clean to do that. > > Am I wrong? Are there resources describing how to do this already? > Could you be a bit more precise about your RTS needs? For example, if you want to run Haskell on raw hardware you might be interested with House project, http://programatica.cs.pdx.edu/House/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100211/659bbc6c/attachment.html From vanenkj at gmail.com Thu Feb 11 11:45:14 2010 From: vanenkj at gmail.com (John Van Enk) Date: Thu Feb 11 11:16:21 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> Message-ID: I'm not specifically interested in raw hardware, but I am interested in, say, making the garbage collection deterministic and altering the scheduler to fit some other needs. I'll try and find a link to the paper describing the GC i want to implement.... On Thu, Feb 11, 2010 at 11:10 AM, Ivan Panachev wrote: > On Thu, Feb 11, 2010 at 6:30 PM, John Van Enk wrote: > >> I need to be able to swap out the RTS. The place I want to stick Haskell >> absolutely needs its own custom RTS, and currently, I don't think it's all >> that easy or clean to do that. >> >> Am I wrong? Are there resources describing how to do this already? >> > > Could you be a bit more precise about your RTS needs? For example, if you > want to run Haskell on raw hardware you might be interested with House > project, http://programatica.cs.pdx.edu/House/ > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100211/e584bac4/attachment.html From hthiel.char at zonnet.nl Thu Feb 11 11:49:11 2010 From: hthiel.char at zonnet.nl (Hans van Thiel) Date: Thu Feb 11 11:20:21 2010 Subject: [Haskell-cafe] Haskell and the Job Market, e.g. with Google Message-ID: <1265906951.3002.21.camel@dhcppc0> Hello, Somewhat in response to the original post about Haskell engineers I, II and III. This confirms the remark that Haskell experience is now being appreciated, though not (yet) used (very much). Steven Grant, recruiter from Google, asked me to bring to his attention anyone who might be suitable, so that's what I'm doing. We are currently aggressively recruiting for a large number of engineers in EMEA. I spotted your extensive open source experience and was particularily interested to see you have worked with Haskell. I am not looking for a Haskell developer but more interested in people that have worked in exotic languages such as Haskell or Erlang or Scheme. The roles we have are heavily open sourced based and will be mainly working with Python, C, Linux, shell etc and are based in Dublin, London or Zurich. If you have any interest in discussing these further, drop me an email to stevengrant@google.com and we can discuss. >From a second email: The job specs are below. http://www.google.ie/support/jobs/bin/answer.py?answer=34884 http://www.google.ie/support/jobs/bin/answer.py?answer=34883 The roles are within a very specialist team within Google. They are a hybrid type role and are responsible for making our products reliable scalable and more efficient. Get in touch with Steven: Steven Grant European IT Staffing Phone: +353 1 543 5083 Google Ireland Ltd., Barrow Street, Dublin 4, Ireland Registered in Dublin, Ireland Registration Number: 368047 I think this is interesting even to those who are not looking for a job right now, since it shows the current mind-set regarding Haskell, at a major and leading IT company. Best Regards, Hans van Thiel From vanenkj at gmail.com Thu Feb 11 12:01:03 2010 From: vanenkj at gmail.com (John Van Enk) Date: Thu Feb 11 11:32:09 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> Message-ID: Here's the paper: http://comjnl.oxfordjournals.org/cgi/content/abstract/33/5/466 On Thu, Feb 11, 2010 at 11:45 AM, John Van Enk wrote: > I'm not specifically interested in raw hardware, but I am interested in, > say, making the garbage collection deterministic and altering the scheduler > to fit some other needs. I'll try and find a link to the paper describing > the GC i want to implement.... > > On Thu, Feb 11, 2010 at 11:10 AM, Ivan Panachev wrote: > >> On Thu, Feb 11, 2010 at 6:30 PM, John Van Enk wrote: >> >>> I need to be able to swap out the RTS. The place I want to stick Haskell >>> absolutely needs its own custom RTS, and currently, I don't think it's all >>> that easy or clean to do that. >>> >>> Am I wrong? Are there resources describing how to do this already? >>> >> >> Could you be a bit more precise about your RTS needs? For example, if you >> want to run Haskell on raw hardware you might be interested with House >> project, http://programatica.cs.pdx.edu/House/ >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100211/a39ed0b8/attachment.html From jason.dusek at gmail.com Thu Feb 11 12:13:00 2010 From: jason.dusek at gmail.com (Jason Dusek) Date: Thu Feb 11 11:44:05 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> Message-ID: <42784f261002110913l5a348b6bke2f4d1535598f713@mail.gmail.com> Is JHC not suitable in this case? It won't compile all of Haskell but it does some to be doing the right things as regards a pluggable RTS. I think it's fair to say at this point that GHC can compile all the Haskell we want and that new Haskell pieces will come to GHC before anything else gets them. So going with a totally new system, front-to-back, is not really desirable when all you want is a new RTS; however, I don't think GHC was designed to be a "Haskell compiler superserver". -- Jason Dusek From dagit at codersbase.com Thu Feb 11 12:23:05 2010 From: dagit at codersbase.com (Jason Dagit) Date: Thu Feb 11 11:54:11 2010 Subject: [Haskell-cafe] Streamed creation of STArray from list? Message-ID: Hello, I was wondering if there is a trick for generating a new STArray from a list in such a way that you do not have to hold both the list and array in memory? http://www.haskell.org/ghc/docs/latest/html/libraries/array-0.3.0.0/Data-Array-MArray.html As far as I can tell, that is the interface for creating ST Arrays. For example, newListArray looks almost perfect: *newListArray* :: (MArraya e m, Ixi) => (i, i) -> [e] -> m (a i e) If I know the length of the list, I might expect newListArray to have the memory behavior I want. In my case, the code calls (length xs) to calculate the length of the list. As I understand it, that will force the spine of the list into memory. Can this be avoided? The only trick that comes into mind is the one used by the C++ vector class where you dynamically resize the array and copy the values to the new array. That's potentially a lot of copying, right? Is some other array better suited for this, such as vector or uvector? Thanks, Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100211/273b25d5/attachment.html From vanenkj at gmail.com Thu Feb 11 12:24:38 2010 From: vanenkj at gmail.com (John Van Enk) Date: Thu Feb 11 11:55:44 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <42784f261002110913l5a348b6bke2f4d1535598f713@mail.gmail.com> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> <42784f261002110913l5a348b6bke2f4d1535598f713@mail.gmail.com> Message-ID: Well, my point here is that if we want to see GHC branch into other fields (mine being safety critical), and actually see the code generated by GHC be what's really running (rather than once-removed in the form of an EDSL), some changes will have to be made. Being able to experiment with GHC's RTS and possibly being able to write your own (should the project require it) would go a long way to helping me make the case for GHC in safety critical. Perhaps I'd be better off looking at UHC/LHC/JHC as a starting place. /jve On Thu, Feb 11, 2010 at 12:13 PM, Jason Dusek wrote: > Is JHC not suitable in this case? It won't compile all of > Haskell but it does some to be doing the right things as > regards a pluggable RTS. > > I think it's fair to say at this point that GHC can compile > all the Haskell we want and that new Haskell pieces will come > to GHC before anything else gets them. So going with a totally > new system, front-to-back, is not really desirable when all > you want is a new RTS; however, I don't think GHC was designed > to be a "Haskell compiler superserver". > > -- > Jason Dusek > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100211/b958e95c/attachment.html From job.vranish at gmail.com Thu Feb 11 12:35:09 2010 From: job.vranish at gmail.com (Job Vranish) Date: Thu Feb 11 12:06:15 2010 Subject: [Haskell-cafe] haskell-src type inference algorithm? Message-ID: Anyone know of a type inference utility that can run right on haskell-src types? or one that could be easily adapted? I want to be able to pass in an HsExp and get back an HsQualType. It doesn't have to be fancy, plain Haskell98 types would do. It wouldn't be to hard to make one myself, but I figured there might be one floating around already and it'd be a shame to write it twice :) Thanks, - Job -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100211/9ae3bff0/attachment.html From stephen.tetley at gmail.com Thu Feb 11 12:39:32 2010 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Thu Feb 11 12:10:38 2010 Subject: [Haskell-cafe] haskell-src type inference algorithm? In-Reply-To: References: Message-ID: <5fdc56d71002110939t4b609a72y60dc33c60ba872@mail.gmail.com> Hello Job For Haskell 98 would the code from 'Typing Haskell in Haskell' paper suffice? A web search should find the code... Best wishes Stephen From stephen.tetley at gmail.com Thu Feb 11 12:41:01 2010 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Thu Feb 11 12:12:06 2010 Subject: [Haskell-cafe] haskell-src type inference algorithm? In-Reply-To: <5fdc56d71002110939t4b609a72y60dc33c60ba872@mail.gmail.com> References: <5fdc56d71002110939t4b609a72y60dc33c60ba872@mail.gmail.com> Message-ID: <5fdc56d71002110941l46246e08rc638b05f5de65180@mail.gmail.com> http://web.cecs.pdx.edu/~mpj/thih/ Looks like its a type _checker_ though... On 11 February 2010 17:39, Stephen Tetley wrote: > Hello Job > > For Haskell 98 would the code from 'Typing Haskell in Haskell' paper suffice? > > A web search should find the code... > > Best wishes > > Stephen > From gwern0 at gmail.com Thu Feb 11 12:41:05 2010 From: gwern0 at gmail.com (Gwern Branwen) Date: Thu Feb 11 12:12:15 2010 Subject: [Haskell-cafe] Haskell and the Job Market, e.g. with Google In-Reply-To: <1265906951.3002.21.camel@dhcppc0> References: <1265906951.3002.21.camel@dhcppc0> Message-ID: On Thu, Feb 11, 2010 at 11:49 AM, Hans van Thiel wrote: > Hello, > Somewhat in response to the original post about Haskell engineers I, II > and III. This confirms the remark that Haskell experience is now being > appreciated, though not (yet) used (very much). Steven Grant, recruiter > from Google, asked me to bring to his attention anyone who might be > suitable, so that's what I'm doing. > > > We are currently aggressively recruiting for a large number of engineers > in EMEA. I spotted your extensive open source experience and was > particularily interested to see you have worked with Haskell. I am not > looking for a Haskell developer but more interested in people that have > worked in exotic languages such as Haskell or Erlang or Scheme. > > The roles we have are heavily open sourced based and will be mainly > working with Python, C, Linux, shell etc and are based in Dublin, London > or Zurich. > > If you have any interest in discussing these further, drop me an email > to stevengrant@google.com and we can discuss. > > > >From a second email: > > The job specs are below. > > http://www.google.ie/support/jobs/bin/answer.py?answer=34884 > http://www.google.ie/support/jobs/bin/answer.py?answer=34883 > > The roles are within a very specialist team within Google. > They are a hybrid type role and are responsible for making our > products reliable scalable and more efficient. > > > Get in touch with Steven: > > Steven Grant > > European IT Staffing > Phone: +353 1 543 5083 > Google Ireland Ltd., Barrow Street, Dublin 4, Ireland > Registered in Dublin, Ireland > Registration Number: 368047 > > I think this is interesting even to those who are not looking for a job > right now, since it shows the current mind-set regarding Haskell, at a > major and leading IT company. > > Best Regards, > > Hans van Thiel I would be far from the first to remark that the 'Python Paradox' (http://www.paulgraham.com/pypar.html) has moved on and become the Scala/Haskell Paradox. -- gwern From sk at k-hornz.de Thu Feb 11 12:43:10 2010 From: sk at k-hornz.de (stefan kersten) Date: Thu Feb 11 12:14:19 2010 Subject: [Haskell-cafe] vector to uvector and back again In-Reply-To: References: <4B72F3F6.3050506@k-hornz.de> Message-ID: <4B7441AE.3070407@k-hornz.de> On 10.02.10 19:03, Bryan O'Sullivan wrote: > I'm thinking of switching the statistics library over to using vector. that would be even better of course! an O(0) solution, at least for me ;) let me know if i can be of any help (e.g. in testing). i suppose uvector-algorithms would also need to be ported to vector, then. > uvector is pretty bit-rotted in comparison to vector at this point, and > it's really seeing no development, while vector is The Shiny Future. > Roman, would you call the vector library good enough to use in > production at the moment? i've been using the library for wavelet transforms, matching pursuits and the like, and while my implementations are not heavily optimized, they perform reasonably well (no benchmarking done yet, though). the key arguments for using vector instead of uvector were the cleaner interface and Data.Vector.Storable for interfacing with foreign libraries (such as fftw, through the fft package). From lennart at augustsson.net Thu Feb 11 12:52:42 2010 From: lennart at augustsson.net (Lennart Augustsson) Date: Thu Feb 11 12:23:51 2010 Subject: [Haskell-cafe] haskell-src type inference algorithm? In-Reply-To: References: Message-ID: To do anything interesting you also to process modules, something which I hope to contribute soon to haskell-src-exts. On Thu, Feb 11, 2010 at 6:35 PM, Job Vranish wrote: > Anyone know of a type inference utility that can run right on haskell-src > types? or one that could be easily adapted? > I want to be able to pass in an HsExp and get back an HsQualType. It doesn't > have to be fancy, plain Haskell98 types would do. > > It wouldn't be to hard to make one myself, but I figured there might be one > floating around already and it'd be a shame to write it twice :) > > Thanks, > > - Job > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From lennart at augustsson.net Thu Feb 11 12:53:34 2010 From: lennart at augustsson.net (Lennart Augustsson) Date: Thu Feb 11 12:24:40 2010 Subject: [Haskell-cafe] haskell-src type inference algorithm? In-Reply-To: <5fdc56d71002110941l46246e08rc638b05f5de65180@mail.gmail.com> References: <5fdc56d71002110939t4b609a72y60dc33c60ba872@mail.gmail.com> <5fdc56d71002110941l46246e08rc638b05f5de65180@mail.gmail.com> Message-ID: It does type inference, it's just not engineered to be part of a real compiler. On Thu, Feb 11, 2010 at 6:41 PM, Stephen Tetley wrote: > http://web.cecs.pdx.edu/~mpj/thih/ > > Looks like its a type _checker_ though... > > > On 11 February 2010 17:39, Stephen Tetley wrote: >> Hello Job >> >> For Haskell 98 would the code from 'Typing Haskell in Haskell' paper suffice? >> >> A web search should find the code... >> >> Best wishes >> >> Stephen >> > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From lemming at henning-thielemann.de Thu Feb 11 12:55:49 2010 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Feb 11 12:25:14 2010 Subject: [Haskell-cafe] vector to uvector and back again In-Reply-To: <4B7441AE.3070407@k-hornz.de> References: <4B72F3F6.3050506@k-hornz.de> <4B7441AE.3070407@k-hornz.de> Message-ID: <4B7444A5.10801@henning-thielemann.de> stefan kersten schrieb: >> uvector is pretty bit-rotted in comparison to vector at this point, and >> it's really seeing no development, while vector is The Shiny Future. >> Roman, would you call the vector library good enough to use in >> production at the moment? > > i've been using the library for wavelet transforms, matching pursuits and the > like, Nice I have also worked on this topics, even with Haskell. However, at that time I used plain lists. > and while my implementations are not heavily optimized, they perform > reasonably well (no benchmarking done yet, though). the key arguments for using > vector instead of uvector were the cleaner interface and Data.Vector.Storable > for interfacing with foreign libraries (such as fftw, through the fft package). Btw. Data.StorableVector can also be used for this interfacing, and I would be very interested in an interface to FFTW. Actually, I have already used FFTW on StorableVector http://code.haskell.org/~thielema/morbus-meniere/src/StorableVectorCArray.hs There is also Data.StorableVector.Lazy which is nice for processing stream data. From lemming at henning-thielemann.de Thu Feb 11 12:57:48 2010 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Feb 11 12:27:10 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> Message-ID: <4B74451C.5030607@henning-thielemann.de> John Van Enk schrieb: > I need to be able to swap out the RTS. The place I want to stick Haskell > absolutely needs its own custom RTS, and currently, I don't think it's > all that easy or clean to do that. > > Am I wrong? Are there resources describing how to do this already? As far as I know JHC is intended to work without an RTS. From mauricio.antunes at gmail.com Thu Feb 11 13:00:36 2010 From: mauricio.antunes at gmail.com (=?ISO-8859-1?Q?Maur=ED=ADcio_CA?=) Date: Thu Feb 11 12:32:06 2010 Subject: [Haskell-cafe] Hackage download statistis Message-ID: Hi, all, Some time ago a download statistic of hackage was made available, and analysed in a few ways. Googling for it still find that at a Galois web page. I though that, since the tools to get that were there, this would be output once in a while, but it seems it hasn't been done since then. Does anyone know if there are plans about that? Thanks, Maur?cio From john at repetae.net Thu Feb 11 13:09:24 2010 From: john at repetae.net (John Meacham) Date: Thu Feb 11 12:40:30 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <4B74451C.5030607@henning-thielemann.de> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> <4B74451C.5030607@henning-thielemann.de> Message-ID: <20100211180923.GA20618@sliver.repetae.net> On Thu, Feb 11, 2010 at 06:57:48PM +0100, Henning Thielemann wrote: > John Van Enk schrieb: > > I need to be able to swap out the RTS. The place I want to stick Haskell > > absolutely needs its own custom RTS, and currently, I don't think it's > > all that easy or clean to do that. > > > > Am I wrong? Are there resources describing how to do this already? > > As far as I know JHC is intended to work without an RTS. It is more that the RTS is generated as a part of the normal code generation process, this is done by implementing as much as possible in haskell itself, jhc has a very rich set of unboxed primitives, making it as expressible as c-- for the most part, for the bits of C I do need, I try to make them conditionally compilable, so parts that arn't used will not be included. all in all, the overhead is ~= 1k or so. A side effect is that jhc is very lightly coupled to any particular RTS, so experimenting with alternate ones is pretty straigtforward. John -- John Meacham - ?repetae.net?john? - http://notanumber.net/ From matthias.goergens at googlemail.com Thu Feb 11 13:24:25 2010 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Thu Feb 11 12:55:54 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <20100211180923.GA20618@sliver.repetae.net> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> <4B74451C.5030607@henning-thielemann.de> <20100211180923.GA20618@sliver.repetae.net> Message-ID: Implementing an alternative RTS for GHC seems like a viable Google Summer of Code project to me. What do you think? From dagit at codersbase.com Thu Feb 11 13:37:40 2010 From: dagit at codersbase.com (Jason Dagit) Date: Thu Feb 11 13:08:44 2010 Subject: [Haskell-cafe] haskell-src type inference algorithm? In-Reply-To: References: Message-ID: On Thu, Feb 11, 2010 at 9:35 AM, Job Vranish wrote: > Anyone know of a type inference utility that can run right on haskell-src > types? or one that could be easily adapted? > I want to be able to pass in an HsExp and get back an HsQualType. It > doesn't have to be fancy, plain Haskell98 types would do. > > It wouldn't be to hard to make one myself, but I figured there might be one > floating around already and it'd be a shame to write it twice :) > I've never checked to know if this is true, but could you use the GHC API to have GHC do your type inference/checking? http://www.haskell.org/ghc/docs/latest/html/libraries/ghc-6.12.1/index.html If you figure out if this is possible (or not), I'd love to hear what you figure out. Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100211/7ef5c45a/attachment.html From ryani.spam at gmail.com Thu Feb 11 13:58:14 2010 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Feb 11 13:29:18 2010 Subject: [Haskell-cafe] Streamed creation of STArray from list? In-Reply-To: References: Message-ID: <2f9b2d31002111058t63617afep9b462f4d9b158ef0@mail.gmail.com> On Thu, Feb 11, 2010 at 9:23 AM, Jason Dagit wrote: > If I know the length of the list, I might expect newListArray to have the > memory behavior I want.? In my case, the code calls (length xs) to calculate > the length of the list.? As I understand it, that will force the spine of > the list into memory.? Can this be avoided?? The only trick that comes into > mind is the one used by the C++ vector class where you dynamically resize > the array and copy the values to the new array.? That's potentially a lot of > copying, right? Not really: as long as you grow the array exponentially the total number of copies is linear in the size of the array. On average you will copy each element twice; the first element gets copied (log n) times but the last half of the elements go directly into the final array. If you want to avoid putting any of the spine into memory you might do a third copy where you shrink the array size at the end (or perhaps there is an array type that has a 'shrink' operation that just reduces the bounds without freeing any memory) -- ryan From jeremy at n-heptane.com Thu Feb 11 14:04:01 2010 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Thu Feb 11 13:35:09 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: References: <910ddf451002091647m4b7e12a5y5a680d7d356fb3d6@mail.gmail.com> <94E8A4F7-E54B-4885-8D6A-6AA4777F6FC1@n-heptane.com> Message-ID: On Wed, Feb 10, 2010 at 1:15 PM, Bardur Arantsson wrote: I've also been contemplating some solutions, but I cannot see any solutions > to this problem which could reasonably be implemented outside of GHC itself. > GHC lacks a "threadWaitError", so there's no way to detect the problem > except by timeout or polling. Solutions involving timeouts and polling are > bad in this case because they arbitrarily restrict the client connection > rate. > > Cheers, I believe solutions involving polling and timeouts may be the *only* solution due to the way TCP works. There are two cases to consider here: 1. what happens when the remote client does a proper disconnect by sending a FIN packet, etc 2. what happens when the remote client just drops the connection Case #1 - Proper Disconnect I believe that in case we are ok. select() may not wakeup due to the socket being closed -- but something will eventually cause select() to wakeup, and then next time through the loop, the call to select will fail with EBADF. This will cause everyone to wakeup. We can test this case by writing a client that purposely (and correctly) terminations the connection while threadWaitWrite is blocking and see if that causes it to wakeup. To ensure that the IOManager is eventually waking up, the server can have an IO thread that just does, forever $ threadDelay (1*10^6) Look here for more details: http://darcs.haskell.org/packages/base/GHC/Conc.lhs Case #2 - Sudden Death In this case, there is no way to tell if the client is still there with out trying to send / recv data. A TCP connection is not a 'tangible' link. It is just an agreement to send packets to/from certain ports with certain sequence numbers. It's much closer to snail mail than a telephone call. If you set the keepalive socket option, then the TCP layer will automatically ping the connection to make sure it is still alive. However, I believe the default time between keepalive packets is 2 hours, and can only be changed on a system wide basis? http://www.unixguide.net/network/socketfaq/2.8.shtml The other option is to try to send some data. There are at least two cases that can happen here. 1. the network cable is unplugged -- this is not an 'error'. The write buffer will fill up and it will wait until it can send the data. If the write buffer is full, it will either block or return EAGAIN depending on the mode. Eventually, after 2 hours, it might give up. 2. the remote client has terminated the connection as far as it is concerned but not notified the server -- when you try to send data it will reject it, and send/write/sendfile/etc will raise sigPIPE. Looking at your debug output, we are seeing the sigPIPE / Broken Pipe error most of the time. But then there is the case where we get stuck on the threadWaitWrite. threadWaitWrite is ultimately implemented by passing the file descriptor to the list of write descriptors in a call to select(). It seems, however, that select() is not waking up just because calling write() on a file descriptor *would* cause sigPIPE. The easiest way to confirm this case is probably to write a small, pure C program and see what really happens. If this is the case, then it means the only way to tell if the client has abruptly dropped the connection is to actually try sending the data and see if the sending function calls sigPIPE. And that means doing some sort of polling/timeout? What do you think? I do not have a good explanation as to why the portable version does not fail. Except maybe it is just so slow that it does not ever fill up the buffer, and hence does not get stuck in threadWaitWrite? Any way, the fundamental question is: When your write buffer is full, and you call select() on that file descriptor, will select() return in the case where calling write() again would raise sigPIPE? - jeremy -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100211/4e29c467/attachment-0001.html From uzytkownik2 at gmail.com Thu Feb 11 14:27:27 2010 From: uzytkownik2 at gmail.com (Maciej Piechotka) Date: Thu Feb 11 13:58:31 2010 Subject: [Haskell-cafe] Re: Haskell-Cafe Digest, Vol 78, Issue 14 In-Reply-To: <87y6izhieu.fsf@gregorycollins.net> References: <20100209133545.82064324655@www.haskell.org> <9979e72e1002090841x4916e029qf32fad7abc8854d3@mail.gmail.com> <1265883701.5700.55.camel@picard> <87y6izhieu.fsf@gregorycollins.net> Message-ID: <1265916447.5994.32.camel@picard> On Thu, 2010-02-11 at 11:00 -0500, Gregory Collins wrote: > Maciej Piechotka writes: > > > On Tue, 2010-02-09 at 16:41 +0000, John Lato wrote: > >> > >> See http://inmachina.net/~jwlato/haskell/ParsecIteratee.hs for a valid > >> Stream instance using iteratee. Also Gregory Collins recently posted > >> an iteratee wrapper for Attoparsec to haskell-cafe. To my knowledge > >> these are not yet in any packages, but hackage is vast. > > > > Hmm. Am I correct that his implementation caches everything? > > The one that John posted (iteratees on top of parsec) has to keep a copy > of the entire input, because parsec wants to be able to do arbitrary > backtracking on the stream. > Well. Not quite. AFAIU (and ByteString implementation indicate so) the uncons have a type uncons :: s -> m (Maybe (t, s)) Where s indicates the position on the stream. Since it is impossible to get back from having s alone the GC should be free to finalize all memory allocated to cache the stream before the first living s. I.e. if input is: text = 'L':'o':'r':'e':'m':' ':'i':'p':'s':'u':'m':[] ^ ^ s1 s2 and s1 and s2 are position in the stream (for stream that is list) GC can free Lor part. It seems that it might be significant in real live as try calls are relatively short comparing with rest of code. By keeping s as 'pointer to' element second uncons have O(1) time instead of O(n). > > > I tried to rewrite the implementation using... well imperative linked > > list. For trivial benchmark it have large improvement (althought it may > > be due to error in test such as using ByteString) and, I believe, that > > it allows to free memory before finish. > > > > Results of test on Core 2 Duo 2.8 GHz: > > 10: 0.000455s 0.000181s > > 100: 0.000669s 0.001104s > > 1000: 0.005209s 0.023704s > > 10000: 0.053292s 1.423443s > > 100000: 0.508093s 132.208597s > > Which column corresponds to which module here, and which module are you > benchmarking against, John's or mine? > > G As I'm implementing for parsec (I don't know attoparsec) [as a kind of exercise to get iteratee better] I benchmarked against John's. My results are on the left. I forgot to compile and optimize. Here's result for ByteString: Mine John's 10: 0.000425s 0.000215s 100: 0.000616s 0.001963s 1000: 0.0041s 0.048359s 10000: 0.041694s 4.492774s 100000: 0.309289s 434.238449s And []: Mine John's 10: 0.000605s 0.000932s 100: 0.001464s 0.008101s 1000: 0.004036s 0.054125s 10000: 0.032341s 1.36938s 100000: 0.317859s 115.846891s Regards and sorry for confusion PS. Sorry - I know that test is somehow simplistic but I thing it emulates real live situation where you are interested in small amount of elements around current position (short try). I also think that /dev/zero have relatively predictable access time (it does not need to be loaded from slow disk first after which it can be accessed from cache, it does not run out of entropy etc.). -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100211/0fa77b47/attachment.bin From aslatter at gmail.com Thu Feb 11 14:34:38 2010 From: aslatter at gmail.com (Antoine Latter) Date: Thu Feb 11 14:05:43 2010 Subject: [Haskell-cafe] Re: Haskell-Cafe Digest, Vol 78, Issue 14 In-Reply-To: <1265916447.5994.32.camel@picard> References: <20100209133545.82064324655@www.haskell.org> <9979e72e1002090841x4916e029qf32fad7abc8854d3@mail.gmail.com> <1265883701.5700.55.camel@picard> <87y6izhieu.fsf@gregorycollins.net> <1265916447.5994.32.camel@picard> Message-ID: <694519c51002111134i3e755777ld4b850aeafd8caa5@mail.gmail.com> On Thu, Feb 11, 2010 at 1:27 PM, Maciej Piechotka wrote: > On Thu, 2010-02-11 at 11:00 -0500, Gregory Collins wrote: >> Maciej Piechotka writes: >> >> > On Tue, 2010-02-09 at 16:41 +0000, John Lato wrote: >> >> >> >> See http://inmachina.net/~jwlato/haskell/ParsecIteratee.hs for a valid >> >> Stream instance using iteratee. ?Also Gregory Collins recently posted >> >> an iteratee wrapper for Attoparsec to haskell-cafe. ?To my knowledge >> >> these are not yet in any packages, but hackage is vast. >> > >> > Hmm. Am I correct that his implementation caches everything? >> >> The one that John posted (iteratees on top of parsec) has to keep a copy >> of the entire input, because parsec wants to be able to do arbitrary >> backtracking on the stream. >> > > Well. Not quite. AFAIU (and ByteString implementation indicate so) the > uncons have a type > ? ?uncons :: s -> m (Maybe (t, s)) > > Where s indicates the position on the stream. Since it is impossible to > get back from having s alone the GC should be free to finalize all > memory allocated to cache the stream before the first living s. > I'm not sure that this is correct - parsec believes that it is free to call 'uncons' multiple times on the same value and receive an equivalent answer. Maybe I'm misunderstanding what we're talking about, but a simple test is: backtrackTest = (try (string "aardvark")) <|> (string "aaple") And then attempt to parse the stream equivalent to "aaple" with 'backtrackTest'. This should be a successful parse (untested). Antoine From sk at k-hornz.de Thu Feb 11 14:39:57 2010 From: sk at k-hornz.de (stefan kersten) Date: Thu Feb 11 14:11:02 2010 Subject: [Haskell-cafe] vector to uvector and back again In-Reply-To: <4B7444A5.10801@henning-thielemann.de> References: <4B72F3F6.3050506@k-hornz.de> <4B7441AE.3070407@k-hornz.de> <4B7444A5.10801@henning-thielemann.de> Message-ID: <4B745D0D.6060503@k-hornz.de> On 11.02.10 18:55, Henning Thielemann wrote: >> i've been using the library for wavelet transforms, matching pursuits >> and the like, > > Nice I have also worked on this topics, even with Haskell. However, at > that time I used plain lists. interesting! was performance acceptable for practical work? at the moment i'm not too concerned about performance -- the base line maybe could be to be competitive with matlab. in the long run i hope i'll be able to scale my stuff to larger amounts of data, however ... >> and while my implementations are not heavily optimized, they perform >> reasonably well (no benchmarking done yet, though). the key arguments >> for using vector instead of uvector were the cleaner interface and >> Data.Vector.Storable for interfacing with foreign libraries (such as >> fftw, through the fft package). > > Btw. Data.StorableVector can also be used for this interfacing, and > I would be very interested in an interface to FFTW. Actually, I have > already used FFTW on StorableVector i'm simply using the fft package and adapted some of it's internals to work on Data.Vector.Storable; nothing fancy though, and only for RC and CR transforms. let me know if you're interested in the code ... > There is also Data.StorableVector.Lazy which is nice for processing > stream data. yes, i know about storablevector, but i already had some code using uvector, so in the end vector was the easier upgrade. to me the relative merits of storablevector vs. vector are still unclear; the lazy interface could be implemented on top of vector as well, i suppose? From uzytkownik2 at gmail.com Thu Feb 11 14:50:51 2010 From: uzytkownik2 at gmail.com (Maciej Piechotka) Date: Thu Feb 11 14:21:55 2010 Subject: Iteratee and parsec (was: Re: [Haskell-cafe] Re: Haskell-Cafe Digest, Vol 78, Issue 14) In-Reply-To: <694519c51002111134i3e755777ld4b850aeafd8caa5@mail.gmail.com> References: <20100209133545.82064324655@www.haskell.org> <9979e72e1002090841x4916e029qf32fad7abc8854d3@mail.gmail.com> <1265883701.5700.55.camel@picard> <87y6izhieu.fsf@gregorycollins.net> <1265916447.5994.32.camel@picard> <694519c51002111134i3e755777ld4b850aeafd8caa5@mail.gmail.com> Message-ID: <1265917851.5994.42.camel@picard> On Thu, 2010-02-11 at 13:34 -0600, Antoine Latter wrote: > On Thu, Feb 11, 2010 at 1:27 PM, Maciej Piechotka > wrote: > > On Thu, 2010-02-11 at 11:00 -0500, Gregory Collins wrote: > >> Maciej Piechotka writes: > >> > >> > On Tue, 2010-02-09 at 16:41 +0000, John Lato wrote: > >> >> > >> >> See http://inmachina.net/~jwlato/haskell/ParsecIteratee.hs for a > valid > >> >> Stream instance using iteratee. Also Gregory Collins recently > posted > >> >> an iteratee wrapper for Attoparsec to haskell-cafe. To my > knowledge > >> >> these are not yet in any packages, but hackage is vast. > >> > > >> > Hmm. Am I correct that his implementation caches everything? > >> > >> The one that John posted (iteratees on top of parsec) has to keep a > copy > >> of the entire input, because parsec wants to be able to do > arbitrary > >> backtracking on the stream. > >> > > > > Well. Not quite. AFAIU (and ByteString implementation indicate so) > the > > uncons have a type > > uncons :: s -> m (Maybe (t, s)) > > > > Where s indicates the position on the stream. Since it is impossible > to > > get back from having s alone the GC should be free to finalize all > > memory allocated to cache the stream before the first living s. > > > > I'm not sure that this is correct - parsec believes that it is free > to call 'uncons' multiple times on the same value and receive an > equivalent answer. That's what I meant. But it have to keep the reference to the first element. Consider example with list: text = 'L':'o':'r':'e':'m':' ':'i':'p':'s':'u':'m':[] ^ ^ ^ s1 s2 s3 uncons s1 == Identity (Just ('e', 'm':' ':'i':'p':'s':'u':'m':[])) uncons s2 == Identity (Just ('p', 's':'u':'m':[])) uncons s3 == Identity Nothing However we will never get (nor we keep reference to): 'L':'o':'r':'e':'m':' ':'i':'p':'s':'u':'m':[], 'o':'r':'e':'m':' ':'i':'p':'s':'u':'m':[] 'r':'e':'m':' ':'i':'p':'s':'u':'m':[] so those values can be freed as they are before first pointer (namely s1). Regards -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100211/db621cd6/attachment.bin From spam at scientician.net Thu Feb 11 14:57:28 2010 From: spam at scientician.net (Bardur Arantsson) Date: Thu Feb 11 14:28:52 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: References: <910ddf451002091647m4b7e12a5y5a680d7d356fb3d6@mail.gmail.com> <94E8A4F7-E54B-4885-8D6A-6AA4777F6FC1@n-heptane.com> Message-ID: Jeremy Shaw wrote: > On Wed, Feb 10, 2010 at 1:15 PM, Bardur Arantsson wrote: > > I've also been contemplating some solutions, but I cannot see any solutions >> to this problem which could reasonably be implemented outside of GHC itself. >> GHC lacks a "threadWaitError", so there's no way to detect the problem >> except by timeout or polling. Solutions involving timeouts and polling are >> bad in this case because they arbitrarily restrict the client connection >> rate. >> >> Cheers, > > > I believe solutions involving polling and timeouts may be the *only* > solution due to the way TCP works. There are two cases to consider here: > True, but my point was rather that a solution in the sendfile libary would incur an _extra_ timeout on top of the timeout which is handled by the OS. It's very hard to come up with a "proper" timeout here because apps will have different requirements depending on the expected connection rate, etc. This is what I see as unacceptable since it would have to be a completely arbitrary timeout -- there's no way for the application to specify a timeout to the sendfile library since the API doesn't permit it. [--snip--] > Case #1 - Proper Disconnect > > I believe that in case we are ok. select() may not wakeup due to the socket > being closed -- but something will eventually cause select() to wakeup, and > then next time through the loop, the call to select will fail with EBADF. > This will cause everyone to wakeup. We can test this case by writing a > client that purposely (and correctly) terminations the connection while > threadWaitWrite is blocking and see if that causes it to wakeup. To ensure > that the IOManager is eventually waking up, the server can have an IO thread > that just does, forever $ threadDelay (1*10^6) > > Look here for more details: > http://darcs.haskell.org/packages/base/GHC/Conc.lhs > I don't have time to write a C test program right now. I'm actually not 100% convinced that this case is *not* problematic, but my limited testing with "well-behaved" clients (wget, curl) hasn't turned up any problems so far. > Case #2 - Sudden Death > > In this case, there is no way to tell if the client is still there with out > trying to send / recv data. A TCP connection is not a 'tangible' link. It is > just an agreement to send packets to/from certain ports with certain > sequence numbers. It's much closer to snail mail than a telephone call. > > If you set the keepalive socket option, then the TCP layer will > automatically ping the connection to make sure it is still alive. However, I > believe the default time between keepalive packets is 2 hours, and can only > be changed on a system wide basis? > > http://www.unixguide.net/network/socketfaq/2.8.shtml There are some options you can set via setsockopt(), see man 7 tcp: tcp_keepalive_intvl (default: 75s) tcp_fin_timeout (default: 60s) (The latter is the amount of time to wait for the final FIN before forcing a the socket to close.) These can be set per-socket. > > The other option is to try to send some data. There are at least two cases > that can happen here. This is what I tried. The trouble here is that you have to force the thread doing threadWaitWrite to wake up periodically... and how do you decide how often? Too often and you're burning CPU doing nothing, too seldom and you're letting threads (and by implication used-but-really-disconnected-as-far-as-the-OS-is-concerned file descriptors) pile up. The overhead of mempcy (avoidance of which is sendfile's raison-d'?tre) is probably much less than the overhead of doing all this administration in userspace instead of just letting the kernel do its thing. Even waking up very seldom (~1/s IIRC) incurred a lot of CPU overhead in my test case... but I suppose I could give it another try to see if I'd made some mistake in my code which caused it to use more CPU than necessary. > > 1. the network cable is unplugged -- this is not an 'error'. The write > buffer will fill up and it will wait until it can send the data. If the > write buffer is full, it will either block or return EAGAIN depending on the > mode. Eventually, after 2 hours, it might give up. I believe the socket is actually in non-blocking mode in my application. I'm not putting it into non-blocking mode, so I'm guessing that the "accept" call is doing that -- or maybe it's just the default behavior of accept() on Linux. Converting a socket to a Handle (which is what the portable sendfile does) automatically puts it into blocking mode. Actually, I think this whole issue could be avoided if the socket could just be forced into blocking mode. In that case, there would be no need to call threadWaitWrite: The native sendfile() call could never return EAGAIN (it would block instead), and so there'd be no need to call threadWaitWrite to avoid busy-waiting. > 2. the remote client has terminated the connection as far as it is > concerned but not notified the server -- when you try to send data it will > reject it, and send/write/sendfile/etc will raise sigPIPE. > > Looking at your debug output, we are seeing the sigPIPE / Broken Pipe error > most of the time. But then there is the case where we get stuck on the > threadWaitWrite. > > threadWaitWrite is ultimately implemented by passing the file descriptor to > the list of write descriptors in a call to select(). It seems, however, that > select() is not waking up just because calling write() on a file descriptor > *would* cause sigPIPE. That's what I expect select() with an "errfd" FDSET would do. > > The easiest way to confirm this case is probably to write a small, pure C > program and see what really happens. > > If this is the case, then it means the only way to tell if the client has > abruptly dropped the connection is to actually try sending the data and see > if the sending function calls sigPIPE. And that means doing some sort of > polling/timeout? Correct, but the trouble is deciding how often to poll and/or how long the timeout should be. I don't see any easy answer to that. That's why my suggested "solution" is to simply punt it to the OS (by using portable mode) and suck up the extra overhead of the portable solution. Hopefully the new GHC I/O manager will make it possible to have a proper solution. > > I do not have a good explanation as to why the portable version does not > fail. Except maybe it is just so slow that it does not ever fill up the > buffer, and hence does not get stuck in threadWaitWrite? The portable version doesn't call threadWaitWrite. It simply turns the Socket into a handle (which causes it to become blocking) and so the kernel is tasked with handling all the gritty details. > > Any way, the fundamental question is: > > When your write buffer is full, and you call select() on that file > descriptor, will select() return in the case where calling write() again > would raise sigPIPE? > I believe so, *if* you give it the FD in the exceptfds FD_SET parameter. Let's face it, any other behavior doesn't make any sense since it's the equivalent of forcing all timeout handling onto the user, just like threadWaitWrite currently does. I've written my fair share of networking code in various languages (including C/C++) and I've never seen this problem of "missing wakeups" before. Cheers, From vanenkj at gmail.com Thu Feb 11 15:23:07 2010 From: vanenkj at gmail.com (John Van Enk) Date: Thu Feb 11 14:54:12 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> <4B74451C.5030607@henning-thielemann.de> <20100211180923.GA20618@sliver.repetae.net> Message-ID: I'd suggested this in an earlier SoC thread. 2010/2/11 Matthias G?rgens > Implementing an alternative RTS for GHC seems like a viable Google > Summer of Code project to me. What do you think? > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100211/617dbc67/attachment.html From vanenkj at gmail.com Thu Feb 11 15:23:26 2010 From: vanenkj at gmail.com (John Van Enk) Date: Thu Feb 11 14:54:33 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <20100211180923.GA20618@sliver.repetae.net> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> <4B74451C.5030607@henning-thielemann.de> <20100211180923.GA20618@sliver.repetae.net> Message-ID: I'll definitely take a closer look. On Thu, Feb 11, 2010 at 1:09 PM, John Meacham wrote: > On Thu, Feb 11, 2010 at 06:57:48PM +0100, Henning Thielemann wrote: > > John Van Enk schrieb: > > > I need to be able to swap out the RTS. The place I want to stick > Haskell > > > absolutely needs its own custom RTS, and currently, I don't think it's > > > all that easy or clean to do that. > > > > > > Am I wrong? Are there resources describing how to do this already? > > > > As far as I know JHC is intended to work without an RTS. > > It is more that the RTS is generated as a part of the normal code > generation process, this is done by implementing as much as possible in > haskell itself, jhc has a very rich set of unboxed primitives, making it > as expressible as c-- for the most part, for the bits of C I do need, I > try to make them conditionally compilable, so parts that arn't used will > not be included. all in all, the overhead is ~= 1k or so. A side effect > is that jhc is very lightly coupled to any particular RTS, so > experimenting with alternate ones is pretty straigtforward. > > John > > -- > John Meacham - ?repetae.net?john? - http://notanumber.net/ > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100211/2a40819c/attachment.html From alp at mestan.fr Thu Feb 11 15:57:12 2010 From: alp at mestan.fr (Alp Mestanogullari) Date: Thu Feb 11 15:28:17 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> <4B74451C.5030607@henning-thielemann.de> <20100211180923.GA20618@sliver.repetae.net> Message-ID: It seems quite big for a 3 months project made by a student, though. 2010/2/11 Matthias G?rgens > Implementing an alternative RTS for GHC seems like a viable Google > Summer of Code project to me. What do you think? -- Alp Mestanogullari http://alpmestan.wordpress.com/ http://alp.developpez.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100211/a917311b/attachment.html From lemming at henning-thielemann.de Thu Feb 11 16:32:14 2010 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Feb 11 16:03:23 2010 Subject: [Haskell-cafe] Undecidable instances with functional dependencies Message-ID: I have the following class and instance class Register a r | a -> r where instance (Register a ra, Register b rb) => Register (a,b) (ra,rb) where and GHC refuses the instance because of violated Coverage Condition. I have more instances like instance Register Int8 (Reg Int8) where instance Register Word8 (Reg Word8) where and for the set of instances I plan, the instance resolution will always terminate. I remember that the term 'undecidable instance' is not fixed and may be relaxed if a more liberal condition can be found. Is there a place, say a Wiki page, where we can collect examples where we think that the current check of GHC is too restrictive? From miguelimo38 at yandex.ru Thu Feb 11 16:48:28 2010 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Thu Feb 11 16:19:34 2010 Subject: [Haskell-cafe] Undecidable instances with functional dependencies In-Reply-To: References: Message-ID: -- {-# LANGUAGE FunctionalDependencies#-} -- {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE TypeFamilies #-} module Register where -- class Register a r | a -> r class Register a where type R a -- instance Register Int Int instance Register Int where type R Int = Int -- instance Register Float Float instance Register Float where type R Float = Float -- instance (Register a1 r1, Register a2 r2) => Register (a1, a2) (r1, r2) instance (Register a, Register b) => Register (a, b) where type R (a, b) = (R a, R b) On 12 Feb 2010, at 00:32, Henning Thielemann wrote: > > I have the following class and instance > > class Register a r | a -> r where > > instance (Register a ra, Register b rb) => > Register (a,b) (ra,rb) where > > and GHC refuses the instance because of violated Coverage Condition. > I have more instances like > > instance Register Int8 (Reg Int8) where > instance Register Word8 (Reg Word8) where > > and for the set of instances I plan, the instance resolution will > always terminate. I remember that the term 'undecidable instance' is > not fixed and may be relaxed if a more liberal condition can be > found. Is there a place, say a Wiki page, where we can collect > examples where we think that the current check of GHC is too > restrictive? > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From vanenkj at gmail.com Thu Feb 11 16:49:08 2010 From: vanenkj at gmail.com (John Van Enk) Date: Thu Feb 11 16:20:14 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> <4B74451C.5030607@henning-thielemann.de> <20100211180923.GA20618@sliver.repetae.net> Message-ID: Perhaps just defining the interface and demonstrating that different RTS's are swappable would be enough? 2010/2/11 Alp Mestanogullari > It seems quite big for a 3 months project made by a student, though. > > 2010/2/11 Matthias G?rgens > >> Implementing an alternative RTS for GHC seems like a viable Google >> >> Summer of Code project to me. What do you think? >> > > > > -- > Alp Mestanogullari > http://alpmestan.wordpress.com/ > http://alp.developpez.com/ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100211/71b63ef0/attachment.html From thomas.dubuisson at gmail.com Thu Feb 11 16:17:49 2010 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Thu Feb 11 16:20:30 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: References: <5679D446-9E50-4DFB-AFBD-E9532C3DCF0B@ece.cmu.edu> <20100206111415.GB29938@kira.casa> Message-ID: <4c44d90b1002111317k298d5200o99f06b1e69f997ff@mail.gmail.com> Bardur Arantsson wrote: >> ... >> ? ? ? then do errno <- getErrno >> ? ? ? ? ? ? ? if errno == eAGAIN >> ? ? ? ? ? ? ? ? then do >> ? ? ? ? ? ? ? ? ? ?threadDelay 100 >> ? ? ? ? ? ? ? ? ? ?sendfile out_fd in_fd poff bytes >> ? ? ? ? ? ? ? ? else throwErrno "Network.Socket.SendFile.Linux" >> ? ? ?else return (fromIntegral sbytes) > > That is, I removed the threadWaitWrite in favor of just adding a > "threadDelay 100" when eAGAIN is encountered. > > With this code, I cannot provoke the leak. > > Unfortunately this isn't really a solution -- the CPU is pegged at > ~50% when I do this and it's not exactly elegant to have a hardcoded > 100 ms delay in there. :) I don't think it matters wrt the desired final solution, but this is NOT a 100 ms delay. It is a 0.1 ms delay, which is less than a GHC time slice and as such is basically a tight loop. If you use a reasonable value for the delay you will probably see the CPU being almost completely idle. Thomas From qdunkan at gmail.com Thu Feb 11 16:55:35 2010 From: qdunkan at gmail.com (Evan Laforge) Date: Thu Feb 11 16:26:41 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> <4B74451C.5030607@henning-thielemann.de> <20100211180923.GA20618@sliver.repetae.net> Message-ID: <2518b95d1002111355s6195503bn3b93838d3e74be8b@mail.gmail.com> On Thu, Feb 11, 2010 at 1:49 PM, John Van Enk wrote: > Perhaps just defining the interface and demonstrating that different RTS's > are swappable would be enough? I read a paper by (I think) a Simon, in which he described a haskell RTS. It would make it easier to experiment with GC, scheduling, and whatever else. I recall a few problems, such as performance, but nothing really intractable. Swappable RTS would be a nice side-effect. Unfortunately I don't remember the title of the paper. Maybe it had to do with the whole GMP thing? It might be big for SoC but perhaps there's some well-defined subset, like fix some blocking issue? From andrewcoppin at btinternet.com Thu Feb 11 16:10:34 2010 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Feb 11 16:41:29 2010 Subject: [Haskell-cafe] Type arithmetic with ATs/TFs In-Reply-To: <4B730935.6030901@btinternet.com> References: <4B730935.6030901@btinternet.com> Message-ID: <4B74724A.9090307@btinternet.com> Andrew Coppin wrote: > OK, so I sat down today and tried this, but I can't figure out how. > > There are various examples of type-level arithmetic around the place. > For example, > > http://www.haskell.org/haskellwiki/Type_arithmetic > > (This is THE first hit on Google, by the way. Haskell is apparently > THAT popular!) But this does type arithmetic using functional > dependencies; what I'm trying to figure out is how to do that with > associated types. > > Any hints? Several people have now replied to this, both on and off-list. But all the replies use type families, not associated types. Now type families are something I don't yet comprehend. (Perhaps the replies will help... I haven't studied them yet.) What I understand is that ATs allow you to write things like class Container c where type Element c :: * ... And now you can explicitly talk about the kind of element a container can hold, rather than relying on the type constructor having a particular kind or something. So the above works for containers that can hold *anything* (such as lists), containers which can only hold *one* thing (e.g., ByteString), and containers which can hold only certain things (e.g., Set). ...which is great. But I can't see a way to use this for type arithmetic. Possibly because I don't have a dramatically solid mental model of exactly how it works. You'd *think* that something like class Add x y where type Sum x y :: * instance Add x y => Add (Succ x) y where type Sum (Succ x) y = Succ (Sum x y) ought to work, but apparently not. As to what type families - type declarations outside of a class - end up meaning, I haven't the vaguest idea. The Wiki page makes it sound increadibly complicated... From schernichkin at gmail.com Thu Feb 11 17:19:46 2010 From: schernichkin at gmail.com (=?UTF-8?B?0KHRgtCw0L3QuNGB0LvQsNCyINCn0LXRgNC90LjRh9C60LjQvQ==?=) Date: Thu Feb 11 16:50:53 2010 Subject: [Haskell-cafe] ANN: Happstack 0.4.1 In-Reply-To: <99D43ACE-4235-45BD-8484-6BA0CC64F6E7@n-heptane.com> References: <99D43ACE-4235-45BD-8484-6BA0CC64F6E7@n-heptane.com> Message-ID: <4B748282.3060100@gmail.com> I was unable to install happstack-data-0.4.1 on windows with GHC 6.12.1. Here the log: Resolving dependencies... Configuring happstack-data-0.4.1... Preprocessing library happstack-data-0.4.1... Preprocessing executables for happstack-data-0.4.1... Building happstack-data-0.4.1... src\Happstack\Data\GOps.hs:54:0: warning: no newline at end of file src\Happstack\Data\SerializeTH.hs:88:0: warning: no newline at end of file [ 1 of 16] Compiling Happstack.Data.GOps ( src\Happstack\Data\GOps.hs, dist\buil d\Happstack\Data\GOps.o ) src\Happstack\Data\Serialize.hs:1:85: Warning: -XPatternSignatures is deprecated: use -XScopedTypeVariables or pra gma {-# LANGUAGE ScopedTypeVariables #-} instead src\Happstack\Data\Xml\Base.hs:6:13: Warning: -XPatternSignatures is deprecated: use -XScopedTypeVariables or pra gma {-# LANGUAGE ScopedTypeVariables #-} instead [ 2 of 16] Compiling Happstack.Data.Normalize ( src\Happstack\Data\Normalize.hs, dist\build\Happstack\Data\Normalize.o ) [ 3 of 16] Compiling Happstack.Data.Migrate ( src\Happstack\Data\Migrate.hs, dis t\build\Happstack\Data\Migrate.o ) [ 4 of 16] Compiling Happstack.Data.Default ( src\Happstack\Data\Default.hs, dis t\build\Happstack\Data\Default.o ) [ 5 of 16] Compiling Happstack.Data.DeriveAll ( src\Happstack\Data\DeriveAll.hs, dist\build\Happstack\Data\DeriveAll.o ) [ 6 of 16] Compiling Happstack.Data.Default.Generic ( src\Happstack\Data\Default \Generic.hs, dist\build\Happstack\Data\Default\Generic.o ) [ 7 of 16] Compiling Happstack.Data.Xml.Base ( src\Happstack\Data\Xml\Base.hs, d ist\build\Happstack\Data\Xml\Base.o ) Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. Loading package array-0.3.0.0 ... linking ... done. Loading package bytestring-0.9.1.5 ... linking ... done. Loading package containers-0.3.0.0 ... linking ... done. Loading package pretty-1.0.1.1 ... linking ... done. Loading package template-haskell ... linking ... done. Loading package syb-with-class-0.6.1 ... linking ... done. Loading package HUnit-1.2.2.1 ... linking ... done. Loading package syb-0.1.0.2 ... linking ... done. Loading package base-3.0.3.2 ... linking ... done. Loading package Win32-2.2.0.1 ... linking ... done. Loading package old-locale-1.0.0.2 ... linking ... done. Loading package time-1.1.4 ... linking ... done. Loading package random-1.0.0.2 ... linking ... done. Loading package QuickCheck-1.2.0.0 ... linking ... done. Loading package extensible-exceptions-0.1.1.1 ... linking ... done. Loading package mtl-1.1.0.2 ... linking ... done. Loading package old-time-1.0.0.3 ... linking ... done. Loading package parsec-2.1.0.1 ... linking ... done. Loading package hsemail-1.3 ... linking ... done. Loading package network-2.2.1.7 ... linking ... done. Loading package SMTPClient-1.0.1 ... linking ... done. Loading package filepath-1.1.0.3 ... linking ... done. Loading package directory-1.0.1.0 ... linking ... done. Loading package process-1.0.1.2 ... linking ... done. Loading package hslogger-1.0.7 ... linking ... done. Loading package deepseq-1.1.0.0 ... linking ... done. Loading package parallel-2.2.0.1 ... linking ... done. Loading package strict-concurrency-0.2.2 ... linking ... done. Loading package unix-compat-0.1.2.1 ... linking ... done. Loading package happstack-util-0.4.1 ... linking ... done. Loading package binary-0.5.0.2 ... linking ... done. Loading package haskell98 ... linking ... done. Loading package HaXml-1.13.3 ... linking ... done. Loading package ffi-1.0 ... linking ... done. ghc.exe: dist\build\Happstack\Data\Default.o: unknown symbol `_sybzmwithzmclassz m0zi6zi1_DataziGenericsziSYBziWithClassziInstances_constrZMacbsZN_closure' cabal: Error: some packages failed to install: happstack-data-0.4.1 failed during the building phase. The exception was: ExitFailure 1 I can create more detailed log if you need. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100211/1e582400/attachment.html From ryani.spam at gmail.com Thu Feb 11 17:41:56 2010 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Feb 11 17:13:00 2010 Subject: [Haskell-cafe] Type arithmetic with ATs/TFs In-Reply-To: <4B74724A.9090307@btinternet.com> References: <4B730935.6030901@btinternet.com> <4B74724A.9090307@btinternet.com> Message-ID: <2f9b2d31002111441j2382652fs10a629fcca4e8957@mail.gmail.com> Actually, at least in GHC, associated types are just syntax sugar for type families. That is, this code: class Container c where type Element c :: * view :: c -> Maybe (Element c,c) instance Container [a] where type Element [a] = a view [] = Nothing view (x:xs) = Just (x,xs) is the same as this code: type family Element c :: * class Container c where view :: c -> Maybe (Element c, c) type instance Container [a] = a instance Container [a] where view [] = Nothing view (x:xs) = Just (x,xs) -- ryan On Thu, Feb 11, 2010 at 1:10 PM, Andrew Coppin wrote: > Andrew Coppin wrote: >> >> OK, so I sat down today and tried this, but I can't figure out how. >> >> There are various examples of type-level arithmetic around the place. For >> example, >> >> http://www.haskell.org/haskellwiki/Type_arithmetic >> >> (This is THE first hit on Google, by the way. Haskell is apparently THAT >> popular!) But this does type arithmetic using functional dependencies; what >> I'm trying to figure out is how to do that with associated types. >> >> Any hints? > > Several people have now replied to this, both on and off-list. But all the > replies use type families, not associated types. > > Now type families are something I don't yet comprehend. (Perhaps the replies > will help... I haven't studied them yet.) What I understand is that ATs > allow you to write things like > > ?class Container c where > ? type Element c :: * > ? ... > > And now you can explicitly talk about the kind of element a container can > hold, rather than relying on the type constructor having a particular kind > or something. So the above works for containers that can hold *anything* > (such as lists), containers which can only hold *one* thing (e.g., > ByteString), and containers which can hold only certain things (e.g., Set). > > ...which is great. But I can't see a way to use this for type arithmetic. > Possibly because I don't have a dramatically solid mental model of exactly > how it works. You'd *think* that something like > > ?class Add x y where > ? type Sum x y :: * > > ?instance Add x y => Add (Succ x) y where > ? type Sum (Succ x) y = Succ (Sum x y) > > ought to work, but apparently not. > > As to what type families - type declarations outside of a class - end up > meaning, I haven't the vaguest idea. The Wiki page makes it sound > increadibly complicated... > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From john at repetae.net Thu Feb 11 17:42:08 2010 From: john at repetae.net (John Meacham) Date: Thu Feb 11 17:13:16 2010 Subject: [Haskell-cafe] Examples/docs for simulated annealing bindings In-Reply-To: <2d3641330910150641v4d59c8c9la1b2821a1d1d3939@mail.gmail.com> References: <2d3641330910150641v4d59c8c9la1b2821a1d1d3939@mail.gmail.com> Message-ID: <20100211224208.GC20618@sliver.repetae.net> On Thu, Oct 15, 2009 at 02:41:42PM +0100, Dougal Stanton wrote: > I found the HsASA library [1] on Hackage, but there's no documentation > and it's not particularly intuitive. I can't see any obvious way of > choosing initial config or generating new configurations. Google > reveals no one using it. Does anyone have ideas? Hi, performing ASA efficiently relies on a very efficient implementation of the algorithm, the actual parameters of the ASA are hard coded as C #defines, see the original C distribution for documentation on them. For using HsASA in projects, it is recommended you directly include the modules into your program and modify them with the specific parameters appropriate to your task. John -- John Meacham - ?repetae.net?john? - http://notanumber.net/ From robgreayer at gmail.com Thu Feb 11 17:55:48 2010 From: robgreayer at gmail.com (Robert Greayer) Date: Thu Feb 11 17:27:18 2010 Subject: [Haskell-cafe] Type arithmetic with ATs/TFs In-Reply-To: <4B74724A.9090307@btinternet.com> References: <4B730935.6030901@btinternet.com> <4B74724A.9090307@btinternet.com> Message-ID: <4ec472cb1002111455y21bee180sf7ddf6dd9d65b82a@mail.gmail.com> What Ryan said, and here's an example of addition with ATs, specifically (not thoroughly tested, but tested a little). The translation to TFs sans ATs is straightforward. class Add a b where type SumType a b instance Add Zero Zero where type SumType Zero Zero = Zero instance Add (Succ a) Zero where type SumType (Succ a) Zero = Succ a instance Add Zero (Succ a) where type SumType Zero (Succ a) = Succ a instance Add (Succ a) (Succ b) where type SumType (Succ a) (Succ b) = Succ (Succ (SumType a b)) On Thu, Feb 11, 2010 at 4:10 PM, Andrew Coppin wrote: > Andrew Coppin wrote: >> >> OK, so I sat down today and tried this, but I can't figure out how. >> >> There are various examples of type-level arithmetic around the place. For >> example, >> >> http://www.haskell.org/haskellwiki/Type_arithmetic >> >> (This is THE first hit on Google, by the way. Haskell is apparently THAT >> popular!) But this does type arithmetic using functional dependencies; what >> I'm trying to figure out is how to do that with associated types. >> >> Any hints? > > Several people have now replied to this, both on and off-list. But all the > replies use type families, not associated types. > > Now type families are something I don't yet comprehend. (Perhaps the replies > will help... I haven't studied them yet.) What I understand is that ATs > allow you to write things like > > ?class Container c where > ? type Element c :: * > ? ... > > And now you can explicitly talk about the kind of element a container can > hold, rather than relying on the type constructor having a particular kind > or something. So the above works for containers that can hold *anything* > (such as lists), containers which can only hold *one* thing (e.g., > ByteString), and containers which can hold only certain things (e.g., Set). > > ...which is great. But I can't see a way to use this for type arithmetic. > Possibly because I don't have a dramatically solid mental model of exactly > how it works. You'd *think* that something like > > ?class Add x y where > ? type Sum x y :: * > > ?instance Add x y => Add (Succ x) y where > ? type Sum (Succ x) y = Succ (Sum x y) > > ought to work, but apparently not. > > As to what type families - type declarations outside of a class - end up > meaning, I haven't the vaguest idea. The Wiki page makes it sound > increadibly complicated... > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From niklas.broberg at gmail.com Thu Feb 11 18:13:56 2010 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Thu Feb 11 17:45:01 2010 Subject: [Haskell-cafe] haskell-src type inference algorithm? In-Reply-To: References: Message-ID: > Anyone know of a type inference utility that can run right on haskell-src > types? or one that could be easily adapted? This is very high on my wish-list for haskell-src-exts, and I'm hoping the stuff Lennart will contribute will go a long way towards making it feasible. I believe I can safely say that no such tool exists (and if it does, why haven't you told me?? ;-)), but if you implement (parts of) one yourself I'd be more than interested to see, and incorporate, the results. Cheers, /Niklas From mle+hs at mega-nerd.com Thu Feb 11 18:22:14 2010 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Thu Feb 11 17:53:23 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> Message-ID: <20100212102214.14e60040.mle+hs@mega-nerd.com> Michael Lesniak wrote: > Hello, > > > > elegance of Haskell. Whether Haskell becomes an easy choice for > > commercial work or remains a boutique language depends on how easy it > > is to build today's applications. > > Do you (or anyone reading this thread) know of some kind of wishlist > of missing features and/or libraries? Would be nice to see what's > still "missing". HTTPS support in the HTTP library. One library that JustWorks (tm) for HTTP and HTTPS. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From jwlato at gmail.com Thu Feb 11 18:49:58 2010 From: jwlato at gmail.com (John Lato) Date: Thu Feb 11 18:21:05 2010 Subject: [Haskell-cafe] Re: Haskell-Cafe Digest, Vol 78, Issue 14 In-Reply-To: <87y6izhieu.fsf@gregorycollins.net> References: <20100209133545.82064324655@www.haskell.org> <9979e72e1002090841x4916e029qf32fad7abc8854d3@mail.gmail.com> <1265883701.5700.55.camel@picard> <87y6izhieu.fsf@gregorycollins.net> Message-ID: <9979e72e1002111549i4c620714v1e51b3bd382f9a67@mail.gmail.com> On Thu, Feb 11, 2010 at 10:00 AM, Gregory Collins wrote: > Maciej Piechotka writes: > >> On Tue, 2010-02-09 at 16:41 +0000, John Lato wrote: >>> >>> See http://inmachina.net/~jwlato/haskell/ParsecIteratee.hs for a valid >>> Stream instance using iteratee. ?Also Gregory Collins recently posted >>> an iteratee wrapper for Attoparsec to haskell-cafe. ?To my knowledge >>> these are not yet in any packages, but hackage is vast. >> >> Hmm. Am I correct that his implementation caches everything? > > The one that John posted (iteratees on top of parsec) has to keep a copy > of the entire input, because parsec wants to be able to do arbitrary > backtracking on the stream. This is true, however I believe this alternative approach is also correct. The Cursor holds the stream state, and parsec holds on to the Cursor for backtracking. Data is only read within the Iteratee monad when it goes beyond the currently available cursors, at which point another cursor is added to the linked list (implemented with IORef or other mutable reference). The downside to this approach is that data is consumed from the iteratee stream for a partial parse, even if the parse fails. I did not want this behavior, so I chose a different approach. > >> I tried to rewrite the implementation using... well imperative linked >> list. For trivial benchmark it have large improvement (althought it may >> be due to error in test such as using ByteString) and, I believe, that >> it allows to free memory before finish. >> >> Results of test on Core 2 Duo 2.8 GHz: >> 10: ? 0.000455s ? ? ? 0.000181s >> 100: ?0.000669s ? ? ? 0.001104s >> 1000: 0.005209s ? ? ? 0.023704s >> 10000: ? ? ? ?0.053292s ? ? ? 1.423443s >> 100000: ? ? ? 0.508093s ? ? ? 132.208597s > I'm surprised your version has better performance for small numbers of elements. I wonder if it's partially due to more aggressive inlining from GHC or something of that nature. Or maybe your version compiles to a tighter loop as elements can be gc'd. I expected poor performance of my code for larger numbers of elements, as demonstrated here. I envisioned the usage scenario where parsers would be relatively short (<20 chars), and most of the work would be done directly with iteratees. In this case it would be more important to preserve the stream state in the case of a failed parse, and the performance issues of appending chunks wouldn't arise either. Cheers, John From jeremy at n-heptane.com Thu Feb 11 18:25:17 2010 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Thu Feb 11 18:45:12 2010 Subject: [Haskell-cafe] ANN: Happstack 0.4.1 In-Reply-To: <4B748282.3060100@gmail.com> References: <99D43ACE-4235-45BD-8484-6BA0CC64F6E7@n-heptane.com> <4B748282.3060100@gmail.com> Message-ID: As a work around install happstack-data like this: cabal install -O0 happstack-data More details at the end of this thread: http://groups.google.com/group/happs/browse_thread/thread/c66c74294d8eabf/a4de5e67853925e0?lnk=gst&q=happstack-data#a4de5e67853925e0 I am using GHC 6.13, and I believe this problem has been resolved. Not sure what the best work around is in the meantime though. I guess I should at least update the download page to mention it.. - jeremy On Feb 11, 2010, at 4:19 PM, ????????? ????????? wrote: > I was unable to install happstack-data-0.4.1 on windows with GHC > 6.12.1. Here the log: > > Resolving dependencies... > Configuring happstack-data-0.4.1... > Preprocessing library happstack-data-0.4.1... > Preprocessing executables for happstack-data-0.4.1... > Building happstack-data-0.4.1... > > src\Happstack\Data\GOps.hs:54:0: > warning: no newline at end of file > > src\Happstack\Data\SerializeTH.hs:88:0: > warning: no newline at end of file > [ 1 of 16] Compiling Happstack.Data.GOps ( src\Happstack\Data > \GOps.hs, dist\buil > d\Happstack\Data\GOps.o ) > > src\Happstack\Data\Serialize.hs:1:85: > Warning: -XPatternSignatures is deprecated: use - > XScopedTypeVariables or pra > gma {-# LANGUAGE ScopedTypeVariables #-} instead > > src\Happstack\Data\Xml\Base.hs:6:13: > Warning: -XPatternSignatures is deprecated: use - > XScopedTypeVariables or pra > gma {-# LANGUAGE ScopedTypeVariables #-} instead > [ 2 of 16] Compiling Happstack.Data.Normalize ( src\Happstack\Data > \Normalize.hs, > dist\build\Happstack\Data\Normalize.o ) > [ 3 of 16] Compiling Happstack.Data.Migrate ( src\Happstack\Data > \Migrate.hs, dis > t\build\Happstack\Data\Migrate.o ) > [ 4 of 16] Compiling Happstack.Data.Default ( src\Happstack\Data > \Default.hs, dis > t\build\Happstack\Data\Default.o ) > [ 5 of 16] Compiling Happstack.Data.DeriveAll ( src\Happstack\Data > \DeriveAll.hs, > dist\build\Happstack\Data\DeriveAll.o ) > [ 6 of 16] Compiling Happstack.Data.Default.Generic ( src\Happstack > \Data\Default > \Generic.hs, dist\build\Happstack\Data\Default\Generic.o ) > [ 7 of 16] Compiling Happstack.Data.Xml.Base ( src\Happstack\Data\Xml > \Base.hs, d > ist\build\Happstack\Data\Xml\Base.o ) > Loading package ghc-prim ... linking ... done. > Loading package integer-gmp ... linking ... done. > Loading package base ... linking ... done. > Loading package array-0.3.0.0 ... linking ... done. > Loading package bytestring-0.9.1.5 ... linking ... done. > Loading package containers-0.3.0.0 ... linking ... done. > Loading package pretty-1.0.1.1 ... linking ... done. > Loading package template-haskell ... linking ... done. > Loading package syb-with-class-0.6.1 ... linking ... done. > Loading package HUnit-1.2.2.1 ... linking ... done. > Loading package syb-0.1.0.2 ... linking ... done. > Loading package base-3.0.3.2 ... linking ... done. > Loading package Win32-2.2.0.1 ... linking ... done. > Loading package old-locale-1.0.0.2 ... linking ... done. > Loading package time-1.1.4 ... linking ... done. > Loading package random-1.0.0.2 ... linking ... done. > Loading package QuickCheck-1.2.0.0 ... linking ... done. > Loading package extensible-exceptions-0.1.1.1 ... linking ... done. > Loading package mtl-1.1.0.2 ... linking ... done. > Loading package old-time-1.0.0.3 ... linking ... done. > Loading package parsec-2.1.0.1 ... linking ... done. > Loading package hsemail-1.3 ... linking ... done. > Loading package network-2.2.1.7 ... linking ... done. > Loading package SMTPClient-1.0.1 ... linking ... done. > Loading package filepath-1.1.0.3 ... linking ... done. > Loading package directory-1.0.1.0 ... linking ... done. > Loading package process-1.0.1.2 ... linking ... done. > Loading package hslogger-1.0.7 ... linking ... done. > Loading package deepseq-1.1.0.0 ... linking ... done. > Loading package parallel-2.2.0.1 ... linking ... done. > Loading package strict-concurrency-0.2.2 ... linking ... done. > Loading package unix-compat-0.1.2.1 ... linking ... done. > Loading package happstack-util-0.4.1 ... linking ... done. > Loading package binary-0.5.0.2 ... linking ... done. > Loading package haskell98 ... linking ... done. > Loading package HaXml-1.13.3 ... linking ... done. > Loading package ffi-1.0 ... linking ... done. > ghc.exe: dist\build\Happstack\Data\Default.o: unknown symbol > `_sybzmwithzmclassz > m0zi6zi1_DataziGenericsziSYBziWithClassziInstances_constrZMacbsZN_closure > ' > > cabal: Error: some packages failed to install: > happstack-data-0.4.1 failed during the building phase. The exception > was: > ExitFailure 1 > > I can create more detailed log if you need. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100211/78d0485c/attachment.html From jeremy at n-heptane.com Thu Feb 11 18:28:23 2010 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Thu Feb 11 18:45:53 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: References: <910ddf451002091647m4b7e12a5y5a680d7d356fb3d6@mail.gmail.com> <94E8A4F7-E54B-4885-8D6A-6AA4777F6FC1@n-heptane.com> Message-ID: On Feb 11, 2010, at 1:57 PM, Bardur Arantsson wrote: > >> 2. the remote client has terminated the connection as far as it is >> concerned but not notified the server -- when you try to send data >> it will >> reject it, and send/write/sendfile/etc will raise sigPIPE. >> Looking at your debug output, we are seeing the sigPIPE / Broken >> Pipe error >> most of the time. But then there is the case where we get stuck on >> the >> threadWaitWrite. >> threadWaitWrite is ultimately implemented by passing the file >> descriptor to >> the list of write descriptors in a call to select(). It seems, >> however, that >> select() is not waking up just because calling write() on a file >> descriptor >> *would* cause sigPIPE. > > That's what I expect select() with an "errfd" FDSET would do. Nope. The expectfds are only trigger in esoteric conditions. For TCP sockets, I think it only occurs if there is out-of-band data available to be read via recv() with the MSG_OOB flag. http://uw714doc.sco.com/en/SDK_netapi/sockC.OoBdata.html >> The easiest way to confirm this case is probably to write a small, >> pure C >> program and see what really happens. >> If this is the case, then it means the only way to tell if the >> client has >> abruptly dropped the connection is to actually try sending the data >> and see >> if the sending function calls sigPIPE. And that means doing some >> sort of >> polling/timeout? > > Correct, but the trouble is deciding how often to poll and/or how > long the timeout should be. > > I don't see any easy answer to that. That's why my suggested > "solution" is to simply punt it to the OS (by using portable mode) > and suck up the extra overhead of the portable solution. Hopefully > the new GHC I/O manager will make it possible to have a proper > solution. The whole point of the sendfile library is to use sendfile(), so not using sendfile() seems like the wrong solution. I am also not convinced that the new GHC I/O manager will do anything new to make it possible to have a proper solution. I believe we would be seeing the same error even in pure C, so we need to know the work around that works in pure C as well. I am not convinced we are punting to the OS by using portable mode either (more below). >> I do not have a good explanation as to why the portable version >> does not >> fail. Except maybe it is just so slow that it does not ever fill up >> the >> buffer, and hence does not get stuck in threadWaitWrite? > > The portable version doesn't call threadWaitWrite. It simply turns > the Socket into a handle (which causes it to become blocking) and > so the kernel is tasked with handling all the gritty details. The portable version does not directly call threadWaitWrite, but it still calls it. Data.ByteString.Char8.hPutStr calls Data.ByteString.hPut which calls Data.ByteString.hPutBuf which calls System.IO.hPutBuf which calls GHC.IO.Handle.Text.hPutBuf which calls GHC.IO.Handle.bufWrite.Text which calls GHC.IO.Device.write which calls GHC.IO.FD.fdWrite which calls GHC.IO.FD.writeRawBufferPtr which calls which is defined as: writeRawBufferPtr :: String -> FD -> Ptr Word8 -> Int -> CSize -> IO CInt writeRawBufferPtr loc !fd buf off len | isNonBlocking fd = unsafe_write -- unsafe is ok, it can't block | otherwise = do r <- unsafe_fdReady (fdFD fd) 1 0 0 if r /= 0 then write else do threadWaitWrite (fromIntegral (fdFD fd)); write where do_write call = fromIntegral `fmap` throwErrnoIfMinus1RetryMayBlock loc call (threadWaitWrite (fromIntegral (fdFD fd))) write = if threaded then safe_write else unsafe_write unsafe_write = do_write (c_write (fdFD fd) (buf `plusPtr` off) len) safe_write = do_write (c_safe_write (fdFD fd) (buf `plusPtr` off) len) According to the following test program, I expect that 'isNonBlocking fd' will be 'True'. So it seems like the portable solution should be vulnerable to the same condition. Perhaps the portable version is just so slow that the OS buffers never fill up so EAGAIN is never raised? ------------------------------------------------------------------------------------------------------- {-# LANGUAGE RecordWildCards #-} module Main where import Control.Concurrent (forkIO) import Control.Monad (forever) import Network (PortID(PortNumber), Socket, listenOn) import Network.Socket (accept, socketToHandle) import System.IO import qualified GHC.IO.FD as FD import GHC.IO.Handle.Internals (withHandle, flushWriteBuffer) import GHC.IO.Handle.Types (Handle__(..), HandleType(..)) import qualified GHC.IO.FD as FD import System.Posix.Types (Fd(..)) import System.IO.Error import GHC.IO.Exception import Data.Typeable (cast) import GHC.IO.Handle.Internals (wantWritableHandle) main = listen (PortNumber (toEnum 2525)) $ \s -> do h <- socketToHandle s ReadWriteMode wantWritableHandle "main" h $ \h_ -> showBlocking h_ showBlocking :: Handle__ -> IO () showBlocking h_@Handle__{..} = case cast haDevice of Nothing -> return () Just fd -> case (FD.fdIsNonBlocking fd) of 1 -> putStrLn "is NonBlocking" 0 -> putStrLn "is not NonBlocking" listen :: PortID -> (Socket -> IO ()) -> IO () listen port handler = do socket <- listenOn port forever $ do (s,sa) <- accept socket forkIO $ handler s ------------------------------------------------------------------------------------------------------- >> Any way, the fundamental question is: >> When your write buffer is full, and you call select() on that file >> descriptor, will select() return in the case where calling write() >> again >> would raise sigPIPE? > > I believe so, *if* you give it the FD in the exceptfds FD_SET > parameter. Let's face it, any other behavior doesn't make any sense > since it's the equivalent of forcing all timeout handling onto the > user, just like threadWaitWrite currently does. I've written my fair > share of networking code in various languages (including C/C++) and > I've never seen this problem of "missing wakeups" before. All my reading seems to indicate that exceptfds won't help anything -- it is a seldom used feature and doesn't do what people wish it actually did. For example, see answer 1 on this page: http://stackoverflow.com/questions/1342712/nix-select-and-exceptfds-errorfds-semantics There is some evidence that when you are doing select() on a readfds, and the connection is closed, select() will indicate that the fds is ready to be read, but when you read it, you get 0-bytes. That indicates that a disconnect has happened. However, if you are only doing read()/recv(), I expect that only happens in the event of a proper disconnect, because if you are just listening for packets, there is no way to tell the difference between the sender just not saying anything, and the sender dying: http://beej.us/guide/bgnet/output/html/singlepage/bgnet.html#advanced http://channel9.msdn.com/forums/TechOff/434466-TcpClient-Test-for-Disconnected/ http://bytes.com/topic/python/answers/40278-detecting-shutdown-remot But I can not find any clear information on what happens when you do select() on a write socket, and the remote end abruptly disconnects. Consider first the case that does not use select() at all: 1. write() to a non-blocking socket. That copies the data into the OS buffers, and then returns successfully. 2. But then the OS tries to send the data, and the connection has been reset. It can't notify you that the write() failed, because it that call to write() already returned. 3. you try to do a second write(), that is when you get sigPIPE. Now let's say you do: write() select() write () I believe that select() will not wakeup if it is just monitoring the ability to write to the socket and the remote end abruptly drops the connection. (I am certain that under linux, if another thread explicitly closes the socket, that does not cause select() to wake up either.) However, there is some evidence that if you monitor the socket for both reads and writes, that when the first write fails, select will wakeup and tell you that there is data available to read(). If you read() the data, you will find out that there are 0- bytes available, meaning the connection was closed. Alternatively, if you tried the second write, then you would get sigPIPE. http://www.developerweb.net/forum/showthread.php?t=2956 http://stackoverflow.com/questions/180095/how-to-handle-a-broken-pipe-sigpipe-in-python The tricky part is that if you wake up for a read() and there is data available, we don't want to actually read it in then sendfile function, (because that data is destined for somewhere else). So, you need to just peek at the data with out actually reading it to see if there is at least 1 byte available. If this method of detection is correct, then what we need is a threadWaitReadWrite, that will notify us if the socket can be read or written. The IO manager does not currently provide a function like that.. but we could fake it like this: (untested): import Control.Concurrent import Control.Concurrent.MVar import System.Posix.Types data RW = Read | Write threadWaitReadWrite :: Fd -> IO RW threadWaitReadWrite fd = do m <- newEmptyMVar rid <- forkIO $ threadWaitRead fd >> putMVar m Read wid <- forkIO $ threadWaitWrite fd >> putMVar m Write r <- takeMVar m killThread rid killThread wid return r Of course, in the case where the client disconnects because someone turns off the power or pulls the ethernet cable, we have no way of knowing what is going on -- so there is still the possibility that dead connections will be left open for a long time. And, there is also the concern that even the portable version may have this issue. My research indicates that it should. In fact, any application which tries to send data over the network could be vulnerable to this bug. So, I am a little disturbed as to why the portable version does not appear to have issues.. - jeremy -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100211/7199cdbb/attachment.html From spam at scientician.net Thu Feb 11 19:14:44 2010 From: spam at scientician.net (Bardur Arantsson) Date: Thu Feb 11 18:46:16 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: <4c44d90b1002111317k298d5200o99f06b1e69f997ff@mail.gmail.com> References: <5679D446-9E50-4DFB-AFBD-E9532C3DCF0B@ece.cmu.edu> <20100206111415.GB29938@kira.casa> <4c44d90b1002111317k298d5200o99f06b1e69f997ff@mail.gmail.com> Message-ID: Thomas DuBuisson wrote: > Bardur Arantsson wrote: >>> ... >>> then do errno <- getErrno >>> if errno == eAGAIN >>> then do >>> threadDelay 100 >>> sendfile out_fd in_fd poff bytes >>> else throwErrno "Network.Socket.SendFile.Linux" >>> else return (fromIntegral sbytes) >> That is, I removed the threadWaitWrite in favor of just adding a >> "threadDelay 100" when eAGAIN is encountered. >> >> With this code, I cannot provoke the leak. >> >> Unfortunately this isn't really a solution -- the CPU is pegged at >> ~50% when I do this and it's not exactly elegant to have a hardcoded >> 100 ms delay in there. :) > > I don't think it matters wrt the desired final solution, but this is > NOT a 100 ms delay. It is a 0.1 ms delay, which is less than a GHC > time slice and as such is basically a tight loop. If you use a > reasonable value for the delay you will probably see the CPU being > almost completely idle. > Excellent, thanks. I was probably too tired or annoyed when I wrote that code. I sorta-kinda-knew I must have been doing *something* wrong :). I'll retry with a more reasonable delay tomorrow. Cheers, From ok at cs.otago.ac.nz Thu Feb 11 19:29:25 2010 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Thu Feb 11 19:00:34 2010 Subject: [Haskell-cafe] Seen on reddit: or, foldl and foldr considered slightly harmful In-Reply-To: <555dc06a-b80d-4067-a803-d8a43059dc0f@g28g2000yqh.googlegroups.com> References: <555dc06a-b80d-4067-a803-d8a43059dc0f@g28g2000yqh.googlegroups.com> Message-ID: <716FEA02-9CDA-4C13-AAA9-CF13554B9544@cs.otago.ac.nz> On Feb 11, 2010, at 9:41 PM, Johann H?chtl wrote: > In a presentation of Guy Steele for ICFP 2009 in Edinburgh: > http://www.vimeo.com/6624203 > he "considers foldl and foldr" harmful as they hinder parallelism > because of "Process first element, then the rest" Instead he proposes > a divide and merge aproach, especially in the light of going parallel. I think I first heard about that issue in the 80s. Let me just take an Erlang perspective on this for a few minutes. Ignoring types, the classic foldl in Erlang (which is strict) is foldl(F, A, [X|Xs]) -> foldl(F, F(X, A), Xs); foldl(_, A, []) -> A. In a strict language, you have to wait for F to finish before you can go on to the next element. In a non-strict language, you don't. The interesting question is how far F can get just given X, before it has to look at A. Suppose we can factor F(X, A) into G(H(X), A) where H is rather time-consuming, but G is cheap (maybe it's an add). So we write foldl_map(G, H, A, [X|Xs]) -> foldl_map(G, H, G(H(X), A), Xs); foldl_map(_, _, A, []) -> A. Now we can parallelise it. We'll spark off a separate thread for each call of H. pfoldl_map(G, H, A, Xs) -> Outer = self(), Pids = [spawn(fun () -> Outer ! {self(),H(X)} end || X <- Xs], foldl(G, A, [receive {Pid,Val} -> Val end | Pid <- Pids]). If N is the length of the list and G is O(1) we have O(N) time to traverse the list and O(N) time to collect and fold the results. The H calculations can take place in parallel. Provided each H calculation is expensive enough, we may not _care_ about the O(N) bits. In fact, if they aren't, we probably shouldn't be worrying about parallelism here. The problem exists when we *can't* factor F(X, A) into G(H(X), A) with a cheap G and costly H. Then divide-and-parallel-conquer using k-way trees gives us a computation depth of $\log_k N$ calls of G waiting for results to come back. As I say, I met this stuff in the 80s. It's hardly news. Indeed, if I remember correctly, back when Occam was hot stuff people were worried about PAR i = 0 for n ... which forks n processes. Doing that one at a time in the parent process takes O(n) time. I believe something was done about making this work by recursive bisection. From spam at scientician.net Thu Feb 11 19:49:07 2010 From: spam at scientician.net (Bardur Arantsson) Date: Thu Feb 11 19:20:37 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: References: <910ddf451002091647m4b7e12a5y5a680d7d356fb3d6@mail.gmail.com> <94E8A4F7-E54B-4885-8D6A-6AA4777F6FC1@n-heptane.com> Message-ID: Jeremy Shaw wrote: > > On Feb 11, 2010, at 1:57 PM, Bardur Arantsson wrote: >> [--snip lots of technical info--] Thanks for digging so much into this. Just a couple of comments: > > The whole point of the sendfile library is to use sendfile(), so not > using sendfile() seems like the wrong solution. Heh, well, presumably it could still use sendfile() only platforms where it can actually guarantee correctness :). > > There is some evidence that when you are doing select() on a readfds, > and the connection is closed, select() will indicate that the fds is > ready to be read, but when you read it, you get 0-bytes. That indicates > that a disconnect has happened. However, if you are only doing > read()/recv(), I expect that only happens in the event of a proper > disconnect, because if you are just listening for packets, there is no > way to tell the difference between the sender just not saying anything, > and the sender dying: True, but the point here is that the OS has a built-in timeout mechanism (via keepalives) and *can* tell the program when that timeout has elapsed. That's the timeout we're trying to "get at" instead of having to implement a new one. Good point about the the readfds triggering when the client disconnects. I think that's what I've been seeing in all my other network-related code and I just misremembered the details. All my code is extremely likely to have been both reading and writing from (roughly) the same set of FDs at the same time. > If this method of detection is correct, then what we need is a > threadWaitReadWrite, that will notify us if the socket can be read or > written. The IO manager does not currently provide a function like > that.. but we could fake it like this: (untested): > > import Control.Concurrent > import Control.Concurrent.MVar > import System.Posix.Types > > data RW = Read | Write > > threadWaitReadWrite :: Fd -> IO RW > threadWaitReadWrite fd = > do m <- newEmptyMVar > rid <- forkIO $ threadWaitRead fd >> putMVar m Read > wid <- forkIO $ threadWaitWrite fd >> putMVar m Write > r <- takeMVar m > killThread rid > killThread wid > return r > I'll try to get the sendfile code to use this instead. AFAICT it shouldn't actually be necessary to "peek" on the read end of the socket to detect that something has gone wrong. We're guaranteed that sendfile() to a connection that's died (according to the OS, either due to proper disconnect or a timeout) will fail. I might get a bit tricky to use this if the client is actually expecting to send proper data while the sendfile() is in progress -- if there's actual data to be read from the socket() then the naive "replace threadWaitR by threadWaitRW" will end up busy-waiting on EAGAIN since the socket() will be readable every time threadWaitReadWrite gets called. HOWEVER, that's not an issue in my particular scenario, so a simple relacement of threadWaitWrite by threadWaitReadWrite should do fine for testing purposes. > Of course, in the case where the client disconnects because someone > turns off the power or pulls the ethernet cable, we have no way of > knowing what is going on -- so there is still the possibility that dead > connections will be left open for a long time. True, but then it's (properly) left to the OS to decide and timeouts can be controlled via setsockopt -- as they should IMO. I'll test tomorrow. What I'll expect is that I'll still see a few "dead" threads lingering around for ~60 seconds (the OS-based timeout), but that I'll not see any threads lingering indefinitely -- something which usually happens after a few hours of persistent use of my media server. From dons at galois.com Thu Feb 11 20:39:12 2010 From: dons at galois.com (Don Stewart) Date: Thu Feb 11 20:10:23 2010 Subject: [Haskell-cafe] vector to uvector and back again In-Reply-To: References: <4B72F3F6.3050506@k-hornz.de> Message-ID: <20100212013912.GC16869@whirlpool.galois.com> bos: > I'm thinking of switching the statistics library over to using vector. uvector > is pretty bit-rotted in comparison to vector at this point, and it's really > seeing no development, while vector is The Shiny Future. Roman, would you call > the vector library good enough to use in production at the moment? uvector's not seeing much development, but at least in the last round of benchmarks it was still consistently faster -- since it's been micro-optimized. Also, we have uvector-algorithms, so you can sort etc. a uvector. I'm not sure its the long term solution, but its a simpler, faster lib at the moment, with more surrounding support, users and documentation. -- Don From dons at galois.com Thu Feb 11 20:40:10 2010 From: dons at galois.com (Don Stewart) Date: Thu Feb 11 20:11:25 2010 Subject: [Haskell-cafe] vector to uvector and back again In-Reply-To: References: <4B72F3F6.3050506@k-hornz.de> Message-ID: <20100212014010.GD16869@whirlpool.galois.com> rl: > On 11/02/2010, at 05:03, Bryan O'Sullivan wrote: > > > I'm thinking of switching the statistics library over to using vector. uvector is pretty bit-rotted in comparison to vector at this point, and it's really seeing no development, while vector is The Shiny Future. Roman, would you call the vector library good enough to use in production at the moment? > > Yes, with the caveat that I haven't really used it in production code > (I have tested and benchmarked it, though). BTW, I'll release version > 0.5 as soon as get a code.haskell.org account and move the repo there. > That's the main problem. I think we could move to vector as a whole, if the suite of testing/ performance/documentation stuff from uvector was ported. Maybe this is a good job for the hackathon. -- Don From tphyahoo at gmail.com Thu Feb 11 20:42:34 2010 From: tphyahoo at gmail.com (Thomas Hartman) Date: Thu Feb 11 20:13:40 2010 Subject: [Haskell-cafe] ANN: Dungeons of Wor - a largish FRP example and a fun game, all in one! In-Reply-To: <1265877335.18142.1359423573@webmail.messagingengine.com> References: <1265877335.18142.1359423573@webmail.messagingengine.com> Message-ID: <910ddf451002111742l5e8eef3sf589549fafc8a49c@mail.gmail.com> 1) This is missing the obligatory youtube video. 2) AWESOME! :) thomas. 2010/2/11 Patai Gergely : > Hello all, > > I just uploaded the first public version of Dungeons of Wor [1], a > homage to the renowned three-decade-old arcade game, Wizard of Wor. > While it makes a fine time killer if you have a few minutes to spare, it > might be of special interest to the lost souls who are trying to figure > out FRP. The game was programmed using the Simple version of the > experimental branch of Elerea [2], which provides first-class discrete > streams to describe time-varying quantities, and the main game logic is > described as a composition of streams instead of a world state > transformer. Developing in this manner was an interesting experience, > and I'll write about it in more detail over the weekend. > > All the best, > > Gergely > > [1] http://hackage.haskell.org/package/dow > [2] > http://hackage.haskell.org/packages/archive/elerea/1.2.3/doc/html/FRP-Elerea-Experimental-Simple.html > > -- > http://www.fastmail.fm - The professional email service > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From dan.doel at gmail.com Thu Feb 11 20:54:15 2010 From: dan.doel at gmail.com (Dan Doel) Date: Thu Feb 11 20:25:24 2010 Subject: [Haskell-cafe] vector to uvector and back again In-Reply-To: <4B7441AE.3070407@k-hornz.de> References: <4B72F3F6.3050506@k-hornz.de> <4B7441AE.3070407@k-hornz.de> Message-ID: <201002112054.17250.dan.doel@gmail.com> On Thursday 11 February 2010 12:43:10 pm stefan kersten wrote: > On 10.02.10 19:03, Bryan O'Sullivan wrote: > > I'm thinking of switching the statistics library over to using vector. > > that would be even better of course! an O(0) solution, at least for me ;) > let me know if i can be of any help (e.g. in testing). i suppose > uvector-algorithms would also need to be ported to vector, then. I could do this. I've been occupied with things other than uvector-algorithms for a while, but I've been meaning to get back into it (perhaps finally get timsort in there). How widespread is the consensus on vector over uvector? dons seems to have added to uvector as recently as mid December, so I'm not really sure how bit rotted it is. But vector seems to have a lot more going on in it, including boxed arrays, which I suppose is a gap in using uvector. I also notice that vector seems to have discarded the idea of Vec (A * B) = Vec A * Vec B with associated types. Was this determined to not be worth it? uvector- algorithms actually used the fact for a cute trick (Schwartzian transform can be done for such arrays by computing a new array containing 'f e' for each 'e' in the original array, pairing up the two arrays, and performing an algorithm that only looks at the 'f e' half, and then pulling the 'e' half out of the pair; doing it this way requires no copying of the original array). Anyhow, if vector is the clear way forward, I don't mind porting uvector- algorithms. But I don't relish maintaining two slightly different parallel branches. -- Dan From dons at galois.com Thu Feb 11 20:55:58 2010 From: dons at galois.com (Don Stewart) Date: Thu Feb 11 20:27:06 2010 Subject: [Haskell-cafe] Hackage download statistis In-Reply-To: References: Message-ID: <20100212015558.GF16869@whirlpool.galois.com> mauricio.antunes: > Hi, all, > > Some time ago a download statistic of hackage was made available, > and analysed in a few ways. Googling for it still find that at a > Galois web page. > > I though that, since the tools to get that were there, this would > be output once in a while, but it seems it hasn't been done since > then. > > Does anyone know if there are plans about that? Since we moved Hackage to a new machine, the logs are stored differently. I need to get access to the machine to get the stats again. Hopefully this weekend. From simon at joyful.com Thu Feb 11 21:22:57 2010 From: simon at joyful.com (Simon Michael) Date: Thu Feb 11 20:54:30 2010 Subject: [Haskell-cafe] Re: ANN: Dungeons of Wor - a largish FRP example and a fun game, all in one! In-Reply-To: <1265877335.18142.1359423573@webmail.messagingengine.com> References: <1265877335.18142.1359423573@webmail.messagingengine.com> Message-ID: Exciting! But on a mac, I can't get the window to become focussed or accept input. Tips ? From rl at cse.unsw.edu.au Thu Feb 11 21:47:10 2010 From: rl at cse.unsw.edu.au (Roman Leshchinskiy) Date: Thu Feb 11 21:18:27 2010 Subject: [Haskell-cafe] vector to uvector and back again In-Reply-To: <20100212013912.GC16869@whirlpool.galois.com> References: <4B72F3F6.3050506@k-hornz.de> <20100212013912.GC16869@whirlpool.galois.com> Message-ID: On 12/02/2010, at 12:39, Don Stewart wrote: > bos: >> I'm thinking of switching the statistics library over to using vector. uvector >> is pretty bit-rotted in comparison to vector at this point, and it's really >> seeing no development, while vector is The Shiny Future. Roman, would you call >> the vector library good enough to use in production at the moment? > > uvector's not seeing much development, but at least in the last round of > benchmarks it was still consistently faster -- since it's been > micro-optimized. FWIW, the development version of vector is usually faster the both uvector and dph-prim-seq, at least for the development version of NoSlow. Roman From dons at galois.com Thu Feb 11 21:49:59 2010 From: dons at galois.com (Don Stewart) Date: Thu Feb 11 21:21:07 2010 Subject: [Haskell-cafe] vector to uvector and back again In-Reply-To: References: <4B72F3F6.3050506@k-hornz.de> <20100212013912.GC16869@whirlpool.galois.com> Message-ID: <20100212024959.GA18085@whirlpool.galois.com> rl: > On 12/02/2010, at 12:39, Don Stewart wrote: > > > bos: > >> I'm thinking of switching the statistics library over to using vector. uvector > >> is pretty bit-rotted in comparison to vector at this point, and it's really > >> seeing no development, while vector is The Shiny Future. Roman, would you call > >> the vector library good enough to use in production at the moment? > > > > uvector's not seeing much development, but at least in the last round of > > benchmarks it was still consistently faster -- since it's been > > micro-optimized. > > FWIW, the development version of vector is usually faster the both > uvector and dph-prim-seq, at least for the development version of > NoSlow. Ah ha -- that's useful. Public benchmarks soon? In time for the Zurich Hackathon?? (March 20) From rl at cse.unsw.edu.au Thu Feb 11 21:50:40 2010 From: rl at cse.unsw.edu.au (Roman Leshchinskiy) Date: Thu Feb 11 21:21:53 2010 Subject: [Haskell-cafe] vector to uvector and back again In-Reply-To: <20100212014010.GD16869@whirlpool.galois.com> References: <4B72F3F6.3050506@k-hornz.de> <20100212014010.GD16869@whirlpool.galois.com> Message-ID: On 12/02/2010, at 12:40, Don Stewart wrote: > rl: >> On 11/02/2010, at 05:03, Bryan O'Sullivan wrote: >> >>> I'm thinking of switching the statistics library over to using vector. uvector is pretty bit-rotted in comparison to vector at this point, and it's really seeing no development, while vector is The Shiny Future. Roman, would you call the vector library good enough to use in production at the moment? >> >> Yes, with the caveat that I haven't really used it in production code >> (I have tested and benchmarked it, though). BTW, I'll release version >> 0.5 as soon as get a code.haskell.org account and move the repo there. >> > > That's the main problem. I think we could move to vector as a whole, if > the suite of testing/ performance/documentation stuff from uvector was ported. Hmm, I'm not sure what you mean here. Mostly thanks to Max Bolingbroke's efforts, vector has a fairly extensive testsuite. I benchmark it a lot (with NoSlow) and haven't found any significant performance problems in a while. As to documentation, there are comments for most of the functions :-) Roman From dons at galois.com Thu Feb 11 21:51:43 2010 From: dons at galois.com (Don Stewart) Date: Thu Feb 11 21:22:50 2010 Subject: [Haskell-cafe] vector to uvector and back again In-Reply-To: References: <4B72F3F6.3050506@k-hornz.de> <20100212013912.GC16869@whirlpool.galois.com> Message-ID: <20100212025143.GB18085@whirlpool.galois.com> rl: > On 12/02/2010, at 12:39, Don Stewart wrote: > > > bos: > >> I'm thinking of switching the statistics library over to using vector. uvector > >> is pretty bit-rotted in comparison to vector at this point, and it's really > >> seeing no development, while vector is The Shiny Future. Roman, would you call > >> the vector library good enough to use in production at the moment? > > > > uvector's not seeing much development, but at least in the last round of > > benchmarks it was still consistently faster -- since it's been > > micro-optimized. > > FWIW, the development version of vector is usually faster the both > uvector and dph-prim-seq, at least for the development version of > NoSlow. If Roman declares the vector to be faster -- my main concern here for flat uarrays -- and makes the repo available so we can work on it, I'd be willing to merge uvector's tests and docs and extra array operations in. -- Don From rl at cse.unsw.edu.au Thu Feb 11 21:57:40 2010 From: rl at cse.unsw.edu.au (Roman Leshchinskiy) Date: Thu Feb 11 21:28:48 2010 Subject: [Haskell-cafe] vector to uvector and back again In-Reply-To: <201002112054.17250.dan.doel@gmail.com> References: <4B72F3F6.3050506@k-hornz.de> <4B7441AE.3070407@k-hornz.de> <201002112054.17250.dan.doel@gmail.com> Message-ID: <64CF1F34-3162-4A8B-954E-CBC5B467D61E@cse.unsw.edu.au> On 12/02/2010, at 12:54, Dan Doel wrote: > I also notice that vector seems to have discarded the idea of > > Vec (A * B) = Vec A * Vec B Oh no, it hasn't. In contrast to uvector/DPH, which use a custom strict tuple type for rather outdated reasons, vector uses normal tuples. For instance, Data.Vector.Unboxed.Vector (a,b,c) is internally represented as a triple of unboxed vectors of a, b and c. In general, vector supports 4 kinds of arrays at the moment: Data.Vector.Primitive wrappers around ByteArray#, can store primitive types Data.Vector.Unboxed uses type families, can store everything D.V.Primitive can plus tuples and can be extended for user-defined types Data.Vector.Storable wrappers around ForeignPtr, can store Storable things Data.Vector boxed arrays Roman From simon at joyful.com Thu Feb 11 22:02:14 2010 From: simon at joyful.com (Simon Michael) Date: Thu Feb 11 21:33:19 2010 Subject: [Haskell-cafe] ANN: hledger 0.8 released Message-ID: <9BD50E1A-712C-4269-B912-07F397801E72@joyful.com> hledger 0.8 is out! http://hledger.org http://hledger.org/MANUAL.html#installing Bug fixes, refactoring and Hi-Res Graphical Charts. (See Roman Cheplyaka's blog: http://www.reddit.com/r/haskell/comments/b0w0q/using_the_hledger_package_to_track_finances) Best - Simon Release notes: ...................... * parsing: in date=date2, use first date's year as a default for the second * add: ctrl-d doesn't work on windows, suggest ctrl-c instead * add: --no-new-accounts option disallows new accounts (Roman Cheplyaka) * add: re-use the previous transaction's date as default (Roman Cheplyaka) * add: a command-line argument now filters by account during history matching (Roman Cheplyaka) * chart: new command, generates balances pie chart (requires - fchart flag, gtk2hs) (Roman Cheplyaka, Simon Michael) * register: make reporting intervals honour a display expression (#18) * web: fix help link * web: use today as default when adding with a blank date * web: re-enable account/period fields, they seem to be fixed, along with file re-reading (#16) * web: get static files from the cabal data dir, or the current dir when using make (#13) * web: preserve encoding during add, assuming it's utf-8 (#15) * fix some non-utf8-aware file handling (#15) * filter ledger again for each command, not just once at program start * refactoring, clearer data types Stats: 62 days since last release, 2 contributors, 76 commits, 3464 lines of non-test code, 97 tests, 53% test coverage From dan.doel at gmail.com Thu Feb 11 22:07:36 2010 From: dan.doel at gmail.com (Dan Doel) Date: Thu Feb 11 21:38:44 2010 Subject: [Haskell-cafe] vector to uvector and back again In-Reply-To: <64CF1F34-3162-4A8B-954E-CBC5B467D61E@cse.unsw.edu.au> References: <4B72F3F6.3050506@k-hornz.de> <201002112054.17250.dan.doel@gmail.com> <64CF1F34-3162-4A8B-954E-CBC5B467D61E@cse.unsw.edu.au> Message-ID: <201002112207.37416.dan.doel@gmail.com> On Thursday 11 February 2010 9:57:40 pm Roman Leshchinskiy wrote: > Oh no, it hasn't. In contrast to uvector/DPH, which use a custom strict > tuple type for rather outdated reasons, vector uses normal tuples. For > instance, Data.Vector.Unboxed.Vector (a,b,c) is internally represented as > a triple of unboxed vectors of a, b and c. In general, vector supports 4 > kinds of arrays at the moment: Ah, all right. I was looking at the (0.4.2) documentation on hackage, which doesn't mention Data.Vector.Unboxed. Never mind about that bit, then. -- Dan From allbery at ece.cmu.edu Thu Feb 11 22:18:35 2010 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Thu Feb 11 21:51:11 2010 Subject: [Haskell-cafe] ANN: hledger 0.8 released In-Reply-To: <9BD50E1A-712C-4269-B912-07F397801E72@joyful.com> References: <9BD50E1A-712C-4269-B912-07F397801E72@joyful.com> Message-ID: <71EDAD2F-7F24-4986-AED5-F58BA0323161@ece.cmu.edu> On Feb 11, 2010, at 22:02 , Simon Michael wrote: > * add: ctrl-d doesn't work on windows, suggest ctrl-c instead Ctrl-Z would be the usual EOF in the Windows world, fwiw. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100211/762d23fd/PGP.bin From tphyahoo at gmail.com Thu Feb 11 22:23:48 2010 From: tphyahoo at gmail.com (Thomas Hartman) Date: Thu Feb 11 21:54:54 2010 Subject: [Haskell-cafe] How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <42784f261002101511v1eea1955md37b090aa783f207@mail.gmail.com> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <4B73085E.4060109@btinternet.com> <42784f261002101511v1eea1955md37b090aa783f207@mail.gmail.com> Message-ID: <910ddf451002111923u70f43fd6x1c0f30795aaddbd0@mail.gmail.com> Hear hear. But a few successful happstack private sector startups could change that... 2010/2/10 Jason Dusek : > 2010/02/10 Roderick Ford : >> A U.S. president?would probably subsidize such a job-creating endeavor too! > > ?The US government generally subsidizes these kinds of things > ?through DoD spending (and a few NSF grants). That is probably > ?hard to get into. > > -- > Jason Dusek > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From rl at cse.unsw.edu.au Thu Feb 11 22:28:56 2010 From: rl at cse.unsw.edu.au (Roman Leshchinskiy) Date: Thu Feb 11 22:00:10 2010 Subject: [Haskell-cafe] vector to uvector and back again In-Reply-To: <20100212024959.GA18085@whirlpool.galois.com> References: <4B72F3F6.3050506@k-hornz.de> <20100212013912.GC16869@whirlpool.galois.com> <20100212024959.GA18085@whirlpool.galois.com> Message-ID: <54FC2D95-9DE4-4390-AC5A-6E9C403D1BF3@cse.unsw.edu.au> On 12/02/2010, at 13:49, Don Stewart wrote: > rl: >> On 12/02/2010, at 12:39, Don Stewart wrote: >> >>> bos: >>>> I'm thinking of switching the statistics library over to using vector. uvector >>>> is pretty bit-rotted in comparison to vector at this point, and it's really >>>> seeing no development, while vector is The Shiny Future. Roman, would you call >>>> the vector library good enough to use in production at the moment? >>> >>> uvector's not seeing much development, but at least in the last round of >>> benchmarks it was still consistently faster -- since it's been >>> micro-optimized. >> >> FWIW, the development version of vector is usually faster the both >> uvector and dph-prim-seq, at least for the development version of >> NoSlow. > > Ah ha -- that's useful. Public benchmarks soon? In time for the Zurich > Hackathon?? (March 20) I've been trying to find the time to put the benchmarks on my blog since the beginning of January but, alas, unsuccessfully so far. In any case, vector and NoSlow currently live in http://www.cse.unsw.edu.au/~rl/code/darcs/vector http://www.cse.unsw.edu.au/~rl/code/darcs/NoSlow > If Roman declares the vector to be faster -- my main concern here for > flat uarrays -- and makes the repo available so we can work on it, I'd > be willing to merge uvector's tests and docs and extra array operations > in. It is generally faster than dph-prim-seq. Benchmarking against uvector is a bit difficult because it's missing operations necessary for implementing most of the algorithms in NoSlow (in particular, bulk updates). For the ones that uvector supports, vector tends to be faster. BTW, this is for unsafe operations which don't use bounds checking. Bounds checking can make things a little slower but often doesn't cost anything as long as only collective operations are used. Sometimes it makes things faster which means that the simplifier still gets confused in some situations. There are also some significant differences between 6.12 and the HEAD (the HEAD is much more predictable). In general, I find it hard to believe that the performance differences I'm seeing really matter all that much in real-world programs. Roman From jason.dusek at gmail.com Thu Feb 11 23:34:24 2010 From: jason.dusek at gmail.com (Jason Dusek) Date: Thu Feb 11 23:05:29 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> Message-ID: <42784f261002112034s2df614d7r6d69902fc4cd92a8@mail.gmail.com> Things are missing but Haskell was certainly fit for practical use two years ago. The big things missing now are trust, mindshare and enough people who think reliability and consistency are a good play for long term productivity. -- Jason Dusek From florbitous at gmail.com Thu Feb 11 23:47:56 2010 From: florbitous at gmail.com (Bernie Pope) Date: Thu Feb 11 23:19:02 2010 Subject: [Haskell-cafe] haskell-src type inference algorithm? In-Reply-To: References: Message-ID: <4d8ad03a1002112047g4afc777q864e1a4ce7fa83e4@mail.gmail.com> On 12 February 2010 10:13, Niklas Broberg wrote: >> Anyone know of a type inference utility that can run right on haskell-src >> types? or one that could be easily adapted? > > This is very high on my wish-list for haskell-src-exts, and I'm hoping > the stuff Lennart will contribute will go a long way towards making it > feasible. I believe I can safely say that no such tool exists (and if > it does, why haven't you told me?? ;-)), but if you implement (parts > of) one yourself I'd be more than interested to see, and incorporate, > the results. A long time ago I worked on hatchet: http://www.cs.mu.oz.au/~bjpop/hatchet/src/hatchet.tar.gz which I believe was incorporated into JHC. Hatchet was based on thih and haskell-src. I gave up on it when I figured out a way to do what I wanted without type information. If I was going to do it again then I'd consider using Chameleon as a starting point, (I don't know where the most up-to-date sources are). Cheers, Bernie. From jpeterson at western.edu Thu Feb 11 23:51:55 2010 From: jpeterson at western.edu (John Peterson) Date: Thu Feb 11 23:23:07 2010 Subject: [Haskell-cafe] Computer Camp for kids 13 - 15 years old in Colorado featuring Functional Reactive Programming Message-ID: Western State College in Colorado has a computer camp for kids aged 13 - 15. Although we don't use Haskell (it's Python on the inside) the underlying engine is Functional Reactive Programming. We use a 3-D game engine to explore more than just programming - we cover a lot of math and physics. We have a very unique camp - every day includes 3 - 4 hours of recreation in the area: rafting, rock climbing, kayaking, mountain biking. Our website is at http://western.edu/academics/computerscience/computer-camp.html The camp is the last week of June. See the website for further details. We're trying to get the software in releasable form - should be ready to go in a few months. This is the fourth year of our camp and FRP has been an ideal way to introduce novices to computing. John (PS - all recreational activities at our camp are approved by Simon PJ - http://haskell.org/haskellwiki/Simon_Has_Fun) From florbitous at gmail.com Fri Feb 12 00:02:19 2010 From: florbitous at gmail.com (Bernie Pope) Date: Thu Feb 11 23:33:25 2010 Subject: [Haskell-cafe] parallel and distributed haskell? In-Reply-To: References: Message-ID: <4d8ad03a1002112102q2cbc44dckded97d24f53021fe@mail.gmail.com> On 17 December 2009 06:21, Scott A. Waterman wrote: > I feel there is quite a bit of latent interest in the subject here, > but relatively little active development (compared to erlang, clojure, etc.) > Can anyone involved give a quick overview (or pointers to one)? > It would be good to hear what directions people are taking, and why, > and where it's going. I've recently moved into HPC and am now quite interested in using Haskell on large clusters. My first goal was to get hMPI working (HaskellMPI). The original version appears to be from Michael Weber: http://www.foldr.org/~michaelw/hmpi/ which was followed up by Hal Daume III: http://hal3.name/newhmpi.tar.gz It doesn't appear to be cabalised. I wonder if anyone else has been using it? Cheers, Bernie. From bos at serpentine.com Fri Feb 12 01:00:08 2010 From: bos at serpentine.com (Bryan O'Sullivan) Date: Fri Feb 12 00:31:11 2010 Subject: [Haskell-cafe] Time for a San Francisco Hackathon? Message-ID: I'm thinking it might be a good idea to organise a Haskell Hackathon for people in (and who'd like to visit) the Bay Area. The tentative date I have in mind is the first weekend in May (conveniently May 1). If you'd be interested in attending or helping to organise, please let me know. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100212/e53d87be/attachment.html From iainspeed at gmail.com Fri Feb 12 01:36:35 2010 From: iainspeed at gmail.com (Iain Barnett) Date: Fri Feb 12 01:08:22 2010 Subject: [Haskell-cafe] HDBC convert [SqlValue] without muchos boilerplate In-Reply-To: <8feb08f71002110205s7380a815hc754d55521624c7f@mail.gmail.com> References: <1EA33878-F2E1-4F18-B770-B3D46A67D0D8@gmail.com> <8feb08f71002110205s7380a815hc754d55521624c7f@mail.gmail.com> Message-ID: On 11 Feb 2010, at 10:05, Vasyl Pasternak wrote: > > But fromSql function could convert everything to String, so you never > need to use `show`, just simply write > > convrow2 :: [SqlValue] -> String > convrow2 (x:xs) = foldl (\i j -> i ++ " | " ++ (fromSql j)) (fromSql x) xs > But, IMO, this is more readable version of your function: > > convrow2' :: [SqlValue] -> String > convrow2' = unwords . intersperse "|" . map fromSql > On 11 Feb 2010, at 10:06, Miguel Mitrofanov wrote: > > What if you just omit the "show" function? fromSql seems to be able to convert almost anything to String. Ok, thanks, that's a big help. I'm really glad to get rid off all that extra cruft I had there. I'd forgotten about intersperse, too. The new code works fine. Regards, Iain -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100212/0fb6766d/attachment.html From dons at galois.com Fri Feb 12 01:46:05 2010 From: dons at galois.com (Don Stewart) Date: Fri Feb 12 01:17:11 2010 Subject: [Haskell-cafe] Time for a San Francisco Hackathon? In-Reply-To: References: Message-ID: <20100212064605.GA18667@whirlpool.galois.com> bos: > I'm thinking it might be a good idea to organise a Haskell Hackathon for people > in (and who'd like to visit) the Bay Area. The tentative date I have in mind is > the first weekend in May (conveniently May 1). If you'd be interested in > attending or helping to organise, please let me know. Interesting. We were planning a PDX one for late April. Maybe we can coordinate and have a unified West Coast hackathon... Video + IRC can keep the hackers in sync :) -- Don From jason.dusek at gmail.com Fri Feb 12 01:53:42 2010 From: jason.dusek at gmail.com (Jason Dusek) Date: Fri Feb 12 01:24:45 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> <4B74451C.5030607@henning-thielemann.de> <20100211180923.GA20618@sliver.repetae.net> Message-ID: <42784f261002112253g7232dca9n7d0124c415237914@mail.gmail.com> I looked at generating C for AVR with JHC. I wanted to see what this program became: http://github.com/solidsnack/trippy-waves/blob/99ad424a3ed4a21ff6f6a662293d6d21e92d6611/using-jhc/RGB.hs The program is relatively simple. It doesn't work, of course (I never did get the right FFI bindings figured out) but the generated C is suggestive. http://github.com/solidsnack/trippy-waves/blob/99ad424a3ed4a21ff6f6a662293d6d21e92d6611/using-jhc/hs.out_code.c The generated `main' is very plain: static void A_STD ftheMain(void) { jhc_function_inc(); uintptr_t v10 = ((uintptr_t)DDRB()); *((uint8_t *)(v10)) = 23; uintptr_t v18 = ((uintptr_t)PORTB()); return *((uint8_t *)(v18)) = 23; } This is a simple, literal translation of my foreign calls. To all appearances, the runtime is entirely bypassed. The function `jhc_function_inc()' is a performance counter, set to no-op for non-profiling builds as far as I can tell. It also doesn't compile but that's because I can't figure out how to declare pointers in the FFI; and if I could, then I'd have to go through by hand and pull out includes for things that aren't available for AVR programming -- and such. -- Jason Dusek From patai_gergely at fastmail.fm Fri Feb 12 02:12:33 2010 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Fri Feb 12 01:43:35 2010 Subject: [Haskell-cafe] ANN: Dungeons of Wor - a largish FRP example and a fun game, all in one! In-Reply-To: <910ddf451002111742l5e8eef3sf589549fafc8a49c@mail.gmail.com> References: <1265877335.18142.1359423573@webmail.messagingengine.com> <910ddf451002111742l5e8eef3sf589549fafc8a49c@mail.gmail.com> Message-ID: <1265958753.13875.1359612391@webmail.messagingengine.com> > 1) This is missing the obligatory youtube video. That's usually handled by dons. ;) Gergely -- http://www.fastmail.fm - Email service worth paying for. Try it for free From patai_gergely at fastmail.fm Fri Feb 12 02:34:51 2010 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Fri Feb 12 02:05:54 2010 Subject: [Haskell-cafe] ANN: Dungeons of Wor - a largish FRP example and a fun game, all in one! In-Reply-To: <910ddf451002111742l5e8eef3sf589549fafc8a49c@mail.gmail.com> References: <1265877335.18142.1359423573@webmail.messagingengine.com> <910ddf451002111742l5e8eef3sf589549fafc8a49c@mail.gmail.com> Message-ID: <1265960091.16293.1359613675@webmail.messagingengine.com> > Exciting! But on a mac, I can't get the window to become focussed > or accept input. Tips ? I don't have a Mac, but I heard that GLFW is not without problems there, so maybe it's the culprit this time too. Do other GLFW apps work on your machine? Gergely -- http://www.fastmail.fm - IMAP accessible web-mail From lennart at augustsson.net Fri Feb 12 04:14:40 2010 From: lennart at augustsson.net (Lennart Augustsson) Date: Fri Feb 12 03:45:44 2010 Subject: [Haskell-cafe] haskell-src type inference algorithm? In-Reply-To: References: Message-ID: Well, something like such a tool exists, but I can't give it away. On Fri, Feb 12, 2010 at 12:13 AM, Niklas Broberg wrote: >> Anyone know of a type inference utility that can run right on haskell-src >> types? or one that could be easily adapted? > > This is very high on my wish-list for haskell-src-exts, and I'm hoping > the stuff Lennart will contribute will go a long way towards making it > feasible. I believe I can safely say that no such tool exists (and if > it does, why haven't you told me?? ;-)), but if you implement (parts > of) one yourself I'd be more than interested to see, and incorporate, > the results. > > Cheers, > > /Niklas > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From uzytkownik2 at gmail.com Fri Feb 12 05:32:24 2010 From: uzytkownik2 at gmail.com (Maciej Piechotka) Date: Fri Feb 12 05:03:26 2010 Subject: [Haskell-cafe] Re: Haskell-Cafe Digest, Vol 78, Issue 14 In-Reply-To: <9979e72e1002111549i4c620714v1e51b3bd382f9a67@mail.gmail.com> References: <20100209133545.82064324655@www.haskell.org> <9979e72e1002090841x4916e029qf32fad7abc8854d3@mail.gmail.com> <1265883701.5700.55.camel@picard> <87y6izhieu.fsf@gregorycollins.net> <9979e72e1002111549i4c620714v1e51b3bd382f9a67@mail.gmail.com> Message-ID: <1265970745.9281.10.camel@picard> On Thu, 2010-02-11 at 17:49 -0600, John Lato wrote: > On Thu, Feb 11, 2010 at 10:00 AM, Gregory Collins > wrote: > > Maciej Piechotka writes: > > > >> On Tue, 2010-02-09 at 16:41 +0000, John Lato wrote: > >>> > >>> See http://inmachina.net/~jwlato/haskell/ParsecIteratee.hs for a valid > >>> Stream instance using iteratee. Also Gregory Collins recently posted > >>> an iteratee wrapper for Attoparsec to haskell-cafe. To my knowledge > >>> these are not yet in any packages, but hackage is vast. > >> > >> Hmm. Am I correct that his implementation caches everything? > > > > The one that John posted (iteratees on top of parsec) has to keep a copy > > of the entire input, because parsec wants to be able to do arbitrary > > backtracking on the stream. > > This is true, however I believe this alternative approach is also > correct. The Cursor holds the stream state, and parsec holds on to > the Cursor for backtracking. Data is only read within the Iteratee > monad when it goes beyond the currently available cursors, at which > point another cursor is added to the linked list (implemented with > IORef or other mutable reference). > > The downside to this approach is that data is consumed from the > iteratee stream for a partial parse, even if the parse fails. I did > not want this behavior, so I chose a different approach. > Hmm. AFAIU your code you are doing something like: > concatCursor :: (Monad m, Reference r m, StreamChunk c el) > => Cursor r m c el -> m (c el) > concatCursor c = liftM mconcat (concatCursor' c) > > concatCursor' :: (Monad m, Reference r m, StreamChunk c el) > => Cursor r m c el -> m [c el] > concatCursor' (Cursor r v) = > liftM2 (:) (return v) (readRef r >>= concatNextCursor') > > concatNextCursor' :: (Monad m, Reference r m, StreamChunk c el) > => NextCursor r m c el -> m [c el] > concatNextCursor' (NextCursor c) = concatCursor' $! c > concatNextCursor' _ = return $! [] > > parsecIteratee' :: (Monad m, Reference r m, StreamChunk c el) > => ParsecT (Cursor r m c el) u (IterateeG c el m) a > -> u > -> SourceName > -> IterateeG c el m (Either ParseError a) > parsecIteratee' p u sn = do > c <- lift $ mkCursor :: IterateeG c el m (Cursor r m c el) > res <- runParserT (liftM2 (,) p getInput) u sn c > case res of > Right (a, c) -> do sc <- lift $ concatCursor c > liftI $! Done (Right a) $! Chunk $! sc > Left err -> return $ Left err Which seems that it should work (I just checked if it is suppose to compile). Unfortunately I need to work the clash between transformers and mtl). EDIT. Ops. sorry. It will not work. However it will (as it should) return the remaining part back to stream. > > > >> I tried to rewrite the implementation using... well imperative linked > >> list. For trivial benchmark it have large improvement (althought it may > >> be due to error in test such as using ByteString) and, I believe, that > >> it allows to free memory before finish. > >> > >> Results of test on Core 2 Duo 2.8 GHz: > >> 10: 0.000455s 0.000181s > >> 100: 0.000669s 0.001104s > >> 1000: 0.005209s 0.023704s > >> 10000: 0.053292s 1.423443s > >> 100000: 0.508093s 132.208597s > > > > I'm surprised your version has better performance for small numbers of > elements. I wonder if it's partially due to more aggressive inlining > from GHC or something of that nature. Or maybe your version compiles > to a tighter loop as elements can be gc'd. > It is possible as my code was in the same module. I'll try to use 2 different modules. > I expected poor performance of my code for larger numbers of elements, > as demonstrated here. > I haven't tested for more then 1e5 (which was in comment). > I envisioned the usage scenario where parsers would be relatively > short (<20 chars), and most of the work would be done directly with > iteratees. In this case it would be more important to preserve the > stream state in the case of a failed parse, and the performance issues > of appending chunks wouldn't arise either. > Fortunately parsec does not limit the number of streams per monad so it is up to user which one he will choose (depending on problem). > Cheers, > John Regards PS. Why iteratee uses transformers? It seems to be identical (both have functional dependencies etc.) to mtl except that mtl is standard in platform. Using both lead to clashes between names. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100212/e8fe99ff/attachment.bin From niklas.broberg at gmail.com Fri Feb 12 06:34:43 2010 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Fri Feb 12 06:05:46 2010 Subject: [Haskell-cafe] haskell-src type inference algorithm? In-Reply-To: References: Message-ID: On Fri, Feb 12, 2010 at 10:14 AM, Lennart Augustsson wrote: > Well, something like such a tool exists, but I can't give it away. I know. :-) /Niklas From dan.doel at gmail.com Fri Feb 12 07:28:17 2010 From: dan.doel at gmail.com (Dan Doel) Date: Fri Feb 12 06:59:24 2010 Subject: [Haskell-cafe] vector to uvector and back again In-Reply-To: <201002112054.17250.dan.doel@gmail.com> References: <4B72F3F6.3050506@k-hornz.de> <4B7441AE.3070407@k-hornz.de> <201002112054.17250.dan.doel@gmail.com> Message-ID: <201002120728.17965.dan.doel@gmail.com> On Thursday 11 February 2010 8:54:15 pm Dan Doel wrote: > On Thursday 11 February 2010 12:43:10 pm stefan kersten wrote: > > On 10.02.10 19:03, Bryan O'Sullivan wrote: > > > I'm thinking of switching the statistics library over to using vector. > > > > that would be even better of course! an O(0) solution, at least for me ;) > > let me know if i can be of any help (e.g. in testing). i suppose > > uvector-algorithms would also need to be ported to vector, then. > > I could do this. To this end, I've done a preliminary port of the library, such that all the modules compile. I've just used safe operations so far, so it's probably a significant decrease in performance over the 0.2 uvector-algorithms (unless perhaps you turn off the bounds checking flag), but it's a start. It can be gotten with: darcs get http://code.haskell.org/~dolio/vector-algorithms I only encountered a couple snags during the porting so far: * swap isn't exported from D.V.Generic.Mutable, so I'm using my own. * I use a copy with an offset into the from and to arrays, and with a length (this is necessary for merge sort). However, I only saw a whole array copy (and only with identical sizes) in vector (so I wrote my own again). * Some kind of thawing of immutable vectors into mutable vectors, or other way to copy the former into the latter would be useful. Right now I'm using unstream . stream, but I'm not sure that's the best way to do it. Other than that, things went pretty smoothly. I haven't ported the test suite or benchmarks yet, so I don't recommend that anyone actually uses this for anything important yet. Cheers, -- Dan From matthias.goergens at googlemail.com Fri Feb 12 07:32:29 2010 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Fri Feb 12 07:03:53 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <2518b95d1002111355s6195503bn3b93838d3e74be8b@mail.gmail.com> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> <4B74451C.5030607@henning-thielemann.de> <20100211180923.GA20618@sliver.repetae.net> <2518b95d1002111355s6195503bn3b93838d3e74be8b@mail.gmail.com> Message-ID: > It might be big for SoC but perhaps there's some well-defined subset, > like fix some blocking issue? Good idea. By the way, do all SoC projects have to be single-contributor projects, or could someone get together with a friend and work together on a somewhat larger project? From jwlato at gmail.com Fri Feb 12 07:51:13 2010 From: jwlato at gmail.com (John Lato) Date: Fri Feb 12 07:22:17 2010 Subject: [Haskell-cafe] Re: Haskell-Cafe Digest, Vol 78, Issue 14 In-Reply-To: <1265970745.9281.10.camel@picard> References: <20100209133545.82064324655@www.haskell.org> <9979e72e1002090841x4916e029qf32fad7abc8854d3@mail.gmail.com> <1265883701.5700.55.camel@picard> <87y6izhieu.fsf@gregorycollins.net> <9979e72e1002111549i4c620714v1e51b3bd382f9a67@mail.gmail.com> <1265970745.9281.10.camel@picard> Message-ID: <9979e72e1002120451k6456ec14g7d98601549aea4d@mail.gmail.com> On Fri, Feb 12, 2010 at 10:32 AM, Maciej Piechotka wrote: > On Thu, 2010-02-11 at 17:49 -0600, John Lato wrote: >> On Thu, Feb 11, 2010 at 10:00 AM, Gregory Collins >> wrote: >> > Maciej Piechotka writes: >> > >> >> On Tue, 2010-02-09 at 16:41 +0000, John Lato wrote: >> >>> >> >>> See http://inmachina.net/~jwlato/haskell/ParsecIteratee.hs for a valid >> >>> Stream instance using iteratee. ?Also Gregory Collins recently posted >> >>> an iteratee wrapper for Attoparsec to haskell-cafe. ?To my knowledge >> >>> these are not yet in any packages, but hackage is vast. >> >> >> >> Hmm. Am I correct that his implementation caches everything? >> > >> > The one that John posted (iteratees on top of parsec) has to keep a copy >> > of the entire input, because parsec wants to be able to do arbitrary >> > backtracking on the stream. >> >> This is true, however I believe this alternative approach is also >> correct. ?The Cursor holds the stream state, and parsec holds on to >> the Cursor for backtracking. ?Data is only read within the Iteratee >> monad when it goes beyond the currently available cursors, at which >> point another cursor is added to the linked list (implemented with >> IORef or other mutable reference). >> >> The downside to this approach is that data is consumed from the >> iteratee stream for a partial parse, even if the parse fails. ?I did >> not want this behavior, so I chose a different approach. >> > > Hmm. AFAIU your code you are doing something like: > >> concatCursor :: (Monad m, Reference r m, StreamChunk c el) >> ? ? ? ? ? ? ?=> Cursor r m c el -> m (c el) >> concatCursor c = liftM mconcat (concatCursor' c) >> >> concatCursor' :: (Monad m, Reference r m, StreamChunk c el) >> ? ? ? ? ? ? ? => Cursor r m c el -> m [c el] >> concatCursor' (Cursor r v) = >> ? liftM2 (:) (return v) (readRef r >>= concatNextCursor') >> >> concatNextCursor' :: (Monad m, Reference r m, StreamChunk c el) >> ? ? ? ? ? ? ? ? ?=> NextCursor r m c el -> m [c el] >> concatNextCursor' (NextCursor c) = concatCursor' $! c >> concatNextCursor' _ ? ? ? ? ? ? ?= return $! [] >> >> parsecIteratee' :: (Monad m, Reference r m, StreamChunk c el) >> ? ? ? ? ? ? ? ? => ParsecT (Cursor r m c el) u (IterateeG c el m) a >> ? ? ? ? ? ? ? ? -> u >> ? ? ? ? ? ? ? ? -> SourceName >> ? ? ? ? ? ? ? ? -> IterateeG c el m (Either ParseError a) >> parsecIteratee' p u sn = do >> ? ?c <- lift $ mkCursor :: IterateeG c el m (Cursor r m c el) >> ? ?res <- runParserT (liftM2 (,) p getInput) u sn c >> ? ?case res of >> ? ? ?Right (a, c) -> do sc <- lift $ concatCursor c >> ? ? ? ? ? ? ? ? ? ? ? ? liftI $! Done (Right a) $! Chunk $! sc >> ? ? ?Left ? err ? -> return $ Left err > > Which seems that it should work (I just checked if it is suppose to > compile). Unfortunately I need to work the clash between transformers > and mtl). > > EDIT. Ops. sorry. It will not work. However it will (as it should) > return the remaining part back to stream. Yes, the remaining part will be returned, but the consumed portion is lost. I couldn't figure out how to solve that problem other than cacheing everything. > >> > >> >> I tried to rewrite the implementation using... well imperative linked >> >> list. For trivial benchmark it have large improvement (althought it may >> >> be due to error in test such as using ByteString) and, I believe, that >> >> it allows to free memory before finish. >> >> >> >> Results of test on Core 2 Duo 2.8 GHz: >> >> 10: ? 0.000455s ? ? ? 0.000181s >> >> 100: ?0.000669s ? ? ? 0.001104s >> >> 1000: 0.005209s ? ? ? 0.023704s >> >> 10000: ? ? ? ?0.053292s ? ? ? 1.423443s >> >> 100000: ? ? ? 0.508093s ? ? ? 132.208597s >> > > >> I expected poor performance of my code for larger numbers of elements, >> as demonstrated here. >> > > I haven't tested for more then 1e5 (which was in comment). Interesting. I expect good performance as long as chunks don't need to be concatenated. The default chunk size is either 4096 or 8192 (I don't remember ATM). This also assumes that no intervening functions (take, drop, etc.) alter the stream too significantly. Testing 1e5 wouldn't do more than two concats, and particularly with bytestrings shouldn't impose too much penalty. List performance would be much worse though. Incidentally, performance of the WrappedByteString newtype is poor relative to true bytestrings. This will be fixed in the next major release (due in maybe a month or so?) > >> I envisioned the usage scenario where parsers would be relatively >> short (<20 chars), and most of the work would be done directly with >> iteratees. ?In this case it would be more important to preserve the >> stream state in the case of a failed parse, and the performance issues >> of appending chunks wouldn't arise either. >> > > Fortunately parsec does not limit the number of streams per monad so it > is up to user which one he will choose (depending on problem). > Good point. > > Regards > PS. Why iteratee uses transformers? It seems to be identical (both have > functional dependencies etc.) to mtl except that mtl is standard in > platform. Using both lead to clashes between names. Short answer: I am using iteratee with another package that uses transformers. Longer answer: see discussions on mtl vs. transformers in the haskell-libraries archive. There are a few simple solutions. You can build iteratee against mtl by changing the build-depends: field in iteratee.cabal. You can also use the LANGUAGE PackageImports pragma. I'm unaware of any difficulties with either of these approaches. Cheers, John From Malcolm.Wallace at cs.york.ac.uk Fri Feb 12 08:02:23 2010 From: Malcolm.Wallace at cs.york.ac.uk (Malcolm Wallace) Date: Fri Feb 12 07:33:57 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> <4B74451C.5030607@henning-thielemann.de> <20100211180923.GA20618@sliver.repetae.net> <2518b95d1002111355s6195503bn3b93838d3e74be8b@mail.gmail.com> Message-ID: <5A61FE42-82AC-48D9-9A2E-48E46E031C44@cs.york.ac.uk> On 12 Feb 2010, at 12:32, Matthias G?rgens wrote: >> It might be big for SoC but perhaps there's some well-defined subset, >> like fix some blocking issue? > > Good idea. By the way, do all SoC projects have to be > single-contributor projects, or could someone get together with a > friend and work together on a somewhat larger project? In theory, two students could work together on a single project. However, in practice there would need to be a clear delineation (in advance) of what each student would contribute, so that we can determine whether either student individually succeeds and gets paid. Also, at the initial submission stage, there is no guarantee that if one student gets a place, the other will as well. So there would need to be a contingency plan for what each student would do in the absence of the other. Regards, Malcolm From rl at cse.unsw.edu.au Fri Feb 12 08:12:51 2010 From: rl at cse.unsw.edu.au (Roman Leshchinskiy) Date: Fri Feb 12 07:44:01 2010 Subject: [Haskell-cafe] vector to uvector and back again In-Reply-To: <201002120728.17965.dan.doel@gmail.com> References: <4B72F3F6.3050506@k-hornz.de> <4B7441AE.3070407@k-hornz.de> <201002112054.17250.dan.doel@gmail.com> <201002120728.17965.dan.doel@gmail.com> Message-ID: On 12/02/2010, at 23:28, Dan Doel wrote: > On Thursday 11 February 2010 8:54:15 pm Dan Doel wrote: >> On Thursday 11 February 2010 12:43:10 pm stefan kersten wrote: >>> On 10.02.10 19:03, Bryan O'Sullivan wrote: >>>> I'm thinking of switching the statistics library over to using vector. >>> >>> that would be even better of course! an O(0) solution, at least for me ;) >>> let me know if i can be of any help (e.g. in testing). i suppose >>> uvector-algorithms would also need to be ported to vector, then. >> >> I could do this. > > To this end, I've done a preliminary port of the library, such that all the > modules compile. I've just used safe operations so far, so it's probably a > significant decrease in performance over the 0.2 uvector-algorithms (unless > perhaps you turn off the bounds checking flag), but it's a start. It can be > gotten with: > > darcs get http://code.haskell.org/~dolio/vector-algorithms That's great, thanks! FWIW, vector has two kinds of bounds checks: "real" ones which catch invalid indices supplied by the user (on by default) and internal ones which catch bugs in the library (off by default since the library is, of course, bug-free ;-). I guess you'd eventually want to use the latter but not the former; that's exactly what unsafe operations provide. > I only encountered a couple snags during the porting so far: > > * swap isn't exported from D.V.Generic.Mutable, so I'm using my own. Ah, I'll export it. Also, I gladly accept patches :-) > * I use a copy with an offset into the from and to arrays, and with a > length (this is necessary for merge sort). However, I only saw a whole > array copy (and only with identical sizes) in vector (so I wrote my own > again). That's actually a conscious decision. Since vectors support O(1) slicing, you can simply copy a slice of the source vector into a slice of the target vector. > * Some kind of thawing of immutable vectors into mutable vectors, or other > way to copy the former into the latter would be useful. Right now I'm > using unstream . stream, but I'm not sure that's the best way to do it. At the moment, it is (although it ought to be wrapped in a nicer interface). Something like memcpy doesn't work for Data.Vector.Unboxed because the ByteArrays aren't pinned. I don't really want to provide thawing until someone convinces me that it is actually useful. BTW, vector also supports array recycling so you could implement true in-place sorting for fused pipelines. Something like map (+1) . sort . update xs wouldn't allocate any temporary arrays in that case. Roman From rick.richardson at gmail.com Fri Feb 12 08:19:02 2010 From: rick.richardson at gmail.com (Rick R) Date: Fri Feb 12 07:50:05 2010 Subject: [Haskell-cafe] Haskell RPC / Cluster Message-ID: <9810b81b1002120519x3fe79de2j4a5f7e2b73ad3b16@mail.gmail.com> I am preparing to embark on some serious cluster oriented coding (high availability, monitoring, failover, etc). My primary concern is conforming to standards. I would also like to aid any existing project that fall under this scope. HackPar seems currently targeted towards HPC style clustering, but the page seems to hint at future work in the cloud/high-availability area. I was looking around for RPC libs for Haskell and stumbled across this http://github.com/mariusaeriksen/bert It implements BERT, which is based on Erlang's binary serialization protocol. It seems to have quite a bit of support. Does anyone know of any other RPC modules for Haskell? In addition, can anyone recommend other cluster oriented modules for monitoring, process management, etc? If those don't exist, can anyone recommend some standards off of which to base these? SNMP seems obvious (and daunting), any others? Thanks, Rick From dan.doel at gmail.com Fri Feb 12 08:44:06 2010 From: dan.doel at gmail.com (Dan Doel) Date: Fri Feb 12 08:15:14 2010 Subject: [Haskell-cafe] vector to uvector and back again In-Reply-To: References: <4B72F3F6.3050506@k-hornz.de> <201002120728.17965.dan.doel@gmail.com> Message-ID: <201002120844.07078.dan.doel@gmail.com> On Friday 12 February 2010 8:12:51 am Roman Leshchinskiy wrote: > That's actually a conscious decision. Since vectors support O(1) slicing, > you can simply copy a slice of the source vector into a slice of the > target vector. Ah! I hadn't thought of that. That makes sense. > At the moment, it is (although it ought to be wrapped in a nicer > interface). Something like memcpy doesn't work for Data.Vector.Unboxed > because the ByteArrays aren't pinned. I don't really want to provide > thawing until someone convinces me that it is actually useful. Well, my use case is (of course) that I have lots of algorithms on mutable arrays, but they work just as well on immutable arrays by creating an intermediary. So I provided a combinator 'apply' that did something like: apply algo iv = new (safeThaw iv >>= \mv -> algo mv >> return mv) In uvector, the safeThaw part was copying iv into mv with a provided function. For the port, I used unstream . stream, which works fine assuming stream produces a correct size hint, I guess. That's the extent of what I have use for at the moment, though. > BTW, vector also supports array recycling so you could implement true > in-place sorting for fused pipelines. Something like > > map (+1) . sort . update xs > > wouldn't allocate any temporary arrays in that case. I'll look into it. -- Dan From aruiz at um.es Fri Feb 12 08:56:56 2010 From: aruiz at um.es (Alberto Ruiz) Date: Fri Feb 12 08:28:03 2010 Subject: [Haskell-cafe] ANN: hmatrix 0.8.3 Message-ID: <4B755E28.2060303@um.es> Hello, I have released a new version of hmatrix, a library for numeric computation based on LAPACK, BLAS and GSL. Recent developments include improved SVD functions, a simple ODE solver, easier OS/X installation (thanks to H. Apfelmus), and updated tutorial. hackage : http://hackage.haskell.org/package/hmatrix home page: http://code.haskell.org/hmatrix tutorial : http://code.haskell.org/hmatrix/hmatrix.pdf Any feedback is welcome! Alberto Ruiz From marlowsd at gmail.com Fri Feb 12 10:29:14 2010 From: marlowsd at gmail.com (Simon Marlow) Date: Fri Feb 12 10:00:29 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> Message-ID: <4B7573CA.4020201@gmail.com> On 11/02/2010 17:01, John Van Enk wrote: > Here's the paper: > http://comjnl.oxfordjournals.org/cgi/content/abstract/33/5/466 Can you say a bit about why that GC fits your needs? Must it be that particular algorithm? I don't seem to be able to find the paper online. Replacing GHC's RTS is no mean feat, as you're probably aware. There are a large number of dependencies between the compiler, the RTS, and the low-level libraries. I expect rather than thinking about replacing the RTS it would be more profitable to look at what kinds of things you need the RTS to do that it currently does not. I'm aware that some people need a GC with shorter pause times. We'll probably put that on the roadmap at some point. Cheers, Simon From vanenkj at gmail.com Fri Feb 12 10:45:21 2010 From: vanenkj at gmail.com (John Van Enk) Date: Fri Feb 12 10:16:24 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <4B7573CA.4020201@gmail.com> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> <4B7573CA.4020201@gmail.com> Message-ID: I _think_ that the abstract points out that reference-counted garbage collection can be done deterministically. Haskell could some day be an excellent replacement for C/Ada in safety critical markets, but some serious changes to the RTS (most having to do with memory allocation, garbage collection, and multi-threading) would have to be made. If the GC becomes deterministic, then a much better case can be made for using the language on a plane or in medical devices. /jve On Fri, Feb 12, 2010 at 10:29 AM, Simon Marlow wrote: > On 11/02/2010 17:01, John Van Enk wrote: > >> Here's the paper: >> http://comjnl.oxfordjournals.org/cgi/content/abstract/33/5/466 >> > > Can you say a bit about why that GC fits your needs? Must it be that > particular algorithm? I don't seem to be able to find the paper online. > > Replacing GHC's RTS is no mean feat, as you're probably aware. There are a > large number of dependencies between the compiler, the RTS, and the > low-level libraries. I expect rather than thinking about replacing the RTS > it would be more profitable to look at what kinds of things you need the RTS > to do that it currently does not. > > I'm aware that some people need a GC with shorter pause times. We'll > probably put that on the roadmap at some point. > > Cheers, > Simon > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100212/616b1323/attachment.html From yairchu at gmail.com Fri Feb 12 10:55:15 2010 From: yairchu at gmail.com (yairchu@gmail.com) Date: Fri Feb 12 10:26:16 2010 Subject: [Haskell-cafe] Re: ANN: Dungeons of Wor - a largish FRP example and a fun game, all in one! In-Reply-To: References: <1265877335.18142.1359423573@webmail.messagingengine.com> Message-ID: On Feb 12, 4:22?am, Simon Michael wrote: > Exciting! But on a mac, I can't get the window to become focussed or accept input. Tips ? Tips: $ cabal install mkbndl $ cd ~/.cabal/bin $ mkbndl dow $ open Dow.app Ok, but you need to click the right control key to select stuff on the menu, and you probably only have a left control key, so: $ cd $ tar xvzf ~/.cabal/packages/hackage.haskell.org/dow/0.1.0/ dow-0.1.0.tar.gz $ cd dow-0.1.0/src $ head -n 86 Main.hs > tmp $ echo " kt1 <- getKey ' '" >> tmp $ tail -n 7 Main.hs >> tmp $ cp tmp Main.hs $ cd .. $ cabal install $ cd ~/.cabal/bin $ mkbndl -f dow $ open Dow.app > _______________________________________________ > Haskell-Cafe mailing list > Haskell-C...@haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe From marlowsd at gmail.com Fri Feb 12 10:59:24 2010 From: marlowsd at gmail.com (Simon Marlow) Date: Fri Feb 12 10:30:45 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> <4B74451C.5030607@henning-thielemann.de> <20100211180923.GA20618@sliver.repetae.net> Message-ID: <4B757ADC.2010801@gmail.com> On 11/02/2010 20:57, Alp Mestanogullari wrote: > It seems quite big for a 3 months project made by a student, though. No kidding :-) I last rewrote the RTS in 1998: http://www.mail-archive.com/glasgow-haskell-users@haskell.org/msg00329.html So as you can see from that announcement, it took "a few months" to rewrite the RTS. At the time, we redesigned things quite a bit, so that includes changes in the compiler too. Back then of course the RTS didn't have a few things it has now: - anything to do with multithreading or parallel execution - generational GC - profiling - dynamic linking and the byte-code interpreter (GHCi) - STM - asynchronous exceptions (throwTo) - event logging and tracing but even so, it was about 20k lines. It did have concurrency, a 2-space GC, the FFI, all the primitives, and lots of debugging code. Cheers, Simon From sk at k-hornz.de Fri Feb 12 11:01:34 2010 From: sk at k-hornz.de (stefan kersten) Date: Fri Feb 12 10:32:38 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <4B7573CA.4020201@gmail.com> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> <4B7573CA.4020201@gmail.com> Message-ID: <4B757B5E.7060705@k-hornz.de> On 12.02.10 16:29, Simon Marlow wrote: > I'm aware that some people need a GC with shorter pause times. We'll > probably put that on the roadmap at some point. for some applications (like realtime audio processing) it would be interesting to even have short pause times with a guaranteed upper bound, but i realize this is a very specialized need that could be better served by making the GC implementation swappable (which otoh doesn't seem to be trivial). From marlowsd at gmail.com Fri Feb 12 11:07:07 2010 From: marlowsd at gmail.com (Simon Marlow) Date: Fri Feb 12 10:38:20 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> <4B7573CA.4020201@gmail.com> Message-ID: <4B757CAB.4010908@gmail.com> On 12/02/2010 15:45, John Van Enk wrote: > I _think_ that the abstract points out that reference-counted garbage > collection can be done deterministically. Haskell could some day be an > excellent replacement for C/Ada in safety critical markets, but some > serious changes to the RTS (most having to do with memory allocation, > garbage collection, and multi-threading) would have to be made. > > If the GC becomes deterministic, then a much better case can be made for > using the language on a plane or in medical devices. In a sense the GC *is* deterministic: it guarantees to collect all the unreachable garbage. But I expect what you're referring to is the fact that the garbage remains around for a non-deterministic amount of time. To me that doesn't seem to be a problem: you could run the GC at any time to reclaim it (pause-times notwithstanding). Even if you collected garbage immediately, I wouldn't feel comfortable about claiming any kind of deterministic memory behaviour for Haskell, given that transformations performed by the compiler behind your back can change the space usage, sometimes asymptotically. If you have to have guaranteed deterministic memory usage, perhaps something like Hume[1] is more appropriate? Cheers, Simon http://www-fp.cs.st-andrews.ac.uk/hume/index.shtml From marlowsd at gmail.com Fri Feb 12 11:13:49 2010 From: marlowsd at gmail.com (Simon Marlow) Date: Fri Feb 12 10:45:04 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <2518b95d1002111355s6195503bn3b93838d3e74be8b@mail.gmail.com> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> <4B74451C.5030607@henning-thielemann.de> <20100211180923.GA20618@sliver.repetae.net> <2518b95d1002111355s6195503bn3b93838d3e74be8b@mail.gmail.com> Message-ID: <4B757E3D.7020405@gmail.com> On 11/02/2010 21:55, Evan Laforge wrote: > On Thu, Feb 11, 2010 at 1:49 PM, John Van Enk wrote: >> Perhaps just defining the interface and demonstrating that different RTS's >> are swappable would be enough? > > I read a paper by (I think) a Simon, in which he described a haskell > RTS. It would make it easier to experiment with GC, scheduling, and > whatever else. I recall a few problems, such as performance, but > nothing really intractable. Swappable RTS would be a nice > side-effect. You're probably referring to this: http://www.haskell.org/~simonmar/papers/conc-substrate.pdf the idea there was to move as much of the scheduler as possible into Haskell. It's still something we'd like to do, but getting even close to the performance of the current RTS was difficult, which is why the project is currently dormant. In order to get decent performance we'd probably have to sacrifice some of the nice abstractions, like transactions, but then the advantages become less clear. I'm hoping that someday hardware TM will help here. Also, it was only the scheduler, which is quite a small part of the RTS (probably 5% is an overestimate). Cheers, Simon From robgreayer at gmail.com Fri Feb 12 11:18:14 2010 From: robgreayer at gmail.com (Robert Greayer) Date: Fri Feb 12 10:49:16 2010 Subject: [Haskell-cafe] Haskell RPC / Cluster In-Reply-To: <9810b81b1002120519x3fe79de2j4a5f7e2b73ad3b16@mail.gmail.com> References: <9810b81b1002120519x3fe79de2j4a5f7e2b73ad3b16@mail.gmail.com> Message-ID: <4ec472cb1002120818i31b63ae2hb1b6d359f7aabc4d@mail.gmail.com> Perhaps not exactly what you're after, but at least in the same vein: http://hackage.haskell.org/package/hspread http://www.spread.org/ On Fri, Feb 12, 2010 at 8:19 AM, Rick R wrote: > I am preparing to embark on some serious cluster oriented coding (high > availability, monitoring, failover, etc). My primary concern is > conforming to standards. I would also like to aid any existing project > that fall under this scope. ?HackPar seems currently targeted towards > HPC style clustering, but the page seems to hint at future work in the > cloud/high-availability area. > > I was looking around for RPC libs for Haskell and stumbled across this > > http://github.com/mariusaeriksen/bert > > It implements BERT, which is based on Erlang's binary serialization > protocol. It seems to have quite a bit of support. > > Does anyone know of any other RPC modules for Haskell? In addition, > can anyone recommend other cluster oriented modules for monitoring, > process management, etc? > > If those don't exist, can anyone recommend some standards off of which > to base these? > SNMP seems obvious (and daunting), any others? > > > Thanks, > Rick > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From fnnirvana at gmail.com Fri Feb 12 11:30:23 2010 From: fnnirvana at gmail.com (Xinyu Jiang) Date: Fri Feb 12 11:01:26 2010 Subject: [Haskell-cafe] Infix and postfix operators in Parsec Message-ID: <882cb01e1002120830t378c715dtd55e31cb9d74317d@mail.gmail.com> I'm writing a parser for a Haskell-style language, and when I need to use the same symbol for infix, prefix and postfix operators, the combinator "buildExpressionParser" seems not to work as intended. For example, in: (1)x + y (2)x + (3)+ x If I set the priority of the postfix version of "+" to be higher than the infix version, the parser cannot recognize (1), for it stops at the end of "x +". And if the priority of postfix "+" is lower, Parsec complains about (2) by returning an error message which expects something after "+". Is there some way to get over this problem, and let me be able to still benifit from the expression mechanism in Parsec. Or should I write these stuff from scratch? Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100212/1b2c9409/attachment.html From Christian.Maeder at dfki.de Fri Feb 12 11:54:49 2010 From: Christian.Maeder at dfki.de (Christian Maeder) Date: Fri Feb 12 11:25:53 2010 Subject: [Haskell-cafe] Re: Infix and postfix operators in Parsec In-Reply-To: <882cb01e1002120830t378c715dtd55e31cb9d74317d@mail.gmail.com> References: <882cb01e1002120830t378c715dtd55e31cb9d74317d@mail.gmail.com> Message-ID: <4B7587D9.3000502@dfki.de> It seems that the case of identical postfix and infix operators was not considered. So I recommend to write something from scratch. Cheers Christian Xinyu Jiang schrieb: > I'm writing a parser for a Haskell-style language, and when I need to > use the same symbol for infix, prefix and postfix operators, the > combinator "buildExpressionParser" seems not to work as intended. For > example, in: > > (1)x + y > (2)x + > (3)+ x > > If I set the priority of the postfix version of "+" to be higher than > the infix version, the parser cannot recognize (1), for it stops at the > end of "x +". And if the priority of postfix "+" is lower, Parsec > complains about (2) by returning an error message which expects > something after "+". > > Is there some way to get over this problem, and let me be able to still > benifit from the expression mechanism in Parsec. Or should I write these > stuff from scratch? Thanks. From Christian.Maeder at dfki.de Fri Feb 12 12:00:13 2010 From: Christian.Maeder at dfki.de (Christian Maeder) Date: Fri Feb 12 11:31:16 2010 Subject: [Haskell-cafe] Re: Infix and postfix operators in Parsec In-Reply-To: <4B7587D9.3000502@dfki.de> References: <882cb01e1002120830t378c715dtd55e31cb9d74317d@mail.gmail.com> <4B7587D9.3000502@dfki.de> Message-ID: <4B75891D.9000008@dfki.de> Parse a sequence of primitive expressions first and then do fixity resolution independent from Parsec. C. Christian Maeder schrieb: > It seems that the case of identical postfix and infix operators was not > considered. So I recommend to write something from scratch. > > Cheers Christian > > Xinyu Jiang schrieb: >> I'm writing a parser for a Haskell-style language, and when I need to >> use the same symbol for infix, prefix and postfix operators, the >> combinator "buildExpressionParser" seems not to work as intended. For >> example, in: >> >> (1)x + y >> (2)x + >> (3)+ x >> >> If I set the priority of the postfix version of "+" to be higher than >> the infix version, the parser cannot recognize (1), for it stops at the >> end of "x +". And if the priority of postfix "+" is lower, Parsec >> complains about (2) by returning an error message which expects >> something after "+". >> >> Is there some way to get over this problem, and let me be able to still >> benifit from the expression mechanism in Parsec. Or should I write these >> stuff from scratch? Thanks. From jon at jrock.us Fri Feb 12 12:27:57 2010 From: jon at jrock.us (Jonathan Rockway) Date: Fri Feb 12 11:59:00 2010 Subject: [Haskell-cafe] Using Cabal during development In-Reply-To: <90889fe71002090803p78d1be5bo34a97175d8d22d0d@mail.gmail.com> (Johan Tibell's message of "Tue, 9 Feb 2010 08:03:15 -0800") References: <27515446.post@talk.nabble.com> <87r5ouebyn.fsf@malde.org> <90889fe71002090803p78d1be5bo34a97175d8d22d0d@mail.gmail.com> Message-ID: <877hqipdnm.fsf@snowball2.jrock.us> * On Tue, Feb 09 2010, Johan Tibell wrote: > On Tue, Feb 9, 2010 at 6:10 AM, Ketil Malde wrote: > > Limestra?l writes: > > > how do usually Haskell developpers build their softwares (and > > especially medium or big libraries) while they are still developping them ? > > With cabal-install, by doing one 'cabal configure' once and 'cabal build' > > each time they have altered their code ? > > With only Cabal, through some 'runhaskell Setup.hs build's ? > > Generally, the first thing I do is hit C-c C-l in Emacs to load the > current file into a haskell process. ?Then back to fix the type errors > (click on the error to jump to the code), and iterate until it loads > correctly. > > It's really unfortunate that this approach doesn't work for .hsc files. When writing > low level libraries I often have a couple of these which forces me out of my nice > Emacs workflow into an Emacs + terminal + Cabal workflow. This is solve-able. I bind compile-command to the c2hs invocation, and then have my C-c C-l keybinding run "compile" before "inferior-haskell-load-file". The only hangup is that having a -*- comment at the top of a c2hs file confuses ghc when c2hs generates the code. So I set the buffer-local variable via eproject (in the .eproject file in the project root) instead, and everything is happy. I would post the exact code, but it's on my work machine, and it's nearly impossible to get files out of my work environment without getting nasty emails about how I'm stealing the company's IP. (But hey, at least I get to use Haskell. I can't complain too loudly :) Ping me on #haskell or #emacs if you need help getting something like this working. Oh; one other thing. You don't need to leave emacs to run cabal commands; you can run ":!cabal build" from the ghci window, you can bind compile-command to "cabal build" and run M-x compile, or you can use eshell. I use all three approaches depending on my mood. But since I'm on Windows, I certainly never venture outside of my Emacs window. :) Regards, Jonathan Rockway -- Just "another Haskell hacker" From jgoerzen at complete.org Fri Feb 12 12:50:57 2010 From: jgoerzen at complete.org (John Goerzen) Date: Fri Feb 12 12:22:01 2010 Subject: [Haskell-cafe] MissingH dropped QuickCheck dep In-Reply-To: <20100212164508.GA1824@protagoras.phil.berkeley.edu> References: <9066fa251001272138v63e5b306ic7943aaf8692a912@mail.gmail.com> <20100128055450.GA24676@whirlpool.galois.com> <8d862979-0364-4af9-8890-3900ac4c3e0b@k6g2000prg.googlegroups.com> <20100212164508.GA1824@protagoras.phil.berkeley.edu> Message-ID: <20100212175057.GA32117@excelii.com> On Fri, Feb 12, 2010 at 08:45:09AM -0800, John MacFarlane wrote: > +++ thomas hartman [Feb 11 10 21:07 ]: > > gitit on hackage is still blocked because of dependency on missingh, > > which depends on qc1. Not an easy fix -- I couldn't figure out how to > > migrate testpack to qc2. > > > > However, missingh dependency was removed from gitit head > > > > http://github.com/jgm/gitit > > > > so that's good. > > No, gitit head still depends on MissingH, via ConfigFile. > > I imagine John will update MissingH to use QuickCheck2 soon... Hey guys, I took a look at MissingH and there was no need for the main library to depend on QuickCheck in the first place. It was only needed by the tests. So I've uploaded a new MissingH 1.1.0.2 to Hackage that drops that dep. That ought to solve it for you. -- John > > John > > > From spam at scientician.net Fri Feb 12 13:00:05 2010 From: spam at scientician.net (Bardur Arantsson) Date: Fri Feb 12 12:31:32 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: References: <910ddf451002091647m4b7e12a5y5a680d7d356fb3d6@mail.gmail.com> <94E8A4F7-E54B-4885-8D6A-6AA4777F6FC1@n-heptane.com> Message-ID: Jeremy Shaw wrote: > import Control.Concurrent > import Control.Concurrent.MVar > import System.Posix.Types > > data RW = Read | Write > > threadWaitReadWrite :: Fd -> IO RW > threadWaitReadWrite fd = > do m <- newEmptyMVar > rid <- forkIO $ threadWaitRead fd >> putMVar m Read > wid <- forkIO $ threadWaitWrite fd >> putMVar m Write > r <- takeMVar m > killThread rid > killThread wid > return r > Initial testing seems promising. I haven't been able to provoke the "leak" during 15-20 minutes of testing. I'll test more thoroughly during the weekend. Cheers, From jason.dusek at gmail.com Fri Feb 12 13:11:46 2010 From: jason.dusek at gmail.com (Jason Dusek) Date: Fri Feb 12 12:42:47 2010 Subject: [Haskell-cafe] Time for a San Francisco Hackathon? In-Reply-To: References: Message-ID: <42784f261002121011h310b049bq929f2b6e157b204b@mail.gmail.com> I'd help organize. How do these usually work? Some worthy package is selected for hacking? People hack whatever they like? -- Jason Dusek From jason.dusek at gmail.com Fri Feb 12 13:18:51 2010 From: jason.dusek at gmail.com (Jason Dusek) Date: Fri Feb 12 12:49:51 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <4B757B5E.7060705@k-hornz.de> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> <4B7573CA.4020201@gmail.com> <4B757B5E.7060705@k-hornz.de> Message-ID: <42784f261002121018y7b70609sa38c3d2b7b1a2b3d@mail.gmail.com> 2010/02/12 stefan kersten : > On 12.02.10 16:29, Simon Marlow wrote: > > I'm aware that some people need a GC with shorter pause > > times. ?We'll probably put that on the roadmap at some point. > > for some applications (like realtime audio processing) it > would be interesting to even have short pause times with a > guaranteed upper bound, but i realize this is a very > specialized need that could be better served by making the GC > implementation swappable (which otoh doesn't seem to be > trivial). I think this is not a unique need. When you consider things like scalable network services with strong SLAs, largish embedded systems (iPhone, planes, &c.) and other environments where verification is a big win, it's generally also important to control latency and memory use. To be honest, though, I am of two minds about this. Why shouldn't we enforce our timing/memory requirements by writing EDSLs and compiling them? The approach Atom takes is maybe the most flexible option (there be parens, though). -- Jason Dusek From dons at galois.com Fri Feb 12 13:51:59 2010 From: dons at galois.com (Don Stewart) Date: Fri Feb 12 13:23:13 2010 Subject: [Haskell-cafe] Re: MissingH dropped QuickCheck dep In-Reply-To: <20100212175057.GA32117@excelii.com> References: <9066fa251001272138v63e5b306ic7943aaf8692a912@mail.gmail.com> <20100128055450.GA24676@whirlpool.galois.com> <8d862979-0364-4af9-8890-3900ac4c3e0b@k6g2000prg.googlegroups.com> <20100212164508.GA1824@protagoras.phil.berkeley.edu> <20100212175057.GA32117@excelii.com> Message-ID: <20100212185159.GE21071@whirlpool.galois.com> jgoerzen: > On Fri, Feb 12, 2010 at 08:45:09AM -0800, John MacFarlane wrote: > > +++ thomas hartman [Feb 11 10 21:07 ]: > > > gitit on hackage is still blocked because of dependency on missingh, > > > which depends on qc1. Not an easy fix -- I couldn't figure out how to > > > migrate testpack to qc2. > > > > > > However, missingh dependency was removed from gitit head > > > > > > http://github.com/jgm/gitit > > > > > > so that's good. > > > > No, gitit head still depends on MissingH, via ConfigFile. > > > > I imagine John will update MissingH to use QuickCheck2 soon... > > Hey guys, I took a look at MissingH and there was no need for the main > library to depend on QuickCheck in the first place. It was only > needed by the tests. So I've uploaded a new MissingH 1.1.0.2 to > Hackage that drops that dep. > > That ought to solve it for you. Excellent! Would it be possible to disable the runtests executable by default? Enable it only with a conditional? -- Don From jgoerzen at complete.org Fri Feb 12 14:07:56 2010 From: jgoerzen at complete.org (John Goerzen) Date: Fri Feb 12 13:39:01 2010 Subject: [Haskell-cafe] Re: MissingH dropped QuickCheck dep In-Reply-To: <20100212185159.GE21071@whirlpool.galois.com> References: <9066fa251001272138v63e5b306ic7943aaf8692a912@mail.gmail.com> <20100128055450.GA24676@whirlpool.galois.com> <8d862979-0364-4af9-8890-3900ac4c3e0b@k6g2000prg.googlegroups.com> <20100212164508.GA1824@protagoras.phil.berkeley.edu> <20100212175057.GA32117@excelii.com> <20100212185159.GE21071@whirlpool.galois.com> Message-ID: <4B75A70C.6020209@complete.org> Don Stewart wrote: > Excellent! > > Would it be possible to disable the runtests executable by default? > Enable it only with a conditional? It's been that way for quite some time now: Executable runtests Buildable: False heh, and I didn't even add a flag for it yet like I have with HDBC. Guess I ought to do that so a person can build tests more easily if they wish. -- John From andrewcoppin at btinternet.com Fri Feb 12 14:11:03 2010 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Feb 12 13:41:55 2010 Subject: [Haskell-cafe] Type arithmetic with ATs/TFs In-Reply-To: <2f9b2d31002111441j2382652fs10a629fcca4e8957@mail.gmail.com> References: <4B730935.6030901@btinternet.com> <4B74724A.9090307@btinternet.com> <2f9b2d31002111441j2382652fs10a629fcca4e8957@mail.gmail.com> Message-ID: <4B75A7C7.9060906@btinternet.com> Ryan Ingram wrote: > Actually, at least in GHC, associated types are just syntax sugar for > type families. > > That is, this code: > > class Container c where > type Element c :: * > view :: c -> Maybe (Element c,c) > > instance Container [a] where > type Element [a] = a > view [] = Nothing > view (x:xs) = Just (x,xs) > > is the same as this code: > > type family Element c :: * > class Container c where > view :: c -> Maybe (Element c, c) > type instance Container [a] = a > instance Container [a] where > view [] = Nothing > view (x:xs) = Just (x,xs) > OK, well in that case, I'm utterly puzzled as to why both forms exist in the first place. If TFs don't allow you to do anything that can't be done with ATs, why have them? My head hurts... From andrewcoppin at btinternet.com Fri Feb 12 14:11:56 2010 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Feb 12 13:42:48 2010 Subject: [Haskell-cafe] Type arithmetic with ATs/TFs In-Reply-To: <4ec472cb1002111455y21bee180sf7ddf6dd9d65b82a@mail.gmail.com> References: <4B730935.6030901@btinternet.com> <4B74724A.9090307@btinternet.com> <4ec472cb1002111455y21bee180sf7ddf6dd9d65b82a@mail.gmail.com> Message-ID: <4B75A7FC.4020005@btinternet.com> Robert Greayer wrote: > What Ryan said, and here's an example of addition with ATs, > specifically (not thoroughly tested, but tested a little). The > translation to TFs sans ATs is straightforward. > > class Add a b where > type SumType a b > > instance Add Zero Zero where > type SumType Zero Zero = Zero > > instance Add (Succ a) Zero where > type SumType (Succ a) Zero = Succ a > > instance Add Zero (Succ a) where > type SumType Zero (Succ a) = Succ a > > instance Add (Succ a) (Succ b) where > type SumType (Succ a) (Succ b) = Succ (Succ (SumType a b)) > I'm pretty sure this is almost exactly what I wrote in the first place, and it didn't work. I'll try again and see if I get anywhere... From uzytkownik2 at gmail.com Fri Feb 12 14:27:10 2010 From: uzytkownik2 at gmail.com (Maciej Piechotka) Date: Fri Feb 12 13:58:12 2010 Subject: Iteratee and parsec (was: Re: [Haskell-cafe] Re: Haskell-Cafe Digest, Vol 78, Issue 14) In-Reply-To: <9979e72e1002120451k6456ec14g7d98601549aea4d@mail.gmail.com> References: <20100209133545.82064324655@www.haskell.org> <9979e72e1002090841x4916e029qf32fad7abc8854d3@mail.gmail.com> <1265883701.5700.55.camel@picard> <87y6izhieu.fsf@gregorycollins.net> <9979e72e1002111549i4c620714v1e51b3bd382f9a67@mail.gmail.com> <1265970745.9281.10.camel@picard> <9979e72e1002120451k6456ec14g7d98601549aea4d@mail.gmail.com> Message-ID: <1266002830.12673.26.camel@picard> On Fri, 2010-02-12 at 12:51 +0000, John Lato wrote: > > Yes, the remaining part will be returned, but the consumed portion is > lost. I couldn't figure out how to solve that problem other than > cacheing everything. > I decided to post the new code on webpage (http://www.doc.ic.ac.uk/~mmp08/iteratee/) to not spam everyone's inbox. I think you want something more like safeParsecIteratee from my code. From the same CPU more random numbers (I wonder how they'll look like in a month when BS problems will be resolved). For ByteString: Maciej's Maciej's Safe John's Short parser 5: 0.000144s 0.000040s 0.000067s 10: 0.000052s 0.000042s 0.000048s 15: 0.000053s 0.000052s 0.000061s 20: 0.000041s 0.000033s 0.000039s 50: 0.000054s 0.000049s 0.000111s 100: 0.000082s 0.000101s 0.000254s 1000: 0.000610s 0.000623s 0.014414s 10000: 0.007069s 0.007947s 1.197706s 100000: 0.058025s 0.057382s 117.231680s Short failing parser 5: 0.000104s 0.000030s 0.000026s 10: 0.000028s 0.000024s 0.000023s 15: 0.000026s 0.000025s 0.000031s 20: 0.000027s 0.000028s 0.000025s 50: 0.000027s 0.000025s 0.000042s 100: 0.000026s 0.000024s 0.000023s 1000: 0.000024s 0.000023s 0.000023s 10000: 0.000259s 0.000025s 0.000022s 100000: 0.000025s 0.000039s 0.000024s Failing parser 5: 0.000025s 0.000024s 0.000022s 10: 0.000027s 0.000024s 0.000026s 15: 0.000028s 0.000028s 0.000031s 20: 0.000032s 0.000045s 0.000038s 50: 0.000045s 0.000045s 0.000096s 100: 0.000069s 0.000144s 0.000228s 1000: 0.000544s 0.000512s 0.013124s 10000: 0.004760s 0.004695s 1.240703s 100000: 0.046858s 0.046897s 119.860964s For []: Maciej's Maciej's Safe John's Short parser 5: 0.000215s 0.000141s 0.000541s 10: 0.000054s 0.000286s 0.000178s 15: 0.000046s 0.000078s 0.000248s 20: 0.000130s 0.000050s 0.000420s 50: 0.000066s 0.000200s 0.000785s 100: 0.000176s 0.000240s 0.001522s 1000: 0.000826s 0.000857s 0.014399s 10000: 0.006674s 0.007185s 0.381615s 100000: 0.062452s 0.065178s 31.454621s Short failing parser 5: 0.000210s 0.000054s 0.000099s 10: 0.000096s 0.000037s 0.000104s 15: 0.000059s 0.000039s 0.000184s 20: 0.000038s 0.000036s 0.000114s 50: 0.000037s 0.000100s 0.000111s 100: 0.000165s 0.000037s 0.000103s 1000: 0.000079s 0.000036s 0.000103s 10000: 0.000037s 0.000037s 0.000179s 100000: 0.000037s 0.000168s 0.000104s Failing parser 5: 0.000037s 0.000090s 0.000089s 10: 0.000157s 0.000055s 0.000169s 15: 0.000062s 0.000039s 0.000303s 20: 0.000043s 0.000194s 0.000311s 50: 0.000183s 0.000056s 0.000780s 100: 0.000080s 0.000172s 0.001624s 1000: 0.000714s 0.000714s 0.014076s 10000: 0.005451s 0.006890s 0.379960s 100000: 0.052609s 0.055770s 31.537776s The timings where about the same in every run. Also it seems that keeping reference to input does not create significant slow-down if it is not an artefact of testing method. Short failing parser probably have somewhere an error. > Interesting. I expect good performance as long as chunks don't need > to be concatenated. The default chunk size is either 4096 or 8192 (I > don't remember ATM). This also assumes that no intervening functions > (take, drop, etc.) alter the stream too significantly. Testing 1e5 > wouldn't do more than two concats, and particularly with bytestrings > shouldn't impose too much penalty. List performance would be much > worse though. > With 1e5 it should have 1e5/(4e3 or 8e3) \approx 10-20 concats. > > > > Regards > > PS. Why iteratee uses transformers? It seems to be identical (both have > > functional dependencies etc.) to mtl except that mtl is standard in > > platform. Using both lead to clashes between names. > > Short answer: I am using iteratee with another package that uses transformers. > Longer answer: see discussions on mtl vs. transformers in the > haskell-libraries archive. I'll read them. I will ask one more question regarding iteratee. Why StreamChunk have 10 methods which already are in ListLike? Regards -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100212/3b93ff43/attachment.bin From andrewcoppin at btinternet.com Fri Feb 12 14:33:20 2010 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Fri Feb 12 14:04:11 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <4B757ADC.2010801@gmail.com> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> <4B74451C.5030607@henning-thielemann.de> <20100211180923.GA20618@sliver.repetae.net> <4B757ADC.2010801@gmail.com> Message-ID: <4B75AD00.40205@btinternet.com> Simon Marlow wrote: > On 11/02/2010 20:57, Alp Mestanogullari wrote: >> It seems quite big for a 3 months project made by a student, though. > > No kidding :-) I last rewrote the RTS in 1998: > > but even so, it was about 20k lines. Man, that's at least two orders of magnitude larger than anything I've ever written in my entire life! And to think that's just the RTS - the part of GHC that most people don't neven notice. ;-) Did you really write all that code single-handedly? Also... Those old release notes are some hard-core nostalga. ;-) "At least 32 MB of RAM"... that's special. As is the list of "new" features in GHC. (Exceptions. Ooo!) From robgreayer at gmail.com Fri Feb 12 15:32:10 2010 From: robgreayer at gmail.com (Robert Greayer) Date: Fri Feb 12 15:03:12 2010 Subject: [Haskell-cafe] Type arithmetic with ATs/TFs In-Reply-To: <4B75A7C7.9060906@btinternet.com> References: <4B730935.6030901@btinternet.com> <4B74724A.9090307@btinternet.com> <2f9b2d31002111441j2382652fs10a629fcca4e8957@mail.gmail.com> <4B75A7C7.9060906@btinternet.com> Message-ID: <4ec472cb1002121232g6cedbc80j1f992790862e7b2@mail.gmail.com> On Fri, Feb 12, 2010 at 2:11 PM, Andrew Coppin wrote: > OK, well in that case, I'm utterly puzzled as to why both forms exist in the > first place. If TFs don't allow you to do anything that can't be done with > ATs, why have them? > > My head hurts... > I think the question is the reverse -- why do ATs exist when you can do everything with the more general Type Families? This is the answer from the GHC documentation: "Type families appear in two flavours: (1) they can be defined on the toplevel or (2) they can appear inside type classes (in which case they are known as associated type synonyms). The former is the more general variant, as it lacks the requirement for the type-indices to coincide with the class parameters. However, the latter can lead to more clearly structured code and compiler warnings if some type instances were - possibly accidentally - omitted." http://www.haskell.org/haskellwiki/GHC/Indexed_types#Detailed_definition_of_type_synonym_families From byorgey at seas.upenn.edu Fri Feb 12 16:01:24 2010 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Fri Feb 12 15:32:27 2010 Subject: [Haskell-cafe] Call for Copy: Monad.Reader Issue 16 Message-ID: <20100212210124.GA27020@seas.upenn.edu> Call for Copy: The Monad.Reader - Issue 16 ------------------------------------------ Whether you're an established academic or have only just started learning Haskell, if you have something to say, please consider writing an article for The Monad.Reader! The submission deadline for Issue 16 will be: **Friday, April 16, 2010** The Monad.Reader ~~~~~~~~~~~~~~~~ The Monad.Reader is a electronic magazine about all things Haskell. It is less formal than journal, but somehow more enduring than a wiki- page. There have been a wide variety of articles: exciting code fragments, intriguing puzzles, book reviews, tutorials, and even half-baked research ideas. Submission Details ~~~~~~~~~~~~~~~~~~ Get in touch with me if you intend to submit something -- the sooner you let me know what you're up to, the better. Please submit articles for the next issue to me by e-mail (byorgey at cis.upenn.edu). Articles should be written according to the guidelines available from http://themonadreader.wordpress.com/contributing/ Please submit your article in PDF, together with any source files you used. The sources will be released together with the magazine under a BSD license. If you would like to submit an article, but have trouble with LaTeX please let me know and we'll work something out. From ekmett at gmail.com Fri Feb 12 16:10:18 2010 From: ekmett at gmail.com (Edward Kmett) Date: Fri Feb 12 15:41:19 2010 Subject: [Haskell-cafe] Type arithmetic with ATs/TFs In-Reply-To: <4B75A7C7.9060906@btinternet.com> References: <4B730935.6030901@btinternet.com> <4B74724A.9090307@btinternet.com> <2f9b2d31002111441j2382652fs10a629fcca4e8957@mail.gmail.com> <4B75A7C7.9060906@btinternet.com> Message-ID: <7fb8f82f1002121310u6c8a7dbevd9c66934b5ec4605@mail.gmail.com> On Fri, Feb 12, 2010 at 2:11 PM, Andrew Coppin wrote: > OK, well in that case, I'm utterly puzzled as to why both forms exist in > the first place. If TFs don't allow you to do anything that can't be done > with ATs, why have them? > > My head hurts... You can say anything you might say with type families using GADTs, but you'll often be talking about stuff you don't care about. =) sometimes you don't care what the Element type of a container is, just that it is a container. Yet using GADTs you must always reference the content type. size :: Container' c e => c -> Int -- using Container' defined with GADTs as opposed to size :: Container c => c -> Int That doesn't seem like a huge sacrifice at first, until you start considering things like: http://hackage.haskell.org/packages/archive/category-extras/0.53.5/doc/html/Control-Category-Cartesian-Closed.html Instead of just being able to talk about a CCC based on the type used for its homomorphisms, now I must constantly talk about the type used for its product, and exponentials, and the identity of the product, even when I don't care about those properties! This ability to not talk about those extra types becomes useful when you start defining data types. Say you define a simple imperative growable hash data type, parameterized over the monad type. You could do so with TFs fairly easily: newtype Hash m k v = Hash (Ref m (Array Int (Ref m [(k,v)]))) empty :: MonadRef m => m (Hash m k v) insert :: (Hashable k, MonadRef m) => k -> v -> Hash m k v -> m () But the GADT version leaks implementation-dependent details out to the data type: newtype Hash r k v = Hash (r (Array Int (r [(k,v)]))) empty :: MonadRef m r => m (Hash r k v) insert :: (Hashable k, MonadRef m r) => k -> v -> Hash r k v -> m () This gets worse as you need more and more typeclass machinery. On the other hand, GADTs are useful when you want to define multidirectional mutual dependencies without repeating yourself. Each is a win in terms of the amount of boilerplate you have to write in different circumstances. class Foo a b c | a b -> c, b c -> a, c a -> b where foo :: a -> b -> c would require 3 different class associate types, one for each fundep. -Edward Kmett -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100212/bf1db310/attachment.html From alistair at abayley.org Fri Feb 12 16:45:10 2010 From: alistair at abayley.org (Alistair Bayley) Date: Fri Feb 12 16:16:11 2010 Subject: [Haskell-cafe] Haskell IDEs on Windows; gtk2hs Message-ID: <79d7c4981002121345w60da5efbl9b8e864b0b3cbe11@mail.gmail.com> I thought I'd try some of the Haskell IDEs: eclipsefp, leksah, and yi. So far, leksah requires gtk2hs (and apparently yi can use it too?), and the latest gtk2hs installer for Windows doesn't like the latest Haskell Platform, so I'm going to try building gtk2hs from source, unless anyone tells me that it's a waste of time. Building yi fails with: Yi\Prelude.hs:182:9: Duplicate instance declarations: instance Category Accessor.T -- Defined at Yi\Prelude.hs:182:9-38 instance Category Accessor.T -- Defined in data-accessor-0.2.1.2:Data.Accessor.Private cabal: Error: some packages failed to install: yi-0.6.1 failed during the building phase. The exception was: exit: ExitFailure 1 Presumably data-accessor has been updated, but yi has not? What is the easiest fix? Downgrade to an earlier version of data-accessor? So that just leaves eclipsefp. Still trying to figure out how to install eclipse plugins... Alistair From daniel.is.fischer at web.de Fri Feb 12 17:08:19 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Fri Feb 12 16:41:16 2010 Subject: [Haskell-cafe] Haskell IDEs on Windows; gtk2hs In-Reply-To: <79d7c4981002121345w60da5efbl9b8e864b0b3cbe11@mail.gmail.com> References: <79d7c4981002121345w60da5efbl9b8e864b0b3cbe11@mail.gmail.com> Message-ID: <201002122308.19822.daniel.is.fischer@web.de> Am Freitag 12 Februar 2010 22:45:10 schrieb Alistair Bayley: > I thought I'd try some of the Haskell IDEs: eclipsefp, leksah, and yi. > So far, leksah requires gtk2hs (and apparently yi can use it too?), > and the latest gtk2hs installer for Windows doesn't like the latest > Haskell Platform, so I'm going to try building gtk2hs from source, > unless anyone tells me that it's a waste of time. > > Building yi fails with: > > Yi\Prelude.hs:182:9: > Duplicate instance declarations: > instance Category Accessor.T -- Defined at Yi\Prelude.hs:182:9-38 > instance Category Accessor.T > -- Defined in data-accessor-0.2.1.2:Data.Accessor.Private > cabal: Error: some packages failed to install: > yi-0.6.1 failed during the building phase. The exception was: > exit: ExitFailure 1 > > Presumably data-accessor has been updated, but yi has not? What is the > easiest fix? Downgrade to an earlier version of data-accessor? You would need to edit the .cabal file anyway so that the older version of data-accessor would be used. Since you need to unpack the package and edit a file anyway, you might as well comment out the instance declaration in Yi/Prelude.hs (I think). > > So that just leaves eclipsefp. Still trying to figure out how to > install eclipse plugins... > > Alistair From waldmann at imn.htwk-leipzig.de Fri Feb 12 17:25:13 2010 From: waldmann at imn.htwk-leipzig.de (Johannes Waldmann) Date: Fri Feb 12 16:56:23 2010 Subject: [Haskell-cafe] haddock forgets parens in type sigs? Message-ID: <4B75D549.3060407@imn.htwk-leipzig.de> The annotated type of "update" is missing parentheses: http://hackage.haskell.org/packages/archive/haskelldb/0.12/doc/html/Database-HaskellDB.html#v%3Aupdate (compare with the signature given in the source) - Best, J.W. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 260 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100212/3d5487a1/signature.bin From lrpalmer at gmail.com Fri Feb 12 18:11:43 2010 From: lrpalmer at gmail.com (Luke Palmer) Date: Fri Feb 12 17:42:43 2010 Subject: [Haskell-cafe] Type arithmetic with ATs/TFs In-Reply-To: <7fb8f82f1002121310u6c8a7dbevd9c66934b5ec4605@mail.gmail.com> References: <4B730935.6030901@btinternet.com> <4B74724A.9090307@btinternet.com> <2f9b2d31002111441j2382652fs10a629fcca4e8957@mail.gmail.com> <4B75A7C7.9060906@btinternet.com> <7fb8f82f1002121310u6c8a7dbevd9c66934b5ec4605@mail.gmail.com> Message-ID: <7ca3f0161002121511x31aec2f0v358c5c541c48620e@mail.gmail.com> On Fri, Feb 12, 2010 at 2:10 PM, Edward Kmett wrote: > On Fri, Feb 12, 2010 at 2:11 PM, Andrew Coppin > wrote: >> >> OK, well in that case, I'm utterly puzzled as to why both forms exist in >> the first place. If TFs don't allow you to do anything that can't be done >> with ATs, why have them? >> >> My head hurts... > s/GADT/Fundep/g ? > You can say anything you might say with type families using GADTs, but > you'll often be talking about stuff you don't care about. =) > > sometimes you don't care what the Element type of a container is, just that > it is a container. Yet using GADTs you must always reference the content > type. > > size :: Container' c e => c -> Int -- using Container' defined with GADTs > > as opposed to > > size :: Container c => c -> Int > > That doesn't seem like a huge sacrifice at first, until you start > considering things like: > > http://hackage.haskell.org/packages/archive/category-extras/0.53.5/doc/html/Control-Category-Cartesian-Closed.html > > Instead of just being able to talk about a CCC based on the type used for > its homomorphisms, now I must constantly talk about the type used for its > product, and exponentials, and the identity of the product, even when I > don't care about those properties! > > This ability to not talk about those extra types becomes useful when you > start defining data types. > > Say you define a simple imperative growable hash data type, parameterized > over the monad type. You could do so with TFs fairly easily: > > newtype Hash m k v = Hash (Ref m (Array Int (Ref m [(k,v)]))) > empty :: MonadRef m => m (Hash m k v) > insert :: (Hashable k, MonadRef m) => k -> v -> Hash m k v -> m () > > But the GADT version leaks implementation-dependent details out to the data > type: > > newtype Hash r k v = Hash (r (Array Int (r [(k,v)]))) > empty :: MonadRef m r => m (Hash r k v) > insert :: (Hashable k, MonadRef m r) => k -> v -> Hash r k v -> m () > > This gets worse as you need more and more typeclass machinery. > > On the other hand, GADTs are useful when you want to define multidirectional > mutual dependencies without repeating yourself. Each is a win in terms of > the amount of boilerplate you have to write in different circumstances. > > class Foo a b c | a b -> c, b c -> a, c a -> b where > ??? foo :: a -> b -> c > > would require 3 different class associate types, one for each fundep. > > -Edward Kmett > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From dagit at codersbase.com Fri Feb 12 18:17:26 2010 From: dagit at codersbase.com (Jason Dagit) Date: Fri Feb 12 17:48:26 2010 Subject: [Haskell-cafe] Where are the Takusen sources? Message-ID: Hello, I wanted the takusen sources as I may want to add features. I looked on hackage and it lists this url for the repository: http://darcs.haskell.org/takusen I get a 404 on that URL. I checked Oleg's website: http://okmij.org/ftp/Haskell/misc.html#takusen And the links on that page have similar problems. I see that the 0.8.5 release has source on hackage, but I would prefer access to the full repository as I may want to send patches. Does anyone know what has happened to Takusen? Thanks, Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100212/f243e33c/attachment.html From allbery at ece.cmu.edu Fri Feb 12 18:24:11 2010 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Fri Feb 12 17:55:16 2010 Subject: [Haskell-cafe] Where are the Takusen sources? In-Reply-To: References: Message-ID: <9A9AED2B-9719-4B92-A9EB-60E4EEFED4F8@ece.cmu.edu> Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100212/6922dc52/PGP-0001.bin From david.waern at gmail.com Fri Feb 12 18:58:03 2010 From: david.waern at gmail.com (David Waern) Date: Fri Feb 12 18:29:06 2010 Subject: [Haskell-cafe] haddock forgets parens in type sigs? In-Reply-To: <4B75D549.3060407@imn.htwk-leipzig.de> References: <4B75D549.3060407@imn.htwk-leipzig.de> Message-ID: 2010/2/12 Johannes Waldmann : > The annotated type of "update" is missing parentheses: > http://hackage.haskell.org/packages/archive/haskelldb/0.12/doc/html/Database-HaskellDB.html#v%3Aupdate > (compare with the signature given in the source) - Best, J.W. Already fixed in the darcs version. Stay tuned for the next release. David From felipe.lessa at gmail.com Fri Feb 12 20:04:19 2010 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Fri Feb 12 19:35:25 2010 Subject: [Haskell-cafe] ANN: hmatrix 0.8.3 In-Reply-To: <4B755E28.2060303@um.es> References: <4B755E28.2060303@um.es> Message-ID: <20100213010419.GA15829@kira.casa> On Fri, Feb 12, 2010 at 02:56:56PM +0100, Alberto Ruiz wrote: > I have released a new version of hmatrix, a library for numeric > computation based on LAPACK, BLAS and GSL. Recent developments > include improved SVD functions, a simple ODE solver, easier OS/X > installation (thanks to H. Apfelmus), and updated tutorial. Thanks for working on this nice package! Cheers, -- Felipe. From dagit at codersbase.com Fri Feb 12 20:04:39 2010 From: dagit at codersbase.com (Jason Dagit) Date: Fri Feb 12 19:35:44 2010 Subject: [Haskell-cafe] Where are the Takusen sources? In-Reply-To: <9A9AED2B-9719-4B92-A9EB-60E4EEFED4F8@ece.cmu.edu> References: <9A9AED2B-9719-4B92-A9EB-60E4EEFED4F8@ece.cmu.edu> Message-ID: On Fri, Feb 12, 2010 at 3:24 PM, Brandon S. Allbery KF8NH < allbery@ece.cmu.edu> wrote: > On Feb 12, 2010, at 18:17 , Jason Dagit wrote: > > I wanted the takusen sources as I may want to add features. I looked on > hackage and it lists this url for the repository: > http://darcs.haskell.org/takusen > > > In general, stuff that was on darcs.haskell.org (which is being retired) > seems to be moving to code.haskell.org. I found > http://code.haskell.org/takusen and it looks reasonably up to date (10 > Feb). > Great! Thanks! Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100212/8de65b6c/attachment.html From john at repetae.net Fri Feb 12 20:56:04 2010 From: john at repetae.net (John Meacham) Date: Fri Feb 12 20:27:05 2010 Subject: [Haskell-cafe] haskell-src type inference algorithm? In-Reply-To: <4d8ad03a1002112047g4afc777q864e1a4ce7fa83e4@mail.gmail.com> References: <4d8ad03a1002112047g4afc777q864e1a4ce7fa83e4@mail.gmail.com> Message-ID: <20100213015604.GD20618@sliver.repetae.net> On Fri, Feb 12, 2010 at 03:47:56PM +1100, Bernie Pope wrote: > On 12 February 2010 10:13, Niklas Broberg wrote: > >> Anyone know of a type inference utility that can run right on haskell-src > >> types? or one that could be easily adapted? > > > > This is very high on my wish-list for haskell-src-exts, and I'm hoping > > the stuff Lennart will contribute will go a long way towards making it > > feasible. I believe I can safely say that no such tool exists (and if > > it does, why haven't you told me?? ;-)), but if you implement (parts > > of) one yourself I'd be more than interested to see, and incorporate, > > the results. > > A long time ago I worked on hatchet: > > http://www.cs.mu.oz.au/~bjpop/hatchet/src/hatchet.tar.gz > > which I believe was incorporated into JHC. Yes, hatchet formed the base of the original type checker for jhc. It has since been fully replaced, probably twice over, but jhc could not have gotten off the ground without it. John -- John Meacham - ?repetae.net?john? - http://notanumber.net/ From jwlato at gmail.com Fri Feb 12 22:30:20 2010 From: jwlato at gmail.com (John Lato) Date: Fri Feb 12 22:01:22 2010 Subject: [Haskell-cafe] data-accessor-template-0.2.1.3 breaks cabal-install with ghc-6.12 Message-ID: <9979e72e1002121930g3d37f3b9qa122e43fd0075699@mail.gmail.com> Hello, I've recently run across an odd situation. I have a brand new install of GHC-6.12.1 (just did a fresh install of OSX 10.6), and am reinstalling some libraries. I've run into an unusual problem. I'm not sure if this would be considered a cabal bug or not, but I don't think it's a good situation. data-accessor-template depends upon template-haskell (>=2.2 && <2.4), unless built with the flag -ftemplate_2_4, in which case it depends upon template-haskell 2.4 (appropriate for ghc-6.12.1). The relevant lines of the .cabal file are: Flag template_2_4 description: Adapt to TemplateHaskell version of GHC-6.12 default: False If flag(template_2_4) Hs-Source-Dirs: src-5 Build-Depends: template-haskell >=2.4 && <2.5 Else Hs-Source-Dirs: src-3 Build-Depends: template-haskell >=2.2 && <2.4 I can install data-accessor-template when the template_2_4 flag is used, but then when I try to install a package that depends upon data-accessor-template cabal-install calculates the template-haskell >=2.2 && <2.4 dependency and attempts to fulfill it. Which fails at packedstring (can't find Data.Data in a hidden base package). I've included output from attempting to install Chart that demonstrates the behavior. Note that even though cabal-install sees data-accessor-template as installed, it attempts to reinstall it. John-Latos-MacBook:packages johnlato$ cabal install -v -O Chart In order, the following would be installed: packedstring-0.1.0.1 (new package) template-haskell-2.3.0.1 (new version) data-accessor-template-0.2.1.3 (reinstall) changes: template-haskell-2.4.0.0 -> 2.3.0.1 Chart-0.12 (new package) This affects everything down the dependency tree, notably Chart, criterion, and yi. I can work around this by specifying a previous version of data-accessor-template, but unfortunately I don't know how to address the real problem. Cheers, John From shumovichy at gmail.com Sat Feb 13 03:44:29 2010 From: shumovichy at gmail.com (Yuras Shumovich) Date: Sat Feb 13 03:15:29 2010 Subject: [Haskell-cafe] hsWidgets: yet another GUI library Message-ID: <1d6a9f301002130044x581f75b4q340bf2106a1fc81a@mail.gmail.com> Hello First of all, sorry my pure english... My aim was to prove that haskell GUI library can be: - pure: does not use any kind of mutable variables - statically typed: does not use existential types, Data.Dynamic, etc. - easy to use: simple things should be simple - easy to extend: writing new widgets should be as simple as possible The result is here: http://community.haskell.org/~YurasShumovich/hsWidgets/ Usage example: http://community.haskell.org/~YurasShumovich/hsWidgets/src/Test.hs The library is based on X11 and is tested on Linux and Mac OS. It is only an experiment in haskell GUI design, so it is mainly useless (currently only label, button and button with label are implemented) and looks ugly. Your comments and ideas are highly welcome. From tomahawkins at gmail.com Sat Feb 13 06:10:55 2010 From: tomahawkins at gmail.com (Tom Hawkins) Date: Sat Feb 13 05:41:54 2010 Subject: [Haskell-cafe] ANN: atom-1.0.0 Message-ID: <594c1e831002130310v7e5e92bci8439eab9b7794d1@mail.gmail.com> Atom is a Haskell DSL for designing hard realtime embedded software. The 1.0 release is meant to indicate some level of stability; most of the core has been unchanged for quite some time. That said, there are a few interesting changes in 1.0. First the var' family of variable declarations (bool', word8', double', etc.) are no longer part of the Atom monad. For example: bool' :: Name -> V Bool This cleaned up quite a bit of code in our production design. This also made the randomization in Atom's unit testing framework monadless as well. The other significant change with 1.0 is all state variables are now packed into a hierarchical C structure that matches the hierarchy of the Atom design. Not only does this make the generated C a bit more legible, it is now possible to interface external C code directly to Atom's state variables and arrays. Prior to this change, all interfacing had to be done through var' declarations and action calls -- too often a messy process. To further aid interfacing to external code, Atom now generates a header file that exposes both the iterative function and the hierarchical state structure. -Tom http://hackage.haskell.org/package/atom From kg2007.kg at gmail.com Sat Feb 13 08:03:12 2010 From: kg2007.kg at gmail.com (kg) Date: Sat Feb 13 07:32:45 2010 Subject: [Haskell-cafe] What is the meaning of tilde ("~") symbol Message-ID: <4B76A310.9090406@gmail.com> Hi, I'm reading the following subject : http://www.haskell.org/pipermail/haskell-cafe/2007-July/028227.html In the sample code, we can see : instance ReadAsAnyOf () ex where readAsAnyOf ~() = mzero And, I've search the meaning of the symbol "~", but I've found nothing about this (note that's not easy to search "~" on google ...) Could you give me a link about this, or explain me it ? Thx in advance. From uzytkownik2 at gmail.com Sat Feb 13 08:08:03 2010 From: uzytkownik2 at gmail.com (Maciej Piechotka) Date: Sat Feb 13 07:39:21 2010 Subject: [Haskell-cafe] Re: What is the meaning of tilde ("~") symbol In-Reply-To: <4B76A310.9090406@gmail.com> References: <4B76A310.9090406@gmail.com> Message-ID: <1266066483.12673.27.camel@picard> On Sat, 2010-02-13 at 14:03 +0100, kg wrote: > Hi, > > I'm reading the following subject : > http://www.haskell.org/pipermail/haskell-cafe/2007-July/028227.html > > In the sample code, we can see : > > instance ReadAsAnyOf () ex > where readAsAnyOf ~() = mzero > > > > And, I've search the meaning of the symbol "~", but I've found nothing > about this (note that's not easy to search "~" on google ...) > > Could you give me a link about this, or explain me it ? > > Thx in advance. http://www.haskell.org/tutorial/patterns.html - Section lazy patterns Regards -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100213/b22ee794/attachment.bin From marlowsd at gmail.com Sat Feb 13 11:47:42 2010 From: marlowsd at gmail.com (Simon Marlow) Date: Sat Feb 13 11:18:45 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <4B75AD00.40205@btinternet.com> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> <4B74451C.5030607@henning-thielemann.de> <20100211180923.GA20618@sliver.repetae.net> <4B757ADC.2010801@gmail.com> <4B75AD00.40205@btinternet.com> Message-ID: <4B76D7AE.2040501@gmail.com> On 12/02/10 19:33, Andrew Coppin wrote: > Simon Marlow wrote: >> On 11/02/2010 20:57, Alp Mestanogullari wrote: >>> It seems quite big for a 3 months project made by a student, though. >> >> No kidding :-) I last rewrote the RTS in 1998: >> >> but even so, it was about 20k lines. > > Man, that's at least two orders of magnitude larger than anything I've > ever written in my entire life! And to think that's just the RTS - the > part of GHC that most people don't neven notice. ;-) > > Did you really write all that code single-handedly? Not entirely, I cribbed heavily from the old RTS which was written by various people but mostly Will Partain, and some was written by Alastair Reid who was working on porting Hugs to use GHC's RTS at the time - it was the death of that project that prompted us to build GHCi, which first appeared in GHC version 5.00. Cheers, Simon From hjgtuyl at chello.nl Sat Feb 13 15:49:53 2010 From: hjgtuyl at chello.nl (Henk-Jan van Tuyl) Date: Sat Feb 13 15:20:48 2010 Subject: [Haskell-cafe] ANN: Dungeons of Wor - a largish FRP example and a fun game, all in one! In-Reply-To: <1265877335.18142.1359423573@webmail.messagingengine.com> References: <1265877335.18142.1359423573@webmail.messagingengine.com> Message-ID: On Thu, 11 Feb 2010 09:35:35 +0100, Patai Gergely wrote: > I just uploaded the first public version of Dungeons of Wor [1], a > [1] http://hackage.haskell.org/package/dow I tried it, but after briefly displaying a window, the program terminates with the message: dow: user error (unknown OpenGL extension entry glTexParameteri, check for OpenGL 3.1) I suppose the program needs a newer version than is supplied with Windows (opengl.org states that Microsoft always includes an old version of OpenGL [1]) Does anybody know how to deal with this? Regards, Henk-Jan van Tuyl [1] http://www.opengl.org/wiki/Getting_started#OpenGL_2.0.2B_and_extensions -- http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html -- From felipe.lessa at gmail.com Sat Feb 13 16:07:53 2010 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sat Feb 13 15:38:57 2010 Subject: [Haskell-cafe] ANN: Dungeons of Wor - a largish FRP example and a fun game, all in one! In-Reply-To: References: <1265877335.18142.1359423573@webmail.messagingengine.com> Message-ID: <20100213210753.GB6526@kira.casa> On Sat, Feb 13, 2010 at 09:49:53PM +0100, Henk-Jan van Tuyl wrote: > I tried it, but after briefly displaying a window, the program > terminates with the message: > dow: user error (unknown OpenGL extension entry glTexParameteri, > check for OpenGL 3.1) > > I suppose the program needs a newer version than is supplied with > Windows (opengl.org states that Microsoft always includes an old > version of OpenGL [1]) > Does anybody know how to deal with this? Just a thought: maybe it is something else. That function appears to exist since Windows 95 according msdn[1] and OpenGL 1.1[2]. [1] http://msdn.microsoft.com/en-us/library/dd368641(VS.85).aspx [2] http://www.talisman.org/opengl-1.1/Reference/glTexParameter.html HTH, -- Felipe. From gue.schmidt at web.de Sat Feb 13 16:12:15 2010 From: gue.schmidt at web.de (=?ISO-8859-1?Q?G=FCnther_Schmidt?=) Date: Sat Feb 13 15:43:40 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <3c6288ab1002100826x2034c079n789d3b392944208a@mail.gmail.com> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <3c6288ab1002100826x2034c079n789d3b392944208a@mail.gmail.com> Message-ID: <4B7715AF.4060903@web.de> Hi Sean, about the Haskell Summer School, who can participate and what does it cost? G?nther Am 10.02.10 17:26, schrieb Sean Leather: > I wonder how many people actually write Haskell, > principally or exclusively, at work? > > > I suppose you're implying non-academic jobs by that statement, but most > of the people in my research group develop programs in Haskell on a > daily basis. You'll find a number of libraries on Hackage from us. > > http://www.cs.uu.nl/staff/cur/IDX/sds.html > > As a shameless plug, I will also add that we have a great master's > program in which you can get your fill of Haskell and compilers, among > other things. > > http://www.cs.uu.nl/wiki/Master/ > > As second (but related) shameless plug, we also have a two-week-long > summer school which is an excellent way to jump-start the above master's > program or to get quickly up to speed on Haskell for business or > pleasure. The course is in August, and the deadline is May 1. > > http://www.utrechtsummerschool.nl/index.php?type=courses&code=H9 > > > Regards, > Sean > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From leon.p.smith at gmail.com Sat Feb 13 16:18:12 2010 From: leon.p.smith at gmail.com (Leon Smith) Date: Sat Feb 13 15:49:10 2010 Subject: [Haskell-cafe] Implementing "unionAll" Message-ID: With the urging and assistance of Omar Antol?n Camarena, I will be adding two functions to data-ordlist: mergeAll and unionAll, which merge (or union) a potentially infinite list of potentially infinite ordered lists, under the assumption that the heads of the non-empty lists appear in a non-decreasing sequence. Union takes two sorted lists and produces a new sorted list; an element occurs in the result as many times as the maximum number of occurrences in either list. The unionAll function generalizes this behavior to an infinite number of lists. A reasonable implementation of mergeAll is: > import Data.List.Ordered(merge, union) > mergeAll :: Ord a => [[a]] -> [a] > mergeAll = foldr (\(x:xs) ys -> x : merge xs ys) [] However, for many inputs, we can do better; the library implementation of mergeAll is based on H. Apfelmus's article "Implicit Heaps", which presents a simplification of Dave Bayer's "venturi" algorithm. The difference is that the foldr version uses a line of comparisons, whereas "venturi" uses a tree of comparisons. http://apfelmus.nfshost.com/articles/implicit-heaps.html http://www.mail-archive.com/haskell-cafe@haskell.org/msg27612.html However, as Omar pointed out to me, the following implementation of unionAll has a flaw: > unionAll :: Ord a => [[a]] -> [a] > unionAll = foldr (\(x:xs) ys -> x : union xs ys) [] Namely unionAll [[1,2],[1,2]] should return [1,2], whereas it actually returns [1,1,2]. After some work, I believe I have generalized H. Apfelmus's algorithm to handle this; however it seems a bit complicated. I would love feedback, especially with regard to simplifications, bugs, testing strategies, and optimizations: > unionAll' :: Ord a => [[a]] -> [a] > unionAll' = unionAllBy compare > data People a = VIP a (People a) | Crowd [a] > unionAllBy :: (a -> a -> Ordering) -> [[a]] -> [a] > unionAllBy cmp xss = loop [ (VIP x (Crowd xs)) | (x:xs) <- xss ] > where > loop [] = [] > loop ( VIP x xs : VIP y ys : xss ) > = case cmp x y of > LT -> x : loop ( xs : VIP y ys : xss ) > EQ -> loop ( VIP x (union' xs ys) : unionPairs xss ) > GT -> error "Data.List.Ordered.unionAll: assumption violated!" > loop ( VIP x xs : xss ) > = x : loop (xs:xss) > loop [Crowd xs] = xs > loop (xs:xss) = loop (unionPairs (xs:xss)) > > unionPairs [] = [] > unionPairs [x] = [x] > unionPairs (x:y:zs) = union' x y : unionPairs zs > > union' (VIP x xs) (VIP y ys) > = case cmp x y of > LT -> VIP x (union' xs (VIP y ys)) > EQ -> VIP x (union' xs ys) > GT -> error "Data.List.Ordered.unionAll: assumption violated!" > union' (VIP x xs) (Crowd ys) = VIP x (union' xs (Crowd ys)) > union' (Crowd []) ys = ys > union' (Crowd xs) (Crowd ys) = Crowd (unionBy cmp xs ys) > union' xs@(Crowd (x:xt)) ys@(VIP y yt) > = case cmp x y of > LT -> VIP x (union' (Crowd xt) ys) > EQ -> VIP x (union' (Crowd xt) yt) > GT -> VIP y (union' xs yt) -- Leon From limestrael at gmail.com Sat Feb 13 17:29:43 2010 From: limestrael at gmail.com (=?UTF-8?Q?Limestra=C3=ABl?=) Date: Sat Feb 13 17:00:42 2010 Subject: [Haskell-cafe] ANN: Dungeons of Wor - a largish FRP example and a fun game, all in one! In-Reply-To: <20100213210753.GB6526@kira.casa> References: <1265877335.18142.1359423573@webmail.messagingengine.com> <20100213210753.GB6526@kira.casa> Message-ID: <27579234.post@talk.nabble.com> Seems like today FRP is the last word in game programming with Haskell. Do you know something that could be a good tutorial, or at least introduction to FRP ? Something that could somewhat help me learn the ropes, 'cause I'm afraid if I dive directly into your code I'm gonna be lost. Good job, by the way. Yves Par?s Felipe Lessa wrote: > > On Sat, Feb 13, 2010 at 09:49:53PM +0100, Henk-Jan van Tuyl wrote: >> I tried it, but after briefly displaying a window, the program >> terminates with the message: >> dow: user error (unknown OpenGL extension entry glTexParameteri, >> check for OpenGL 3.1) >> >> I suppose the program needs a newer version than is supplied with >> Windows (opengl.org states that Microsoft always includes an old >> version of OpenGL [1]) >> Does anybody know how to deal with this? > > Just a thought: maybe it is something else. That function > appears to exist since Windows 95 according msdn[1] and OpenGL > 1.1[2]. > > [1] http://msdn.microsoft.com/en-us/library/dd368641(VS.85).aspx > [2] http://www.talisman.org/opengl-1.1/Reference/glTexParameter.html > > HTH, > > -- > Felipe. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- View this message in context: http://old.nabble.com/ANN%3A-Dungeons-of-Wor---a-largish-FRP-example-and-a-fun-game%2C-all-in-one%21-tp27543827p27579234.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From leather at cs.uu.nl Sat Feb 13 17:56:25 2010 From: leather at cs.uu.nl (Sean Leather) Date: Sat Feb 13 17:27:44 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <4B7715AF.4060903@web.de> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <3c6288ab1002100826x2034c079n789d3b392944208a@mail.gmail.com> <4B7715AF.4060903@web.de> Message-ID: <3c6288ab1002131456h43253594oe0c8b71eaa6a5421@mail.gmail.com> Hi G?nther, > about the Haskell Summer School, > > who can participate and what does it cost? > >> > As second (but related) shameless plug, we also have a two-week-long >> summer school which is an excellent way to jump-start the above master's >> program or to get quickly up to speed on Haskell for business or >> pleasure. The course is in August, and the deadline is May 1. >> >> http://www.utrechtsummerschool.nl/index.php?type=courses&code=H9 >> > The link above has all the details (more than I do) on the Utrecht Summer School for Applied Functional Programming. I don't believe there are any restrictions on who can participant, though the course is geared towards advanced bachelor's and beginning master's students. Since there are a limited number of spots, an applicant should try to put together a convincing application (e.g. write a good letter of motivation). Regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100213/8e0d8ca0/attachment.html From limestrael at gmail.com Sat Feb 13 19:30:13 2010 From: limestrael at gmail.com (=?UTF-8?Q?Yves_Par=C3=A8s?=) Date: Sat Feb 13 19:01:10 2010 Subject: [Haskell-cafe] ANN: atom-1.0.0 In-Reply-To: <594c1e831002130310v7e5e92bci8439eab9b7794d1@mail.gmail.com> References: <594c1e831002130310v7e5e92bci8439eab9b7794d1@mail.gmail.com> Message-ID: <27579930.post@talk.nabble.com> I've been interested in using Atom since I saw this: http://blog.sw17ch.com/wordpress/?p=84 However those samples are very outdated, do you have newer ones? Tom Hawkins-2 wrote: > > Atom is a Haskell DSL for designing hard realtime embedded software. > The 1.0 release is meant to indicate some level of stability; most of > the core has been unchanged for quite some time. > > That said, there are a few interesting changes in 1.0. First the var' > family of variable declarations (bool', word8', double', etc.) are no > longer part of the Atom monad. For example: > > bool' :: Name -> V Bool > > This cleaned up quite a bit of code in our production design. This > also made the randomization in Atom's unit testing framework monadless > as well. > > The other significant change with 1.0 is all state variables are now > packed into a hierarchical C structure that matches the hierarchy of > the Atom design. Not only does this make the generated C a bit more > legible, it is now possible to interface external C code directly to > Atom's state variables and arrays. Prior to this change, all > interfacing had to be done through var' declarations and action calls > -- too often a messy process. To further aid interfacing to external > code, Atom now generates a header file that exposes both the iterative > function and the hierarchical state structure. > > -Tom > > http://hackage.haskell.org/package/atom > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > ----- Yves Par?s Live long and prosper -- View this message in context: http://old.nabble.com/ANN%3A-atom-1.0.0-tp27574165p27579930.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From vanenkj at gmail.com Sat Feb 13 22:53:26 2010 From: vanenkj at gmail.com (John Van Enk) Date: Sat Feb 13 22:24:25 2010 Subject: [Haskell-cafe] ANN: atom-1.0.0 In-Reply-To: <27579930.post@talk.nabble.com> References: <594c1e831002130310v7e5e92bci8439eab9b7794d1@mail.gmail.com> <27579930.post@talk.nabble.com> Message-ID: Hmm... that's my outdated blog post. I've been meaning to add an updated version. I'll try and get to that soon. On Sat, Feb 13, 2010 at 7:30 PM, Yves Par?s wrote: > > I've been interested in using Atom since I saw this: > http://blog.sw17ch.com/wordpress/?p=84 > However those samples are very outdated, do you have newer ones? > > > > Tom Hawkins-2 wrote: > > > > Atom is a Haskell DSL for designing hard realtime embedded software. > > The 1.0 release is meant to indicate some level of stability; most of > > the core has been unchanged for quite some time. > > > > That said, there are a few interesting changes in 1.0. First the var' > > family of variable declarations (bool', word8', double', etc.) are no > > longer part of the Atom monad. For example: > > > > bool' :: Name -> V Bool > > > > This cleaned up quite a bit of code in our production design. This > > also made the randomization in Atom's unit testing framework monadless > > as well. > > > > The other significant change with 1.0 is all state variables are now > > packed into a hierarchical C structure that matches the hierarchy of > > the Atom design. Not only does this make the generated C a bit more > > legible, it is now possible to interface external C code directly to > > Atom's state variables and arrays. Prior to this change, all > > interfacing had to be done through var' declarations and action calls > > -- too often a messy process. To further aid interfacing to external > > code, Atom now generates a header file that exposes both the iterative > > function and the hierarchical state structure. > > > > -Tom > > > > http://hackage.haskell.org/package/atom > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > > > ----- > Yves Par?s > > Live long and prosper > -- > View this message in context: > http://old.nabble.com/ANN%3A-atom-1.0.0-tp27574165p27579930.html > Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100213/800ae53a/attachment.html From tomahawkins at gmail.com Sat Feb 13 23:59:31 2010 From: tomahawkins at gmail.com (Tom Hawkins) Date: Sat Feb 13 23:30:29 2010 Subject: [Haskell-cafe] Atom Examples Message-ID: <594c1e831002132059s2f32eff8w8a6c15cb5bda5f8@mail.gmail.com> On Sun, Feb 14, 2010 at 1:30 AM, Yves Par?s wrote: > > I've been interested in using Atom since I saw this: > http://blog.sw17ch.com/wordpress/?p=84 > However those samples are very outdated, do you have newer ones? Unfortunately, no. I wish I had the time to write Atom examples and tutorials, but I don't. So in lieu of a tutorial, here's a few modules we use on our real projects -- with limited documentation. Arbiter.hs: A general purpose non-preemptive arbiter than implements Lamport's bakery algorithm. We use this to arbitrate multiple software components that need to use the CAN protocol stacks for sending multi-packet messages. This is a good example that illustrates some of the benefits of atomic state transitions rules. What I find interesting is it works without any centralized arbiter logic; notice there are no rule declarations in mkArbiter. ECU.hs: This is the hardware abstraction layer to our ECU. Nothing too interesting, but a good example of how to wire Atom up to external C code. Note the ECU record includes a bunch of expressions (E types) and variables (V types). The expressions form the inputs, like ADCs and discrete inputs, and the mutable variables form the outputs, such as PWMs and discrete outputs. It also provides hooks to send and receive CAN messages. EVU.hs: The eVU is a little display mounted on the dash. It presents the driver with information such as charge pressure, mode settings, and fault conditions. The ECU talks to the eVU via the CAN bus. This is a good example because it illustrates a common object-oriented pattern we tend to use all over the place: the object contructor (mkEVU) creates some state variables, defines rules for stuff to do, and packages the state variables into an abstract type, or object (EVU); then methods operate on this object. In the case of EVU, the object constructor defines variables for the things the eVU displays, and it defines a rule to periodically send this information to the eVU device via CAN. And the methods set the various display elements such as the active fault code (setCode), the accumulator pressure (setCharge), and the active mode (setMode). Sensors.hs: Sensor processing, which takes data from the hardware abstraction layer (ECU.hs). One interesting feature is the oil temperature sensor computation. Based on a 1-D lookup table the 'lookup1D' function searches the table for the corresponding points and performs interpolation. In C, this probably would have been written as a for-loop that would compute the lookup on every sample. But because change in oil temperature is much slower than the sample rate of the system, we only need to search one row of the table every 50 samples or so (i.e. with rules 'below', 'above', 'next', and 'found'). This effectively spreads out the computation over many samples, thus lowering the processing latency of every sample. Doing this type of time-sharing in C would be tricky. But in Atom, it's trivial. One of the many ways Atom benefits hard realtime programming. I hope this helps. -Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: AtomExamples.tar.gz Type: application/x-gzip Size: 4542 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100213/64c60b3b/AtomExamples.tar.gz From patai_gergely at fastmail.fm Sun Feb 14 01:51:18 2010 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Sun Feb 14 01:22:14 2010 Subject: [Haskell-cafe] ANN: Dungeons of Wor - a largish FRP example and a fun game, all in one! In-Reply-To: <910ddf451002111742l5e8eef3sf589549fafc8a49c@mail.gmail.com> References: <1265877335.18142.1359423573@webmail.messagingengine.com> <910ddf451002111742l5e8eef3sf589549fafc8a49c@mail.gmail.com> Message-ID: <1266130278.20536.1359883325@webmail.messagingengine.com> > I tried it, but after briefly displaying a window, the program terminates > with the message: > dow: user error (unknown OpenGL extension entry glTexParameteri, check > for OpenGL 3.1) I just tried it under XP, using an unaltered Haskell Platform 2009.2.0.1 (GHC 6.10.3), and it compiled and worked out of the box. I got some other error reports too (about segfaults under Linux), but I can't reproduce any of them. Gergely -- http://www.fastmail.fm - Access your email from home and the web From patai_gergely at fastmail.fm Sun Feb 14 02:21:20 2010 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Sun Feb 14 01:52:16 2010 Subject: [Haskell-cafe] ANN: Dungeons of Wor - a largish FRP example and a fun game, all in one! In-Reply-To: <910ddf451002111742l5e8eef3sf589549fafc8a49c@mail.gmail.com> References: <1265877335.18142.1359423573@webmail.messagingengine.com> <910ddf451002111742l5e8eef3sf589549fafc8a49c@mail.gmail.com> Message-ID: <1266132080.24944.1359883489@webmail.messagingengine.com> > Seems like today FRP is the last word in game programming with Haskell. > Do you know something that could be a good tutorial, or at least > introduction to FRP ? Something that could somewhat help me learn the ropes, > 'cause I'm afraid if I dive directly into your code I'm gonna be lost. I don't think there's any material on FRP that could be considered a general tutorial, because there are many flavours with smaller and bigger differences, and no-one really seems to know how to program in this manner beyond toy examples. So, for the time being, I'd probably start with the original Fran paper [1], which is quite accessible in my opinion, and even though some of the details are obsolete, it explains the basics reasonably well. The Yampa Arcade [2] is probably the best introduction to the arrow-based approach (AFRP). The new Reactive paper [3] is not beginner friendly, but if you already grokked Fran, it shouldn't be too hard to follow, and it describes a way to design an applicative style reactive library with a much cleaner interface than that of Fran. Gergely [1] http://conal.net/papers/icfp97/ [2] http://www.haskell.org/yale/papers/haskell-workshop03/index.html [3] http://conal.net/papers/push-pull-frp/ -- http://www.fastmail.fm - A fast, anti-spam email service. From limestrael at gmail.com Sun Feb 14 04:29:38 2010 From: limestrael at gmail.com (=?UTF-8?Q?Yves_Par=C3=A8s?=) Date: Sun Feb 14 04:00:35 2010 Subject: [Haskell-cafe] Atom Examples In-Reply-To: <594c1e831002132059s2f32eff8w8a6c15cb5bda5f8@mail.gmail.com> References: <594c1e831002132059s2f32eff8w8a6c15cb5bda5f8@mail.gmail.com> Message-ID: <27581803.post@talk.nabble.com> Thanks! Looks a bit complex to me at the moment, but I'll probably have a look at it when I have the time. Tom Hawkins-2 wrote: > > On Sun, Feb 14, 2010 at 1:30 AM, Yves Par?s wrote: >> >> I've been interested in using Atom since I saw this: >> http://blog.sw17ch.com/wordpress/?p=84 >> However those samples are very outdated, do you have newer ones? > > Unfortunately, no. I wish I had the time to write Atom examples and > tutorials, but I don't. > > So in lieu of a tutorial, here's a few modules we use on our real > projects -- with limited documentation. > > Arbiter.hs: A general purpose non-preemptive arbiter than implements > Lamport's bakery algorithm. We use this to arbitrate multiple > software components that need to use the CAN protocol stacks for > sending multi-packet messages. This is a good example that > illustrates some of the benefits of atomic state transitions rules. > What I find interesting is it works without any centralized arbiter > logic; notice there are no rule declarations in mkArbiter. > > ECU.hs: This is the hardware abstraction layer to our ECU. Nothing > too interesting, but a good example of how to wire Atom up to external > C code. Note the ECU record includes a bunch of expressions (E types) > and variables (V types). The expressions form the inputs, like ADCs > and discrete inputs, and the mutable variables form the outputs, such > as PWMs and discrete outputs. It also provides hooks to send and > receive CAN messages. > > EVU.hs: The eVU is a little display mounted on the dash. It presents > the driver with information such as charge pressure, mode settings, > and fault conditions. The ECU talks to the eVU via the CAN bus. This > is a good example because it illustrates a common object-oriented > pattern we tend to use all over the place: the object contructor > (mkEVU) creates some state variables, defines rules for stuff to do, > and packages the state variables into an abstract type, or object > (EVU); then methods operate on this object. In the case of EVU, the > object constructor defines variables for the things the eVU displays, > and it defines a rule to periodically send this information to the eVU > device via CAN. And the methods set the various display elements such > as the active fault code (setCode), the accumulator pressure > (setCharge), and the active mode (setMode). > > Sensors.hs: Sensor processing, which takes data from the hardware > abstraction layer (ECU.hs). One interesting feature is the oil > temperature sensor computation. Based on a 1-D lookup table the > 'lookup1D' function searches the table for the corresponding points > and performs interpolation. In C, this probably would have been > written as a for-loop that would compute the lookup on every sample. > But because change in oil temperature is much slower than the sample > rate of the system, we only need to search one row of the table every > 50 samples or so (i.e. with rules 'below', 'above', 'next', and > 'found'). This effectively spreads out the computation over many > samples, thus lowering the processing latency of every sample. Doing > this type of time-sharing in C would be tricky. But in Atom, it's > trivial. One of the many ways Atom benefits hard realtime > programming. > > I hope this helps. > > -Tom > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > ----- Yves Par?s Live long and prosper -- View this message in context: http://old.nabble.com/Atom-Examples-tp27580935p27581803.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From wagnerdm at seas.upenn.edu Sun Feb 14 05:02:06 2010 From: wagnerdm at seas.upenn.edu (wagnerdm@seas.upenn.edu) Date: Sun Feb 14 04:33:08 2010 Subject: [Haskell-cafe] ANN: wyvern, a Dragon Go Server "client" Message-ID: <20100214050206.17735bpg7osw3e4o@webmail.seas.upenn.edu> I've just done the first release of wyvern [1], a small program to play moves for you on the Dragon Go Server [2], along with point releases for two supporting libraries. On DGS, people play many games of go simultaneously, making only one move per day in each game (about). A commonly requested feature is the ability to specify several moves in advance, and have them be played automatically whenever the opponent logs in. Wyvern provides this capability, as well as the ability to program in advance several "branches" -- conditional on the opponent's move. Along with wyvern, I've been developing two supplementary libraries. The "dgs" library [3] is a very small wrapper around DGS' handy robot interface. The "sgf" library [4] is a parser for the SGF file format (used to store games of go) that strives to balance using the type system to enforce the construction of correct SGF trees against conveniently manipulating said trees. It was also something of an experiment for me in documentation writing -- I may have gone a little overboard. =) If, like me, you love to mix Haskell and go, I invite you to check out one or more of these and let me know what you think. ~d [1] http://dmwit.com/wyvern [2] http://www.dragongoserver.net/ [3] http://hackage.haskell.org/package/dgs [4] http://hackage.haskell.org/package/sgf From knyttv at gmail.com Sun Feb 14 05:31:23 2010 From: knyttv at gmail.com (=?utf-8?Q?Vojt=C4=9Bch_Knyttl?=) Date: Sun Feb 14 05:02:25 2010 Subject: [Haskell-cafe] running HGL on OSX Message-ID: Hello, I am having difficulties running HGL on Mac OSX, Snow Leopard. Here is what I've done: ?? 1. Installed X11 for OSX ("About" dialog says: The X Window System, XQuartz 2.3.4 (xorg-server 1.4.2-apple45)) ?? 2. Got X11 from Hackage ? configured, built and installed ? however, there where quite a lot of warnings: ? [ 8 of 25] Compiling Graphics.X11.Xlib.Color ( Graphics/X11/Xlib/Color.hs, dist/build/Graphics/X11/Xlib/Color.o ) Graphics/X11/Xlib/Color.hs:38:0: Warning: The import of `Foreign.C.Types' is redundant except perhaps to import instances from `Foreign.C.Types' To import instances alone, use: import Foreign.C.Types() [ 9 of 25] Compiling Graphics.X11.Xlib.Font ( dist/build/Graphics/X11/Xlib/Font.hs, dist/build/Graphics/X11/Xlib/Font.o ) Graphics/X11/Xlib/Font.hsc:167:1: Warning: A do-notation statement discarded a result of type CInt. Suppress this warning by saying "_ <- xTextExtents font_struct c_string (fromIntegral nchars) direction_return font_ascent_return font_descent_return overall_return", or by using the flag -fno-warn-unused-do-bind ? and so on. ?? 3. Got HGL package, built and installed with some warnings like: ? [ 1 of 27] Compiling Graphics.HGL.Internals.Flag ( Graphics/HGL/Internals/Flag.hs, dist/build/Graphics/HGL/Internals/Flag.o ) Graphics/HGL/Internals/Flag.hs:1:0: Warning: Module `Prelude' is deprecated: You are using the old package `base' version 3.x. Future GHC versions will not support base version 3.x. You should update your code to use the new base version 4.x. ? ?? Now, when I try to run simple program like: main = runGraphics $ withWindow_ "Hello World Window" (300, 200) $ \ w -> do drawInWindow w $ text (100, 100) "Hello World" drawInWindow w $ ellipse (100, 80) (200, 180) getKey w it says: $ ghci graphics.hs GHCi, version 6.12.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. Loading package ffi-1.0 ... linking ... done. Ok, modules loaded: Main. Prelude Main> main Loading package syb-0.1.0.2 ... linking ... done. Loading package X11-1.5.0.0 ... can't load .so/.DLL for: X11 (dlopen(libX11.dylib, 9): image not found) Prelude Main> Just to precise, I have X11 running (it can be seen in the OSX dock) Thanks From shumovichy at gmail.com Sun Feb 14 05:35:51 2010 From: shumovichy at gmail.com (Yuras Shumovich) Date: Sun Feb 14 05:06:49 2010 Subject: [Haskell-cafe] running HGL on OSX In-Reply-To: References: Message-ID: <1d6a9f301002140235v43ea2304wbfd089e43f8f39cf@mail.gmail.com> > Loading package X11-1.5.0.0 ... can't load .so/.DLL for: X11 (dlopen(libX11.dylib, 9): image not found) try DYLD_LIBRARY_PATH=/usr/X11R6/lib ghci graphics.hs http://hackage.haskell.org/trac/ghc/ticket/1019 From gue.schmidt at web.de Sun Feb 14 07:38:36 2010 From: gue.schmidt at web.de (=?ISO-8859-15?Q?G=FCnther_Schmidt?=) Date: Sun Feb 14 07:09:56 2010 Subject: [Haskell-cafe] on finding abstractions ... Message-ID: <4B77EECC.7080103@web.de> Hello, I've got a problem, in short my haskell code sucks. While it does work and I do manage to use higher-orderish aspects quite extensively to make my code more concise it still is nowhere abstract, always concrete and thus always with lots of boilerplate. Oh I have gotten better compared to when I started but on the abstraction slope I'm still stuck. So fellows, what is the next stop on my road to enlightenment? I really think I need best to start from scratch. I think I'm sufficiently familiar now with most of Haskell's technicalities but how do I climb the ladder of abstraction? G?nther From jesper.louis.andersen at gmail.com Sun Feb 14 08:04:58 2010 From: jesper.louis.andersen at gmail.com (Jesper Louis Andersen) Date: Sun Feb 14 07:36:14 2010 Subject: [Haskell-cafe] on finding abstractions ... In-Reply-To: <4B77EECC.7080103@web.de> References: <4B77EECC.7080103@web.de> Message-ID: <56a0a2841002140504m40fd06cjc68ea3b99130495d@mail.gmail.com> 2010/2/14 G?nther Schmidt : > So fellows, what is the next stop on my road to enlightenment? I really > think I need best to start from scratch. I think I'm sufficiently familiar > now with most of Haskell's technicalities but how do I climb the ladder of > abstraction? A couple of suggestions: - Read the code of other people. You will learn things from this. - Use hLint on your code. - Read "The Monad Reader", Brent's excellent typeclassopedia article for instance. You must know the tool box before you can apply it. - Read some of the papers that introduce various new abstract code concepts. The trick is to ask the question "Can this apply to some of my code?" for each of them. -- J. From jon at jrock.us Sun Feb 14 08:05:50 2010 From: jon at jrock.us (Jonathan Rockway) Date: Sun Feb 14 07:36:47 2010 Subject: [Haskell-cafe] on finding abstractions ... In-Reply-To: <4B77EECC.7080103@web.de> (=?utf-8?Q?=22G=C3=BCnther?= Schmidt"'s message of "Sun, 14 Feb 2010 13:38:36 +0100") References: <4B77EECC.7080103@web.de> Message-ID: <876360nf0x.fsf@snowball2.jrock.us> * On Sun, Feb 14 2010, G?nther Schmidt wrote: > So fellows, what is the next stop on my road to enlightenment? I > really think I need best to start from scratch. I think I'm > sufficiently familiar now with most of Haskell's technicalities but > how do I climb the ladder of abstraction? Read more code. Write more code. Repeat. Regards, Jonathan Rockway -- Just "another Haskell hacker" From andrewcoppin at btinternet.com Sun Feb 14 08:24:03 2010 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sun Feb 14 07:54:59 2010 Subject: [Haskell-cafe] What is the meaning of tilde ("~") symbol In-Reply-To: <4B76A310.9090406@gmail.com> References: <4B76A310.9090406@gmail.com> Message-ID: <4B77F973.4090304@btinternet.com> Here's an idea... maybe we should make a small page on the Wiki explaining what all the various symbols in Haskell mean? There are a couple which are rare enough that most tutorials don't mention them that often. And there are of course symbols which mean different things in different contexts. (I especially love how curly braces are used for overriding layout *and* for named fields...) From fw at deneb.enyo.de Sun Feb 14 08:27:04 2010 From: fw at deneb.enyo.de (Florian Weimer) Date: Sun Feb 14 07:58:01 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <4B757CAB.4010908@gmail.com> (Simon Marlow's message of "Fri, 12 Feb 2010 16:07:07 +0000") References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> <4B7573CA.4020201@gmail.com> <4B757CAB.4010908@gmail.com> Message-ID: <87bpfsvtg7.fsf@mid.deneb.enyo.de> * Simon Marlow: > In a sense the GC *is* deterministic: it guarantees to collect all the > unreachable garbage. But I expect what you're referring to is the > fact that the garbage remains around for a non-deterministic amount of > time. To me that doesn't seem to be a problem: you could run the GC at > any time to reclaim it (pause-times notwithstanding). Most of the time, the concern is about pause times and the lack of upper bounds on them. With traditional reference counting, this is still a problem because if the last reference to a large data structure goes away, you need to free the whole data structure at once. (I'm not sure if Axford's paper deals with that aspect, though.) From mightybyte at gmail.com Sun Feb 14 08:36:49 2010 From: mightybyte at gmail.com (MightyByte) Date: Sun Feb 14 08:07:45 2010 Subject: [Haskell-cafe] What is the meaning of tilde ("~") symbol In-Reply-To: <4B77F973.4090304@btinternet.com> References: <4B76A310.9090406@gmail.com> <4B77F973.4090304@btinternet.com> Message-ID: I like that idea. When I was first learning Haskell, I remember spending a non-trivial amount of time trying to figure out what '$' did. I incorrectly assumed that it was provided by some library. '!' and '~' would certainly be other good candidates for this kind of a page. These types of things can be pretty hard to google. On Sun, Feb 14, 2010 at 8:24 AM, Andrew Coppin wrote: > Here's an idea... maybe we should make a small page on the Wiki explaining > what all the various symbols in Haskell mean? > > There are a couple which are rare enough that most tutorials don't mention > them that often. And there are of course symbols which mean different things > in different contexts. (I especially love how curly braces are used for > overriding layout *and* for named fields...) > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From andrewcoppin at btinternet.com Sun Feb 14 08:39:03 2010 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sun Feb 14 08:10:00 2010 Subject: [Haskell-cafe] What is the meaning of tilde ("~") symbol In-Reply-To: References: <4B76A310.9090406@gmail.com> <4B77F973.4090304@btinternet.com> Message-ID: <4B77FCF7.7030100@btinternet.com> MightyByte wrote: > I like that idea. When I was first learning Haskell, I remember > spending a non-trivial amount of time trying to figure out what '$' > did. I incorrectly assumed that it was provided by some library. > Technically, it is... > '!' > and '~' would certainly be other good candidates for this kind of a > page. Every now and then somebody asks about "@" too. > These types of things can be pretty hard to google. > Well yes, there is that too... ;-) Of course, the next question is if we're going to do this, how to we make it so that all the newbies stumble across this page without having to spend 25 years tracking it down? A wiki page isn't much good if nobody finds it... From mightybyte at gmail.com Sun Feb 14 09:00:14 2010 From: mightybyte at gmail.com (MightyByte) Date: Sun Feb 14 08:31:10 2010 Subject: [Haskell-cafe] What is the meaning of tilde ("~") symbol In-Reply-To: <4B77FCF7.7030100@btinternet.com> References: <4B76A310.9090406@gmail.com> <4B77F973.4090304@btinternet.com> <4B77FCF7.7030100@btinternet.com> Message-ID: On Sun, Feb 14, 2010 at 8:39 AM, Andrew Coppin wrote: > MightyByte wrote: >> >> I like that idea. ?When I was first learning Haskell, I remember >> spending a non-trivial amount of time trying to figure out what '$' >> did. ?I incorrectly assumed that it was provided by some library. > > Technically, it is... Hmmm, both Hoogle and Hayoo give me the right answer when I search for '$'. For some reason I thought I had tried that without success. However, I'm pretty sure that was before Hayoo came out; and maybe Hoogle wasn't as good in those days. At any rate, they still don't help for things like '~', so there's definitely a use for a wiki page like this. From felipe.lessa at gmail.com Sun Feb 14 09:40:50 2010 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sun Feb 14 09:11:49 2010 Subject: [Haskell-cafe] What is the meaning of tilde ("~") symbol In-Reply-To: References: <4B76A310.9090406@gmail.com> <4B77F973.4090304@btinternet.com> <4B77FCF7.7030100@btinternet.com> Message-ID: <20100214144049.GA12722@kira.casa> On Sun, Feb 14, 2010 at 09:00:14AM -0500, MightyByte wrote: > At any rate, they still don't help for things like '~', so > there's definitely a use for a wiki page like this. Of course, Hoogle and Hayoo could be modified to show the docs when such symbols are searched as a special condition. -- Felipe. From stephen.tetley at gmail.com Sun Feb 14 09:55:50 2010 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Sun Feb 14 09:26:47 2010 Subject: [Haskell-cafe] on finding abstractions ... In-Reply-To: <4B77EECC.7080103@web.de> References: <4B77EECC.7080103@web.de> Message-ID: <5fdc56d71002140655k36b01077y943c8ac377f11aaf@mail.gmail.com> Hi G?nther Promoting a slightly contrary view, I'm not sure that abstraction should be a goal in itself. Richard Gabriel makes a point of valuing 'habitable' code over abstract code in his 'Patterns of Software' book (free from his website now that it's out of print). Habitable code being code you can live with - understand and modify. I'd look to making the code readable in the first instance, if you are working from a published algorithm can you code it line-for-line (hiding supplementary definitions in where-clauses or helper functions when necessary)? Or, if you are working from your own algorithms, maybe you need to work a little bit more on factoring the algorithm before it comes to writing the actual code. Best wishes Stephen From sergueyz at gmail.com Sun Feb 14 10:53:36 2010 From: sergueyz at gmail.com (Serguey Zefirov) Date: Sun Feb 14 10:24:34 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <87bpfsvtg7.fsf@mid.deneb.enyo.de> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> <4B7573CA.4020201@gmail.com> <4B757CAB.4010908@gmail.com> <87bpfsvtg7.fsf@mid.deneb.enyo.de> Message-ID: <600376291002140753t28b4ce2cw45ccda2d5433b5d8@mail.gmail.com> 2010/2/14 Florian Weimer : > Most of the time, the concern is about pause times and the lack of > upper bounds on them. ?With traditional reference counting, this is > still a problem because if the last reference to a large data > structure goes away, you need to free the whole data structure at > once. And this could be done... lazily! ;) From hjgtuyl at chello.nl Sun Feb 14 11:02:36 2010 From: hjgtuyl at chello.nl (Henk-Jan van Tuyl) Date: Sun Feb 14 10:33:29 2010 Subject: [Haskell-cafe] What is the meaning of tilde ("~") symbol In-Reply-To: <4B77F973.4090304@btinternet.com> References: <4B76A310.9090406@gmail.com> <4B77F973.4090304@btinternet.com> Message-ID: On Sun, 14 Feb 2010 14:24:03 +0100, Andrew Coppin wrote: > Here's an idea... maybe we should make a small page on the Wiki > explaining what all the various symbols in Haskell mean? > > There are a couple which are rare enough that most tutorials don't > mention them that often. And there are of course symbols which mean > different things in different contexts. (I especially love how curly > braces are used for overriding layout *and* for named fields...) > The symbols that are not specified in a library can be found here: http://www.haskell.org/haskellwiki/Keywords Hoogle used to show links to this page, when a keyword was searched, but not anymore. -- Met vriendelijke groet, Henk-Jan van Tuyl -- http://Van.Tuyl.eu/ http://functor.bamikanarie.com http://members.chello.nl/hjgtuyl/tourdemonad.html -- From dougal at dougalstanton.net Sun Feb 14 11:07:43 2010 From: dougal at dougalstanton.net (Dougal Stanton) Date: Sun Feb 14 10:38:40 2010 Subject: [Haskell-cafe] What is the meaning of tilde ("~") symbol In-Reply-To: <4B76A310.9090406@gmail.com> References: <4B76A310.9090406@gmail.com> Message-ID: <2d3641331002140807pb17db1fj688a07180d5cc1a1@mail.gmail.com> > And, I've search the meaning of the symbol "~", but I've found nothing about > this (note that's not easy to search "~" on google ...) Searching for "haskell tilde" produces a lot of results and they're all relevant (on the first page at least). D From ckkashyap at gmail.com Sun Feb 14 11:44:16 2010 From: ckkashyap at gmail.com (C K Kashyap) Date: Sun Feb 14 11:15:14 2010 Subject: [Haskell-cafe] EDSL's using Filet-O-Fish of Barrelfish project Message-ID: <844f6ea61002140844p1be2c37dnb651a1ddf93a49f9@mail.gmail.com> Hi All, I'd been looking for a mechanism to generate "C" from Haskell as EDSL - to develop an OS. In the process, I ran into the Barrelfish project ( http://www.barrelfish.org) - They seem to be using Haskell based "DSL generator" called Filet-O-Fish - http://www.barrelfish.org/fof_plos09.pdf It will take me some time understand Filet-O-Fish more but if any of the Haskell experts have already looked at it, I was wondering if I could use Filet-O-Fish to generate EDSL's for arbitrary things. For example, lets say, I wanted to write a EDSL for Linux's network drivers. Could I use Filet-O-Fish and generate a EDSL that allows me to write a driver in a really highlevel manner and then generate the "C" code for it? -- Regards, Kashyap -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100214/06d27e55/attachment.html From aeyakovenko at gmail.com Sun Feb 14 12:52:18 2010 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Sun Feb 14 12:23:13 2010 Subject: [Haskell-cafe] pandoc code bocks not working Message-ID: i am getting these failures with pandoc, or maybe i am not using markdown correctly 1. hello world ~~~~~~~~~ code block failed ~~~~~~~~~ * hello world ~~~~~~~~~ code block failed ~~~~~~~~~ * hello world clode block failed hello world =========== ~~~~~~~~~ code block ok ~~~~~~~~~ From pedagand at gmail.com Sun Feb 14 12:57:16 2010 From: pedagand at gmail.com (Pierre-Evariste Dagand) Date: Sun Feb 14 12:28:32 2010 Subject: [Haskell-cafe] EDSL's using Filet-O-Fish of Barrelfish project In-Reply-To: <844f6ea61002140844p1be2c37dnb651a1ddf93a49f9@mail.gmail.com> References: <844f6ea61002140844p1be2c37dnb651a1ddf93a49f9@mail.gmail.com> Message-ID: <6cb897b31002140957x4a5c17dbr89bb09691eac0189@mail.gmail.com> Hi, On Sun, Feb 14, 2010 at 4:44 PM, C K Kashyap wrote: > For example, lets say, I wanted to write a EDSL for Linux's network drivers. Could I use > Filet-O-Fish and generate a EDSL that allows me to write a driver in a > really highlevel manner and then generate the "C" code for it? That sounds perfectly reasonable to me. However, you write "generate a EDSL that allows me to [...]". Filet-o-Fish will not "generate" an EDSL for you. Filet-o-Fish will help you implement the *back-end* of your (E)DSL compiler. You still have to define a syntax and a semantics for your (E)DSL. FoF is here to bridge the gap from your (E)DSL semantics to C, by doing it for you. In Barrelfish, we have implemented the capability system this way: we have defined the syntax and semantics of a DSL for specifying capability systems, called Hamlet. Then, the Hamlet compiler back-end has been implemented with FoF, which allowed us, for example, to quickcheck some key property of the generated C code, by working at the (more friendly) FoF code level (assuming that FoF is "correct" ;-). For fun, we have implemented tic-tac-toe in the capability system. Each game state is represented by a capability, you can "retype" a capability from one to another iif this is a valid tic-tac-toe move. For a 3x3 board, that's more than 4.800 unique capabilities, which is quite a huge number of caps for an OS :-) You won't find that code in the official Barrelfish, though. Whereas this work was done in the specific context of Barrelfish, other people have designed DSLs for Linux. The examples I have in mind, related to your question are: * Devil [http://phoenix.inria.fr/index.php/projects/past-projects/devil]: a device interface language, but still quite low-level compared to what you're interested in ; * Bossa [http://bossa.lip6.fr/]: a DSL for specifying schedulers for Linux, which automatically turns the spec into code directly integrated in the Linux kernel. I had the opportunity to discuss with the designer of these systems and it is clear to me that this could be done with FoF as well. Hope this help, -- Pierre-Evariste DAGAND http://perso.eleves.bretagne.ens-cachan.fr/~dagand/ From aslatter at gmail.com Sun Feb 14 13:41:33 2010 From: aslatter at gmail.com (Antoine Latter) Date: Sun Feb 14 13:12:29 2010 Subject: [Haskell-cafe] Using Cabal during development In-Reply-To: <27544307.post@talk.nabble.com> References: <27515446.post@talk.nabble.com> <27544307.post@talk.nabble.com> Message-ID: <694519c51002141041m21cb94d1kc316adad7b3ee1bc@mail.gmail.com> On Thu, Feb 11, 2010 at 4:28 AM, Limestra?l wrote: > > Eventually, I think using cabal during development may be convenient. The > only drawback is that you have to specify each dependency and -- above all > -- every module each time you add one. > Nevertheless, I'm not convinced regarding the use of Makefiles with Cabal. I > happen to think it's a bit outsize. > A shell script is enough. > By the way, I've found another way to develop simultaneously a (or many) > library(ies) and an executable. > It would be to use a local ghc package database. > > In my project directory, I do: > ghc-pky init pkg.conf.d > > It create a directory pkg.conf.d which will contain my local database. > > Then all the libs must be configured with: > cabal configure --package-db pkg.conf.d > (or 'runhaskell Setup.hs configure --package-db pkg.conf.d' if you don't use > cabal-install) > Then build normally ('cabal build') > Then, the little trouble is that you have to register you newly-built > manually with a: > cabal register --inplace > (Anyone knows how to tell cabal to register automatically to the local pkg > database?) > > Then, to compile you executable with ghc (because Cabal is definitely not > convient when you have a lib and an executable in the same package): > ghc --make --package-conf pkg.conf.d main.hs > This is great - now I can do proper benchmarks against my libraries without doing all-at-once compilation (which seems to change how inlining works), while at the same time not cluttering up my real package db. I have this wrapped up into a shell script, but that assumes I'm not doing my benchmarks on windows. Antoine From spam at scientician.net Sun Feb 14 15:04:30 2010 From: spam at scientician.net (Bardur Arantsson) Date: Sun Feb 14 14:36:01 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: References: <910ddf451002091647m4b7e12a5y5a680d7d356fb3d6@mail.gmail.com> <94E8A4F7-E54B-4885-8D6A-6AA4777F6FC1@n-heptane.com> Message-ID: > Jeremy Shaw wrote: > >> import Control.Concurrent >> import Control.Concurrent.MVar >> import System.Posix.Types >> >> data RW = Read | Write >> >> threadWaitReadWrite :: Fd -> IO RW >> threadWaitReadWrite fd = >> do m <- newEmptyMVar >> rid <- forkIO $ threadWaitRead fd >> putMVar m Read >> wid <- forkIO $ threadWaitWrite fd >> putMVar m Write >> r <- takeMVar m >> killThread rid >> killThread wid >> return r >> [--snip--] I've tested this extensively during this weekend and not a single "leaked" FD so far. I think we can safely say that polling an FD for read readiness is sufficient to properly detect a disconnected client regardless of why/how the client disconnected. The only issue I can see with just dropping the above code directly into the sendfile library is that it may lead to busy-waiting on EAGAIN *if* the client is actually trying to send data to the server while it's receiving the file via sendfile(). If the client sends even a single byte and the server isn't reading it from the socket, then threadWaitRead will keep returning immediately since it's level-triggered rather than edge triggered. In the worst case this could be exploited by evil clients as a trivial way to DoS a server -- simply send data while the server is sending you a file. Bam, instant 100% CPU utilization on the server. Not sure what the best solution for this would be, API-wise... Maybe actually have sendfile read the data and supply it to a user-defined function which could react to the data in some way? (Could supply two standard functions: "disconnect immediately" and "accumulate all received data into a bytestring".) Cheers, From andrewcoppin at btinternet.com Sun Feb 14 16:49:06 2010 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sun Feb 14 16:20:02 2010 Subject: [Haskell-cafe] What is the meaning of tilde ("~") symbol In-Reply-To: References: <4B76A310.9090406@gmail.com> <4B77F973.4090304@btinternet.com> Message-ID: <4B786FD2.3000202@btinternet.com> Henk-Jan van Tuyl wrote: > The symbols that are not specified in a library can be found here: > http://www.haskell.org/haskellwiki/Keywords Ah, nice. It seems somebody else has already thought of this. Also, I read this page and discovered something new within about 30 seconds. (Pattern guards...) > Hoogle used to show links to this page, when a keyword was searched, > but not anymore. Hmm, pitty. As I commented, documentation isn't much help if nobody finds it. From jakewheatmail at googlemail.com Sun Feb 14 17:00:02 2010 From: jakewheatmail at googlemail.com (Jake Wheat) Date: Sun Feb 14 16:30:58 2010 Subject: [Haskell-cafe] What is the meaning of tilde ("~") symbol In-Reply-To: References: <4B76A310.9090406@gmail.com> <4B77F973.4090304@btinternet.com> Message-ID: <4b5b53361002141400s4c8cfdf7j7c26cd383cbddcea@mail.gmail.com> On 14 February 2010 16:02, Henk-Jan van Tuyl wrote: > The symbols that are not specified in a library can be found here: > ?http://www.haskell.org/haskellwiki/Keywords > Hoogle used to show links to this page, when a keyword was searched, but not > anymore. In section 5 ! on this page it says > Finally, it is the array subscript operator: > > let x = arr ! 10 Shouldn't this be let x = arr !! 10 ? From qdunkan at gmail.com Sun Feb 14 17:11:26 2010 From: qdunkan at gmail.com (Evan Laforge) Date: Sun Feb 14 16:42:22 2010 Subject: [Haskell-cafe] What is the meaning of tilde ("~") symbol In-Reply-To: <4b5b53361002141400s4c8cfdf7j7c26cd383cbddcea@mail.gmail.com> References: <4B76A310.9090406@gmail.com> <4B77F973.4090304@btinternet.com> <4b5b53361002141400s4c8cfdf7j7c26cd383cbddcea@mail.gmail.com> Message-ID: <2518b95d1002141411p25fc0131k61c69a9a1f141991@mail.gmail.com> >> Finally, it is the array subscript operator: >> >> let x = arr ! 10 > > Shouldn't this be > > let x = arr !! 10 !! is the list subscript. Look in Data.Array.IArray for (!). Or Data.Map. There's still no consensus on typeclasses for collections, so these are all separate functions. Has anyone taken a shot at a set of AT-using classes for the standard collections? From wagnerdm at seas.upenn.edu Sun Feb 14 17:17:36 2010 From: wagnerdm at seas.upenn.edu (wagnerdm@seas.upenn.edu) Date: Sun Feb 14 16:48:37 2010 Subject: [Haskell-cafe] What is the meaning of tilde ("~") symbol In-Reply-To: <4b5b53361002141400s4c8cfdf7j7c26cd383cbddcea@mail.gmail.com> References: <4B76A310.9090406@gmail.com> <4B77F973.4090304@btinternet.com> <4b5b53361002141400s4c8cfdf7j7c26cd383cbddcea@mail.gmail.com> Message-ID: <20100214171736.20565qhidki7y0kc@webmail.seas.upenn.edu> Quoting Jake Wheat : > On 14 February 2010 16:02, Henk-Jan van Tuyl wrote: >> Finally, it is the array subscript operator: >> >> let x = arr ! 10 > > Shouldn't this be > > let x = arr !! 10 (!) is for arrays, (!!) is for lists. ~d From jakewheatmail at googlemail.com Sun Feb 14 17:21:44 2010 From: jakewheatmail at googlemail.com (Jake Wheat) Date: Sun Feb 14 16:52:39 2010 Subject: [Haskell-cafe] What is the meaning of tilde ("~") symbol In-Reply-To: <2518b95d1002141411p25fc0131k61c69a9a1f141991@mail.gmail.com> References: <4B76A310.9090406@gmail.com> <4B77F973.4090304@btinternet.com> <4b5b53361002141400s4c8cfdf7j7c26cd383cbddcea@mail.gmail.com> <2518b95d1002141411p25fc0131k61c69a9a1f141991@mail.gmail.com> Message-ID: <4b5b53361002141421j1f779ca5oaf2eedcf4710ae75@mail.gmail.com> On 14 February 2010 22:11, Evan Laforge wrote: >>> Finally, it is the array subscript operator: >>> >>> let x = arr ! 10 >> >> Shouldn't this be >> >> let x = arr !! 10 > > !! is the list subscript. ?Look in Data.Array.IArray for (!). ?Or Data.Map. > > There's still no consensus on typeclasses for collections, so these > are all separate functions. ?Has anyone taken a shot at a set of > AT-using classes for the standard collections? > Oops, thanks. That is a really useful page (http://www.haskell.org/haskellwiki/Keywords). From stephen.tetley at gmail.com Sun Feb 14 17:22:09 2010 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Sun Feb 14 16:53:06 2010 Subject: [Haskell-cafe] What is the meaning of tilde ("~") symbol In-Reply-To: <2518b95d1002141411p25fc0131k61c69a9a1f141991@mail.gmail.com> References: <4B76A310.9090406@gmail.com> <4B77F973.4090304@btinternet.com> <4b5b53361002141400s4c8cfdf7j7c26cd383cbddcea@mail.gmail.com> <2518b95d1002141411p25fc0131k61c69a9a1f141991@mail.gmail.com> Message-ID: <5fdc56d71002141422p3bd6a272j214bdbfa628978bf@mail.gmail.com> On 14 February 2010 22:11, Evan Laforge wrote: > There's still no consensus on typeclasses for collections, so these > are all separate functions. ?Has anyone taken a shot at a set of > AT-using classes for the standard collections? The standard collections have different shapes depending on what they represent (maps, trees, lists, sequences) so considering Functor, Traversable, Foldable perhaps the common operations are largely already covered. A unifying 'collection' class might be as problematic as good old Num is for numbers... Best wishes Stephen From ajs at 2piix.com Sun Feb 14 17:37:08 2010 From: ajs at 2piix.com (Alexander Solla) Date: Sun Feb 14 17:08:04 2010 Subject: [Haskell-cafe] on finding abstractions ... In-Reply-To: <4B77EECC.7080103@web.de> References: <4B77EECC.7080103@web.de> Message-ID: <36ACAC03-AADD-4D53-B708-C57A23B33C53@2piix.com> On Feb 14, 2010, at 4:38 AM, G?nther Schmidt wrote: > I've got a problem, in short my haskell code sucks. While it does > work and I do manage to use higher-orderish aspects quite > extensively to make my code more concise it still is nowhere > abstract, always concrete and thus always with lots of boilerplate. There is a such a thing as too much higher-ordered-ness. Every time you introduce a new higher order dispatch mechanism, you go through many of the same steps, and produce "slightly incompatible" interfaces. You're basically defining plumbing, which you might have to plumb into your existing plumbing. Boilerplate city. Instead of looking for a higher-order solution to your problem, look for a normal form to express abstract terms that solve your problem. The higher-order solution will become "obvious" when you have the right normal forms (because now you know what you're quantifying over) For example, algebraic data types are a natural encoding for tree-like structures. They can even contain things. Monads are an encoding for tree-like structures with an interface to the things the nodes contain. I'm not saying you need to use monads. I'm saying you should use them when they are the right normal form. Unfortunately, boilerplate is kind of a fact of life in Haskell, unless you use things like TemplateHaskell or SYB. After making all our nice orthogonal classes and data types in sensible normal forms, we need to join these classes and types, with functions and class instances. Taking big types down a chain of type classes is no fun. But at least all that complexity is kept in one sensible place. One thing I wish GHC would do better is deal with cyclical module dependencies more flexibly. More flexibility would mean letting us organize our code by the normal form it embodies, as opposed to the modules/types it uses. That makes code look a lot less boilerplate- ish, since the "irrelevant" but important bits can all go together. From qdunkan at gmail.com Sun Feb 14 17:41:31 2010 From: qdunkan at gmail.com (Evan Laforge) Date: Sun Feb 14 17:12:25 2010 Subject: [Haskell-cafe] What is the meaning of tilde ("~") symbol In-Reply-To: <5fdc56d71002141422p3bd6a272j214bdbfa628978bf@mail.gmail.com> References: <4B76A310.9090406@gmail.com> <4B77F973.4090304@btinternet.com> <4b5b53361002141400s4c8cfdf7j7c26cd383cbddcea@mail.gmail.com> <2518b95d1002141411p25fc0131k61c69a9a1f141991@mail.gmail.com> <5fdc56d71002141422p3bd6a272j214bdbfa628978bf@mail.gmail.com> Message-ID: <2518b95d1002141441y778aef2aw15014cf0c8f224d1@mail.gmail.com> On Sun, Feb 14, 2010 at 2:22 PM, Stephen Tetley wrote: > On 14 February 2010 22:11, Evan Laforge wrote: > >> There's still no consensus on typeclasses for collections, so these >> are all separate functions. ?Has anyone taken a shot at a set of >> AT-using classes for the standard collections? > > > The standard collections have different shapes depending on what they > represent (maps, trees, lists, sequences) so considering Functor, > Traversable, Foldable perhaps the common operations are largely > already covered. A unifying 'collection' class might be as problematic > as good old Num is for numbers... But how about indexing? It would be nice to have universal operators like (!!) :: collection elt -> index -> elt lookup :: index -> collection elt -> Maybe elt member :: index -> collection elt -> Bool That way you can have nice short names for these common operations. Lists are very flexible but it's nothing Monoid hasn't already done with integers and newtype wrappers, and there are plenty of others which would be applicable (no pun intended): Map, Set, Bytestring, Sequence. I suppose we can get empty and concat with Monoid. What about singleton? The names and locations are all over the map (no really, not intended) too, symptomatic I suppose of the fact that they all evolved separately. From stephen.tetley at gmail.com Sun Feb 14 18:09:28 2010 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Sun Feb 14 17:40:23 2010 Subject: [Haskell-cafe] What is the meaning of tilde ("~") symbol In-Reply-To: <2518b95d1002141441y778aef2aw15014cf0c8f224d1@mail.gmail.com> References: <4B76A310.9090406@gmail.com> <4B77F973.4090304@btinternet.com> <4b5b53361002141400s4c8cfdf7j7c26cd383cbddcea@mail.gmail.com> <2518b95d1002141411p25fc0131k61c69a9a1f141991@mail.gmail.com> <5fdc56d71002141422p3bd6a272j214bdbfa628978bf@mail.gmail.com> <2518b95d1002141441y778aef2aw15014cf0c8f224d1@mail.gmail.com> Message-ID: <5fdc56d71002141509x8191528j38174794f47c342a@mail.gmail.com> Hi Evan Singleton (aka wrap) would be nice - isn't it called Pointed in the typeclassopedia but not otherwise existent? I suppose its missing by historical accident rather than design. I frequently use Semigroup (append but no zero) - there is one on Hackage without any instances: http://hackage.haskell.org/package/algebra I'm no fan of (!!) on lists or other containers where it isn't O(1), but lookup/member are a bit more promising. However are there any useful derived operations or constructions that can be defined only in terms of a Lookup type class? For comparison, Monoid has mconcat as a derived op and e.g. the Writer monad can be usefully abstract by relying only on the Monoid interface as can Foldable. Excepting Data.Tree, Data.Graph and HashTable, 'containers' seems pretty regular now - it certainly has moved on with 0.3.0.0. Best wishes Stephen From tonymorris at gmail.com Sun Feb 14 18:12:15 2010 From: tonymorris at gmail.com (Tony Morris) Date: Sun Feb 14 17:43:49 2010 Subject: [Haskell-cafe] What is the meaning of tilde ("~") symbol In-Reply-To: <5fdc56d71002141509x8191528j38174794f47c342a@mail.gmail.com> References: <4B76A310.9090406@gmail.com> <4B77F973.4090304@btinternet.com> <4b5b53361002141400s4c8cfdf7j7c26cd383cbddcea@mail.gmail.com> <2518b95d1002141411p25fc0131k61c69a9a1f141991@mail.gmail.com> <5fdc56d71002141422p3bd6a272j214bdbfa628978bf@mail.gmail.com> <2518b95d1002141441y778aef2aw15014cf0c8f224d1@mail.gmail.com> <5fdc56d71002141509x8191528j38174794f47c342a@mail.gmail.com> Message-ID: <4B78834F.6010708@gmail.com> Stephen Tetley wrote: > Hi Evan > > Singleton (aka wrap) would be nice - isn't it called Pointed in the > typeclassopedia but not otherwise existent? I suppose its missing by > historical accident rather than design. > > I frequently use Semigroup (append but no zero) - there is one on > Hackage without any instances: > http://hackage.haskell.org/package/algebra > I do too. I also wish there was an associative: class F f where k :: f a -> f a -> f a without the zero component. -- Tony Morris http://tmorris.net/ From qdunkan at gmail.com Sun Feb 14 18:41:06 2010 From: qdunkan at gmail.com (Evan Laforge) Date: Sun Feb 14 18:12:01 2010 Subject: [Haskell-cafe] What is the meaning of tilde ("~") symbol In-Reply-To: <5fdc56d71002141509x8191528j38174794f47c342a@mail.gmail.com> References: <4B76A310.9090406@gmail.com> <4B77F973.4090304@btinternet.com> <4b5b53361002141400s4c8cfdf7j7c26cd383cbddcea@mail.gmail.com> <2518b95d1002141411p25fc0131k61c69a9a1f141991@mail.gmail.com> <5fdc56d71002141422p3bd6a272j214bdbfa628978bf@mail.gmail.com> <2518b95d1002141441y778aef2aw15014cf0c8f224d1@mail.gmail.com> <5fdc56d71002141509x8191528j38174794f47c342a@mail.gmail.com> Message-ID: <2518b95d1002141541s6f62dbecs56990418dc858f28@mail.gmail.com> > I'm no fan of (!!) on lists or other containers where it isn't O(1), > but lookup/member are a bit more promising. However are there any > useful derived operations or constructions that can be defined only in > terms of a Lookup type class? For comparison, Monoid has mconcat as a > derived op and e.g. the Writer monad can be usefully abstract by > relying only on the Monoid interface as can Foldable. I was thinking of (!!) as an unsafe lookup, where lookup is the safe one. Of course historically (!!) considers lists as (Int -> elt) while elem considers them a set, which is why you'd need some newtype wrappers. Anyway, I'd be happy to not include the unsafe variants at all. That would mean putting [] into Setlike with 'member' but not Maplike with 'lookup'. You'd have to come up with a better name or hide the Prelude alist lookup. I don't know about derived operations, I suppose you could come up with some sort of Evironment monad that required merely a (Maplike a) class constraint instead of a concrete data type like Map, but for me the prime motivation would be the short universal name. I could stick it in my "import unqualified" toolbox and type less. > Excepting Data.Tree, Data.Graph and HashTable, 'containers' seems > pretty regular now - it certainly has moved on with 0.3.0.0. Yes, and it's not a big deal to me. I use Map and Set and List and the overhead of separate functions for each is pretty minimal. If I used a wider variety of containers I'd probably want it more. From wren at freegeek.org Sun Feb 14 19:38:47 2010 From: wren at freegeek.org (wren ng thornton) Date: Sun Feb 14 19:01:55 2010 Subject: [Haskell-cafe] Linguistic hair-splitting In-Reply-To: <5E7558A6-91A0-44A6-889F-036AF20824DC@2piix.com> References: <4B60862A.2090403@btinternet.com> <7ca3f0161001271214h413bd1c4s191d7657eea5cd53@mail.gmail.com> <201001272302.50650.daniel.is.fischer@web.de> <5E7558A6-91A0-44A6-889F-036AF20824DC@2piix.com> Message-ID: <4B789797.7040809@freegeek.org> Alexander Solla wrote: > On Jan 27, 2010, at 4:57 PM, Conor McBride wrote: > >> Yes, the separation is not clear in Haskell. (I consider this >> unfortunate.) I was thinking of Paul Levy's call-by-push-value >> calculus, where the distinction is clear, but perhaps not as fluid as >> one might like. > > What, exactly, is the supposed difference between a value and a > computation? Please remember that computations can and very often do > "return" computations as results. Please remember that in order for a > function to be computed for a value, binding and computation must > occur. And that for every value computed, a computation must occur, > even if it is "just" under identity the identity function. The difference is ontological. To pull in some category theory ---only because it helps make the distinction explicit--- there's a big difference between a morphism |A->B| and an exponential object |B^A|. What's the difference? Well, one is a morphism and the other is an object; they're simply different sorts of things, and it's a syntactic error to put one in the place of the other. In Cartesian Closed Categories (and similar) it so happens that the category "has exponentials", i.e. for every morphism |f:A->B| there exists an exponential object |o:B^A|. Because of the has-exponentials law, we know that in a CCC for every |f| there's an |o| and for every (exponential) |o| there's an |f|; but that does not mean that |f| and |o| are the *same* thing, it merely means we can conceptually convert between them. So what has any of this to do with Haskell? For the non category theorists in the audience: morphisms capture the notion of functions as procedures; that is, morphisms *do* things (or: are actions). Exponential objects capture the notion of functions as values/arguments; that is, objects *are* things. Down in the compiler we make the same exact distinction when distinguishing code or code pointers (morphisms) from closures (objects). In functional languages there are invisible coercions between functions-as-procedures and functions-as-values. The problem, as it were, is that the coercion is invisible. Why is this a problem? Most of the time it isn't; it's part of what makes functional programming so clean and elegant. Consider the identity monad. It's a simple monad, it's exactly the same thing as using direct values except with a newtype wrapper. Since it's exactly the same, why not try writing a program using |Id| everywhere instead of using the direct style. If you try this you'll see just how much invisible coercion is going on. That's part of the reason why it's sugared away. But some of the times you want or need to be explicit about the coercions (or conversely, want to change which coercions are implicit). Consider for instance the problem of having distinct functions |map| vs |mapM| or any other |foo| vs |fooM|. The reason for this proliferation is that, syntactically, we must write different code depending on whether we're using the invisible coercions of direct values, vs whether we're making the coercions explicit by using some monad (or applicative, or whatever). Haskell and similar languages choose a particular set of coercions to make invisible and implicit. Currying, uncurrying, application, etc. But there's nothing sacred about choosing to make those particular coercions invisible instead of choosing a different set of coercions to sugar away. -- Live well, ~wren From gue.schmidt at web.de Sun Feb 14 19:31:39 2010 From: gue.schmidt at web.de (=?ISO-8859-1?Q?G=FCnther_Schmidt?=) Date: Sun Feb 14 19:02:36 2010 Subject: [Haskell-cafe] on finding abstractions ... In-Reply-To: <36ACAC03-AADD-4D53-B708-C57A23B33C53@2piix.com> References: <4B77EECC.7080103@web.de> <36ACAC03-AADD-4D53-B708-C57A23B33C53@2piix.com> Message-ID: <4B7895EB.8020404@web.de> Well I just noticed that the boilerplate part consists of this: Import data by selecting fields from a table, feed them into some sort of internal data structure for later querying, times 12. All this involves quite a bit of boilerplate. Yeah, I guess I could abstract here a little. G?nther Am 14.02.10 23:37, schrieb Alexander Solla: > > On Feb 14, 2010, at 4:38 AM, G?nther Schmidt wrote: > >> I've got a problem, in short my haskell code sucks. While it does >> work and I do manage to use higher-orderish aspects quite extensively >> to make my code more concise it still is nowhere abstract, always >> concrete and thus always with lots of boilerplate. > > There is a such a thing as too much higher-ordered-ness. Every time > you introduce a new higher order dispatch mechanism, you go through > many of the same steps, and produce "slightly incompatible" > interfaces. You're basically defining plumbing, which you might have > to plumb into your existing plumbing. Boilerplate city. > > Instead of looking for a higher-order solution to your problem, look > for a normal form to express abstract terms that solve your problem. > The higher-order solution will become "obvious" when you have the > right normal forms (because now you know what you're quantifying > over) For example, algebraic data types are a natural encoding for > tree-like structures. They can even contain things. Monads are an > encoding for tree-like structures with an interface to the things the > nodes contain. I'm not saying you need to use monads. I'm saying you > should use them when they are the right normal form. > > Unfortunately, boilerplate is kind of a fact of life in Haskell, > unless you use things like TemplateHaskell or SYB. After making all > our nice orthogonal classes and data types in sensible normal forms, > we need to join these classes and types, with functions and class > instances. Taking big types down a chain of type classes is no fun. > But at least all that complexity is kept in one sensible place. > > One thing I wish GHC would do better is deal with cyclical module > dependencies more flexibly. More flexibility would mean letting us > organize our code by the normal form it embodies, as opposed to the > modules/types it uses. That makes code look a lot less > boilerplate-ish, since the "irrelevant" but important bits can all go > together. From wren at freegeek.org Sun Feb 14 20:11:02 2010 From: wren at freegeek.org (wren ng thornton) Date: Sun Feb 14 19:34:10 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> Message-ID: <4B789F26.8020806@freegeek.org> Michael Lesniak wrote: >> elegance of Haskell. Whether Haskell becomes an easy choice for >> commercial work or remains a boutique language depends on how easy it >> is to build today's applications. > > Do you (or anyone reading this thread) know of some kind of wishlist > of missing features and/or libraries? Would be nice to see what's > still "missing". There's the subReddit: http://www.reddit.com/r/haskell_proposals/ That's where I got the impetus to write the bytestring-trie package. I'm not sure how many other proposals have been taken up, or whether there's a good synopsis boiling it down or rating them by priority though. -- Live well, ~wren From maciej.podgurski at googlemail.com Sun Feb 14 20:33:11 2010 From: maciej.podgurski at googlemail.com (Maciej Podgurski) Date: Sun Feb 14 20:04:29 2010 Subject: [Haskell-cafe] Virus alert while installing happstack Message-ID: <4B78A457.6060504@googlemail.com> Hi, I tried to install happstack via "cabal install happstack" on my WinXP system. While installation progress, my anti-virus software (Avira AntiVir) warned me about dll_hsc_make.exe and files_hsc_make.exe to be a Trojan horse called "TR/Dropper.Gen". It's a bit confusing to get a virus alert while installing Haskell packages. Has anyone experienced this problem? And can I trust these files to be harmless? Besh wishes, Maciej From w.dj at skynet.be Sun Feb 14 20:48:52 2010 From: w.dj at skynet.be (Walter De Jonge) Date: Sun Feb 14 20:19:45 2010 Subject: [Haskell-cafe] pandoc code bocks not working Message-ID: <4B78A804.7010601@skynet.be> http://johnmacfarlane.net/pandoc/README.html#delimited-code-blocks "Like regular code blocks, delimited code blocks must be separated from surrounding text by blank lines." goodluck walter From marco-oweber at gmx.de Sun Feb 14 21:28:22 2010 From: marco-oweber at gmx.de (Marc Weber) Date: Sun Feb 14 20:59:20 2010 Subject: [Haskell-cafe] Virus alert while installing happstack In-Reply-To: <4B78A457.6060504@googlemail.com> References: <4B78A457.6060504@googlemail.com> Message-ID: <1266200522-sup-3402@nixos> Hi Maciej, Several open source projects suffered from false positives. Usually you sent the file to the company having written your Virus detection application for review. It may be a Virus. However it's very unlikely. If you're in doubt you should compile from source and also check the source which was used to compile ghc .. etc. I want to say if you really want to be secure the amount of work is infinity. So I'd sent the file to AntiVir. Then I would go one ignoring the warning (If it *is* a Virus don't make me responsible for any damage - you never know.) I just tell you what I would do. Maybe delete the file and redownload it to make sure that it wasn't modified while traveling through the net? You can also paste the md5sum of those executables. Maybe someone else can verify them easily. Good luck Marc Weber From max.rabkin at gmail.com Sun Feb 14 22:20:37 2010 From: max.rabkin at gmail.com (Max Rabkin) Date: Sun Feb 14 21:51:50 2010 Subject: [Haskell-cafe] Virus alert while installing happstack In-Reply-To: <1266200522-sup-3402@nixos> References: <4B78A457.6060504@googlemail.com> <1266200522-sup-3402@nixos> Message-ID: On Mon, Feb 15, 2010 at 11:28 AM, Marc Weber wrote: > unlikely. If you're in doubt you should compile from source and also > check the source which was used to compile ghc .. etc. I want to say if > you really want to be secure the amount of work is infinity. http://cm.bell-labs.com/who/ken/trust.html --Max From artyom.shalkhakov at gmail.com Sun Feb 14 23:23:33 2010 From: artyom.shalkhakov at gmail.com (Artyom Shalkhakov) Date: Sun Feb 14 22:54:28 2010 Subject: [Haskell-cafe] on finding abstractions ... In-Reply-To: <4B77EECC.7080103@web.de> References: <4B77EECC.7080103@web.de> Message-ID: <2076f2f91002142023i232b8f20ua06d62010ea4060b@mail.gmail.com> Hello, 2010/2/14, G?nther Schmidt : > Hello, > > I've got a problem, in short my haskell code sucks. While it does work > and I do manage to use higher-orderish aspects quite extensively to make > my code more concise it still is nowhere abstract, always concrete and > thus always with lots of boilerplate. > > Oh I have gotten better compared to when I started but on the > abstraction slope I'm still stuck. > > So fellows, what is the next stop on my road to enlightenment? I really > think I need best to start from scratch. I think I'm sufficiently > familiar now with most of Haskell's technicalities but how do I climb > the ladder of abstraction? It's actually okay: you come up with abstractions as a result of abstracting things out, :) not the other way round. I'd advise you to read "How To Design Programs". Unrelated to Haskell, it shows a bunch of nice examples of abstraction, including the steps required to get there, with motivation and justifications. The books is aimed at beginners in programming, but don't let that discourage you: it has good ideas to share. Cheers, Artyom Shalkhakov From knyttv at gmail.com Mon Feb 15 00:53:36 2010 From: knyttv at gmail.com (=?utf-8?Q?Vojt=C4=9Bch_Knyttl?=) Date: Mon Feb 15 00:24:35 2010 Subject: [Haskell-cafe] performance issue and HGL Message-ID: <1D36F086-7ADA-4D84-9C81-3286009894B9@gmail.com> Hello, I've created a simple Mandelbrot set generator, using HGL, the source is viewable at: http://pastebin.dqd.cz/cUmg/ 1. The problem is, that it is very slow. It is obvious that what takes the most time is the "mandel" function computation. I have no idea, how it can be improved. 2. What is the easiest way of changing a color and plotting a pixel with it? Do I always have to "create a pen" for it? Isn't there a simple way? Already ? using a line to plot a pixel is probably not the best way? Thanks From knyttv at gmail.com Mon Feb 15 00:57:56 2010 From: knyttv at gmail.com (=?utf-8?Q?Vojt=C4=9Bch_Knyttl?=) Date: Mon Feb 15 00:28:52 2010 Subject: [Haskell-cafe] running HGL on OSX In-Reply-To: <1d6a9f301002140235v43ea2304wbfd089e43f8f39cf@mail.gmail.com> References: <1d6a9f301002140235v43ea2304wbfd089e43f8f39cf@mail.gmail.com> Message-ID: <8AFC23FB-8B42-424A-B4EA-947E2FA9D22C@gmail.com> Thanks for reply ? another issue is with ghc: $ ghc --make graphics.hs -lHSrts -lSystemStubs (the only way which I found to compile correctly on OSX) will compile okay and will run okay, but the program runs slowly and consumes only 15 % of processor in average. In GHCI, it consumes easily 100 % and runs even a bit more fast... Thanks On Feb 14, 2010, at 11:35, Yuras Shumovich wrote: >> Loading package X11-1.5.0.0 ... can't load .so/.DLL for: X11 (dlopen(libX11.dylib, 9): image not found) > > try > DYLD_LIBRARY_PATH=/usr/X11R6/lib ghci graphics.hs > > http://hackage.haskell.org/trac/ghc/ticket/1019 From mlesniak at uni-kassel.de Mon Feb 15 03:24:13 2010 From: mlesniak at uni-kassel.de (Michael Lesniak) Date: Mon Feb 15 02:55:07 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <4B789F26.8020806@freegeek.org> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> <4B789F26.8020806@freegeek.org> Message-ID: <5f8b37691002150024r30cc33ddq4900073c2c8b49de@mail.gmail.com> Hello, > There's the subReddit: http://www.reddit.com/r/haskell_proposals/ I know it. The problem is that (at least in my opinion) only a small fraction of Haskell'ers use it. On the other hand, I have not found anything on the Wiki regarding these things, so maybe it's better than nothing. Cheers, Michael -- Dipl.-Inf. Michael C. Lesniak University of Kassel Programming Languages / Methodologies Research Group Department of Computer Science and Electrical Engineering Wilhelmsh?her Allee 73 34121 Kassel Phone: +49-(0)561-804-6269 From jon at jrock.us Mon Feb 15 03:32:47 2010 From: jon at jrock.us (Jonathan Rockway) Date: Mon Feb 15 03:03:43 2010 Subject: [Haskell-cafe] performance issue and HGL In-Reply-To: <1D36F086-7ADA-4D84-9C81-3286009894B9@gmail.com> (=?utf-8?Q?=22Vojt=C4=9Bch?= Knyttl"'s message of "Mon, 15 Feb 2010 06:53:36 +0100") References: <1D36F086-7ADA-4D84-9C81-3286009894B9@gmail.com> Message-ID: <87iq9ysxu8.fsf@snowball2.jrock.us> * On Sun, Feb 14 2010, Vojt?ch Knyttl wrote: > http://pastebin.dqd.cz/cUmg/ > > 1. The problem is, that it is very slow. It is obvious that what takes > the most time is the "mandel" function computation. I have no idea, > how it can be improved. Why 1000 iterations? Why is "Infinity" equal to 50? The sequence usually diverges an order of magnitude sooner than you anticipate, and 2 is considered to be a fine value for Infinity (it makes sense if you look at the plot). (Also, "it is obvious what takes the most time"? Did the profiler tell you that, or are you guessing?) If you want a really fast implementation, you are going to lose the simplicity. I wrote a very simple, multi-thread, mathematically-pure (infinity is Infinity, the complex numbers are Complex, etc.) a few weeks ago: http://gist.github.com/291074 It generated this 100M-pixel image in an hour and a half: http://jrock.us/mandelbrot-big.png (Warning: apparently that causes many browsers to crash. Gotta love C programs...) Anyway, not saying this is a good implementation, but it might give you some ideas. (The notable "innovation" is that the set membership is computed in threads, but the image is only generated in the first thread. This is a limitation of the library I used, but I was still able to realize massive speed gains by parallelizing: 8 hours of CPU time in 1.5 hours of wall clock time!) Reading the Google results for "mandelbrot set" is also enlightening, and yields optimizations that you may find useful. But when you start optimizing, you lose "simplicity", so consider first what your goals are -- a simple implementation, or a really fast implementation. Your needs might be met by changing iterations to 50 and "infinity" to 2. So basically, make sure "mandel" is what's slow, then optimize that. But make sure your plotting is also fast enough -- you are plotting as many points are you are calculating, after all. Regards, Jonathan Rockway -- Just "another Haskell hacker" From uzytkownik2 at gmail.com Mon Feb 15 04:06:41 2010 From: uzytkownik2 at gmail.com (Maciej Piechotka) Date: Mon Feb 15 03:37:48 2010 Subject: [Haskell-cafe] Re: Virus alert while installing happstack In-Reply-To: <4B78A457.6060504@googlemail.com> References: <4B78A457.6060504@googlemail.com> Message-ID: <1266224801.5440.4.camel@picard> On Mon, 2010-02-15 at 02:33 +0100, Maciej Podgurski wrote: > Hi, > > I tried to install happstack via "cabal install happstack" on my WinXP > system. While installation progress, my anti-virus software (Avira > AntiVir) warned me about dll_hsc_make.exe and files_hsc_make.exe to be a > Trojan horse called "TR/Dropper.Gen". It's a bit confusing to get a > virus alert while installing Haskell packages. Has anyone experienced > this problem? And can I trust these files to be harmless? > > > Besh wishes, > > Maciej I have virus alert every time I try to install something on Windows. Apparently the virus (in my case) is of form: int main(int argc, char *argv[]) { return 0; } I checked haskell-platform sources and found nothing. Regards PS. I had malware something but still... -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100215/f0d944b2/attachment.bin From dominic at steinitz.org Mon Feb 15 05:21:58 2010 From: dominic at steinitz.org (Dominic Steinitz) Date: Mon Feb 15 04:53:24 2010 Subject: [Haskell-cafe] Re: Linguistic hair-splitting References: <4B60862A.2090403@btinternet.com> <7ca3f0161001271214h413bd1c4s191d7657eea5cd53@mail.gmail.com> <201001272302.50650.daniel.is.fischer@web.de> <5E7558A6-91A0-44A6-889F-036AF20824DC@2piix.com> <4B789797.7040809@freegeek.org> Message-ID: wren ng thornton freegeek.org> writes: > or whatever). > > Haskell and similar languages choose a particular set of coercions to Nice explanation. From ckkashyap at gmail.com Mon Feb 15 08:33:44 2010 From: ckkashyap at gmail.com (C K Kashyap) Date: Mon Feb 15 08:04:38 2010 Subject: [Haskell-cafe] EDSL's using Filet-O-Fish of Barrelfish project In-Reply-To: <6cb897b31002140957x4a5c17dbr89bb09691eac0189@mail.gmail.com> References: <844f6ea61002140844p1be2c37dnb651a1ddf93a49f9@mail.gmail.com> <6cb897b31002140957x4a5c17dbr89bb09691eac0189@mail.gmail.com> Message-ID: <844f6ea61002150533i14bf97e0g836160eec0aaaf0a@mail.gmail.com> Thank you very much, What would be your recommendation on how to get a grasp of FoF - would the tic-tac-toe sample help - could you share that please? Regards, Kashyap On Sun, Feb 14, 2010 at 11:27 PM, Pierre-Evariste Dagand wrote: > Hi, > > On Sun, Feb 14, 2010 at 4:44 PM, C K Kashyap wrote: > > For example, lets say, I wanted to write a EDSL for Linux's network > drivers. Could I use > > Filet-O-Fish and generate a EDSL that allows me to write a driver in a > > really highlevel manner and then generate the "C" code for it? > > That sounds perfectly reasonable to me. > > However, you write "generate a EDSL that allows me to [...]". > Filet-o-Fish will not "generate" an EDSL for you. Filet-o-Fish will > help you implement the *back-end* of your (E)DSL compiler. You still > have to define a syntax and a semantics for your (E)DSL. FoF is here > to bridge the gap from your (E)DSL semantics to C, by doing it for > you. > > In Barrelfish, we have implemented the capability system this way: we > have defined the syntax and semantics of a DSL for specifying > capability systems, called Hamlet. Then, the Hamlet compiler back-end > has been implemented with FoF, which allowed us, for example, to > quickcheck some key property of the generated C code, by working at > the (more friendly) FoF code level (assuming that FoF is "correct" > ;-). > > For fun, we have implemented tic-tac-toe in the capability system. > Each game state is represented by a capability, you can "retype" a > capability from one to another iif this is a valid tic-tac-toe move. > For a 3x3 board, that's more than 4.800 unique capabilities, which is > quite a huge number of caps for an OS :-) You won't find that code in > the official Barrelfish, though. > > Whereas this work was done in the specific context of Barrelfish, > other people have designed DSLs for Linux. The examples I have in > mind, related to your question are: > * Devil [http://phoenix.inria.fr/index.php/projects/past-projects/devil]: > a device interface language, but still quite low-level compared to > what you're interested in ; > * Bossa [http://bossa.lip6.fr/]: a DSL for specifying schedulers for > Linux, which automatically turns the spec into code directly > integrated in the Linux kernel. > > I had the opportunity to discuss with the designer of these systems > and it is clear to me that this could be done with FoF as well. > > > Hope this help, > > -- > Pierre-Evariste DAGAND > http://perso.eleves.bretagne.ens-cachan.fr/~dagand/ > -- Regards, Kashyap -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100215/eb51070a/attachment.html From ramsdell0 at gmail.com Mon Feb 15 10:22:04 2010 From: ramsdell0 at gmail.com (John D. Ramsdell) Date: Mon Feb 15 09:52:56 2010 Subject: [Haskell-cafe] How to find unused exported symbols? Message-ID: <7687290b1002150722tb4e42cfs9ec94ddc6af7dca9@mail.gmail.com> I would like to find symbols exported from each module in a program that are not used outside the module. I'm worried my program is accumulating cruft. I'm looking for suggestions on how to find unused exported symbols. Do I have to analyse .hi files? Thanks in advance. John From shumovichy at gmail.com Mon Feb 15 10:35:14 2010 From: shumovichy at gmail.com (Yuras Shumovich) Date: Mon Feb 15 10:06:09 2010 Subject: [Haskell-cafe] How to find unused exported symbols? In-Reply-To: <7687290b1002150722tb4e42cfs9ec94ddc6af7dca9@mail.gmail.com> References: <7687290b1002150722tb4e42cfs9ec94ddc6af7dca9@mail.gmail.com> Message-ID: <1d6a9f301002150735y16366546s52aaea65a447b0d6@mail.gmail.com> Hmm... It looks like a useful tool to implement. (Of course it does not make sense for libraries, only for executables) It can be easily implemented using haskell-src-exts package. 2010/2/15 John D. Ramsdell : > I would like to find symbols exported from each module in a program > that are not used outside the module. ?I'm worried my program is > accumulating cruft. ?I'm looking for suggestions on how to find unused > exported symbols. ?Do I have to analyse .hi files? ?Thanks in advance. > > John > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From korpios at korpios.com Mon Feb 15 11:32:01 2010 From: korpios at korpios.com (Tom Tobin) Date: Mon Feb 15 11:02:58 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: <5f8b37691002150024r30cc33ddq4900073c2c8b49de@mail.gmail.com> References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> <4B789F26.8020806@freegeek.org> <5f8b37691002150024r30cc33ddq4900073c2c8b49de@mail.gmail.com> Message-ID: On Mon, Feb 15, 2010 at 2:24 AM, Michael Lesniak wrote: >> There's the subReddit: http://www.reddit.com/r/haskell_proposals/ > I know it. The problem is that (at least in my opinion) only a small > fraction of Haskell'ers use it. I strongly dislike "social X" sites (where X is "networking", "bookmarking", etc.). I'd rather keep that sort of thing on mailing lists, wikis, and bug trackers. From jason.dusek at gmail.com Mon Feb 15 13:25:37 2010 From: jason.dusek at gmail.com (Jason Dusek) Date: Mon Feb 15 12:56:29 2010 Subject: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there? In-Reply-To: References: <42784f261002100759h1ba0c51fy6d4bf3b24b6518a9@mail.gmail.com> <5f8b37691002110712y8f9faf8g4476dc29b865329f@mail.gmail.com> <4B789F26.8020806@freegeek.org> <5f8b37691002150024r30cc33ddq4900073c2c8b49de@mail.gmail.com> Message-ID: <42784f261002151025w8f2ad5by9758a5d4c951a90a@mail.gmail.com> 2010/02/15 Tom Tobin : > On Mon, Feb 15, 2010 at 2:24 AM, Michael Lesniak wrote: > > > There's the subReddit: http://www.reddit.com/r/haskell_proposals/ > > > > I know it. The problem is that (at least in my opinion) only a small > > fraction of Haskell'ers use it. > > I strongly dislike "social X" sites (where X is "networking", > "bookmarking", etc.). ?I'd rather keep that sort of thing on mailing > lists, wikis, and bug trackers. A Haskell proposals mailing list would work well, I think. I didn't have the necessary permissions to create mailing lists for haskell.org, though. -- Jason Dusek From jason.dusek at gmail.com Mon Feb 15 13:29:49 2010 From: jason.dusek at gmail.com (Jason Dusek) Date: Mon Feb 15 13:00:42 2010 Subject: [Haskell-cafe] Two authors especially likely to be spammed. Message-ID: <42784f261002151029w31140781i31a72492fc69faf2@mail.gmail.com> I recently discovered that many haskell-cafe mails are being dumped in my SPAM folder. A lot of them are from John Lato and Simon Marlow. I wonder if anyone else has experienced this? -- Jason Dusek From korpios at korpios.com Mon Feb 15 13:35:02 2010 From: korpios at korpios.com (Tom Tobin) Date: Mon Feb 15 13:05:55 2010 Subject: [Haskell-cafe] Two authors especially likely to be spammed. In-Reply-To: <42784f261002151029w31140781i31a72492fc69faf2@mail.gmail.com> References: <42784f261002151029w31140781i31a72492fc69faf2@mail.gmail.com> Message-ID: On Mon, Feb 15, 2010 at 12:29 PM, Jason Dusek wrote: > ?I recently discovered that many haskell-cafe mails are > ?being dumped in my SPAM folder. A lot of them are from John > ?Lato and Simon Marlow. I just did this search on my Gmail: "in:spam haskell" ... and got no results, so I think I'm okay. FWIW I'm using the Google Apps version of Gmail; I don't know if that makes a difference. From andrewcoppin at btinternet.com Mon Feb 15 16:23:33 2010 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Mon Feb 15 15:54:24 2010 Subject: [Haskell-cafe] Two authors especially likely to be spammed. In-Reply-To: <42784f261002151029w31140781i31a72492fc69faf2@mail.gmail.com> References: <42784f261002151029w31140781i31a72492fc69faf2@mail.gmail.com> Message-ID: <4B79BB55.9020801@btinternet.com> Jason Dusek wrote: > I recently discovered that many haskell-cafe mails are > being dumped in my SPAM folder. A lot of them are from John > Lato and Simon Marlow. > > I wonder if anyone else has experienced this? > My ISP classifies huge amounts of Haskell-related mail as spam - no matter how many times I tell it this stuff isn't spam. It also utterly fails to classify the "Nigerian bank transfer" emails as spam. Hotmail seems to do a much better job. Although since The Monad Reader, I'm suddenly getting far more spam incoming there too... From dons at galois.com Mon Feb 15 16:35:57 2010 From: dons at galois.com (Don Stewart) Date: Mon Feb 15 16:06:54 2010 Subject: [Haskell-cafe] Notes on migrating from uvector to vector Message-ID: <20100215213557.GH4036@whirlpool.galois.com> I've summarised my notes on how to migrate array code from the uvector package to Roman's vector package: http://donsbot.wordpress.com/2010/02/15/migrating-from-uvector-to-vector/ And I'll take this opportunity to declare that uvector is now in official maintainance-only mode. Enjoy the new decade of flexible, fusible, fast arrays for Haskell! -- Don From andrewcoppin at btinternet.com Mon Feb 15 16:49:26 2010 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Mon Feb 15 16:20:20 2010 Subject: [Haskell-cafe] Notes on migrating from uvector to vector In-Reply-To: <20100215213557.GH4036@whirlpool.galois.com> References: <20100215213557.GH4036@whirlpool.galois.com> Message-ID: <4B79C166.7060500@btinternet.com> Don Stewart wrote: > Enjoy the new decade of flexible, fusible, fast arrays for Haskell! > More interesting might be a post on how to migrate from Data.Array to vector; it's news to me that any of these post-Haskell98 array libraries are production-ready yet. (And while we're on the subject, what's the status of DHP? Is that supposed to work yet? For nontrivial programs?) From creswick at gmail.com Mon Feb 15 17:16:05 2010 From: creswick at gmail.com (Rogan Creswick) Date: Mon Feb 15 16:47:18 2010 Subject: [Haskell-cafe] Notes on migrating from uvector to vector In-Reply-To: <20100215213557.GH4036@whirlpool.galois.com> References: <20100215213557.GH4036@whirlpool.galois.com> Message-ID: On Mon, Feb 15, 2010 at 1:35 PM, Don Stewart wrote: > And I'll take this opportunity to declare that uvector is now in > official maintainance-only mode. Would it make sense to add a note to that effect to the package description / cabal file, so it shows up on hackage? ('Stability: Experimental' seems particularly odd ;) --Rogan From dons at galois.com Mon Feb 15 17:28:54 2010 From: dons at galois.com (Don Stewart) Date: Mon Feb 15 16:59:49 2010 Subject: [Haskell-cafe] Notes on migrating from uvector to vector In-Reply-To: References: <20100215213557.GH4036@whirlpool.galois.com> Message-ID: <20100215222854.GA4626@whirlpool.galois.com> creswick: > On Mon, Feb 15, 2010 at 1:35 PM, Don Stewart wrote: > > And I'll take this opportunity to declare that uvector is now in > > official maintainance-only mode. > > Would it make sense to add a note to that effect to the package > description / cabal file, so it shows up on hackage? ('Stability: > Experimental' seems particularly odd ;) Done: http://hackage.haskell.org/package/uvector-0.1.1.1 From dons at galois.com Mon Feb 15 19:10:38 2010 From: dons at galois.com (Don Stewart) Date: Mon Feb 15 18:41:33 2010 Subject: [Haskell-cafe] vector to uvector and back again In-Reply-To: <201002120728.17965.dan.doel@gmail.com> References: <4B72F3F6.3050506@k-hornz.de> <4B7441AE.3070407@k-hornz.de> <201002112054.17250.dan.doel@gmail.com> <201002120728.17965.dan.doel@gmail.com> Message-ID: <20100216001038.GN4626@whirlpool.galois.com> dan.doel: > On Thursday 11 February 2010 8:54:15 pm Dan Doel wrote: > > On Thursday 11 February 2010 12:43:10 pm stefan kersten wrote: > > > On 10.02.10 19:03, Bryan O'Sullivan wrote: > > > > I'm thinking of switching the statistics library over to using vector. > > > > > > that would be even better of course! an O(0) solution, at least for me ;) > > > let me know if i can be of any help (e.g. in testing). i suppose > > > uvector-algorithms would also need to be ported to vector, then. > > > > I could do this. > > To this end, I've done a preliminary port of the library, such that all the > modules compile. I've just used safe operations so far, so it's probably a > significant decrease in performance over the 0.2 uvector-algorithms (unless > perhaps you turn off the bounds checking flag), but it's a start. It can be > gotten with: > > darcs get http://code.haskell.org/~dolio/vector-algorithms I've ported uvector's tests to vector, and mostly got identical code, except for: * tail * zip* * empty/null I think if you find any slowdown over uvector it has to be a bug in vector. Let Roman know. -- Don From schlepptop at henning-thielemann.de Mon Feb 15 19:35:04 2010 From: schlepptop at henning-thielemann.de (Henning Thielemann) Date: Mon Feb 15 19:06:39 2010 Subject: [Haskell-cafe] Undecidable instances with functional dependencies In-Reply-To: References: Message-ID: <4B79E838.3070804@henning-thielemann.de> Miguel Mitrofanov schrieb: > -- {-# LANGUAGE FunctionalDependencies#-} > -- {-# LANGUAGE MultiParamTypeClasses #-} > {-# LANGUAGE TypeFamilies #-} > module Register where > -- class Register a r | a -> r > class Register a where > type R a > -- instance Register Int Int > instance Register Int where > type R Int = Int > -- instance Register Float Float > instance Register Float where > type R Float = Float > -- instance (Register a1 r1, Register a2 r2) => Register (a1, a2) (r1, > r2) > instance (Register a, Register b) => Register (a, b) where > type R (a, b) = (R a, R b) > So type functions are undecidable by default? From dons at galois.com Mon Feb 15 19:55:47 2010 From: dons at galois.com (Don Stewart) Date: Mon Feb 15 19:26:41 2010 Subject: [Haskell-cafe] IDL - compilers In-Reply-To: <4B4FBEE5.10505@web.de> References: <4B4FBBA2.2050609@web.de> <20100115010025.GB25621@whirlpool.galois.com> <4B4FBEE5.10505@web.de> Message-ID: <20100216005547.GU4626@whirlpool.galois.com> gue.schmidt: > Hi Don, > > Am 15.01.10 02:00, schrieb Don Stewart: >> gue.schmidt: >> >>> Hi, >>> >>> are there any IDL compilers that can create Haskelk modules from header >>> files or type-libs? >>> >>> >> The venerable hdirect. http://www.haskell.org/hdirect/ >> >> I've recently cabalized the package, which is still in fine condition. >> Let me know if you need a copy. >> > > Oh yes!, please!, pretty please! Sigbjorn's hdirect release has now been cabalized and placed on Hackage. http://hackage.haskell.org/package/hdirect hdirect is an IDL compiler for Haskell, which offers a helping hand to the Haskell programmer that wants to better interact with and reuse external code. -- Don From kowey at darcs.net Mon Feb 15 20:35:41 2010 From: kowey at darcs.net (Eric Kow) Date: Mon Feb 15 20:06:35 2010 Subject: [Haskell-cafe] Darcs fundraising 2010 - success! Message-ID: <20100216013539.GA159@dewdrop.local> Hi everybody, Here's the final report on our Darcs 2010 fundraising effort. In a word, success! I wasn't sure we could pull it off, but thanks to all of your contributions, we reached our target of $2000. Thanks, everyone! We'll be using this money to fund travel expenses for our bi-annual Darcs hacking sprints. I'm looking forward to seeing what kind of impact this has, how much easier this makes it for us to bring our community together (literally). Finally, I think this would be a good time to call your attention to our new thank-you page . This is just a small way for us to make a note of all the ways that you have helped the Darcs project, and how much we appreciate your contributions (your feedback, patches, support). Most recently, I've added a new section to this page, which makes a nod to some of ours larger donors. They also had some rather nice things to say about Darcs, so do have a look :-) Rah! Eric PS. Please let me know if you'd like to make a travel claim for ZuriHac -- Eric Kow PGP Key ID: 08AC04F9 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 195 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100215/5ac92e3a/attachment.bin From dmehrtash at gmail.com Mon Feb 15 21:58:51 2010 From: dmehrtash at gmail.com (Daryoush Mehrtash) Date: Mon Feb 15 21:29:41 2010 Subject: [Haskell-cafe] How can i run darcs in ghci? Message-ID: I am trying to load darc.hs (from darcs 2.3.1, ghci 6.10.4 on Ubuntu) and I get the following :~/darcs-src/darcs-2.3.1/src$ ghci GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Prelude> :load darcs Darcs/RepoPath.hs:59:0: error: impossible.h: No such file or directory phase `C pre-processor' failed (exitcode = 1) > What am I doing wrong? Thanks, Daryoush -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100215/ec6aeb13/attachment.html From ivan.miljenovic at gmail.com Mon Feb 15 22:42:19 2010 From: ivan.miljenovic at gmail.com (Ivan Miljenovic) Date: Mon Feb 15 22:13:12 2010 Subject: [Haskell-cafe] How to find unused exported symbols? In-Reply-To: <7687290b1002150722tb4e42cfs9ec94ddc6af7dca9@mail.gmail.com> References: <7687290b1002150722tb4e42cfs9ec94ddc6af7dca9@mail.gmail.com> Message-ID: On 16 February 2010 02:22, John D. Ramsdell wrote: > I would like to find symbols exported from each module in a program > that are not used outside the module. ?I'm worried my program is > accumulating cruft. ?I'm looking for suggestions on how to find unused > exported symbols. ?Do I have to analyse .hi files? ?Thanks in advance. -Wall will tell you which entities in are module are top-level but not exported; my SourceGraph program (available from Hackage) will tell you which entities in the entire project are top-level but not exported. Note that at the moment the output is rather ugly.... -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com Mike Ditka - "If God had wanted man to play soccer, he wouldn't have given us arms." - http://www.brainyquote.com/quotes/authors/m/mike_ditka.html From ivan.miljenovic at gmail.com Mon Feb 15 22:43:49 2010 From: ivan.miljenovic at gmail.com (Ivan Miljenovic) Date: Mon Feb 15 22:14:39 2010 Subject: [Haskell-cafe] Notes on migrating from uvector to vector In-Reply-To: <20100215213557.GH4036@whirlpool.galois.com> References: <20100215213557.GH4036@whirlpool.galois.com> Message-ID: On 16 February 2010 08:35, Don Stewart wrote: > Enjoy the new decade of flexible, fusible, fast arrays for Haskell! /me points out that 2010 is actually the last year of the decade, and not the first year of a new decade... ;-) -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com Pablo Picasso - "Computers are useless. They can only give you answers." - http://www.brainyquote.com/quotes/authors/p/pablo_picasso.html From dons at galois.com Mon Feb 15 22:45:51 2010 From: dons at galois.com (Don Stewart) Date: Mon Feb 15 22:16:43 2010 Subject: [Haskell-cafe] Notes on migrating from uvector to vector In-Reply-To: References: <20100215213557.GH4036@whirlpool.galois.com> Message-ID: <20100216034551.GB6020@whirlpool.galois.com> ivan.miljenovic: > On 16 February 2010 08:35, Don Stewart wrote: > > Enjoy the new decade of flexible, fusible, fast arrays for Haskell! > > /me points out that 2010 is actually the last year of the decade, and > not the first year of a new decade... Computer scientists count from zero. :-) -- Don From ivan.miljenovic at gmail.com Mon Feb 15 22:53:38 2010 From: ivan.miljenovic at gmail.com (Ivan Miljenovic) Date: Mon Feb 15 22:24:31 2010 Subject: [Haskell-cafe] Notes on migrating from uvector to vector In-Reply-To: <20100216034551.GB6020@whirlpool.galois.com> References: <20100215213557.GH4036@whirlpool.galois.com> <20100216034551.GB6020@whirlpool.galois.com> Message-ID: On 16 February 2010 14:45, Don Stewart wrote: > ivan.miljenovic: >> On 16 February 2010 08:35, Don Stewart wrote: >> > Enjoy the new decade of flexible, fusible, fast arrays for Haskell! >> >> /me points out that 2010 is actually the last year of the decade, and >> not the first year of a new decade... > > Computer scientists count from zero. :-) Except that the current numbering system to record the number of revolutions that our planet has revolved around the nearest solar body was not devised by computer scientists... -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com Charles de Gaulle - "The better I get to know men, the more I find myself loving dogs." - http://www.brainyquote.com/quotes/authors/c/charles_de_gaulle.html From korpios at korpios.com Mon Feb 15 23:15:27 2010 From: korpios at korpios.com (Tom Tobin) Date: Mon Feb 15 22:46:19 2010 Subject: [Haskell-cafe] Notes on migrating from uvector to vector In-Reply-To: References: <20100215213557.GH4036@whirlpool.galois.com> Message-ID: On Mon, Feb 15, 2010 at 9:43 PM, Ivan Miljenovic wrote: > On 16 February 2010 08:35, Don Stewart wrote: >> Enjoy the new decade of flexible, fusible, fast arrays for Haskell! > > /me points out that 2010 is actually the last year of the decade, and > not the first year of a new decade... Hm, I'm not sure about that; while it's fairly established that millenniums are 1-indexed (as there was no "Year 0" ... silly Gregorian calendar), it seems that decades are 0-indexed (e.g., "the 80s"). Unfortunately neither of my go-to usage guides (_Garner's Modern American Usage_ and _The Chicago Manual of Style_) says much on the topic. :p From ramsdell0 at gmail.com Mon Feb 15 23:19:49 2010 From: ramsdell0 at gmail.com (John D. Ramsdell) Date: Mon Feb 15 22:50:39 2010 Subject: [Haskell-cafe] How to find unused exported symbols? In-Reply-To: References: <7687290b1002150722tb4e42cfs9ec94ddc6af7dca9@mail.gmail.com> Message-ID: <7687290b1002152019r1ae92935ua726b3b7eca5c48b@mail.gmail.com> I wonder if I should use the GHC API to do this. I notice there is a module called BinIface that contains a reader for interface files. The trouble is you have to figure out how to initialize a program that uses the module, and that seems to be difficult. I couldn't find anything relevant on the Wiki. John On Mon, Feb 15, 2010 at 10:42 PM, Ivan Miljenovic wrote: > On 16 February 2010 02:22, John D. Ramsdell wrote: >> I would like to find symbols exported from each module in a program >> that are not used outside the module. ?I'm worried my program is >> accumulating cruft. ?I'm looking for suggestions on how to find unused >> exported symbols. ?Do I have to analyse .hi files? ?Thanks in advance. > > -Wall will tell you which entities in are module are top-level but not > exported; my SourceGraph program (available from Hackage) will tell > you which entities in the entire project are top-level but not > exported. ?Note that at the moment the output is rather ugly.... > > -- > Ivan Lazar Miljenovic > Ivan.Miljenovic@gmail.com > IvanMiljenovic.wordpress.com > Mike Ditka ?- "If God had wanted man to play soccer, he wouldn't have > given us arms." - > http://www.brainyquote.com/quotes/authors/m/mike_ditka.html > From ok at cs.otago.ac.nz Mon Feb 15 23:32:02 2010 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Mon Feb 15 23:03:02 2010 Subject: [Haskell-cafe] Notes on migrating from uvector to vector In-Reply-To: References: <20100215213557.GH4036@whirlpool.galois.com> <20100216034551.GB6020@whirlpool.galois.com> Message-ID: On Feb 16, 2010, at 4:53 PM, Ivan Miljenovic wrote: > On 16 February 2010 14:45, Don Stewart wrote: >> ivan.miljenovic: >>> On 16 February 2010 08:35, Don Stewart wrote: >>>> Enjoy the new decade of flexible, fusible, fast arrays for Haskell! >>> >>> /me points out that 2010 is actually the last year of the decade, >>> and >>> not the first year of a new decade... >> >> Computer scientists count from zero. :-) > > Except that the current numbering system to record the number of > revolutions that our planet has revolved around the nearest solar body > was not devised by computer scientists... I'm not sure what kind of people are responsible for ISO 8601, but the ISO calendar, mandated by several programming language standards including ANSI Smalltalk, uses something called the "proleptic Gregorian calendar" (ISO 8601) or the "retrospective Gregorian calendar" (ANSI Smalltalk), which includes a year zero. Although 1AD was preceded by 1BC, 1CE is preceded by 0CE. Given that Europe got the concept of zero from the Muslims, I wonder whether the Muslim calendar(s) has(have) a year 0? From marco-oweber at gmx.de Tue Feb 16 01:49:58 2010 From: marco-oweber at gmx.de (Marc Weber) Date: Tue Feb 16 01:20:52 2010 Subject: [Haskell-cafe] How can i run darcs in ghci? In-Reply-To: References: Message-ID: <1266302824-sup-6353@nixos> > What am I doing wrong? I don't know exactly. What's your use case? You should be able to load the darcs library into ghci without problems. Maybe this is good enough for you? impossible.h is located in src. So looking up ghc flags about how to to pass -I flags to CPP should be enough (?). Another way to find those flags fast is running ./Setup -v3 which will output the ghc commands cabal is running. HTH Marc Weber From dmehrtash at gmail.com Tue Feb 16 02:53:23 2010 From: dmehrtash at gmail.com (Daryoush Mehrtash) Date: Tue Feb 16 02:24:14 2010 Subject: [Haskell-cafe] How can i run darcs in ghci? In-Reply-To: <1266302824-sup-6353@nixos> References: <1266302824-sup-6353@nixos> Message-ID: I am trying to understand darcs implementation. I can install the app using cabal, so now I want to load it in ghci to be able to play around with it. Any help on how to load the .h is greatly appreciated. I tried -i with path to the src directory but it didn't work (should it?). I am also very curious how others approach a new code base. What do the you do to figure out an implementation? Thanks, Daryoush On Mon, Feb 15, 2010 at 10:49 PM, Marc Weber wrote: > > What am I doing wrong? > I don't know exactly. What's your use case? You should be able to load > the darcs library into ghci without problems. Maybe this is good enough > for you? > > impossible.h is located in src. So looking up ghc flags about how to > to pass -I flags to CPP should be enough (?). > > Another way to find those flags fast is running ./Setup -v3 > which will output the ghc commands cabal is running. > > HTH > Marc Weber > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100216/7e4718f1/attachment.html From marco-oweber at gmx.de Tue Feb 16 03:17:59 2010 From: marco-oweber at gmx.de (Marc Weber) Date: Tue Feb 16 02:48:56 2010 Subject: [Haskell-cafe] How can i run darcs in ghci? In-Reply-To: References: <1266302824-sup-6353@nixos> Message-ID: <1266307997-sup-2585@nixos> > Any help on how to load the .h is greatly appreciated. I tried -i > with > path to the src directory but it didn't work (should it?). Try -I -i is used for .hs files only (?). > I am also very curious how others approach a new code base. What do > the you > do to figure out an implementation? ghci offers a debugger. I haven't used that much yet. If things are a little bit more complex I don't use ghci. I use ghc to call the code I'm interested in. This way my memory :-) doesn't vanish. If you stop ghci things are gone. Yeah, you can copy paste code into an editor.. Sometimes the only way for me to understand code is spending hours reading it. However I'm not sure whether you can get to know code that much faster. Afterall it depends on your goals. What do you want to do with darcs? There are some papers as well. You should also know that there is a darcs (devel/users) mailinglist if you're stuck that's the appropriate place to ask questions (or try irc) Marc Weber From limestrael at gmail.com Tue Feb 16 04:14:51 2010 From: limestrael at gmail.com (=?UTF-8?Q?Yves_Par=C3=A8s?=) Date: Tue Feb 16 03:45:41 2010 Subject: [Haskell-cafe] Undecidable instances with functional dependencies In-Reply-To: <4B79E838.3070804@henning-thielemann.de> References: <4B79E838.3070804@henning-thielemann.de> Message-ID: <27605436.post@talk.nabble.com> However, TypeFamilies seems too be non portable as according to this http://www.haskell.org/haskellwiki/GHC/Type_families, it works only as from GHC 6.10.1. Henning Thielemann-4 wrote: > > Miguel Mitrofanov schrieb: >> -- {-# LANGUAGE FunctionalDependencies#-} >> -- {-# LANGUAGE MultiParamTypeClasses #-} >> {-# LANGUAGE TypeFamilies #-} >> module Register where >> -- class Register a r | a -> r >> class Register a where >> type R a >> -- instance Register Int Int >> instance Register Int where >> type R Int = Int >> -- instance Register Float Float >> instance Register Float where >> type R Float = Float >> -- instance (Register a1 r1, Register a2 r2) => Register (a1, a2) (r1, >> r2) >> instance (Register a, Register b) => Register (a, b) where >> type R (a, b) = (R a, R b) >> > So type functions are undecidable by default? > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > ----- Yves Par?s Live long and prosper -- View this message in context: http://old.nabble.com/Undecidable-instances-with-functional-dependencies-tp27555079p27605436.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From iku.iwasa at gmail.com Tue Feb 16 05:52:51 2010 From: iku.iwasa at gmail.com (iquiw) Date: Tue Feb 16 05:24:02 2010 Subject: [Haskell-cafe] Efficient M to N conversion on fusion? Message-ID: Hi, Is there any efficient way to convert M-length ByteString, Text or Vector into N-length one? For example, (a) converting byte array into array of their hex representations. ("abc" => "616263") (b) escaping some specific characters in string. ("a\bc" => "a\\bc") The only way I found is to use concatMap... Thanks, iquiw From ivan.miljenovic at gmail.com Tue Feb 16 05:58:21 2010 From: ivan.miljenovic at gmail.com (Ivan Miljenovic) Date: Tue Feb 16 05:29:11 2010 Subject: [Haskell-cafe] Efficient M to N conversion on fusion? In-Reply-To: References: Message-ID: On 16 February 2010 21:52, iquiw wrote: > Is there any efficient way to convert M-length ByteString, Text or > Vector into N-length one? I don't believe so, no. Maybe the lazy variants would have better efficiency than the strict ones though... -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com Stephen Leacock - "I detest life-insurance agents: they always argue that I shall some day die, which is not so." - http://www.brainyquote.com/quotes/authors/s/stephen_leacock.html From ozgurakgun at gmail.com Tue Feb 16 08:26:55 2010 From: ozgurakgun at gmail.com (Ozgur Akgun) Date: Tue Feb 16 07:57:50 2010 Subject: [Haskell-cafe] Notes on migrating from uvector to vector In-Reply-To: References: <20100215213557.GH4036@whirlpool.galois.com> <20100216034551.GB6020@whirlpool.galois.com> Message-ID: <7be1feae1002160526j23b072d5w835a3f18100b0aac@mail.gmail.com> Wikipedia claims in short that "Year Zero is the year before 1 A.D. used in astronomical calculations.". In full: http://en.wikipedia.org/wiki/Year_zero Seems like no calendar, other than astronomical things include it. On 16 February 2010 04:32, Richard O'Keefe wrote: > > On Feb 16, 2010, at 4:53 PM, Ivan Miljenovic wrote: > > On 16 February 2010 14:45, Don Stewart wrote: >> >>> ivan.miljenovic: >>> >>>> On 16 February 2010 08:35, Don Stewart wrote: >>>> >>>>> Enjoy the new decade of flexible, fusible, fast arrays for Haskell! >>>>> >>>> >>>> /me points out that 2010 is actually the last year of the decade, and >>>> not the first year of a new decade... >>>> >>> >>> Computer scientists count from zero. :-) >>> >> >> Except that the current numbering system to record the number of >> revolutions that our planet has revolved around the nearest solar body >> was not devised by computer scientists... >> > > I'm not sure what kind of people are responsible for ISO 8601, > but the ISO calendar, mandated by several programming language > standards including ANSI Smalltalk, uses something called the > "proleptic Gregorian calendar" (ISO 8601) or the "retrospective > Gregorian calendar" (ANSI Smalltalk), which includes a year zero. > Although 1AD was preceded by 1BC, 1CE is preceded by 0CE. > > Given that Europe got the concept of zero from the Muslims, > I wonder whether the Muslim calendar(s) has(have) a year 0? > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Ozgur Akgun -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100216/33c70869/attachment.html From felipe.lessa at gmail.com Tue Feb 16 09:12:13 2010 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Tue Feb 16 08:43:10 2010 Subject: [Haskell-cafe] Efficient M to N conversion on fusion? In-Reply-To: References: Message-ID: <20100216141213.GA15121@kira.casa> On Tue, Feb 16, 2010 at 07:52:51PM +0900, iquiw wrote: > Is there any efficient way to convert M-length ByteString, Text or > Vector into N-length one? This is just a guess, but in vector at least it should be possible to use sized[1] to tell how much space should be allocated on the final vector. For example, something like the following *untested* code: import qualified Data.Vector.Stream.Monadic as S import qualified Data.Vector.Generic as G import Control.Applicative import Data.Vector.Stream.Size -- | The size should be the size of each v b. concatMapSized :: (G.Vector v a, G.Vector v b) => Size -> (a -> v b) -> v a -> v b concatMapSized size_each f v = let stream = G.stream v size = mult size_each (S.size stream) in G.unstream . flip S.sized size . S.concatMap (G.stream . f) $ stream mult :: Size -> Size -> Size mult (Exact n) (Exact m) = Exact (n*m) mult x y = maybe Max Unknown $ (*) <$> upperBound x <*> upperBound y I really don't know if this would improve or worsen performance, you should check the core and do benchmarks :). [1] http://hackage.haskell.org/packages/archive/vector/0.5/doc/html/Data-Vector-Fusion-Stream.html#v%3Asized -- Felipe. From martijn at van.steenbergen.nl Tue Feb 16 09:26:26 2010 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Tue Feb 16 08:57:22 2010 Subject: [Haskell-cafe] Notes on migrating from uvector to vector In-Reply-To: References: <20100215213557.GH4036@whirlpool.galois.com> Message-ID: <4B7AAB12.7040401@van.steenbergen.nl> Ivan Miljenovic wrote: > On 16 February 2010 08:35, Don Stewart wrote: >> Enjoy the new decade of flexible, fusible, fast arrays for Haskell! > > /me points out that 2010 is actually the last year of the decade, and > not the first year of a new decade... There certainly is /a/ decade that starts today. :-) Martijn. From sergueyz at gmail.com Tue Feb 16 09:33:50 2010 From: sergueyz at gmail.com (Serguey Zefirov) Date: Tue Feb 16 09:04:39 2010 Subject: [Haskell-cafe] DLL on Windows Message-ID: <600376291002160633m638099cy846dd3770a3190cf@mail.gmail.com> I tried the way described in http://www.haskell.org/ghc/docs/latest/html/users_guide/win32-dlls.html and i got this error message: -------------------------------------------------------------------------------------------- ghc -shared -o test.dll --make test.hs [1 of 1] Compiling Test ( test.hs, test.o ) ghc.exe: panic! (the 'impossible' happened) (GHC version 6.10.3 for i386-unknown-mingw32): link: GHC not built to link this way: LinkDynLib Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug -------------------------------------------------------------------------------------------- How can I fix it? From jmg at gaillourdet.net Tue Feb 16 09:45:38 2010 From: jmg at gaillourdet.net (Jean-Marie Gaillourdet) Date: Tue Feb 16 09:16:10 2010 Subject: [Haskell-cafe] Interpreting profiling results In-Reply-To: <201001041605.45336.daniel.is.fischer@web.de> References: <201001041605.45336.daniel.is.fischer@web.de> Message-ID: <4B7AAF92.5080105@gaillourdet.net> Hi, Daniel Fischer wrote: >> total alloc = 165,728 bytes (excludes profiling overheads) >> >> COST CENTRE MODULE %time %alloc >> >> CAF GHC.Handle 0.0 10.7 >> CAF Text.Read.Lex 0.0 2.1 >> CAF GHC.Read 0.0 1.2 >> square Main 0.0 2.8 >> solve Main 0.0 1.3 >> show_aVx Main 0.0 3.7 >> readsPrec_aYF Main 0.0 60.6 >> main Main 0.0 9.6 >> genNums Main 0.0 5.0 >> cell Main 0.0 1.2 >> >> >> >> individual inherited >> COST CENTRE MODULE >> no. entries %time %alloc %time %alloc >> >> MAIN MAIN >> 1 0 0.0 0.3 0.0 100.0 >> main Main >> 186 1 0.0 9.6 0.0 85.6 >> show_aVx Main >> 196 2 0.0 3.7 0.0 3.7 >> cell Main >> 197 16 0.0 0.0 0.0 0.0 >> solve Main >> 188 5 0.0 1.3 0.0 11.8 >> genNums Main >> 189 8 0.0 5.0 0.0 10.4 >> square Main >> 194 88 0.0 2.8 0.0 3.2 >> cell Main >> 195 16 0.0 0.4 0.0 0.4 >> col Main >> 192 4 0.0 0.7 0.0 1.1 >> cell Main >> 193 16 0.0 0.4 0.0 0.4 >> row Main >> 190 4 0.0 0.7 0.0 1.1 >> cell Main >> 191 16 0.0 0.4 0.0 0.4 >> readsPrec_aYF Main >> 187 3 0.0 60.6 0.0 60.6 >> CAF GHC.Read >> 151 1 0.0 1.2 0.0 1.2 >> CAF Text.Read.Lex >> 144 8 0.0 2.1 0.0 2.1 >> CAF GHC.Handle >> 128 4 0.0 10.7 0.0 10.7 >> CAF GHC.Conc >> 127 1 0.0 0.0 0.0 0.0 >> >> Does the column 'entries' represent the number of times the function >> was called? > > Number of times it was 'entered', not quite the same as the number of times it was called. > I think (Warning: speculation ahead, I don't *know* how the profiles are generated) it's > thus: > Say you call a function returning a list. One call, first entry. It finds the beginning of > the list, the first k elements and hands them to the caller. Caller processes these, asks > "can I have more, or was that it?". Same call, second entry: f looks for more, finds the > next m elements, hands them to caller. Caller processes. Repeat until whatever happens > first, caller doesn't ask whether there's more or callee finds there's nothing more (or > hits bottom). > Warning: speculation ahead, but is based on my knowledge on other profilers. Many profilers work statistically, they interrupt a program at more less random (or equal) intervals and inspect the stack, whick is of course quite difficult in Haskell as far as I understand it. I have interpreted the entries column as an indication for the amount of "profile interrupts" which happened when a function f was on top of the stack, whatever that means in Haskell. The manual of GHC 6.10.4, chapter 5 states: >The actual meaning of the various columns in the output is: > >entries > > The number of times this particular point in the call graph was > entered. So for me the question remains open, is "entries" a precisely counted value or a statistically determined one? Best regards, Jean From daniel.is.fischer at web.de Tue Feb 16 10:17:37 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Feb 16 09:50:41 2010 Subject: [Haskell-cafe] Interpreting profiling results In-Reply-To: <4B7AAF92.5080105@gaillourdet.net> References: <201001041605.45336.daniel.is.fischer@web.de> <4B7AAF92.5080105@gaillourdet.net> Message-ID: <201002161617.37626.daniel.is.fischer@web.de> Am Dienstag 16 Februar 2010 15:45:38 schrieb Jean-Marie Gaillourdet: > Warning: speculation ahead, but is based on my knowledge on other > profilers. > > Many profilers work statistically, they interrupt a program at more less > random (or equal) intervals and inspect the stack, whick is of course > quite difficult in Haskell as far as I understand it. I have interpreted > the entries column as an indication for the amount of "profile > interrupts" which happened when a function f was on top of the stack, > whatever that means in Haskell. > > The manual of GHC 6.10.4, chapter 5 states: > >The actual meaning of the various columns in the output is: > > > >entries > > > > ? ?The number of times this particular point in the call graph was > > ? ?entered. > > So for me the question remains open, is "entries" a precisely counted > value or a statistically determined one? I have one observation that supports "precisely counted", namely, while the time spent in each cost centre (number of ticks) varies between profiling runs of the same code, the number of bytes allocated and the number of entries remain the same. It's far from conclusive, though. Anybody willing to dig into the profiler code? 8-) > > > Best regards, > Jean Cheers, Daniel From vandijk.roel at gmail.com Tue Feb 16 10:51:42 2010 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Tue Feb 16 10:22:33 2010 Subject: [Haskell-cafe] RFC: concurrent-extra Message-ID: Hello, We wrote a small library (1) which offers a few extra synchronization primitives. These primitives are found in the standard libraries of languages like Java and Python, but not in Haskell. Before releasing concurrent-extra on hackage, we would like some comments on its name, design, implementation, documentation (2) and general usefulness. All primitives are implemented with MVars and IORefs, except for Control.Concurrent.STM.Event. There is a small test suite which tests some properties: cabal configure -ftest cabal build cabal test The test suite still needs to be expanded a great deal. We found that testing concurrent algorithms is really hard. Now we test things like "this shouldn't deadlock" by checking if it doesn't take too long. But that doesn't feel very formal. Is there a more principled approach to testing concurrent algorithms in Haskell? After writing our version of a read-write lock we noticed the package rwlock (3) on hackage. But there is a difference: rwlock is implemented with STM while our version is implemented entirely with MVars. Regards, Roel & Bas van Dijk 1 - http://code.haskell.org/~roelvandijk/code/concurrent-extra/ 2 - http://code.haskell.org/~roelvandijk/code/concurrent-extra/doc/html/concurrent-extra/index.html 3 - http://hackage.haskell.org/package/rwlock From johan.tibell at gmail.com Tue Feb 16 10:53:16 2010 From: johan.tibell at gmail.com (Johan Tibell) Date: Tue Feb 16 10:24:26 2010 Subject: [Haskell-cafe] Interpreting profiling results In-Reply-To: <4B7AAF92.5080105@gaillourdet.net> References: <201001041605.45336.daniel.is.fischer@web.de> <4B7AAF92.5080105@gaillourdet.net> Message-ID: <90889fe71002160753x17ac2e1dhf24e4f8ec59bbbc4@mail.gmail.com> On Tue, Feb 16, 2010 at 3:45 PM, Jean-Marie Gaillourdet wrote: > Hi, > > Daniel Fischer wrote: > >> total alloc = 165,728 bytes (excludes profiling overheads) > >> > >> COST CENTRE MODULE %time %alloc > >> > >> CAF GHC.Handle 0.0 10.7 > >> CAF Text.Read.Lex 0.0 2.1 > >> CAF GHC.Read 0.0 1.2 > >> square Main 0.0 2.8 > >> solve Main 0.0 1.3 > >> show_aVx Main 0.0 3.7 > >> readsPrec_aYF Main 0.0 60.6 > >> main Main 0.0 9.6 > >> genNums Main 0.0 5.0 > >> cell Main 0.0 1.2 > >> > >> > >> > >> individual inherited > >> COST CENTRE MODULE > >> no. entries %time %alloc %time %alloc > >> > >> MAIN MAIN > >> 1 0 0.0 0.3 0.0 100.0 > >> main Main > >> 186 1 0.0 9.6 0.0 85.6 > >> show_aVx Main > >> 196 2 0.0 3.7 0.0 3.7 > >> cell Main > >> 197 16 0.0 0.0 0.0 0.0 > >> solve Main > >> 188 5 0.0 1.3 0.0 11.8 > >> genNums Main > >> 189 8 0.0 5.0 0.0 10.4 > >> square Main > >> 194 88 0.0 2.8 0.0 3.2 > >> cell Main > >> 195 16 0.0 0.4 0.0 0.4 > >> col Main > >> 192 4 0.0 0.7 0.0 1.1 > >> cell Main > >> 193 16 0.0 0.4 0.0 0.4 > >> row Main > >> 190 4 0.0 0.7 0.0 1.1 > >> cell Main > >> 191 16 0.0 0.4 0.0 0.4 > >> readsPrec_aYF Main > >> 187 3 0.0 60.6 0.0 60.6 > >> CAF GHC.Read > >> 151 1 0.0 1.2 0.0 1.2 > >> CAF Text.Read.Lex > >> 144 8 0.0 2.1 0.0 2.1 > >> CAF GHC.Handle > >> 128 4 0.0 10.7 0.0 10.7 > >> CAF GHC.Conc > >> 127 1 0.0 0.0 0.0 0.0 > >> > >> Does the column 'entries' represent the number of times the function > >> was called? > > > > Number of times it was 'entered', not quite the same as the number of > times it was called. > > I think (Warning: speculation ahead, I don't *know* how the profiles are > generated) it's > > thus: > > Say you call a function returning a list. One call, first entry. It finds > the beginning of > > the list, the first k elements and hands them to the caller. Caller > processes these, asks > > "can I have more, or was that it?". Same call, second entry: f looks for > more, finds the > > next m elements, hands them to caller. Caller processes. Repeat until > whatever happens > > first, caller doesn't ask whether there's more or callee finds there's > nothing more (or > > hits bottom). > > > > Warning: speculation ahead, but is based on my knowledge on other > profilers. > > Many profilers work statistically, they interrupt a program at more less > random (or equal) intervals and inspect the stack, whick is of course > quite difficult in Haskell as far as I understand it. I have interpreted > the entries column as an indication for the amount of "profile > interrupts" which happened when a function f was on top of the stack, > whatever that means in Haskell. > > The manual of GHC 6.10.4, chapter 5 states: > > >The actual meaning of the various columns in the output is: > > > >entries > > > > The number of times this particular point in the call graph was > > entered. > > > So for me the question remains open, is "entries" a precisely counted > value or a statistically determined one? I believe it's the latter. I think the RTS uses a periodic SIGALRM to figure out which function is currently executing and to record that in the profile. Simon Marlow would know. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100216/c1de31e8/attachment.html From nccb2 at kent.ac.uk Tue Feb 16 11:18:25 2010 From: nccb2 at kent.ac.uk (Neil Brown) Date: Tue Feb 16 10:50:28 2010 Subject: [Haskell-cafe] RFC: concurrent-extra In-Reply-To: References: Message-ID: <4B7AC551.1080409@kent.ac.uk> Hi, I had a look at the code for Event (both versions) and Lock (but not the others just yet) and it seemed fine. If you do lots of calls to waitTimeout before a set you will accumulate old locks in the list, but that won't cause any error that I can see, so it would only be a problem in pathological cases. I'm not sure there is a good way to test MVar algorithms. One way to do it (which the Concurrent Haskell Debugger did online, IIRC: http://www.informatik.uni-kiel.de/~fhu/chd/) is to reimplement IO to explore different interleavings of the various MVar calls to look for deadlocks. If you're testing STM, generally you can look to capture invariants of your transactions and check that they hold after each transaction (e.g. that if the state is Set, there shouldn't be any locks waiting with an event). Thanks, Neil. Roel van Dijk wrote: > Hello, > > We wrote a small library (1) which offers a few extra synchronization > primitives. These primitives are found in the standard libraries of > languages like Java and Python, but not in Haskell. > > Before releasing concurrent-extra on hackage, we would like some > comments on its name, design, implementation, documentation (2) and > general usefulness. > > All primitives are implemented with MVars and IORefs, except for > Control.Concurrent.STM.Event. > > There is a small test suite which tests some properties: > > cabal configure -ftest > cabal build > cabal test > > The test suite still needs to be expanded a great deal. We found that > testing concurrent algorithms is really hard. Now we test things like > "this shouldn't deadlock" by checking if it doesn't take too long. But > that doesn't feel very formal. Is there a more principled approach to > testing concurrent algorithms in Haskell? > > After writing our version of a read-write lock we noticed the package > rwlock (3) on hackage. But there is a difference: rwlock is > implemented with STM while our version is implemented entirely with > MVars. > > > Regards, > Roel & Bas van Dijk > > > 1 - http://code.haskell.org/~roelvandijk/code/concurrent-extra/ > 2 - http://code.haskell.org/~roelvandijk/code/concurrent-extra/doc/html/concurrent-extra/index.html > 3 - http://hackage.haskell.org/package/rwlock > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ndmitchell at gmail.com Tue Feb 16 11:37:41 2010 From: ndmitchell at gmail.com (Neil Mitchell) Date: Tue Feb 16 11:08:33 2010 Subject: [Haskell-cafe] DLL on Windows In-Reply-To: <600376291002160633m638099cy846dd3770a3190cf@mail.gmail.com> References: <600376291002160633m638099cy846dd3770a3190cf@mail.gmail.com> Message-ID: <404396ef1002160837u172b5cdcs6531b7ec06985aae@mail.gmail.com> Hi Serguey, I notice you are using GHC 6.10.3, I suggest you try 6.10.4 which I know does work. I rewrote that section of the manual recently. I haven't had time to merge it back in, but it might give you more help: http://neilmitchell.blogspot.com/2009/11/haskell-dlls-on-windows.html Thanks, Neil On Tue, Feb 16, 2010 at 2:33 PM, Serguey Zefirov wrote: > I tried the way described in > http://www.haskell.org/ghc/docs/latest/html/users_guide/win32-dlls.html > and i got this error message: > > -------------------------------------------------------------------------------------------- > ghc -shared -o test.dll --make test.hs > [1 of 1] Compiling Test ? ? ? ? ? ? ( test.hs, test.o ) > ghc.exe: panic! (the 'impossible' happened) > ?(GHC version 6.10.3 for i386-unknown-mingw32): > ? ? ? ?link: GHC not built to link this way: LinkDynLib > > Please report this as a GHC bug: ?http://www.haskell.org/ghc/reportabug > -------------------------------------------------------------------------------------------- > How can I fix it? > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From Malcolm.Wallace at cs.york.ac.uk Tue Feb 16 11:42:43 2010 From: Malcolm.Wallace at cs.york.ac.uk (Malcolm Wallace) Date: Tue Feb 16 11:13:48 2010 Subject: [Haskell-cafe] Interpreting profiling results In-Reply-To: <4B7AAF92.5080105@gaillourdet.net> References: <201001041605.45336.daniel.is.fischer@web.de> <4B7AAF92.5080105@gaillourdet.net> Message-ID: <369E4CBD-B1A9-4A60-A190-FBB30A30702A@cs.york.ac.uk> > So for me the question remains open, is "entries" a precisely > counted value or a statistically determined one? The entry count is precise. It is only the time (and allocation) counts that are determined statistically. (If the entry count _were_ statistically sampled, it would give exactly the same information as the time counts, no more and no less.) Regards, Malcolm From marlowsd at gmail.com Tue Feb 16 11:47:02 2010 From: marlowsd at gmail.com (Simon Marlow) Date: Tue Feb 16 11:18:04 2010 Subject: [Haskell-cafe] Re: RFC: concurrent-extra In-Reply-To: References: Message-ID: <4B7ACC06.6070205@gmail.com> On 16/02/2010 15:51, Roel van Dijk wrote: > Hello, > > We wrote a small library (1) which offers a few extra synchronization > primitives. These primitives are found in the standard libraries of > languages like Java and Python, but not in Haskell. > > Before releasing concurrent-extra on hackage, we would like some > comments on its name, design, implementation, documentation (2) and > general usefulness. > > All primitives are implemented with MVars and IORefs, except for > Control.Concurrent.STM.Event. > > There is a small test suite which tests some properties: > > cabal configure -ftest > cabal build > cabal test > > The test suite still needs to be expanded a great deal. We found that > testing concurrent algorithms is really hard. Now we test things like > "this shouldn't deadlock" by checking if it doesn't take too long. But > that doesn't feel very formal. Is there a more principled approach to > testing concurrent algorithms in Haskell? You might want to take a look at the concurrency part of the GHC test suite: http://darcs.haskell.org/testsuite/tests/ghc-regress/concurrent/should_run/ Not that we've really solved the problem you're talking about, but you might get some ideas. Often deadlocks are caught by the RTS and result in an exception which you can catch, though with the threaded RTS this relies on detecting idle time and running the GC, which by default happens after 0.3s of idle time. Some people find this annoying and turn off the idle-time GC (+RTS -I0) but then you lose deadlock detection. Swings and roundabouts. Cheers, Simon From apfelmus at quantentunnel.de Tue Feb 16 11:48:43 2010 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Tue Feb 16 11:20:00 2010 Subject: [Haskell-cafe] Re: on finding abstractions ... In-Reply-To: <4B77EECC.7080103@web.de> References: <4B77EECC.7080103@web.de> Message-ID: G?nther Schmidt wrote: > I've got a problem, in short my haskell code sucks. While it does work > and I do manage to use higher-orderish aspects quite extensively to make > my code more concise it still is nowhere abstract, always concrete and > thus always with lots of boilerplate. > > Oh I have gotten better compared to when I started but on the > abstraction slope I'm still stuck. > > So fellows, what is the next stop on my road to enlightenment? I really > think I need best to start from scratch. I think I'm sufficiently > familiar now with most of Haskell's technicalities but how do I climb > the ladder of abstraction? As others said, there are already a few existing abstractions that you can take advantage of, like applicative functors, functional references (aka data-accessor) or monads; it pays to know them well. Other than that, many abstractions will probably be some kind of domain specific language. Since those are by definition specific to the problem domain, it's hard to give general advice. I'd suggest to learn from examples like Paul Hudak. The Design of a Pretty-printing Library. http://citeseer.ist.psu.edu/hughes95design.html Philip Wadler. A prettier printer. http://decenturl.com/homepages.inf.ed/wadler-98-prettier-printer Simon Peyton Jones, Jean-Marc Eber, Julian Seward. Composing contracts: an adventure in financial engineering. http://decenturl.com/research.microsoft/spj-financial-contracts Regards, Heinrich Apfelmus -- http://apfelmus.nfshost.com From limestrael at gmail.com Tue Feb 16 12:00:08 2010 From: limestrael at gmail.com (=?UTF-8?Q?Yves_Par=C3=A8s?=) Date: Tue Feb 16 11:30:57 2010 Subject: [Haskell-cafe] Threading and FFI Message-ID: <27611528.post@talk.nabble.com> Hello! I was wondering: is the Haskell default runtime (that which uses only one processor) scheduler able to interrupt a thread which is currently calling to a C function in order to enable another haskell thread to progress? I think it can't, because I have starvation problems when I have a thread which calls inside its loop to a C function which makes a little "sleep". BTW, what is the portable way to sleep a thread in Haskell ? Control.Concurrent.threadDelay is "GHC only". ----- Yves Par?s Live long and prosper -- View this message in context: http://old.nabble.com/Threading-and-FFI-tp27611528p27611528.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From sergueyz at gmail.com Tue Feb 16 12:19:15 2010 From: sergueyz at gmail.com (Serguey Zefirov) Date: Tue Feb 16 11:50:05 2010 Subject: [Haskell-cafe] DLL on Windows In-Reply-To: <404396ef1002160837u172b5cdcs6531b7ec06985aae@mail.gmail.com> References: <600376291002160633m638099cy846dd3770a3190cf@mail.gmail.com> <404396ef1002160837u172b5cdcs6531b7ec06985aae@mail.gmail.com> Message-ID: <600376291002160919hcb6e9c6o1a383eb96480364f@mail.gmail.com> I'd like to, but I cannot. My code is tied to gtk2hs, which supports either 6.10.1 or 6.10.3. I put it another way: could I build DLL using ghc 6.12.*? If I can, I'll use 6.10.3 for gtk2hs code and 6.12 for all new stuff. 2010/2/16 Neil Mitchell : > Hi Serguey, > > I notice you are using GHC 6.10.3, I suggest you try 6.10.4 which I > know does work. > > I rewrote that section of the manual recently. I haven't had time to > merge it back in, but it might give you more help: > > http://neilmitchell.blogspot.com/2009/11/haskell-dlls-on-windows.html > > Thanks, Neil > > On Tue, Feb 16, 2010 at 2:33 PM, Serguey Zefirov wrote: >> I tried the way described in >> http://www.haskell.org/ghc/docs/latest/html/users_guide/win32-dlls.html >> and i got this error message: >> >> -------------------------------------------------------------------------------------------- >> ghc -shared -o test.dll --make test.hs >> [1 of 1] Compiling Test ? ? ? ? ? ? ( test.hs, test.o ) >> ghc.exe: panic! (the 'impossible' happened) >> ?(GHC version 6.10.3 for i386-unknown-mingw32): >> ? ? ? ?link: GHC not built to link this way: LinkDynLib >> >> Please report this as a GHC bug: ?http://www.haskell.org/ghc/reportabug >> -------------------------------------------------------------------------------------------- >> How can I fix it? >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > From D.J.Duke at leeds.ac.uk Tue Feb 16 12:21:52 2010 From: D.J.Duke at leeds.ac.uk (David Duke) Date: Tue Feb 16 11:52:44 2010 Subject: [Haskell-cafe] Microsoft Research PhD Scholarship, University of Leeds Message-ID: I'm pleased to announce a PhD Scholarship within the Visualization and VR group at Leeds, generously funded by Microsoft Research. We are seeking a student to investigate how visualization techniques can be further developed to understand and improve the performance of parallel Haskell programs running on multi-core CPUs. Closing date for applications is 22 March 2010. Could you please pass on this call to anyone who might be interested in applying. Further details are included below, and are also available on the web, at http://www.engineering.leeds.ac.uk/pg/studentships/duke.shtml thanks, David Duke PROJECT TITLE: "Visualizing Performance for Multicore Haskell" SUPERVISION: Dr. David Duke, School of Computing, University of Leeds, UK MRL CO-SUPERVISION: Dr. Satnam Singh Prof. Simon Peyton Jones Dr. Simon Marlow Microsoft Research Laboratory, Cambridge, UK OUTLINE: The GHC Haskell compiler now provides high-level abstractions that allow the programmer to benefit from multi-core CPUs. These abstractions support implicit parallelism - the programmer can indicate expressions that could usefully be evaluated in parallel, but is freed from concerns about when parallel evaluation takes place. However, it now becomes more difficult to isolate and resolve performance issues. Visualization of run-time behaviour can help. The Haskell community already have the benefit of a tool, ThreadScope, developed at Microsoft Research Cambridge (research.microsoft.com/en-us/labs/ Cambridge/) that provides insight into resource utilisation. However ThreadScope, like other performance visualization tools, presents the programmer with a view of low-level resources that differs from the level of abstraction at which Haskell programmers are encouraged to work. This studentship will investigate visualization techniques for linking high-level program abstractions with low-level runtime performance data. It should allow Haskell programmers to exploit parallelism more effectively. The student will join the Visualization and VR group at Leeds (www.comp.leeds.ac.uk/vvr) . Work on the PhD will involve: understanding how information about run-time resources can be extracted and visualized, and how programmers use these representations to reason about design and implementation choices; building or extending visualization tools; conducting user evaluations; modify components of the GHC compiler and runtime system. Work will be undertaken with support from the GHC/ ThreadScope team at Microsoft Research (Satnam Singh, Simon Peyton Jones, and Simon Marlow). At the discretion of Microsoft Research, the student may also be offered an internship at MRL Cambridge. FUNDING: The Scholarship provides a bursary of ?20,000 per year for three years, covering fees and maintenance. A further ?3000 per annum has been reserved for travel expenses to attend conferences and visits to Microsoft Research in Cambridge. Applicants from outside of the EU should note that higher student fees (currently ?13,300) will necessarily reduce the amount available for maintenance. Home/EU fees stand at ?3,390 currently. Microsoft Research will provide the successful candidate with a laptop equipped with a suite of software. ENTRY REQUIREMENTS: Applicants must hold a First-Class BSc (Hon) degree in Computer Science or equivalent. It is essential that applicants have excellent knowledge of functional programming and significant practical experience writing software in Haskell, Clean, or ML. Experience with GUI programming and/or information visualization is highly desirable. Knowledge of programming technologies, in particular compilers and implementation techniques for functional languages is also desirable. The position is open to students of all nationalities. SCHOOL OF COMPUTING, LEEDS: The School of Computing (www.comp.leeds.ac.uk) is among the 10 best Computing departments in the UK according to the 2008 Research Assessment Exercise (RAE). An impressive 80% of staff is rated internationally excellent or world leading. This clearly confirms the School?s position as one of the leading computing departments in the UK and a leader in the field internationally. APPLICATION PROCEDURE: Formal applications for research degree study must be made either online through the University website, or on the University?s application form. Detailed information of how to apply on line can be found at: www.leeds.ac.uk/students/apply_research.htm The paper application form is available at: www.leeds.ac.uk/rds/Admissions/Admis_home.htm Please return the completed application form to: Research Degrees & Scholarships Office, University of Leeds, LS2 9JT. Please provide all the documents required as soon as possible, either included with your paper application or sent directly to the School of Computing secretary (rsadmit@comp.leeds.ac.uk) if you apply online. Scanned copies are acceptable for a conditional offer; however you will need to provide originals or certified copies at registration. These will include your degree certificate(s), transcripts of marks achieved in previous degrees, plus evidence of English language qualifications if your first language is not English and you do not hold a degree from an English-speaking country. Please note, if you intend to send academic references we can only accept them if they are on official letter headed paper and contain an original signature and stamp; they must arrive in sealed envelopes. Alternatively, the School will contact your named academic referees directly. CLOSING DATE: Applications must be received by 22 March 2010. ACADEMIC CONTACT: For questions about the research topic, please contact Dr. David Duke, University of Leeds; Tel: +44 113 343 6800; Email: D.J.Duke@leeds.ac.uk; Web: www.comp.leeds.ac.uk/djd/ From apfelmus at quantentunnel.de Tue Feb 16 12:21:53 2010 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Tue Feb 16 11:53:07 2010 Subject: [Haskell-cafe] Re: Implementing "unionAll" In-Reply-To: References: Message-ID: Leon Smith wrote: > With the urging and assistance of Omar Antol?n Camarena, I will be > adding two functions to data-ordlist: mergeAll and unionAll, which > merge (or union) a potentially infinite list of potentially infinite > ordered lists, under the assumption that the heads of the non-empty > lists appear in a non-decreasing sequence. > > However, as Omar pointed out to me, the following implementation of > unionAll has a flaw: > >> unionAll :: Ord a => [[a]] -> [a] >> unionAll = foldr (\(x:xs) ys -> x : union xs ys) [] > > Namely unionAll [[1,2],[1,2]] should return [1,2], whereas it > actually returns [1,1,2]. After some work, I believe I have > generalized H. Apfelmus's algorithm to handle this; however it seems > a bit complicated. I would love feedback, especially with regard to > simplifications, bugs, testing strategies, and optimizations: > >> unionAll' :: Ord a => [[a]] -> [a] >> unionAll' = unionAllBy compare > >> data People a = VIP a (People a) | Crowd [a] > >> unionAllBy :: (a -> a -> Ordering) -> [[a]] -> [a] >> unionAllBy cmp xss = loop [ (VIP x (Crowd xs)) | (x:xs) <- xss ] >> where >> loop [] = [] >> loop ( VIP x xs : VIP y ys : xss ) >> = case cmp x y of >> LT -> x : loop ( xs : VIP y ys : xss ) >> EQ -> loop ( VIP x (union' xs ys) : unionPairs xss ) >> GT -> error "Data.List.Ordered.unionAll: assumption violated!" >> loop ( VIP x xs : xss ) >> = x : loop (xs:xss) >> loop [Crowd xs] = xs >> loop (xs:xss) = loop (unionPairs (xs:xss)) >> >> unionPairs [] = [] >> unionPairs [x] = [x] >> unionPairs (x:y:zs) = union' x y : unionPairs zs >> >> union' (VIP x xs) (VIP y ys) >> = case cmp x y of >> LT -> VIP x (union' xs (VIP y ys)) >> EQ -> VIP x (union' xs ys) >> GT -> error "Data.List.Ordered.unionAll: assumption violated!" >> union' (VIP x xs) (Crowd ys) = VIP x (union' xs (Crowd ys)) >> union' (Crowd []) ys = ys >> union' (Crowd xs) (Crowd ys) = Crowd (unionBy cmp xs ys) >> union' xs@(Crowd (x:xt)) ys@(VIP y yt) >> = case cmp x y of >> LT -> VIP x (union' (Crowd xt) ys) >> EQ -> VIP x (union' (Crowd xt) yt) >> GT -> VIP y (union' xs yt) I see no obvious deficiencies. :) Personally, I'd probably structure it like http://www.haskell.org/haskellwiki/Prime_numbers#Implicit_Heap so that your code becomes unionAll = serve . foldTree union' . map vip Your loop function is a strange melange of many different concerns (building a tree, union', adding and removing the VIP constructors). Note that it's currently unclear to me whether the lazy pattern match in pairs ~(x: ~(y:ys)) = f x y : pairs ys is beneficial or not; you used a strict one unionPairs (x:y:zs) = union' x y : unionPairs zs Daniel Fischer's experiments suggest that the strict one is better http://www.mail-archive.com/haskell-cafe@haskell.org/msg69807.html If you're really concerned about time & space usage, it might even be worth to abandon the lazy tree altogether and use a heap to achieve the same effect, similar to Melissa O'Neils prime number code. It's not as "neat", but much more predictable. :) Regards, Heinrich Apfelmus -- http://apfelmus.nfshost.com From ndmitchell at gmail.com Tue Feb 16 12:24:09 2010 From: ndmitchell at gmail.com (Neil Mitchell) Date: Tue Feb 16 11:54:59 2010 Subject: [Haskell-cafe] What is the meaning of tilde ("~") symbol In-Reply-To: References: <4B76A310.9090406@gmail.com> <4B77F973.4090304@btinternet.com> Message-ID: <404396ef1002160924k1aebf32bw3fb2bf80d953e102@mail.gmail.com> Hi > The symbols that are not specified in a library can be found here: > ?http://www.haskell.org/haskellwiki/Keywords > Hoogle used to show links to this page, when a keyword was searched, but not > anymore. And that's a bug: http://code.google.com/p/ndmitchell/issues/detail?id=280 (that I only just became aware of). I'll fix this up shortly. Thanks, Neil From felipe.lessa at gmail.com Tue Feb 16 12:25:22 2010 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Tue Feb 16 11:56:15 2010 Subject: [Haskell-cafe] Threading and FFI In-Reply-To: <27611528.post@talk.nabble.com> References: <27611528.post@talk.nabble.com> Message-ID: <20100216172522.GC6832@kira.casa> On Tue, Feb 16, 2010 at 09:00:08AM -0800, Yves Par?s wrote: > I was wondering: is the Haskell default runtime (that which uses only one > processor) scheduler able to interrupt a thread which is currently calling > to a C function in order to enable another haskell thread to progress? > I think it can't, because I have starvation problems when I have a thread > which calls inside its loop to a C function which makes a little "sleep". Did you try marking the call as safe? Cheers, -- Felipe. From dev at mobileink.com Tue Feb 16 12:34:28 2010 From: dev at mobileink.com (Gregg Reynolds) Date: Tue Feb 16 12:05:17 2010 Subject: [Haskell-cafe] Linguistic hair-splitting In-Reply-To: References: <4B60862A.2090403@btinternet.com> <4B608848.9090108@functor.nl> <7ca3f0161001271214h413bd1c4s191d7657eea5cd53@mail.gmail.com> Message-ID: <75cc17ac1002160934u233f1dfan2d20c73689e7145c@mail.gmail.com> On Sat, Jan 30, 2010 at 1:24 AM, Conal Elliott wrote: > I call it "an m" or (more specifically) "an Int m" or "a list of Int". For > instance, "a list" or "an Int list" or "a list of Int". - Conal > > > On Wed, Jan 27, 2010 at 12:14 PM, Luke Palmer wrote: > >> On Wed, Jan 27, 2010 at 11:39 AM, Jochem Berndsen >> wrote: >> >> Now, here's the question: Is is correct to say that [3, 5, 8] is a >> >> monad? >> > >> > In what sense would this be a monad? I don't quite get your question. >> >> I think the question is this: if m is a monad, then what do you call >> a thing of type m Int, or m Whatever. >> >> Luke >> > Conal's is the most sensible approach - "what do you call it" amounts to "what sort of a thing is it", and the best we can say in that respect is "er, its a thing of type m Whatever". (My preference, if maximal explicitness is needed, is to say "it's a token of its type"; some say "term of type m Whatever".) Trying to classify such a thing as "value", "object", "computation", "reduction" etc. inevitably (and necessarily) leads to tail-chasing since those notions are all essentially equivalent. Plus they miss the essential point, which is the typing. Original poster would probably find Martin-Lof's philosophically-tinged writings very good on this - clear, reasonably simple, and revelatory, if you've never closely looked at intuitionistic logic before. Truth of a proposition, evidence of a judgment, validity of a proofis especially readable, as is On the meanings of the Logical Constants and the Justifications of the Logical Laws . Presents a completely new (to me) way of thinking about "what is it, really?" questions about computation, monads, etc., i.e. ask not "what is it?" but "how do you know?" or even "how do you make it?" The Stanford article on types and tokensis also very enlightening in this respect. -g -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100216/0d680715/attachment.html From dev at mobileink.com Tue Feb 16 12:43:08 2010 From: dev at mobileink.com (Gregg Reynolds) Date: Tue Feb 16 12:13:56 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> Message-ID: <75cc17ac1002160943r22f871f2ra376ce9c31a246aa@mail.gmail.com> On Tue, Feb 2, 2010 at 5:26 AM, Mark Spezzano wrote: > Hi all, > > Has anyone else found it frustratingly difficult to find details on > easy-to-diget material on Category theory. The Chapter that I'm stuck on is > actually labeled Preliminaries and so I reason that if I can't > I've looked through at least a dozen. For neophytes, the best of the bunch BY FAR is Goldblatt, Topoi: the categorial analysis of logic. Don't be put off by the title. He not only explains the stuff, but he explains the problems that motivated the invention of the stuff. He doesn't cover monads, but he covers all the basics very clearly, so once you've got that down you can move to another author for monads. -gregg -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100216/78f81ae9/attachment.html From ndmitchell at gmail.com Tue Feb 16 12:57:20 2010 From: ndmitchell at gmail.com (Neil Mitchell) Date: Tue Feb 16 12:28:10 2010 Subject: [Haskell-cafe] DLL on Windows In-Reply-To: <600376291002160919hcb6e9c6o1a383eb96480364f@mail.gmail.com> References: <600376291002160633m638099cy846dd3770a3190cf@mail.gmail.com> <404396ef1002160837u172b5cdcs6531b7ec06985aae@mail.gmail.com> <600376291002160919hcb6e9c6o1a383eb96480364f@mail.gmail.com> Message-ID: <404396ef1002160957m6ae4370bxb3b0a1d65353c30b@mail.gmail.com> Hi Serguey, A GHC 6.10.4 version of Gtk2hs: http://www.mail-archive.com/gtk2hs-devel@lists.sourceforge.net/msg00340.html I used to recommend Gtk2hs over wxHaskell for GUI development as there was always a version that worked on Windows with the latest GHC release. I think I might have to switch back to recommending C# for GUI development... Thanks, Neil On Tue, Feb 16, 2010 at 5:19 PM, Serguey Zefirov wrote: > I'd like to, but I cannot. My code is tied to gtk2hs, which supports > either 6.10.1 or 6.10.3. > > I put it another way: could I build DLL using ghc 6.12.*? > > If I can, I'll use 6.10.3 for gtk2hs code and 6.12 for all new stuff. > > 2010/2/16 Neil Mitchell : >> Hi Serguey, >> >> I notice you are using GHC 6.10.3, I suggest you try 6.10.4 which I >> know does work. >> >> I rewrote that section of the manual recently. I haven't had time to >> merge it back in, but it might give you more help: >> >> http://neilmitchell.blogspot.com/2009/11/haskell-dlls-on-windows.html >> >> Thanks, Neil >> >> On Tue, Feb 16, 2010 at 2:33 PM, Serguey Zefirov wrote: >>> I tried the way described in >>> http://www.haskell.org/ghc/docs/latest/html/users_guide/win32-dlls.html >>> and i got this error message: >>> >>> -------------------------------------------------------------------------------------------- >>> ghc -shared -o test.dll --make test.hs >>> [1 of 1] Compiling Test ? ? ? ? ? ? ( test.hs, test.o ) >>> ghc.exe: panic! (the 'impossible' happened) >>> ?(GHC version 6.10.3 for i386-unknown-mingw32): >>> ? ? ? ?link: GHC not built to link this way: LinkDynLib >>> >>> Please report this as a GHC bug: ?http://www.haskell.org/ghc/reportabug >>> -------------------------------------------------------------------------------------------- >>> How can I fix it? >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >> > From sergueyz at gmail.com Tue Feb 16 13:01:51 2010 From: sergueyz at gmail.com (Serguey Zefirov) Date: Tue Feb 16 12:32:46 2010 Subject: [Haskell-cafe] DLL on Windows In-Reply-To: <404396ef1002160957m6ae4370bxb3b0a1d65353c30b@mail.gmail.com> References: <600376291002160633m638099cy846dd3770a3190cf@mail.gmail.com> <404396ef1002160837u172b5cdcs6531b7ec06985aae@mail.gmail.com> <600376291002160919hcb6e9c6o1a383eb96480364f@mail.gmail.com> <404396ef1002160957m6ae4370bxb3b0a1d65353c30b@mail.gmail.com> Message-ID: <600376291002161001x3cda7c88u4b1e74d16f705fa4@mail.gmail.com> Thank you very much. How do you use C# for GUI development? Do you use hs-dotnet? 2010/2/16 Neil Mitchell : > Hi Serguey, > > A GHC 6.10.4 version of Gtk2hs: > > http://www.mail-archive.com/gtk2hs-devel@lists.sourceforge.net/msg00340.html > > I used to recommend Gtk2hs over wxHaskell for GUI development as there > was always a version that worked on Windows with the latest GHC > release. I think I might have to switch back to recommending C# for > GUI development... > > Thanks, Neil > > On Tue, Feb 16, 2010 at 5:19 PM, Serguey Zefirov wrote: >> I'd like to, but I cannot. My code is tied to gtk2hs, which supports >> either 6.10.1 or 6.10.3. >> >> I put it another way: could I build DLL using ghc 6.12.*? >> >> If I can, I'll use 6.10.3 for gtk2hs code and 6.12 for all new stuff. >> >> 2010/2/16 Neil Mitchell : >>> Hi Serguey, >>> >>> I notice you are using GHC 6.10.3, I suggest you try 6.10.4 which I >>> know does work. >>> >>> I rewrote that section of the manual recently. I haven't had time to >>> merge it back in, but it might give you more help: >>> >>> http://neilmitchell.blogspot.com/2009/11/haskell-dlls-on-windows.html >>> >>> Thanks, Neil >>> >>> On Tue, Feb 16, 2010 at 2:33 PM, Serguey Zefirov wrote: >>>> I tried the way described in >>>> http://www.haskell.org/ghc/docs/latest/html/users_guide/win32-dlls.html >>>> and i got this error message: >>>> >>>> -------------------------------------------------------------------------------------------- >>>> ghc -shared -o test.dll --make test.hs >>>> [1 of 1] Compiling Test ? ? ? ? ? ? ( test.hs, test.o ) >>>> ghc.exe: panic! (the 'impossible' happened) >>>> ?(GHC version 6.10.3 for i386-unknown-mingw32): >>>> ? ? ? ?link: GHC not built to link this way: LinkDynLib >>>> >>>> Please report this as a GHC bug: ?http://www.haskell.org/ghc/reportabug >>>> -------------------------------------------------------------------------------------------- >>>> How can I fix it? >>>> _______________________________________________ >>>> Haskell-Cafe mailing list >>>> Haskell-Cafe@haskell.org >>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>>> >>> >> > From ndmitchell at gmail.com Tue Feb 16 13:05:22 2010 From: ndmitchell at gmail.com (Neil Mitchell) Date: Tue Feb 16 12:36:12 2010 Subject: [Haskell-cafe] DLL on Windows In-Reply-To: <600376291002161001x3cda7c88u4b1e74d16f705fa4@mail.gmail.com> References: <600376291002160633m638099cy846dd3770a3190cf@mail.gmail.com> <404396ef1002160837u172b5cdcs6531b7ec06985aae@mail.gmail.com> <600376291002160919hcb6e9c6o1a383eb96480364f@mail.gmail.com> <404396ef1002160957m6ae4370bxb3b0a1d65353c30b@mail.gmail.com> <600376291002161001x3cda7c88u4b1e74d16f705fa4@mail.gmail.com> Message-ID: <404396ef1002161005n55d3534es29630b0532ba5546@mail.gmail.com> Oh no, I just give up on Haskell and use C# entirely - I'd much rather program in Haskell, but if all you are doing is a simple Windows app then a nice GUI is easy in C# with the form designer. Thanks, Neil On Tue, Feb 16, 2010 at 6:01 PM, Serguey Zefirov wrote: > Thank you very much. > > How do you use C# for GUI development? Do you use hs-dotnet? > > 2010/2/16 Neil Mitchell : >> Hi Serguey, >> >> A GHC 6.10.4 version of Gtk2hs: >> >> http://www.mail-archive.com/gtk2hs-devel@lists.sourceforge.net/msg00340.html >> >> I used to recommend Gtk2hs over wxHaskell for GUI development as there >> was always a version that worked on Windows with the latest GHC >> release. I think I might have to switch back to recommending C# for >> GUI development... >> >> Thanks, Neil >> >> On Tue, Feb 16, 2010 at 5:19 PM, Serguey Zefirov wrote: >>> I'd like to, but I cannot. My code is tied to gtk2hs, which supports >>> either 6.10.1 or 6.10.3. >>> >>> I put it another way: could I build DLL using ghc 6.12.*? >>> >>> If I can, I'll use 6.10.3 for gtk2hs code and 6.12 for all new stuff. >>> >>> 2010/2/16 Neil Mitchell : >>>> Hi Serguey, >>>> >>>> I notice you are using GHC 6.10.3, I suggest you try 6.10.4 which I >>>> know does work. >>>> >>>> I rewrote that section of the manual recently. I haven't had time to >>>> merge it back in, but it might give you more help: >>>> >>>> http://neilmitchell.blogspot.com/2009/11/haskell-dlls-on-windows.html >>>> >>>> Thanks, Neil >>>> >>>> On Tue, Feb 16, 2010 at 2:33 PM, Serguey Zefirov wrote: >>>>> I tried the way described in >>>>> http://www.haskell.org/ghc/docs/latest/html/users_guide/win32-dlls.html >>>>> and i got this error message: >>>>> >>>>> -------------------------------------------------------------------------------------------- >>>>> ghc -shared -o test.dll --make test.hs >>>>> [1 of 1] Compiling Test ? ? ? ? ? ? ( test.hs, test.o ) >>>>> ghc.exe: panic! (the 'impossible' happened) >>>>> ?(GHC version 6.10.3 for i386-unknown-mingw32): >>>>> ? ? ? ?link: GHC not built to link this way: LinkDynLib >>>>> >>>>> Please report this as a GHC bug: ?http://www.haskell.org/ghc/reportabug >>>>> -------------------------------------------------------------------------------------------- >>>>> How can I fix it? >>>>> _______________________________________________ >>>>> Haskell-Cafe mailing list >>>>> Haskell-Cafe@haskell.org >>>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>>>> >>>> >>> >> > From limestrael at gmail.com Tue Feb 16 13:25:58 2010 From: limestrael at gmail.com (=?UTF-8?Q?Yves_Par=C3=A8s?=) Date: Tue Feb 16 12:56:48 2010 Subject: [Haskell-cafe] Threading and FFI In-Reply-To: <20100216172522.GC6832@kira.casa> References: <27611528.post@talk.nabble.com> <20100216172522.GC6832@kira.casa> Message-ID: <27612884.post@talk.nabble.com> Well I tried both 'unsafe' and 'safe', and actually I saw no difference... Even with 'safe', I see a huge difference between calling a C function which sleeps and another which doesn't. When there is a sleep, the other thread is really slower (it just prints numbers, and I look at which pace they're displayed). Felipe Lessa wrote: > > On Tue, Feb 16, 2010 at 09:00:08AM -0800, Yves Par?s wrote: >> I was wondering: is the Haskell default runtime (that which uses only one >> processor) scheduler able to interrupt a thread which is currently >> calling >> to a C function in order to enable another haskell thread to progress? >> I think it can't, because I have starvation problems when I have a thread >> which calls inside its loop to a C function which makes a little "sleep". > > Did you try marking the call as safe? > > Cheers, > > -- > Felipe. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > ----- Yves Par?s Live long and prosper -- View this message in context: http://old.nabble.com/Threading-and-FFI-tp27611528p27612884.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From limestrael at gmail.com Tue Feb 16 13:46:04 2010 From: limestrael at gmail.com (=?UTF-8?Q?Yves_Par=C3=A8s?=) Date: Tue Feb 16 13:16:53 2010 Subject: [Haskell-cafe] Threading and FFI In-Reply-To: <27612884.post@talk.nabble.com> References: <27611528.post@talk.nabble.com> <20100216172522.GC6832@kira.casa> <27612884.post@talk.nabble.com> Message-ID: <27613138.post@talk.nabble.com> There is a minimal code which produces this issue: http://old.nabble.com/file/p27613138/func.c func.c http://old.nabble.com/file/p27613138/main.hs main.hs Yves Par?s wrote: > > Well I tried both 'unsafe' and 'safe', and actually I saw no difference... > Even with 'safe', I see a huge difference between calling a C function > which sleeps and another which doesn't. When there is a sleep, the other > thread is really slower (it just prints numbers, and I look at which pace > they're displayed). ----- Yves Par?s Live long and prosper -- View this message in context: http://old.nabble.com/Threading-and-FFI-tp27611528p27613138.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From ajs at 2piix.com Tue Feb 16 14:30:20 2010 From: ajs at 2piix.com (Alexander Solla) Date: Tue Feb 16 14:01:12 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <75cc17ac1002160943r22f871f2ra376ce9c31a246aa@mail.gmail.com> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <75cc17ac1002160943r22f871f2ra376ce9c31a246aa@mail.gmail.com> Message-ID: <427058B1-2B26-4335-8350-A15A0E30D8A2@2piix.com> On Feb 16, 2010, at 9:43 AM, Gregg Reynolds wrote: > I've looked through at least a dozen. For neophytes, the best of > the bunch BY FAR is Goldblatt, Topoi: the categorial analysis of > logic . Don't be put off by the title. He not only explains the > stuff, but he explains the problems that motivated the invention of > the stuff. He doesn't cover monads, but he covers all the basics > very clearly, so once you've got that down you can move to another > author for monads. He does cover monads, briefly. They're called "triples" in this context, and the chapter on interpretations of the intuitionistic logic depend on functorial/monadic techniques. If I remember correctly, he uses the techniques and abstracts from them. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100216/066408d9/attachment.html From wasserman.louis at gmail.com Tue Feb 16 14:37:54 2010 From: wasserman.louis at gmail.com (Louis Wasserman) Date: Tue Feb 16 14:09:05 2010 Subject: [Haskell-cafe] Linear programming in Haskell Message-ID: Is there a nice package out there somewhere with a linear programming implementation? Preferably with a nicely functional interface? Kthxbai, Louis Wasserman wasserman.louis@gmail.com http://profiles.google.com/wasserman.louis -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100216/2b4f2912/attachment.html From felipe.lessa at gmail.com Tue Feb 16 14:54:20 2010 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Tue Feb 16 14:25:13 2010 Subject: [Haskell-cafe] Linear programming in Haskell In-Reply-To: References: Message-ID: <20100216195420.GA26057@kira.casa> On Tue, Feb 16, 2010 at 01:37:54PM -0600, Louis Wasserman wrote: > Is there a nice package out there somewhere with a linear programming > implementation? Preferably with a nicely functional interface? hmatrix? Cheers, -- Felipe. From pumpkingod at gmail.com Tue Feb 16 15:12:53 2010 From: pumpkingod at gmail.com (Daniel Peebles) Date: Tue Feb 16 14:43:42 2010 Subject: [Haskell-cafe] Linear programming in Haskell In-Reply-To: <20100216195420.GA26057@kira.casa> References: <20100216195420.GA26057@kira.casa> Message-ID: How would you use hmatrix? By linear programming I assume he means systems of linear inequalities, as typically solved by the simplex algorithm. I too am interested in this question (and the more general one of nonlinear optimization)! Thanks, Dan On Tue, Feb 16, 2010 at 2:54 PM, Felipe Lessa wrote: > On Tue, Feb 16, 2010 at 01:37:54PM -0600, Louis Wasserman wrote: > > Is there a nice package out there somewhere with a linear programming > > implementation? Preferably with a nicely functional interface? > > hmatrix? > > Cheers, > > -- > Felipe. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100216/1afc7b3b/attachment.html From gue.schmidt at web.de Tue Feb 16 15:14:16 2010 From: gue.schmidt at web.de (=?ISO-8859-15?Q?G=FCnther_Schmidt?=) Date: Tue Feb 16 14:45:30 2010 Subject: [Haskell-cafe] Heterogeneous Data Structures - Nested Pairs and functional references Message-ID: <4B7AFC98.9080103@web.de> Hi, I've been thinking a lot lately about heterogeneous and extensible data structures for which HList certainly offers a solution. While HList is implemented through type-level programming I wonder if I can achieve similar results through value-level programming alone. This is where I was thinking of functional references. I wonder if or rather how one could do this: Let's say there was some clever monad ... someMonad = do h1 <- add "twenty" h2 <- add False h3 <- add 16 ..... modify h2 True and get a ("twenty",(True, 16)) back. And while *in* the monad some accessors available. Now come to think of it I think I actually read about this somewhere so I doubt this is truly my idea. Anybody got some thoughts on this? G?nther From aeyakovenko at gmail.com Tue Feb 16 15:17:13 2010 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Tue Feb 16 14:48:04 2010 Subject: [Haskell-cafe] pandoc code bocks not working In-Reply-To: <4B78A804.7010601@skynet.be> References: <4B78A804.7010601@skynet.be> Message-ID: Thanks, that solved it. I am also seening that pandoc compiled with 6.12 seems to barf on the .css file that is used in the examples. commitAndReleaseBuffer: invalid argument (Invalid or incomplete multibyte or wide character) On Sun, Feb 14, 2010 at 5:48 PM, Walter De Jonge wrote: > http://johnmacfarlane.net/pandoc/README.html#delimited-code-blocks > > "Like regular code blocks, delimited code blocks must be separated from > surrounding text by blank lines." > > goodluck > > walter > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From jeremy at n-heptane.com Tue Feb 16 15:37:23 2010 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Tue Feb 16 15:08:14 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: References: <910ddf451002091647m4b7e12a5y5a680d7d356fb3d6@mail.gmail.com> <94E8A4F7-E54B-4885-8D6A-6AA4777F6FC1@n-heptane.com> Message-ID: On Sun, Feb 14, 2010 at 2:04 PM, Bardur Arantsson wrote: > > I've tested this extensively during this weekend and not a single "leaked" > FD so far. > > I think we can safely say that polling an FD for read readiness is > sufficient to properly detect a disconnected client regardless of why/how > the client disconnected. > > The only issue I can see with just dropping the above code directly into > the sendfile library is that it may lead to busy-waiting on EAGAIN *if* the > client is actually trying to send data to the server while it's receiving > the file via sendfile(). If the client sends even a single byte and the > server isn't reading it from the socket, then threadWaitRead will keep > returning immediately since it's level-triggered rather than edge triggered. > Yeah. That could be trouble. > Not sure what the best solution for this would be, API-wise... Maybe > actually have sendfile read the data and supply it to a user-defined > function which could react to the data in some way? (Could supply two > standard functions: "disconnect immediately" and "accumulate all received > data into a bytestring".) > > I think this goes beyond just a sendfile issue -- anyone trying to write non-blocking network code should run into this issue, right ? For now, maybe we should patch sendfile with what we have. But I think we really need to summarize our findings, see if we can generate a test case, and then see what Simon Marlow and company have to say... - jeremy -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100216/3413ae6a/attachment.html From felipe.lessa at gmail.com Tue Feb 16 15:37:25 2010 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Tue Feb 16 15:08:24 2010 Subject: [Haskell-cafe] Linear programming in Haskell In-Reply-To: References: <20100216195420.GA26057@kira.casa> Message-ID: <20100216203725.GA30360@kira.casa> On Tue, Feb 16, 2010 at 03:12:53PM -0500, Daniel Peebles wrote: > How would you use hmatrix? By linear programming I assume he means systems > of linear inequalities, as typically solved by the simplex algorithm. I too > am interested in this question (and the more general one of nonlinear > optimization)! I have never used this part of hmatrix, but does Numeric.LinearAlgebra satisfy your needs? In particular, see linearSolve[1] and linearSolveR[2]. [1] http://hackage.haskell.org/packages/archive/hmatrix/0.8.3.1/doc/html/Numeric-LinearAlgebra-Algorithms.html#v%3AlinearSolve [2] http://hackage.haskell.org/packages/archive/hmatrix/0.8.3.1/doc/html/Numeric-LinearAlgebra-LAPACK.html#v%3AlinearSolveR HTH, -- Felipe. From ajs at 2piix.com Tue Feb 16 15:48:10 2010 From: ajs at 2piix.com (Alexander Solla) Date: Tue Feb 16 15:19:04 2010 Subject: [Haskell-cafe] Heterogeneous Data Structures - Nested Pairs and functional references In-Reply-To: <4B7AFC98.9080103@web.de> References: <4B7AFC98.9080103@web.de> Message-ID: On Feb 16, 2010, at 12:14 PM, G?nther Schmidt wrote: > Let's say there was some clever monad ... > > someMonad = do > h1 <- add "twenty" > h2 <- add False > h3 <- add 16 > ..... > modify h2 True > > and get a ("twenty",(True, 16)) back. And while *in* the monad some > accessors available. Your return value will be wrapped a bit more strongly if you use monads and try to combine types. Basically, build a monad with lots of values with no free monadic variables. For example, in Maybe, Just has a free variable, whereas Nothing doesn't. You can create values free in the monadic variable to carry any SPECIFIC type you want. (Or even type class instances, if you use existential types) > data Accumulator value = AtomicAccumulator value | StringAccumulator String | IntAccumulator Int | ConcatAccumulators (Accumulator value) (Accumulator value) (Accumulator String)s are (Accumulator value)s for any value. So you can build things like: > ConcatAccumulators (IntAccumulator 10) (StringAccumulator "Hi") I would build up accessors to these values using record syntax. Here's a meaty example I've been working on: data View view = (Left view) `ConcatViews` (Right view) | NestViews (Left view) (Middle view) (Right view) | EmptyView | AtomicView view | ReturnView view -- View Nodes: | DocumentView { document_title_view :: View view , document_toc :: View view , document_footer :: View view , document_header :: View view , document_contents :: View view } | PageView { page_title :: View view , page_contents :: View view } | TableView { table_title_view :: View view , table_heading_view :: View view , table_row_view :: View view , table_subtotal_row_view :: View view , table_total_row_view :: View view } | SectionView { section_title :: View view , section_heading_view :: View view , section_contents :: View view } | SidebarView { sidebar_title :: View view , sidebar_heading :: View view , sidebar_contents :: View view } | FieldView | HeadingView String | ListView [ View view ] -- View of list, not list of views. | PageFooterView | PageHeaderView | PageHeadingView String | ParagraphView String | RowView | TableTitleView String | TextView String deriving Show instance Monoid (View view) where mempty = EmptyView EmptyView `mappend` right = right left `mappend` EmptyView = left left `mappend` right = ConcatViews left right data Field = Field { field_name :: String , field_description :: String } data Row = HeadingRow [Field] instance Monad View where return = ReturnView (AtomicView view) >>= f = f view (ConcatViews left right) >>= f = ( ConcatViews (left >>= f) (right >>=f) ) (DocumentView title toc footer header content) >>= f = ( DocumentView (title >>= f) (toc >>= f) (footer >>= f) (header >>= f) (content >>= f) ) (NestViews l m r) >>= f = ( NestViews (l >>= f) (m >>= f) (r >>= f) ) (EmptyView) >>= f = EmptyView (HeadingView string) >>= f = HeadingView string (ReturnView view) >>= f = f view (PageView t c) >>= f = ( PageView (t >>= f) (c >>= f) ) (TableView title heading row subtotal total) >>= f = ( TableView (title >>= f) (heading >>= f) (row >>= f) (subtotal >>= f) (total >>= f) ) (SectionView title heading contents) >>= f = ( SectionView (title >>= f) (heading >>= f) (contents >>= f) ) (ListView views) >>= f = ListView (fmap (>>= f) views) (SidebarView title heading contents) >>= f = ( SidebarView (title >>= f) (heading >>= f) (contents >>= f) ) (TextView string ) >>= f = TextView string (ParagraphView string ) >>= f = ParagraphView string (TableTitleView string ) >>= f = TableTitleView string (RowView ) >>= f = RowView (FieldView ) >>= f = FieldView (PageFooterView ) >>= f = PageFooterView (PageHeadingView string ) >>= f = PageHeadingView string (PageHeaderView ) >>= f = PageHeaderView -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100216/f7bde709/attachment-0001.html From bos at serpentine.com Tue Feb 16 15:50:08 2010 From: bos at serpentine.com (Bryan O'Sullivan) Date: Tue Feb 16 15:20:58 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: References: <910ddf451002091647m4b7e12a5y5a680d7d356fb3d6@mail.gmail.com> <94E8A4F7-E54B-4885-8D6A-6AA4777F6FC1@n-heptane.com> Message-ID: On Tue, Feb 16, 2010 at 12:37 PM, Jeremy Shaw wrote: > I think this goes beyond just a sendfile issue -- anyone trying to write > non-blocking network code should run into this issue, right ? > What's a fairly concise description of the issue at hand? I haven't been paying much attention to this thread, and the descriptions I have seen have been somewhat confused. One admittedly unhelpful observation is that when something goes wrong in this area, it's usually due to pilot error (either on the part of whoever wrote the Haskell library, or its user), and not so often caused by a bug in the underlying platform. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100216/f31c2997/attachment.html From pumpkingod at gmail.com Tue Feb 16 15:54:51 2010 From: pumpkingod at gmail.com (Daniel Peebles) Date: Tue Feb 16 15:25:39 2010 Subject: [Haskell-cafe] Linear programming in Haskell In-Reply-To: <20100216203725.GA30360@kira.casa> References: <20100216195420.GA26057@kira.casa> <20100216203725.GA30360@kira.casa> Message-ID: As far as I can see, you'd use that for systems of linear *equalities*, but for systems of linear *inequalities* with a linear objective function, it's not suitable. I may be wrong though :) On Tue, Feb 16, 2010 at 3:37 PM, Felipe Lessa wrote: > On Tue, Feb 16, 2010 at 03:12:53PM -0500, Daniel Peebles wrote: > > How would you use hmatrix? By linear programming I assume he means > systems > > of linear inequalities, as typically solved by the simplex algorithm. I > too > > am interested in this question (and the more general one of nonlinear > > optimization)! > > I have never used this part of hmatrix, but does > Numeric.LinearAlgebra satisfy your needs? In particular, see > linearSolve[1] and linearSolveR[2]. > > [1] > http://hackage.haskell.org/packages/archive/hmatrix/0.8.3.1/doc/html/Numeric-LinearAlgebra-Algorithms.html#v%3AlinearSolve > [2] > http://hackage.haskell.org/packages/archive/hmatrix/0.8.3.1/doc/html/Numeric-LinearAlgebra-LAPACK.html#v%3AlinearSolveR > > HTH, > > -- > Felipe. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100216/ae633ab1/attachment.html From spam at scientician.net Tue Feb 16 15:57:23 2010 From: spam at scientician.net (Bardur Arantsson) Date: Tue Feb 16 15:28:37 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: References: <910ddf451002091647m4b7e12a5y5a680d7d356fb3d6@mail.gmail.com> <94E8A4F7-E54B-4885-8D6A-6AA4777F6FC1@n-heptane.com> Message-ID: Jeremy Shaw wrote: > On Sun, Feb 14, 2010 at 2:04 PM, Bardur Arantsson wrote: > > >> Not sure what the best solution for this would be, API-wise... Maybe >> actually have sendfile read the data and supply it to a user-defined >> function which could react to the data in some way? (Could supply two >> standard functions: "disconnect immediately" and "accumulate all received >> data into a bytestring".) >> >> > I think this goes beyond just a sendfile issue -- anyone trying to write > non-blocking network code should run into this issue, right ? For now, maybe > we should patch sendfile with what we have. But I think we really need to > summarize our findings, see if we can generate a test case, and then see > what Simon Marlow and company have to say... As far as I can tell, all nonblocking networking code is vulnerable to this issue (unless it actually does use threadWaitRead, obviously :)). In particular, I would imagine most of the Haskell HTTP servers are vulnerable to this since they do use the same pattern of: 1) read all the input from the client connection, 2) send all the output to the client connection where there is no reading from the socket in step 2. I'm just not sure whether the GHC "built-in" I/O code *somehow* avoids this problem. I think my tests indicate that it does, so it would seem that it's only when you "go C" that you need to worry. Re: a test case, you'll probably need to run the test case code on a client whose OS allows (from userspace) the sudden dropping of connections without sending a proper connection shutdown sequence. I'm not sure that that OS would be. Cheers, From spam at scientician.net Tue Feb 16 16:18:22 2010 From: spam at scientician.net (Bardur Arantsson) Date: Tue Feb 16 15:49:35 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: References: <910ddf451002091647m4b7e12a5y5a680d7d356fb3d6@mail.gmail.com> <94E8A4F7-E54B-4885-8D6A-6AA4777F6FC1@n-heptane.com> Message-ID: Bardur Arantsson wrote: > Jeremy Shaw wrote: [--snip--] > Re: a test case, you'll probably need to run the test case code on a > client whose OS allows (from userspace) the sudden dropping of > connections without sending a proper connection shutdown sequence. I'm > not sure that that OS would be. Actually, scratch that. Maybe it's just a question having a high enough connection rate to hit the case where threadWaitWrite "hangs". Although I did try a few times using wget, I didn't really try hammering the server properly. It probably needs the right timing to trigger the problem (i.e. the disconnect needs to happen exactly when sendfile is done with its block and we're going around to threadWaitWrite again.) I'll see if I get the time try a test client which can really hammer my server -- that ought to be able to trigger the problem. If that works, I'll try to produce a minimal server program which still exhibits the issue. Cheers, From taruti at taruti.net Tue Feb 16 16:28:38 2010 From: taruti at taruti.net (Taru Karttunen) Date: Tue Feb 16 15:59:27 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: References: <910ddf451002091647m4b7e12a5y5a680d7d356fb3d6@mail.gmail.com> <94E8A4F7-E54B-4885-8D6A-6AA4777F6FC1@n-heptane.com> Message-ID: <1266355493-sup-6667@oz.taruti.net> Excerpts from Bardur Arantsson's message of Tue Feb 16 22:57:23 +0200 2010: > As far as I can tell, all nonblocking networking code is vulnerable to > this issue (unless it actually does use threadWaitRead, obviously :)). There are a few easy fixes: 1) socket timeouts with Network.Socket.setSocketOption 2) just make your server code have timeouts in Haskell This cannot be fixed in the sendfile library, it is a feature of TCP that connections may linger for a long time unless explicit timeouts are used. So just document it and in your code using sendfile wrap it in an application specific timeout. - Taru Karttunen From ajs at 2piix.com Tue Feb 16 16:34:29 2010 From: ajs at 2piix.com (Alexander Solla) Date: Tue Feb 16 16:05:18 2010 Subject: [Haskell-cafe] Heterogeneous Data Structures - Nested Pairs and functional references In-Reply-To: References: <4B7AFC98.9080103@web.de> Message-ID: <0A92BAC1-4FF6-41D8-BCB4-8A603B6C2026@2piix.com> On Feb 16, 2010, at 12:48 PM, Alexander Solla wrote: > (Accumulator String)s are (Accumulator value)s for any value. So > you can build things like: > Sorry, I made a typo. I meant "StringAccumulator String"s are "Accumulator value"s for any value. From spam at scientician.net Tue Feb 16 16:48:14 2010 From: spam at scientician.net (Bardur Arantsson) Date: Tue Feb 16 16:19:27 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: <1266355493-sup-6667@oz.taruti.net> References: <910ddf451002091647m4b7e12a5y5a680d7d356fb3d6@mail.gmail.com> <94E8A4F7-E54B-4885-8D6A-6AA4777F6FC1@n-heptane.com> <1266355493-sup-6667@oz.taruti.net> Message-ID: Taru Karttunen wrote: > Excerpts from Bardur Arantsson's message of Tue Feb 16 22:57:23 +0200 2010: >> As far as I can tell, all nonblocking networking code is vulnerable to >> this issue (unless it actually does use threadWaitRead, obviously :)). > > There are a few easy fixes: > > 1) socket timeouts with Network.Socket.setSocketOption The whole point of this thread is that this isn't sufficent. > 2) just make your server code have timeouts in Haskell > > This cannot be fixed in the sendfile library, it is a > feature of TCP that connections may linger for a long > time unless explicit timeouts are used. The problem is that the sendfile library *doesn't* wake up when the connection is terminated (because of threadWaitWrite) -- it doesn't matter what the timeout is. Client code of the sendfile library shouldn't have to try to work around this -- it's absurd to expect it to. Please read the entire thread. Cheers, From jgm at berkeley.edu Tue Feb 16 17:02:13 2010 From: jgm at berkeley.edu (John MacFarlane) Date: Tue Feb 16 16:34:15 2010 Subject: [Haskell-cafe] Re: pandoc code bocks not working In-Reply-To: References: <4B78A804.7010601@skynet.be> Message-ID: <20100216220213.GA29899@protagoras.phil.berkeley.edu> Why don't you direct your pandoc-related questions to the pandoc-discuss mailing list? http://groups.google.com/group/pandoc-discuss In this case, it would also be helpful to have more information -- such as a sample input file and instructions on how to reproduce the problem you're seeing. (I've been using pandoc compiled with GHC 6.12 without problems.) John +++ Anatoly Yakovenko [Feb 16 10 12:17 ]: > Thanks, that solved it. > > I am also seening that pandoc compiled with 6.12 seems to barf on the > .css file that is used in the examples. > > > commitAndReleaseBuffer: invalid argument (Invalid or incomplete > multibyte or wide character) > > > On Sun, Feb 14, 2010 at 5:48 PM, Walter De Jonge wrote: > > http://johnmacfarlane.net/pandoc/README.html#delimited-code-blocks > > > > "Like regular code blocks, delimited code blocks must be separated from > > surrounding text by blank lines." > > > > goodluck > > > > walter > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From stephen.tetley at gmail.com Tue Feb 16 17:11:51 2010 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Tue Feb 16 16:42:41 2010 Subject: [Haskell-cafe] Heterogeneous Data Structures - Nested Pairs and functional references In-Reply-To: References: <4B7AFC98.9080103@web.de> Message-ID: <5fdc56d71002161411i7106f50aq21ac115bfc36115d@mail.gmail.com> Hi Alexander Your monad looks equivalent to the Identity monad but over a much bigger syntax. What advantages do you get from it being a monad, rather than just a functor? Best wishes Stephen From hjgtuyl at chello.nl Tue Feb 16 18:48:06 2010 From: hjgtuyl at chello.nl (Henk-Jan van Tuyl) Date: Tue Feb 16 18:18:58 2010 Subject: GUI (was: Re: [Haskell-cafe] DLL on Windows) In-Reply-To: <404396ef1002160957m6ae4370bxb3b0a1d65353c30b@mail.gmail.com> References: <600376291002160633m638099cy846dd3770a3190cf@mail.gmail.com> <404396ef1002160837u172b5cdcs6531b7ec06985aae@mail.gmail.com> <600376291002160919hcb6e9c6o1a383eb96480364f@mail.gmail.com> <404396ef1002160957m6ae4370bxb3b0a1d65353c30b@mail.gmail.com> Message-ID: On Tue, 16 Feb 2010 18:57:20 +0100, Neil Mitchell wrote: > I used to recommend Gtk2hs over wxHaskell for GUI development as there > was always a version that worked on Windows with the latest GHC > release. I think I might have to switch back to recommending C# for > GUI development... The latest revision of wxHaskell can be compiled relatively easy, so that wxHaskell can be used immediately for the latest version of GHC. Regards, Henk-Jan From ivan.miljenovic at gmail.com Tue Feb 16 18:56:30 2010 From: ivan.miljenovic at gmail.com (Ivan Miljenovic) Date: Tue Feb 16 18:27:17 2010 Subject: [Haskell-cafe] Notes on migrating from uvector to vector In-Reply-To: <4B7AAB12.7040401@van.steenbergen.nl> References: <20100215213557.GH4036@whirlpool.galois.com> <4B7AAB12.7040401@van.steenbergen.nl> Message-ID: On 17 February 2010 01:26, Martijn van Steenbergen wrote: > Ivan Miljenovic wrote: >> >> On 16 February 2010 08:35, Don Stewart wrote: >>> >>> Enjoy the new decade of flexible, fusible, fast arrays for Haskell! >> >> /me points out that 2010 is actually the last year of the decade, and >> not the first year of a new decade... > > There certainly is /a/ decade that starts today. :-) Well, yes. By the way, I'm celebrating New Year's Eve in 12 days time; anyone want to join me? :p -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com Stephen Leacock - "I detest life-insurance agents: they always argue that I shall some day die, which is not so." - http://www.brainyquote.com/quotes/authors/s/stephen_leacock.html From iku.iwasa at gmail.com Tue Feb 16 19:00:12 2010 From: iku.iwasa at gmail.com (iquiw) Date: Tue Feb 16 18:31:19 2010 Subject: [Haskell-cafe] Efficient M to N conversion on fusion? In-Reply-To: <20100216141213.GA15121@kira.casa> References: <20100216141213.GA15121@kira.casa> Message-ID: I'll try it, thanks! iquiw On Tue, Feb 16, 2010 at 11:12 PM, Felipe Lessa wrote: > On Tue, Feb 16, 2010 at 07:52:51PM +0900, iquiw wrote: >> Is there any efficient way to convert M-length ByteString, Text or >> Vector into N-length one? > > This is just a guess, but in vector at least it should be > possible to use sized[1] to tell how much space should be > allocated on the final vector. ?For example, something like the > following *untested* code: > > import qualified Data.Vector.Stream.Monadic as S > import qualified Data.Vector.Generic as G > import Control.Applicative > import Data.Vector.Stream.Size > > -- | The size should be the size of each v b. > concatMapSized :: (G.Vector v a, G.Vector v b) => Size -> (a -> v b) -> v a -> v b > concatMapSized size_each f v = > ?let stream = G.stream v > ? ? ?size ? = mult size_each (S.size stream) > ?in G.unstream . flip S.sized size . S.concatMap (G.stream . f) $ stream > > mult :: Size -> Size -> Size > mult (Exact n) (Exact m) = Exact (n*m) > mult x y = maybe Max Unknown $ (*) <$> upperBound x <*> upperBound y > > I really don't know if this would improve or worsen performance, > you should check the core and do benchmarks :). > > [1] http://hackage.haskell.org/packages/archive/vector/0.5/doc/html/Data-Vector-Fusion-Stream.html#v%3Asized > > -- > Felipe. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ok at cs.otago.ac.nz Tue Feb 16 19:15:43 2010 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Tue Feb 16 18:46:37 2010 Subject: [Haskell-cafe] Notes on migrating from uvector to vector In-Reply-To: <7be1feae1002160526j23b072d5w835a3f18100b0aac@mail.gmail.com> References: <20100215213557.GH4036@whirlpool.galois.com> <20100216034551.GB6020@whirlpool.galois.com> <7be1feae1002160526j23b072d5w835a3f18100b0aac@mail.gmail.com> Message-ID: <4E06EF7F-F472-4038-BC5C-06B22BF2DD6B@cs.otago.ac.nz> On Feb 17, 2010, at 2:26 AM, Ozgur Akgun wrote: > Wikipedia claims in short that "Year Zero is the year before 1 A.D. > used in astronomical calculations.". > In full: http://en.wikipedia.org/wiki/Year_zero > > Seems like no calendar, other than astronomical things include it That's not what that page says. Read on, where it says "there is a year zero in ... ISO 8601:2004 (where it coincides with the Gregorian year 1 BC)" and later "ISO 8601:2004 (and previously ISO 8601:2000, but not ISO 8601:1988) explicitly uses astronomical year numbering in its date reference systems.". Read that carefully; it doesn't mean that the 1988 edition of the standard didn't use year zero, just that it was not explicit about it. ISO 8601 is *the* international standard for representing dates and times. Sort of. XML Schema adopts 8601 *formats* but in section D.3.2 explicitly rejects year 0. Why they felt it advisible to override a core industry standard is not clear to me. From patrick.leboutillier at gmail.com Tue Feb 16 19:32:41 2010 From: patrick.leboutillier at gmail.com (Patrick LeBoutillier) Date: Tue Feb 16 19:03:31 2010 Subject: [Haskell-cafe] What is the meaning of tilde ("~") symbol In-Reply-To: References: <4B76A310.9090406@gmail.com> <4B77F973.4090304@btinternet.com> Message-ID: Hi, > The symbols that are not specified in a library can be found here: > ?http://www.haskell.org/haskellwiki/Keywords I noticed that \ is not in that list, should it be? Patrick -- ===================== Patrick LeBoutillier Rosem?re, Qu?bec, Canada From thomas.dubuisson at gmail.com Tue Feb 16 20:55:33 2010 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Tue Feb 16 20:26:22 2010 Subject: GUI (was: Re: [Haskell-cafe] DLL on Windows) In-Reply-To: References: <600376291002160633m638099cy846dd3770a3190cf@mail.gmail.com> <404396ef1002160837u172b5cdcs6531b7ec06985aae@mail.gmail.com> <600376291002160919hcb6e9c6o1a383eb96480364f@mail.gmail.com> <404396ef1002160957m6ae4370bxb3b0a1d65353c30b@mail.gmail.com> Message-ID: <4c44d90b1002161755n405fb1dck9343a05ca85b69aa@mail.gmail.com> On Tue, Feb 16, 2010 at 3:48 PM, Henk-Jan van Tuyl wrote: > On Tue, 16 Feb 2010 18:57:20 +0100, Neil Mitchell > wrote: > >> I used to recommend Gtk2hs over wxHaskell for GUI development as there >> was always a version that worked on Windows with the latest GHC >> release. I think I might have to switch back to recommending C# for >> GUI development... > > The latest revision of wxHaskell can be compiled relatively easy, so that > wxHaskell can be used immediately for the latest version of GHC. Exciting allegation, but it doesn't quite check out with GHC 6.12.1 + cabal 1.8.0.2 and cabal-install 0.8 (see below). I would expect this issue to be easily resolved by specifying "containers <= 0.3.*" in the "wxdirect" package, but cabal is misbehaving (for me) and stating wxdirect needs reinstalled with a supposedly newer version of containers, 0.2.0.1. Thomas [tommd@Mavlo ~]$ cabal install wx Resolving dependencies... Downloading containers-0.2.0.1... Configuring containers-0.2.0.1... Preprocessing library containers-0.2.0.1... Building containers-0.2.0.1... Data/IntMap.hs:182:7: Could not find module `Data.Data': It is a member of the hidden package `base'. Perhaps you need to add `base' to the build-depends in your .cabal file. Use -v to see a list of the files searched for. cabal: Error: some packages failed to install: containers-0.2.0.1 failed during the building phase. The exception was: ExitFailure 1 wx-0.12.1.2 depends on containers-0.2.0.1 which failed to install. wxcore-0.12.1.2 depends on containers-0.2.0.1 which failed to install. wxdirect-0.12.1.1 depends on containers-0.2.0.1 which failed to install. From ajs at 2piix.com Tue Feb 16 21:08:19 2010 From: ajs at 2piix.com (Alexander Solla) Date: Tue Feb 16 20:39:08 2010 Subject: [Haskell-cafe] Heterogeneous Data Structures - Nested Pairs and functional references In-Reply-To: <5fdc56d71002161411i7106f50aq21ac115bfc36115d@mail.gmail.com> References: <4B7AFC98.9080103@web.de> <5fdc56d71002161411i7106f50aq21ac115bfc36115d@mail.gmail.com> Message-ID: <65E3229E-1099-4B8A-94BD-6E8E0B1B731D@2piix.com> On Feb 16, 2010, at 2:11 PM, Stephen Tetley wrote: > Your monad looks equivalent to the Identity monad but over a much > bigger syntax. What advantages do you get from it being a monad, > rather than just a functor? I replied to Stephen, but forgot to include the list. I took the liberty of making some changes. I mostly use this construct functorially. Defining a monad instance can be done in O(n) lines, but an applicative functor instance needs O(n^2) lines, where n is the number of type constructors. The monadic structure doesn't interfere with the semantics I want, so I went with that. As you said, this is basically an identity monad, but it's not too hard to turn it into a sequencing monad. For example, instead of defining (NestViews l m r) >>= f as (NestViews (l >>= f) (m >>= f) (r >>= f)), we can do it in terms of arbitrary constructors, as long as >>= induced a partial order. This approach has some interesting potential. From leon.p.smith at gmail.com Tue Feb 16 22:56:28 2010 From: leon.p.smith at gmail.com (Leon Smith) Date: Tue Feb 16 22:27:17 2010 Subject: [Haskell-cafe] Re: Implementing "unionAll" In-Reply-To: References: Message-ID: > I see no obvious deficiencies. :) Personally, I'd probably structure it like > > http://www.haskell.org/haskellwiki/Prime_numbers#Implicit_Heap This variant, based on the wiki article, is cleaner, slightly simpler, appears to be just as fast, and allocates slightly less memory: > import GHC.Exts(inline) > import Data.List.Ordered(unionBy) > union' :: People Int -> People Int -> People Int > union' (VIP x xt) ys = VIP x (union' xt ys) > union' (Crowd xs) (Crowd ys) = Crowd (inline unionBy compare xs ys) > union' xs@(Crowd (x:xt)) ys@(VIP y yt) = case compare x y of > LT -> VIP x (union' (Crowd xt) ys) > EQ -> VIP x (union' (Crowd xt) yt) > GT -> VIP y (union' xs yt) > foldTree :: (a -> a -> a) -> [a] -> a > foldTree f xs = case xs of > [] -> [] > xs -> loop xs > where > loop [x] = x > loop (x:xs) = x `f` loop (pairs xs) > > pairs (x:y:ys) = f x y : pairs ys > pairs xs = xs > unions xss = serve $ inline foldTree union' [ VIP x (Crowd xs) | (x:xs) <- xss ] > where > serve (VIP x xs) = x:serve xs > serve (Crowd xs) = xs One of the differences is that I started with a slightly different "foldTree", one that was taken directly from Data.List.sort. The only problem is that it has the same problem as I mentioned: unionAll [[1,2],[1,2]] == [1,1,2] whereas unionAll is intended to be a generalization of "foldr union []" to an infinite number of lists, and should thus return [1,2]. But I should be able to fix this without much difficulty. > Your loop function is a strange melange of many different concerns > (building a tree, union', adding and removing the VIP constructors). > > > Note that it's currently unclear to me whether the lazy pattern match in > > pairs ~(x: ~(y:ys)) = f x y : pairs ys > > is beneficial or not; you used a strict one > > unionPairs (x:y:zs) = union' x y : unionPairs zs > Well, as the library implementation must work on finite cases as well, the lazy pattern seems out of the question. > If you're really concerned about time & space usage, it might even be > worth to abandon the lazy tree altogether and use a heap to achieve the > same effect, similar to Melissa O'Neils prime number code. It's not as > "neat", but much more predictable. :) Well, it is intended as a high quality, generally useful implementation, so of course I care about time and space usage. :) Dave Bayer's original algorithm does slightly better, but was much larger in terms of both source code and object size. Omar implemented something along these lines, but it didn't perform so well. I did not dig into the reasons why, though; it might not have had anything to do with the fact an explicit heap was used. Incidentally, I tried implementing something like implicit heaps once upon a time; but it had a severe performance problem, taking a few minutes to produce 20-30 elements. I didn't have a pressing reason to figure out why though, and didn't pursue it further. Best, Leon From jeremy at n-heptane.com Tue Feb 16 23:47:17 2010 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Tue Feb 16 23:18:07 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: References: <1266355493-sup-6667@oz.taruti.net> Message-ID: On Tue, Feb 16, 2010 at 3:48 PM, Bardur Arantsson wrote: > The problem is that the sendfile library *doesn't* wake > up when the connection is terminated (because of threadWaitWrite) > -- it doesn't matter what the timeout is. > > Have we actually confirmed this? We know that with the default socket configuration things are good. But have we actually tested testing the timeout to something short and seeing what happens? It would be good to know for sure.. - jeremy -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100216/96db8a50/attachment.html From ndmitchell at gmail.com Wed Feb 17 01:56:27 2010 From: ndmitchell at gmail.com (Neil Mitchell) Date: Wed Feb 17 01:27:15 2010 Subject: [Haskell-cafe] What is the meaning of tilde ("~") symbol In-Reply-To: References: <4B76A310.9090406@gmail.com> <4B77F973.4090304@btinternet.com> Message-ID: <404396ef1002162256u55935834k768b61aa16df69df@mail.gmail.com> Hi Patrick, >> The symbols that are not specified in a library can be found here: >> ?http://www.haskell.org/haskellwiki/Keywords > > I noticed that \ is not in that list, should it be? Yes! Add it. If it would help a beginner understand what something means, it should be on that list. Thanks, Neil From taruti at taruti.net Wed Feb 17 03:36:50 2010 From: taruti at taruti.net (Taru Karttunen) Date: Wed Feb 17 03:07:37 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: References: <910ddf451002091647m4b7e12a5y5a680d7d356fb3d6@mail.gmail.com> <94E8A4F7-E54B-4885-8D6A-6AA4777F6FC1@n-heptane.com> <1266355493-sup-6667@oz.taruti.net> Message-ID: <1266394750-sup-7721@oz.taruti.net> Excerpts from Bardur Arantsson's message of Tue Feb 16 23:48:14 +0200 2010: > > This cannot be fixed in the sendfile library, it is a > > feature of TCP that connections may linger for a long > > time unless explicit timeouts are used. > > The problem is that the sendfile library *doesn't* wake > up when the connection is terminated (because of threadWaitWrite) > -- it doesn't matter what the timeout is. Even server code without sendfile has the same issue since all writing to sockets ends up using threadWaitWrite. System.Timeout.timeout terminates a threadWaitWrite using asynchronous exceptions. If you want to detect dead sockets somewhat reliably without a timeout then there is SO_KEEPALIVE combined with polling SO_ERROR every few minutes. - Taru Karttunen From aruiz at um.es Wed Feb 17 03:38:22 2010 From: aruiz at um.es (Alberto Ruiz) Date: Wed Feb 17 03:09:19 2010 Subject: [Haskell-cafe] Linear programming in Haskell In-Reply-To: References: <20100216195420.GA26057@kira.casa> <20100216203725.GA30360@kira.casa> Message-ID: <4B7BAAFE.3080303@um.es> I think that GSL does not include linear programming solvers, but in the GSL home page there is a reference to the GLPK package: http://www.gnu.org/software/glpk/glpk.html I have not used it, but it would be very nice to have a simple Haskell interface to GLPK (or other similar library) in hmatrix or as a separate package. I will take a look at this. Alberto Daniel Peebles wrote: > As far as I can see, you'd use that for systems of linear /equalities/, > but for systems of linear /inequalities/ with a linear objective > function, it's not suitable. I may be wrong though :) > > On Tue, Feb 16, 2010 at 3:37 PM, Felipe Lessa > wrote: > > On Tue, Feb 16, 2010 at 03:12:53PM -0500, Daniel Peebles wrote: > > How would you use hmatrix? By linear programming I assume he > means systems > > of linear inequalities, as typically solved by the simplex > algorithm. I too > > am interested in this question (and the more general one of nonlinear > > optimization)! > > I have never used this part of hmatrix, but does > Numeric.LinearAlgebra satisfy your needs? In particular, see > linearSolve[1] and linearSolveR[2]. > > [1] > http://hackage.haskell.org/packages/archive/hmatrix/0.8.3.1/doc/html/Numeric-LinearAlgebra-Algorithms.html#v%3AlinearSolve > [2] > http://hackage.haskell.org/packages/archive/hmatrix/0.8.3.1/doc/html/Numeric-LinearAlgebra-LAPACK.html#v%3AlinearSolveR > > HTH, > > -- > Felipe. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From vandijk.roel at gmail.com Wed Feb 17 03:56:42 2010 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Wed Feb 17 03:27:30 2010 Subject: [Haskell-cafe] RFC: concurrent-extra In-Reply-To: <4B7AC551.1080409@kent.ac.uk> References: <4B7AC551.1080409@kent.ac.uk> Message-ID: 2010/2/16 Neil Brown : > I had a look at the code for Event (both versions) and Lock (but not the > others just yet) and it seemed fine. ?If you do lots of calls to waitTimeout > before a set you will accumulate old locks in the list, but that won't cause > any error that I can see, so it would only be a problem in pathological > cases. I think I can fix the garbage locks on waitTimeout by tupling each lock with the ThreadId of the thread that created it. When a timeout occurs I can then simply remove the unnecessary lock from the list. The extra overhead would be the construction of a tuple and acquiring a ThreadId each time you wait for an event. > I'm not sure there is a good way to test MVar algorithms. ?One way to do it > (which the Concurrent Haskell Debugger did online, IIRC: > http://www.informatik.uni-kiel.de/~fhu/chd/) is to reimplement IO to explore > different interleavings of the various MVar calls to look for deadlocks. ?If > you're testing STM, generally you can look to capture invariants of your > transactions and check that they hold after each transaction (e.g. that if > the state is Set, there shouldn't be any locks waiting with an event). Interesting. It reminds me of Wouter Swierstra's recent paper "Beauty in the Beast": http://www.cs.nott.ac.uk/~txa/publ/beast.pdf Thanks, Roel From Torsten.Kemps-Benedix at sks-ub.de Wed Feb 17 04:04:44 2010 From: Torsten.Kemps-Benedix at sks-ub.de (Kemps-Benedix, Torsten) Date: Wed Feb 17 03:35:36 2010 Subject: [Haskell-cafe] Example for RVarT? Message-ID: Hello folks, is there an example (simpe or not) for the use of Data.Random.RVarT with an underlying monad other than Identity, e.g. StateT, ReaderT etc.? Thx Torsten -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100217/72ace2cb/attachment.html From vandijk.roel at gmail.com Wed Feb 17 04:23:05 2010 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Wed Feb 17 03:53:52 2010 Subject: [Haskell-cafe] Re: RFC: concurrent-extra In-Reply-To: <4B7ACC06.6070205@gmail.com> References: <4B7ACC06.6070205@gmail.com> Message-ID: 2010/2/16 Simon Marlow : > You might want to take a look at the concurrency part of the GHC test suite: > > http://darcs.haskell.org/testsuite/tests/ghc-regress/concurrent/should_run/ > > Not that we've really solved the problem you're talking about, but you might > get some ideas. The method of testing appears to be similar to what I do now using unit tests. But the contents of the tests are interesting. I'll see if they are applicable to our primitives. Thanks, Roel From nccb2 at kent.ac.uk Wed Feb 17 04:48:39 2010 From: nccb2 at kent.ac.uk (Neil Brown) Date: Wed Feb 17 04:20:44 2010 Subject: [Haskell-cafe] RFC: concurrent-extra In-Reply-To: References: <4B7AC551.1080409@kent.ac.uk> Message-ID: <4B7BBB77.5040202@kent.ac.uk> Roel van Dijk wrote: > 2010/2/16 Neil Brown : > >> I had a look at the code for Event (both versions) and Lock (but not the >> others just yet) and it seemed fine. If you do lots of calls to waitTimeout >> before a set you will accumulate old locks in the list, but that won't cause >> any error that I can see, so it would only be a problem in pathological >> cases. >> > > I think I can fix the garbage locks on waitTimeout by tupling each > lock with the ThreadId of the thread that created it. When a timeout > occurs I can then simply remove the unnecessary lock from the list. > The extra overhead would be the construction of a tuple and acquiring > a ThreadId each time you wait for an event. > You don't need to do use ThreadId: MVar has an Eq instance, so you could make your Lock type derive an Eq instance, and then you can just compare the Locks to remove it after the timeout occurs (e.g. using delete to take it out of the list; it should be quite near the head of the list anyway). In fact, you may as well make most of your types derive an Eq instance where possible, as this can be useful sometimes. Thanks, Neil. From vandijk.roel at gmail.com Wed Feb 17 04:56:41 2010 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Wed Feb 17 04:27:29 2010 Subject: [Haskell-cafe] RFC: concurrent-extra In-Reply-To: <4B7BBB77.5040202@kent.ac.uk> References: <4B7AC551.1080409@kent.ac.uk> <4B7BBB77.5040202@kent.ac.uk> Message-ID: 2010/2/17 Neil Brown : > You don't need to do use ThreadId: MVar has an Eq instance, so you could > make your Lock type derive an Eq instance, and then you can just compare the > Locks to remove it after the timeout occurs (e.g. using delete to take it > out of the list; it should be quite near the head of the list anyway). ?In > fact, you may as well make most of your types derive an Eq instance where > possible, as this can be useful sometimes. Now I am wondering why I didn't think of that before. It's an elegant solution. Thanks! From limestrael at gmail.com Wed Feb 17 05:13:03 2010 From: limestrael at gmail.com (=?UTF-8?Q?Yves_Par=C3=A8s?=) Date: Wed Feb 17 04:43:51 2010 Subject: [Haskell-cafe] Threading and FFI In-Reply-To: <27613138.post@talk.nabble.com> References: <27611528.post@talk.nabble.com> <20100216172522.GC6832@kira.casa> <27612884.post@talk.nabble.com> <27613138.post@talk.nabble.com> Message-ID: <27621580.post@talk.nabble.com> I've also discovered something interesting: when I link with the 'threaded' runtime, but let the program use only one core (with '+RTS -N1'), the problem disappears. How comes? The whole thing remains a mystery, because I think what I'm trying to do is quite common... Yves Par?s wrote: > > There is a minimal code which produces this issue: > http://old.nabble.com/file/p27613138/func.c func.c > http://old.nabble.com/file/p27613138/main.hs main.hs > > > Yves Par?s wrote: >> >> Well I tried both 'unsafe' and 'safe', and actually I saw no >> difference... >> Even with 'safe', I see a huge difference between calling a C function >> which sleeps and another which doesn't. When there is a sleep, the other >> thread is really slower (it just prints numbers, and I look at which pace >> they're displayed). > ----- Yves Par?s Live long and prosper -- View this message in context: http://old.nabble.com/Threading-and-FFI-tp27611528p27621580.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From jeremy.odonoghue at gmail.com Wed Feb 17 06:17:10 2010 From: jeremy.odonoghue at gmail.com (Jeremy O'Donoghue) Date: Wed Feb 17 05:47:57 2010 Subject: GUI (was: Re: [Haskell-cafe] DLL on Windows) In-Reply-To: <4c44d90b1002161755n405fb1dck9343a05ca85b69aa@mail.gmail.com> References: <600376291002160633m638099cy846dd3770a3190cf@mail.gmail.com><404396ef1002160837u172b5cdcs6531b7ec06985aae@mail.gmail.com><600376291002160919hcb6e9c6o1a383eb96480364f@mail.gmail.com><404396ef1002160957m6ae4370bxb3b0a1d65353c30b@mail.gmail.com> <4c44d90b1002161755n405fb1dck9343a05ca85b69aa@mail.gmail.com> Message-ID: <1266405430.30462.1360422343@webmail.messagingengine.com> You're probably correct about the dependencies. I have never tried to compile wxHaskell against GHC 6.12.1 I'm waiting for Haskell Platform to be released to make the required changes since (working primarily on Windows) I just don't have time to create a complete GHC 6.12 installation with most of the HP libraries (some of which are a pain to get working on Windows). wxHaskell will support GHC 6.12.x within a couple of days of release of a suitable Haskell Platform. Regards Jeremy On Tue, 16 Feb 2010 17:55 -0800, "Thomas DuBuisson" wrote: > On Tue, Feb 16, 2010 at 3:48 PM, Henk-Jan van Tuyl > wrote: > > On Tue, 16 Feb 2010 18:57:20 +0100, Neil Mitchell > > wrote: > > > >> I used to recommend Gtk2hs over wxHaskell for GUI development as there > >> was always a version that worked on Windows with the latest GHC > >> release. I think I might have to switch back to recommending C# for > >> GUI development... > > > > The latest revision of wxHaskell can be compiled relatively easy, so that > > wxHaskell can be used immediately for the latest version of GHC. > > Exciting allegation, but it doesn't quite check out with GHC 6.12.1 + > cabal 1.8.0.2 and cabal-install 0.8 (see below). I would expect this > issue to be easily resolved by specifying "containers <= 0.3.*" in the > "wxdirect" package, but cabal is misbehaving (for me) and stating > wxdirect needs reinstalled with a supposedly newer version of > containers, 0.2.0.1. > > Thomas > > [tommd@Mavlo ~]$ cabal install wx > Resolving dependencies... > Downloading containers-0.2.0.1... > Configuring containers-0.2.0.1... > Preprocessing library containers-0.2.0.1... > Building containers-0.2.0.1... > > Data/IntMap.hs:182:7: > Could not find module `Data.Data': > It is a member of the hidden package `base'. > Perhaps you need to add `base' to the build-depends in your .cabal > file. > Use -v to see a list of the files searched for. > cabal: Error: some packages failed to install: > containers-0.2.0.1 failed during the building phase. The exception was: > ExitFailure 1 > wx-0.12.1.2 depends on containers-0.2.0.1 which failed to install. > wxcore-0.12.1.2 depends on containers-0.2.0.1 which failed to install. > wxdirect-0.12.1.1 depends on containers-0.2.0.1 which failed to install. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Jeremy O'Donoghue jeremy.odonoghue@gmail.com From apfelmus at quantentunnel.de Wed Feb 17 06:58:55 2010 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Wed Feb 17 06:29:59 2010 Subject: [Haskell-cafe] Re: Implementing "unionAll" In-Reply-To: References: Message-ID: Leon Smith wrote: > Heinrich Apfelmus wrote: >> I see no obvious deficiencies. :) Personally, I'd probably structure it like >> >> http://www.haskell.org/haskellwiki/Prime_numbers#Implicit_Heap > > This variant, based on the wiki article, is cleaner, slightly > simpler, appears to be just as fast, and allocates slightly less > memory: > >> import GHC.Exts(inline) >> import Data.List.Ordered(unionBy) > >> union' :: People Int -> People Int -> People Int >> union' (VIP x xt) ys = VIP x (union' xt ys) >> union' (Crowd xs) (Crowd ys) = Crowd (inline unionBy compare xs ys) >> union' xs@(Crowd (x:xt)) ys@(VIP y yt) = case compare x y of >> LT -> VIP x (union' (Crowd xt) ys) >> EQ -> VIP x (union' (Crowd xt) yt) >> GT -> VIP y (union' xs yt) > >> foldTree :: (a -> a -> a) -> [a] -> a >> foldTree f xs = case xs of >> [] -> [] >> xs -> loop xs >> where >> loop [x] = x >> loop (x:xs) = x `f` loop (pairs xs) >> >> pairs (x:y:ys) = f x y : pairs ys >> pairs xs = xs > >> unions xss = serve $ inline foldTree union' [ VIP x (Crowd xs) | (x:xs) <- xss ] >> where >> serve (VIP x xs) = x:serve xs >> serve (Crowd xs) = xs > > One of the differences is that I started with a slightly different > "foldTree", one that was taken directly from Data.List.sort. > > The only problem is that it has the same problem as I mentioned: > > unionAll [[1,2],[1,2]] == [1,1,2] > > whereas unionAll is intended to be a generalization of "foldr union > []" to an infinite number of lists, and should thus return [1,2]. > But I should be able to fix this without much difficulty. Ah, I meant to use the union' from your previous message, but I think that doesn't work because it doesn't have the crucial property that the case union (VIP x xs) ys = ... does not pattern match on the second argument. The easiest solution is simply to define unionAll = nub . mergeAll where -- specialized definition of nub nub = map head . groupBy (==) But you're probably concerned that filtering for duplicates afterwards will be less efficient. After all, the (implicit) tree built by mergeAll might needlessly compare a lot of equal elements. Fortunately, it is straightforward to fuse nub into the tree merging: nub . serve . foldTree union' = serve . nubP . foldTree union' = serve . foldTree (nub' . union') with appropriate definitions of nubP and nub' . In particular, the definition -- remove duplicate VIPs nub' (Crowd xs) = Crowd xs nub' (VIP x xs) = VIP x (guard x xs) where guard x (VIP y ys) | x == y = nub' ys | otherwise = VIP y (guard y ys) guard x (Crowd (y:ys)) | x == y = Crowd ys | otherwise = Crowd (y:ys) takes advantage of the facts that * the left and right arguments of union' can now be assumed to not contain duplicates * crowds do not contain duplicates thanks to the call to unionBy Whether nub' saves more comparisons than it introduces is another question. If you want, you can probably fuse nub' and union' as well, but I guess the result won't be pretty. > Incidentally, I tried implementing something like implicit heaps once > upon a time; but it had a severe performance problem, taking a few > minutes to produce 20-30 elements. I didn't have a pressing reason > to figure out why though, and didn't pursue it further. Yeah, they're tricky to get right. One pattern match too strict and it's sucked into a black hole, two pattern matches too lazy and it will leak space like the big bang. :) Regards, Heinrich Apfelmus -- http://apfelmus.nfshost.com From asmith9983 at gmail.com Wed Feb 17 08:49:16 2010 From: asmith9983 at gmail.com (Andrew Smith) Date: Wed Feb 17 08:20:08 2010 Subject: [Haskell-cafe] Lambda's In-Reply-To: <29bf512f0912310035nff870d9y25dd1f97bac2c1d3@mail.gmail.com> References: <29bf512f0912310035nff870d9y25dd1f97bac2c1d3@mail.gmail.com> Message-ID: <1266414556.11790.129.camel@amd64-ws1> Hi I agree with the sentiments below. I subscribe to particular lists because of their specialism. The URL referred to had a tenuous Haskell connection, and definitely not work the bandwidth consumed. I'm having a difficult enough time trying to master Haskell without that form of diversion. Enough said. On Thu, 2009-12-31 at 10:35 +0200, Michael Snoyman wrote: > Some of us prefer not to look at that kind of material. I'd appreciate > if, in the future, you could either refrain from sending such links or > making it clear that they contain objectionable content. > > Thanks, > Michael > > On Thu, Dec 31, 2009 at 1:15 AM, Henk-Jan van Tuyl > wrote: > > > I love lambda's: > http://hawtness.com/2009/12/30/wtf-girl-photo-more-reasons-why-half-life-is-awesome/ > > > -- > Regards, > Henk-Jan van Tuyl > > > -- > http://Van.Tuyl.eu/ > http://members.chello.nl/hjgtuyl/tourdemonad.html > -- > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Andrew From vandijk.roel at gmail.com Wed Feb 17 09:10:38 2010 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Wed Feb 17 08:41:27 2010 Subject: [Haskell-cafe] ANN: concurrent-extra-0.1 Message-ID: Hello, We would like to announce the release of concurrent-extra [1]. A library which offers a few extra synchronization primitives. These primitives are found in the standard libraries of languages like Java and Python, but not in Haskell. Quick overview: * Lock: Enforce exclusive access to a resource. Also known as a mutex or a binary semaphore. * RLock: A lock which can be acquired multiple times by the same thread. Also known as a reentrant mutex. * Event: Wake multiple threads by signaling an event. Includes both pessimistic and optimistic versions. * ReadWriteLock: Multiple-reader, single-writer locks. Used to protect shared resources which may be concurrently read, but only sequentially written. * ReadWriteVar: Concurrent read, sequential write variables. Plug & Play: cabal install concurrent-extra Darcs: darcs get http://code.haskell.org/~roelvandijk/code/concurrent-extra/ Thanks to Neil Brown and Simon Marlow for an initial review. Comments are still more than welcome! Regards, Roel & Bas van Dijk [1] http://hackage.haskell.org/package/concurrent-extra From felipe.lessa at gmail.com Wed Feb 17 09:27:37 2010 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Wed Feb 17 08:58:28 2010 Subject: [Haskell-cafe] ANN: concurrent-extra-0.1 In-Reply-To: References: Message-ID: <20100217142737.GA22630@kira.casa> Hello, Thanks for the release! On Wed, Feb 17, 2010 at 03:10:38PM +0100, Roel van Dijk wrote: > * RLock: A lock which can be acquired multiple times by the same > thread. Also known as a reentrant mutex. In acquire (l. 111), if the lock was already acquired it goes by | otherwise ? do putMVar mv mb Lock.acquire lock So it puts back the information about the owner of the RLock and waits for its release in the normal Lock. And then... nothing? Shouldn't it need to put into mv information about itself? In release (l. 142) Nothing is put into mv then do Lock.release lock putMVar mv Nothing Cheers, -- Felipe. From gue.schmidt at web.de Wed Feb 17 09:55:21 2010 From: gue.schmidt at web.de (=?ISO-8859-1?Q?G=FCnther_Schmidt?=) Date: Wed Feb 17 09:26:30 2010 Subject: [Haskell-cafe] Re: Heterogeneous Data Structures - Nested Pairs and functional references In-Reply-To: <0A92BAC1-4FF6-41D8-BCB4-8A603B6C2026@2piix.com> References: <4B7AFC98.9080103@web.de> <0A92BAC1-4FF6-41D8-BCB4-8A603B6C2026@2piix.com> Message-ID: <4B7C0359.307@web.de> Hi Alex, this looks very very interesting, gimme some time to figure it. I hope you'll take questions later ... G?nther Am 16.02.10 22:34, schrieb Alexander Solla: > > On Feb 16, 2010, at 12:48 PM, Alexander Solla wrote: > >> (Accumulator String)s are (Accumulator value)s for any value. So you >> can build things like: >> > > Sorry, I made a typo. I meant "StringAccumulator String"s are > "Accumulator value"s for any value. From leather at cs.uu.nl Wed Feb 17 10:31:16 2010 From: leather at cs.uu.nl (Sean Leather) Date: Wed Feb 17 10:02:24 2010 Subject: [Haskell-cafe] Pointfree composition for higher arity Message-ID: <3c6288ab1002170731m1661c479r936f3e5b5ff8d89d@mail.gmail.com> I find myself often writing this pattern: someFun x y z = ... fun y z = runFun $ someFun someDefault y z > or, alternatively: fun y = runFun . someFun someDefault y > The second option approaches the ideal pointfreeness (or pointlessness if you prefer), but I'd like to go farther: (...) :: (c -> d) -> (a -> b -> c) -> a -> b -> d > (...) f g x y = f (g x y) > infixr 9 ... > > fun = runFun ... someFun someDefault > There, that's better. More points for fewer points (which means I should really change the name from fun to pun). Does anybody else care about this? What are some alternative solutions? I'd love to have something like this available in the Prelude or a library. (I have no strong feelings about the particular operator.) Regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100217/b7da2a07/attachment.html From nccb2 at kent.ac.uk Wed Feb 17 10:35:54 2010 From: nccb2 at kent.ac.uk (Neil Brown) Date: Wed Feb 17 10:07:59 2010 Subject: [Haskell-cafe] Pointfree composition for higher arity In-Reply-To: <3c6288ab1002170731m1661c479r936f3e5b5ff8d89d@mail.gmail.com> References: <3c6288ab1002170731m1661c479r936f3e5b5ff8d89d@mail.gmail.com> Message-ID: <4B7C0CDA.7000101@kent.ac.uk> Sean Leather wrote: > I find myself often writing this pattern: > > someFun x y z = ... > > > > fun y z = runFun $ someFun someDefault y z > > > or, alternatively: > > fun y = runFun . someFun someDefault y > I very often write this too (wanting function composition, but with a two-argument function on the right hand side). The trick I picked up from somewhere is to do: fun = (runFun .) . someFun someDefault I'm not too keen on that, as it seems clumsy. I often end up writing the operator that you describe, but have never settled on a consistent name (since the obvious one to me, (..), is taken). Thanks, Neil. From mike at embody.org Wed Feb 17 10:41:26 2010 From: mike at embody.org (Mike Dillon) Date: Wed Feb 17 10:11:36 2010 Subject: [Haskell-cafe] Pointfree composition for higher arity In-Reply-To: <3c6288ab1002170731m1661c479r936f3e5b5ff8d89d@mail.gmail.com> References: <3c6288ab1002170731m1661c479r936f3e5b5ff8d89d@mail.gmail.com> Message-ID: <20100217154125.GA25561@home.embody.org> That signature is the `oo` "specs" combinator in Data.Aviary: > fun = runFun `oo` someFun someDefault -md begin Sean Leather quotation: > I find myself often writing this pattern: > > someFun x y z = ... > > > > fun y z = runFun $ someFun someDefault y z > > > > or, alternatively: > > fun y = runFun . someFun someDefault y > > > > The second option approaches the ideal pointfreeness (or pointlessness if > you prefer), but I'd like to go farther: > > (...) :: (c -> d) -> (a -> b -> c) -> a -> b -> d > > (...) f g x y = f (g x y) > > infixr 9 ... > > > > > > fun = runFun ... someFun someDefault > > > > There, that's better. More points for fewer points (which means I should > really change the name from fun to pun). > > Does anybody else care about this? What are some alternative solutions? I'd > love to have something like this available in the Prelude or a library. (I > have no strong feelings about the particular operator.) > > Regards, > Sean > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From stephen.tetley at gmail.com Wed Feb 17 10:48:27 2010 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Wed Feb 17 10:19:16 2010 Subject: [Haskell-cafe] Pointfree composition for higher arity In-Reply-To: <20100217154125.GA25561@home.embody.org> References: <3c6288ab1002170731m1661c479r936f3e5b5ff8d89d@mail.gmail.com> <20100217154125.GA25561@home.embody.org> Message-ID: <5fdc56d71002170748x4288d907q92ec534694abfdf6@mail.gmail.com> On 17 February 2010 15:41, Mike Dillon wrote: > That signature is the `oo` "specs" combinator in Data.Aviary: Hi Mike Thanks - indeed, I was just looking up the thread that covered them a month or two ago: http://www.haskell.org/pipermail/haskell-cafe/2009-December/071392.html I wouldn't recommend writing code that depends on Data.Aviary, but some of the combinators are often worth copy/pasting out of it. Best wishes Stephen From jonas.duregard at gmail.com Wed Feb 17 10:48:45 2010 From: jonas.duregard at gmail.com (=?ISO-8859-1?Q?Jonas_Almstr=F6m_Dureg=E5rd?=) Date: Wed Feb 17 10:19:34 2010 Subject: [Haskell-cafe] The Related monad and constant values in type classes Message-ID: <3690ee141002170748t6a67fb46r5acf96f6aa34936f@mail.gmail.com> Hi, This literate haskell file was intended to be a quick question about a problem i have been pondering, but it developed into a short presentation instead. What i want to know is if there is already something like this (and suggestions for improvement of course). >{-#LANGUAGE GeneralizedNewtypeDeriving#-} Sometimes i find myself needing to associate a constant with a type or, more precisely, with a type class instance. Something like this would be nice: class Sized a where size :: Int instance Sized Int where size = 32 Of course this will not work since there is no way of knowing which instance i refer to when i use "size". A common work-around is to use a dummy parameter: >class SizedDummy a where > sizeDummy :: a -> Int > >instance SizedDummy Int where > sizeDummy = const 32 The size function is typically passed an undefined value. This is not very pretty, and somewhat unsafe. Another workaround is to define a newtype with a type parameter. >newtype SizeOf a = MkSize {toInt :: Int} >class SizedNewType a where > sizeNewType :: SizeOf a > >instance SizedNewType Int where > sizeNewType = MkSize 32 If we want the size of a pair to be the sum of it's components, something like this is needed: >instance (SizedNewType a, SizedNewType b) => SizedNewType (a,b) where > sizeNewType = sizeNewType' sizeNewType sizeNewType where > sizeNewType' :: SizeOf a -> SizeOf b -> SizeOf (a,b) > sizeNewType' a b = MkSize $ toInt a + toInt b This is way to much code say that "size = size a + size b". A more general solution can be achieved by making "Int" another type variable of "SizeOf". I call the resulting type "Related": >newtype Related a b = Related {unrelated :: b} deriving > (Eq,Ord,Show,Read,Bounded,Enum,Fractional,Num, > Real,Integral,RealFrac,Floating,RealFloat) This type is highly reusable and the GeneralizedNewtypeDeriving language extension is very practical (although the instances could be written manually). It can also be used as an Identity monad: >instance Functor (Related a) where > fmap f (Related a) = Related $ f a > >instance Monad (Related a) where > return = Related > (Related a) >>= f = f a This allows the Sized class and instances to be specified in a slim fashion using a familiar monadic interface: >class Sized a where > size :: Related a Int > >instance Sized Int where > size = return 32 > >instance (Sized a, Sized b) => Sized (a,b) where > size = do > a <- return size :: Sized a => Related (a,b) (Related a Int) > b <- return size :: Sized b => Related (a,b) (Related b Int) > return $ unrelated a + unrelated b This still requires a lot of type signatures, some additional magic is required. It is possible to write general versions of the type signatures above, which allows the following instance definition for (,,): >instance (Sized a, Sized b, Sized c) => Sized (a,b,c) where > size = do > a <- on3 size > b <- on2 size > c <- on1 size > return $ a + b + c With the derivation of Num, this can be done even more compact: >instance (Sized a, Sized b, Sized c, Sized d) => Sized (a,b,c,d) where > size = on1 size + on2 size + on3 size + on4 size The code for the onN functions: >rerelate :: Related a b -> Related c b >rerelate = return . unrelated >on1 :: Related a v -> Related (x a) v >on1 = rerelate >on2 :: Related a v -> Related (x a x0) v >on2 = rerelate >on3 :: Related a v -> Related (x a x0 x1) v >on3 = rerelate >on4 :: Related a v -> Related (x a x0 x1 x2) v >on4 = rerelate Regards, Jonas Almstr?m Dureg?rd From daniel.is.fischer at web.de Wed Feb 17 10:59:22 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Feb 17 10:32:06 2010 Subject: [Haskell-cafe] Pointfree composition for higher arity In-Reply-To: <3c6288ab1002170731m1661c479r936f3e5b5ff8d89d@mail.gmail.com> References: <3c6288ab1002170731m1661c479r936f3e5b5ff8d89d@mail.gmail.com> Message-ID: <201002171659.22724.daniel.is.fischer@web.de> Am Mittwoch 17 Februar 2010 16:31:16 schrieb Sean Leather: > I find myself often writing this pattern: > > someFun x y z = ... > > > > fun y z = runFun $ someFun someDefault y z > > > or, alternatively: > > fun y = runFun . someFun someDefault y > > > The second option approaches the ideal pointfreeness (or pointlessness > if you prefer), but I'd like to go farther: > > (...) :: (c -> d) -> (a -> b -> c) -> a -> b -> d > > > (...) f g x y = f (g x y) (...) = (.) . (.) > > infixr 9 ... > > fun = runFun ... someFun someDefault > > > There, that's better. More points for fewer points (which means I should > really change the name from fun to pun). > > Does anybody else care about this? What are some alternative solutions? o = (.) oo = (.) . (.) ooo = (.) . (.) . (.) -- etc. runFun `oo` someFun someDefault I've also seen (.:) = (.) . (.) runFun .: someFun someDefault I don't particularly like (...), it's too much like an ellipsis (and bad to count if you continue on that route), I prefer the 'spectacles' or (?) = (.) (??) = (.) . (.) > I'd love to have something like this available in the Prelude or a > library. (I have no strong feelings about the particular operator.) > > Regards, > Sean From mike at embody.org Wed Feb 17 11:05:59 2010 From: mike at embody.org (Mike Dillon) Date: Wed Feb 17 10:36:02 2010 Subject: [Haskell-cafe] Pointfree composition for higher arity In-Reply-To: <5fdc56d71002170748x4288d907q92ec534694abfdf6@mail.gmail.com> References: <3c6288ab1002170731m1661c479r936f3e5b5ff8d89d@mail.gmail.com> <20100217154125.GA25561@home.embody.org> <5fdc56d71002170748x4288d907q92ec534694abfdf6@mail.gmail.com> Message-ID: <20100217160559.GA25681@home.embody.org> begin Stephen Tetley quotation: > On 17 February 2010 15:41, Mike Dillon wrote: > > That signature is the `oo` "specs" combinator in Data.Aviary: > > Hi Mike > > Thanks - indeed, I was just looking up the thread that covered them a > month or two ago: > > http://www.haskell.org/pipermail/haskell-cafe/2009-December/071392.html > > I wouldn't recommend writing code that depends on Data.Aviary, but > some of the combinators are often worth copy/pasting out of it. Are you kidding me? I love writing code like this: ooooo = bunting bunting cardinal thrush blackbird :) -md From vandijk.roel at gmail.com Wed Feb 17 11:11:45 2010 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Wed Feb 17 10:42:32 2010 Subject: [Haskell-cafe] ANN: concurrent-extra-0.1 In-Reply-To: <20100217142737.GA22630@kira.casa> References: <20100217142737.GA22630@kira.casa> Message-ID: On Wed, Feb 17, 2010 at 3:27 PM, Felipe Lessa wrote: > In acquire (l. 111), if the lock was already acquired it goes by > > ? ? ? ?| otherwise ? ? do putMVar mv mb > ? ? ? ? ? ? ? ? ? ? ? ? ? Lock.acquire lock > > So it puts back the information about the owner of the RLock and > waits for its release in the normal Lock. ?And then... nothing? > Shouldn't it need to put into mv information about itself? Well spotted! In order to fix this we changed the structure of an RLock a bit. The inner lock isn't contained in a Maybe anymore but directly in the MVar. So now there is only 1 Lock associated with an RLock. This makes reasoning about the control flow a bit simpler. We also added a test case which fails on the original code but succeeds with the new version. > In release (l. 142) Nothing is put into mv > > ? ? ? ? ? ? ? ? ? ? ? ?then do Lock.release lock > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?putMVar mv Nothing I'm not sure if that was a bug in the original. In the new version we put the lock back inside the MVar. Current version: http://hackage.haskell.org/package/concurrent-extra-0.1.0.1 Thanks, Roel From stephen.tetley at gmail.com Wed Feb 17 11:15:05 2010 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Wed Feb 17 10:45:56 2010 Subject: [Haskell-cafe] Pointfree composition for higher arity In-Reply-To: <20100217160559.GA25681@home.embody.org> References: <3c6288ab1002170731m1661c479r936f3e5b5ff8d89d@mail.gmail.com> <20100217154125.GA25561@home.embody.org> <5fdc56d71002170748x4288d907q92ec534694abfdf6@mail.gmail.com> <20100217160559.GA25681@home.embody.org> Message-ID: <5fdc56d71002170815r54b3536atffa7bfa5ad9dcf5@mail.gmail.com> On 17 February 2010 16:05, Mike Dillon wrote: ... > Are you kidding me? I love writing code like this: > > ? ?ooooo = bunting bunting cardinal thrush blackbird > > :) Hi Mike Thanks! - it took me a surprising amount of time to get from this (where I cheated and used an online 'combinator calculator'): psi :: (b -> b -> c) -> (a -> b) -> a -> a -> c psi = c (b s (b (b c) (b (b (b b)) (c (b b (b b i)) (c (b b i) i))))) (c (b b i) i) where c = cardinal b = bluebird s = starling i = idiot ... to this: psi :: (b -> b -> c) -> (a -> b) -> a -> a -> c psi = cardinal (bluebird starling (bluebird cardinalstar dovekie)) applicator From mike at embody.org Wed Feb 17 11:26:03 2010 From: mike at embody.org (Mike Dillon) Date: Wed Feb 17 10:56:06 2010 Subject: [Haskell-cafe] Pointfree composition for higher arity In-Reply-To: <5fdc56d71002170815r54b3536atffa7bfa5ad9dcf5@mail.gmail.com> References: <3c6288ab1002170731m1661c479r936f3e5b5ff8d89d@mail.gmail.com> <20100217154125.GA25561@home.embody.org> <5fdc56d71002170748x4288d907q92ec534694abfdf6@mail.gmail.com> <20100217160559.GA25681@home.embody.org> <5fdc56d71002170815r54b3536atffa7bfa5ad9dcf5@mail.gmail.com> Message-ID: <20100217162603.GA26098@home.embody.org> begin Stephen Tetley quotation: > On 17 February 2010 16:05, Mike Dillon wrote: > ... > > > Are you kidding me? I love writing code like this: > > > > ? ?ooooo = bunting bunting cardinal thrush blackbird > > > > :) > > Hi Mike > > Thanks! - it took me a surprising amount of time to get from this > (where I cheated and used an online 'combinator calculator'): > > psi :: (b -> b -> c) -> (a -> b) -> a -> a -> c > psi = c (b s (b (b c) (b (b (b b)) (c (b b (b b i)) (c (b b i) i))))) > (c (b b i) i) > where > c = cardinal > b = bluebird > s = starling > i = idiot > > ... to this: > > psi :: (b -> b -> c) -> (a -> b) -> a -> a -> c > psi = cardinal (bluebird starling (bluebird cardinalstar dovekie)) applicator I just typed a bunch of bird names together, saw that the signature appeared to be "ooooo", and ran a quick test to confirm :) -md From ozgurakgun at gmail.com Wed Feb 17 11:46:38 2010 From: ozgurakgun at gmail.com (Ozgur Akgun) Date: Wed Feb 17 11:17:25 2010 Subject: [Haskell-cafe] Re: Implementing "unionAll" In-Reply-To: References: Message-ID: <7be1feae1002170846p3c3892c2o17bf3e83469e1252@mail.gmail.com> > The easiest solution is simply to define > > unionAll = nub . mergeAll > where > -- specialized definition of nub > nub = map head . groupBy (==) > > Talking about the easiest solution, I guess this is a quite easy way of defining unionAll as well: http://gist.github.com/306782 I, of course, do not claim that it is more efficient or better. But I don't think it'd be rubbish :) -- Ozgur Akgun -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100217/19e68091/attachment.html From jeremy at n-heptane.com Wed Feb 17 11:53:21 2010 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Wed Feb 17 11:24:09 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: <1266394750-sup-7721@oz.taruti.net> References: <1266355493-sup-6667@oz.taruti.net> <1266394750-sup-7721@oz.taruti.net> Message-ID: On Wed, Feb 17, 2010 at 2:36 AM, Taru Karttunen wrote: > Excerpts from Bardur Arantsson's message of Tue Feb 16 23:48:14 +0200 2010: > > > This cannot be fixed in the sendfile library, it is a > > > feature of TCP that connections may linger for a long > > > time unless explicit timeouts are used. > > > > The problem is that the sendfile library *doesn't* wake > > up when the connection is terminated (because of threadWaitWrite) > > -- it doesn't matter what the timeout is. > > Even server code without sendfile has the same issue since > all writing to sockets ends up using threadWaitWrite. > Right, this is my concern -- I want to make sure that all of happstack is fixed, not just sendfile. > System.Timeout.timeout terminates a threadWaitWrite using > asynchronous exceptions. > So for sendfile, instead of threadWaitWrite we could do: r <- timeout (60 * 10^6) threadWaitWrite case r of Nothing -> ... -- timed out (Just ()) -> ... -- keep going It seems tricky to use timeout at a higher level in the code, because some requests may take a very long time to finish. For example, when serving a long video, or streaming music it could be hours or days before the IO request finishes. If you want to detect dead sockets somewhat reliably > without a timeout then there is SO_KEEPALIVE combined > with polling SO_ERROR every few minutes. This approach sounds promising because it seems like it could be incorporated into the guts of happstack-server. The timeout period could be a Config option with a reasonable default. I would be surprised if *any* happstack programs today are handling this correctly, so updating the core to do something reasonable would be a big improvement... And if someone has a special need where it is not ok, they can just change the config to use an infinite timeout... Does that sound like the right fix to you? (Obviously, if people are using sendfile with something other than happstack, it does not help them, but it sounds like trying to fix things in sendfile is misguided anyway.) - jeremy -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100217/686c430d/attachment.html From daniel.is.fischer at web.de Wed Feb 17 12:16:04 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Feb 17 11:51:55 2010 Subject: [Haskell-cafe] Re: Implementing "unionAll" In-Reply-To: <7be1feae1002170846p3c3892c2o17bf3e83469e1252@mail.gmail.com> References: <7be1feae1002170846p3c3892c2o17bf3e83469e1252@mail.gmail.com> Message-ID: <201002171816.04381.daniel.is.fischer@web.de> Am Mittwoch 17 Februar 2010 17:46:38 schrieb Ozgur Akgun: > > The easiest solution is simply to define > > > > unionAll = nub . mergeAll > > where > > -- specialized definition of nub > > nub = map head . groupBy (==) > > Talking about the easiest solution, I guess this is a quite easy way of > defining unionAll as well: http://gist.github.com/306782 > I, of course, do not claim that it is more efficient or better. But I > don't think it'd be rubbish :) let next = minimum (map head xs') doesn't work if you have infinitely many lists :( From bofh at redwerk.com Wed Feb 17 12:34:07 2010 From: bofh at redwerk.com (Eugene Dzhurinsky) Date: Wed Feb 17 12:04:59 2010 Subject: [Haskell-cafe] CURL and threads Message-ID: <20100217173407.GA83448@office.redwerk.com> Hello, all! Can somebody please explain, what is the best way of using CURL with several threads? I wrote simple client, which tries to authenticate against HTTP server. With running this client, it starts to eat memory insanely (and I know this code is far, far away of even being close to be called good one ) ========================================================================================= module NTLMTest where import System.IO import Network.Curl import Control.Concurrent import Control.Concurrent.Chan type ResponseState = Either Bool String type RespChannel = Chan ResponseState delay = 500 * 1000 isResponseOk :: String -> CurlResponse -> ResponseState isResponseOk username response = case respCurlCode response of CurlOK -> Left True _ -> Right $ username ++ " => " ++ respStatusLine response ++ " :: " ++ (show . respStatus $ response) checkAuthResponse :: RespChannel -> String -> String -> String -> IO () checkAuthResponse state user passwd url = do response <- curlGetResponse_ url [CurlHttpAuth [HttpAuthAny], CurlUserPwd $ user ++ ":" ++ passwd] writeChan state $ isResponseOk user response threadDelay $ delay runHTTPThread :: RespChannel -> (String,String) -> IO () runHTTPThread state (user,passwd) = checkAuthResponse state user passwd url url = "http://localhost:8082/" credentials = map (\i -> ("user" ++ show i,"123456")) [1..21] main = withCurlDo $ do chan <- newChan :: IO (RespChannel) mapM_ ( \cred -> forkIO $ runHTTPThread chan cred ) credentials dumpChannel chan $ length credentials main where dumpChannel :: RespChannel -> Int -> IO () dumpChannel _chan n | n == 0 = return () | otherwise = do state <- readChan _chan case state of (Left _) -> return () --putStrLn "OK" (Right err) -> putStrLn err dumpChannel _chan $ n-1 ========================================================================================= If I get rid of forkIO - it stops at 40-50 megabytes and don't raise memory usage anymore. Also, I noticed that (either because of buffering, or may be something else) results are appearing on console much slower than if I simply use "wget" with looping in shell script. JMeter also reports awesome speed, so server can authenticate tens of concurrent users per second (thus it's not server or connection bandwidth issue). Hopefully, someone could help me in overcoming my ignorance :) -- Eugene N Dzhurinsky -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 196 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100217/83f58ee9/attachment.bin From ozgurakgun at gmail.com Wed Feb 17 12:59:42 2010 From: ozgurakgun at gmail.com (Ozgur Akgun) Date: Wed Feb 17 12:30:29 2010 Subject: [Haskell-cafe] Re: Implementing "unionAll" In-Reply-To: <201002171816.04381.daniel.is.fischer@web.de> References: <7be1feae1002170846p3c3892c2o17bf3e83469e1252@mail.gmail.com> <201002171816.04381.daniel.is.fischer@web.de> Message-ID: <7be1feae1002170959t22f224cerf04b704ad26ced21@mail.gmail.com> Ooops I thought the inner lists are possibly of infinite size. On 17 February 2010 17:16, Daniel Fischer wrote: > Am Mittwoch 17 Februar 2010 17:46:38 schrieb Ozgur Akgun: > > > The easiest solution is simply to define > > > > > > unionAll = nub . mergeAll > > > where > > > -- specialized definition of nub > > > nub = map head . groupBy (==) > > > > Talking about the easiest solution, I guess this is a quite easy way of > > defining unionAll as well: http://gist.github.com/306782 > > I, of course, do not claim that it is more efficient or better. But I > > don't think it'd be rubbish :) > > let > next = minimum (map head xs') > > doesn't work if you have infinitely many lists :( > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Ozgur Akgun -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100217/c1b68b64/attachment.html From daniel.is.fischer at web.de Wed Feb 17 13:18:19 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Feb 17 12:51:02 2010 Subject: [Haskell-cafe] Re: Implementing "unionAll" In-Reply-To: <7be1feae1002170959t22f224cerf04b704ad26ced21@mail.gmail.com> References: <201002171816.04381.daniel.is.fischer@web.de> <7be1feae1002170959t22f224cerf04b704ad26ced21@mail.gmail.com> Message-ID: <201002171918.19351.daniel.is.fischer@web.de> Am Mittwoch 17 Februar 2010 18:59:42 schrieb Ozgur Akgun: > Ooops I thought the inner lists are possibly of infinite size. > Both, I think. From felipe.lessa at gmail.com Wed Feb 17 13:41:28 2010 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Wed Feb 17 13:12:18 2010 Subject: [Haskell-cafe] ANN: concurrent-extra-0.1 In-Reply-To: References: <20100217142737.GA22630@kira.casa> Message-ID: <20100217184128.GA1726@kira.casa> On Wed, Feb 17, 2010 at 05:11:45PM +0100, Roel van Dijk wrote: > On Wed, Feb 17, 2010 at 3:27 PM, Felipe Lessa wrote: > > In release (l. 142) Nothing is put into mv > > > > ? ? ? ? ? ? ? ? ? ? ? ?then do Lock.release lock > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?putMVar mv Nothing > > I'm not sure if that was a bug in the original. In the new > version we put the lock back inside the MVar. I think it was workable, I've referenced the code just to make the e-mail more self-contained. That Nothing was going to stay after the inner Lock was acquired. :) Cheers, -- Felipe. From spam at scientician.net Wed Feb 17 14:27:07 2010 From: spam at scientician.net (Bardur Arantsson) Date: Wed Feb 17 13:58:13 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: References: <1266355493-sup-6667@oz.taruti.net> <1266394750-sup-7721@oz.taruti.net> Message-ID: Jeremy Shaw wrote: > On Wed, Feb 17, 2010 at 2:36 AM, Taru Karttunen wrote: > > > So for sendfile, instead of threadWaitWrite we could do: > > r <- timeout (60 * 10^6) threadWaitWrite > case r of > Nothing -> ... -- timed out > (Just ()) -> ... -- keep going > For sendfile, a timeout of 1 second would probably be fine. The *ONLY* purpose of threadWaitWrite in the sendfile code is to avoid busy-waiting on EAGAIN from the native sendfile. What would work is, instead of using threadWaitRead (as in the code you supplied) to simply have a 1 second timeout which causes the loop to call the native sendfile again. Native sendfile *will* fail with an error code if the socket has been disconnected. With that in place "dead" threads waiting on threadWaitWrite will only linger at most 1 second before discovering the disconnect. Not ideal, but a lot better than the current situation. > Does that sound like the right fix to you? [--snip--] > (Obviously, if people are using sendfile with something other than happstack, > it does not help them, but it sounds like trying to fix things in > sendfile is misguided anyway.) > How so? As a user I expect sendfile to work and not semi-randomly block threads indefinitely. Cheers, From leather at cs.uu.nl Wed Feb 17 15:48:35 2010 From: leather at cs.uu.nl (Sean Leather) Date: Wed Feb 17 15:19:44 2010 Subject: [Haskell-cafe] The Related monad and constant values in type classes In-Reply-To: <3690ee141002170748t6a67fb46r5acf96f6aa34936f@mail.gmail.com> References: <3690ee141002170748t6a67fb46r5acf96f6aa34936f@mail.gmail.com> Message-ID: <3c6288ab1002171248t1570a296j2e0baed4080710e7@mail.gmail.com> > What i want to know is if there is already > something like this (and suggestions for improvement of course). > ... > Sometimes i find myself needing to associate a constant with a type > or, more precisely, with a type class instance. > I'm not sure if this is what you're looking for, but it seems related. Oleg Kiselyov, Chung-chieh Shan. "Functional pearl: Implicit configurations-or, type classes reflect the values of types," in Haskell 2004. ACM, 2004, pp. 33-44. http://www.citeulike.org/user/spl/article/313800 Regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100217/2ee8f832/attachment.html From bofh at redwerk.com Wed Feb 17 16:09:02 2010 From: bofh at redwerk.com (Eugeny N Dzhurinsky) Date: Wed Feb 17 15:38:15 2010 Subject: [Haskell-cafe] CURL and threads In-Reply-To: <20100217173407.GA83448@office.redwerk.com> References: <20100217173407.GA83448@office.redwerk.com> Message-ID: <20100217210858.GA3577@localhost> On Wed, Feb 17, 2010 at 07:34:07PM +0200, Eugene Dzhurinsky wrote: > Hopefully, someone could help me in overcoming my ignorance :) I realized that I can share the same Chan instance over all invocations in main, and wrap internal function into withCurlDo to ensure only one IO action gets executed with this library. Finally I've come with the following code, which however still has some memory leaks. May be someone will get an idea what's wrong below? ============================================================================================= module NTLMTest where import System.IO import Network.Curl import Control.Concurrent import Control.Concurrent.Chan type ResponseState = Either Bool String type RespChannel = Chan ResponseState delay = 500 * 1000 isResponseOk :: String -> CurlResponse -> ResponseState isResponseOk username response = case respCurlCode response of CurlOK -> Left True _ -> Right $ username ++ " => " ++ respStatusLine response ++ " :: " ++ (show . respStatus $ response) checkAuthResponse :: RespChannel -> String -> String -> String -> IO () checkAuthResponse state user passwd url = do response <- curlGetResponse_ url [CurlHttpAuth [HttpAuthAny], CurlUserPwd $ user ++ ":" ++ passwd] writeChan state $ isResponseOk user response threadDelay $ delay runHTTPThread :: RespChannel -> (String,String) -> IO () runHTTPThread state (user,passwd) = checkAuthResponse state user passwd url url = "http://localhost:8082/" credentials = map (\i -> ("user" ++ show i,"123456")) [1..21] main = do chan <- newChan :: IO (RespChannel) withCurlDo $ invokeThreads chan where invokeThreads chan = do mapM_ ( \cred -> forkIO $ runHTTPThread chan cred ) credentials dumpChannel chan $ length credentials invokeThreads chan dumpChannel :: RespChannel -> Int -> IO () dumpChannel _chan n | n == 0 = return () | otherwise = do state <- readChan _chan case state of (Left _) -> return () --putStrLn "OK" (Right err) -> putStrLn err dumpChannel _chan $ n-1 ============================================================================================= Thank you in advance! -- Eugene Dzhurinsky -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 196 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100217/7b56945f/attachment.bin From matthias.goergens at googlemail.com Wed Feb 17 16:19:48 2010 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Wed Feb 17 15:50:55 2010 Subject: [Haskell-cafe] Linear programming in Haskell In-Reply-To: References: <20100216195420.GA26057@kira.casa> <20100216203725.GA30360@kira.casa> Message-ID: > As far as I can see, you'd use that for systems of linear equalities, but > for systems of linear inequalities?with a linear objective function, it's > not suitable. I may be wrong though :) There's a linear [1] reduction from one problem to the other and vice versa. [1] The transformation itself is a linear function, and it takes O(n) time, too. From leather at cs.uu.nl Wed Feb 17 16:23:29 2010 From: leather at cs.uu.nl (Sean Leather) Date: Wed Feb 17 15:54:40 2010 Subject: [Haskell-cafe] Pointfree composition for higher arity In-Reply-To: <5fdc56d71002170748x4288d907q92ec534694abfdf6@mail.gmail.com> References: <3c6288ab1002170731m1661c479r936f3e5b5ff8d89d@mail.gmail.com> <20100217154125.GA25561@home.embody.org> <5fdc56d71002170748x4288d907q92ec534694abfdf6@mail.gmail.com> Message-ID: <3c6288ab1002171323x6cc1c0d7n8419aab00c5bc7a5@mail.gmail.com> On Wed, Feb 17, 2010 at 16:48, Stephen Tetley wrote: > On 17 February 2010 15:41, Mike Dillon wrote: > > That signature is the `oo` "specs" combinator in Data.Aviary: > Nice! I wouldn't recommend writing code that depends on Data.Aviary, but > some of the combinators are often worth copy/pasting out of it. > On the contrary, I think the specs combinators and perhaps others in Data.Aviary (probably not Data.Aviary.*) have potential. We could even generalize oo and the others to categories and add it to Control.Category (which is, after all, looking rather empty). import Control.Category > import Prelude hiding ((.)) > > -- oo :: (c -> d) -> (a -> b -> c) -> a -> b -> d > oo :: (Category cat) => cat c d -> (a -> cat b c) -> a -> cat b d > oo = (.) . (.) > > -- ooo :: (d -> e) -> (a -> b -> c -> d) -> a -> b -> c -> e > ooo :: (Category cat) => cat d e -> (a -> b -> cat c d) -> a -> b -> cat c > e > ooo = (.) . (.) . (.) > > -- oooo :: (e -> f) -> (a -> b -> c -> d -> e) -> a -> b -> c -> d -> f > oooo :: (Category cat) => cat e f -> (a -> b -> c -> cat d e) -> a -> b -> > c -> cat d f > oooo = (.) . (.) . (.) . (.) > Is it necessary? Maybe not. I'm guessing that the names oo, etc. do not have a commonly accepted meaning, so I like them. I'd like to have a module (e.g. Control.Pointfree) containing these and other useful general combinators from the community. Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100217/6b625662/attachment-0001.html From jeremy at n-heptane.com Wed Feb 17 16:54:29 2010 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Wed Feb 17 16:25:16 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: References: <1266355493-sup-6667@oz.taruti.net> <1266394750-sup-7721@oz.taruti.net> Message-ID: On Wed, Feb 17, 2010 at 1:27 PM, Bardur Arantsson wrote: > > (Obviously, if people are using sendfile with something other than >> happstack, >> it does not help them, but it sounds like trying to fix things in >> > > sendfile is misguided anyway.) > >> >> > How so? As a user I expect sendfile to work and not semi-randomly block > threads indefinitely. > > Because it only addresses *one* case when this type of blocking can happen. Shouldn't hPut and friends also block indefinitely since they also use threadWaitWrite? If so, what good is just fixing sendfile, when all other network I/O will still block indefinitely? If things are 'fixed' at a higher-level, by using SO_KEEPALIVE, then does sendfile really need a hack to deal with it? With your proposed fix, if the user unplugs the network cable, then won't you get an polling loop that never terminates? That doesn't sound any better than the current situation.. You said that you have not seen this issue when using the code that uses hPut, only the code that uses sendfile(). But my research indicates that we *should* see the error. So, I am not very comfortable fixing just sendfile and ignoring the fact that all network I/O might be borked.. I am also not 100% pleased by the SO_KEEPALIVE solution. There are really two errors which can occur: 1. the remote end drops the connection in such a manner that we immediately get notified of it by seeing that a read select() on the socket is successful but there are 0 bytes available to read. This happens because the remote end sent a notification to us that they have terminated the connection. 2. the remote end drops off the network (for example, the network cable is disconnected). In this case, we will not get any notification via read select(), because the remote server is not there to send the notification. The only solution is to eventually timeout. By using a timeout to handle #2, we implicitly handle #1, but in a very untimely manner. Ideally, we would like to handle both these cases separately. In case #1, we know immediately, that the connection is dead, and can therefore clean things up. With case #2, the remote client might actually come back online, (someone plugs the cable back in), and the transfer resumes. Perhaps in some applications we want infinite timeouts for case #2. That does not mean we do not want case #1 handled. However, I do not really see a good way of handle #1 right now that works for all network code, not just sendfile. The issue seems to be that select() was designed as a way to *avoid* using threads. There seems to be the assumption in the network code that you are going to do a select on the read and write aspects of the socket. When the select returns you will then look at what happened, and take the correct action. But, in Haskell, we are using multiple threads. So the code that is looking to read data and the code that is looking to write data don't really know about each other. So even if the read thread detects the closed socket, it has no idea that some other thread needs to be killed. so, what to do? Perhaps it is wrong to use a socket in more than one thread? Obviously, having multiple threads trying read the same socket, or write to the same socket would be a mess. So why do we expect it is ok to have one thread reading and a different thread writing? But, even if we do restrict ourselves to only accessing a socket from one thread at a time, we still have the issue that every place which uses threadWaitWrite needs to handle the disconnect case. We could, of course, write a wrapper function that does the check, and call that instead. But we still have not really solved the problem. The code in the I/O libraries that eventually implements hPut calls threadWaitWrite. But it has no idea that the file descriptor it is waiting on is a socket which has special requirements. That code is also used for writing to plain old files, etc, so it probably wouldn't make sense for it to behave that way by default.. - jeremy -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100217/cd56eab2/attachment.html From mle+hs at mega-nerd.com Wed Feb 17 17:33:23 2010 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Wed Feb 17 17:04:11 2010 Subject: [Haskell-cafe] Linear programming in Haskell In-Reply-To: <4B7BAAFE.3080303@um.es> References: <20100216195420.GA26057@kira.casa> <20100216203725.GA30360@kira.casa> <4B7BAAFE.3080303@um.es> Message-ID: <20100218093323.2f1b0003.mle+hs@mega-nerd.com> Alberto Ruiz wrote: > I think that GSL does not include linear programming solvers, but in the > GSL home page there is a reference to the GLPK package: > > http://www.gnu.org/software/glpk/glpk.html > > I have not used it, but it would be very nice to have a simple Haskell > interface to GLPK (or other similar library) in hmatrix or as a separate > package. I will take a look at this. I used GLPK many years ago and I found it excellent. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From ben.franksen at online.de Wed Feb 17 17:43:43 2010 From: ben.franksen at online.de (Ben Franksen) Date: Wed Feb 17 17:14:40 2010 Subject: [Haskell-cafe] Re: Threading and FFI References: <27611528.post@talk.nabble.com> <20100216172522.GC6832@kira.casa> <27612884.post@talk.nabble.com> <27613138.post@talk.nabble.com> <27621580.post@talk.nabble.com> Message-ID: Yves Par?s wrote: > I've also discovered something interesting: when I link with the > 'threaded' runtime, but let the program use only one core (with '+RTS > -N1'), the problem disappears. How comes? > The whole thing remains a mystery, because I think what I'm trying to do > is quite common... > > > Yves Par?s wrote: >> >> There is a minimal code which produces this issue: >> http://old.nabble.com/file/p27613138/func.c func.c >> http://old.nabble.com/file/p27613138/main.hs main.hs >> >> >> Yves Par?s wrote: >>> >>> Well I tried both 'unsafe' and 'safe', and actually I saw no >>> difference... >>> Even with 'safe', I see a huge difference between calling a C function >>> which sleeps and another which doesn't. When there is a sleep, the other >>> thread is really slower (it just prints numbers, and I look at which >>> pace they're displayed). This is to be expected. From the docs (http://www.haskell.org/ghc/docs/latest/html/libraries/base-4.2.0.0/Control-Concurrent.html#10): "The downside of having lightweight threads is that only one can run at a time, so if one thread blocks in a foreign call, for example, the other threads cannot continue. The GHC runtime works around this by making use of full OS threads where necessary. When the program is built with the -threaded option (to link against the multithreaded version of the runtime), a thread making a safe foreign call will not block the other threads in the system; another OS thread will take over running Haskell threads until the original call returns. The runtime maintains a pool of these worker threads so that multiple Haskell threads can be involved in external calls simultaneously." IIRC, with -threaded, the RTS spawns a separate OS thread for 'safe' foreign calls _in addition_ to the OS threads used for Haskell code (the number of which you give with the +RTS -N option). Cheers Ben From pumpkingod at gmail.com Wed Feb 17 17:47:47 2010 From: pumpkingod at gmail.com (Daniel Peebles) Date: Wed Feb 17 17:18:33 2010 Subject: [Haskell-cafe] Linear programming in Haskell In-Reply-To: References: <20100216195420.GA26057@kira.casa> <20100216203725.GA30360@kira.casa> Message-ID: Interesting. Do you have any details on this? It seems like it would be hard to express system of linear inequalities as a finite system of linear equations. Thanks, Dan 2010/2/17 Matthias G?rgens > > As far as I can see, you'd use that for systems of linear equalities, but > > for systems of linear inequalities with a linear objective function, it's > > not suitable. I may be wrong though :) > > There's a linear [1] reduction from one problem to the other and vice > versa. > > [1] The transformation itself is a linear function, and it takes O(n) time, > too. > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100217/72187cfb/attachment.html From stephen.tetley at gmail.com Wed Feb 17 17:54:18 2010 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Wed Feb 17 17:25:04 2010 Subject: [Haskell-cafe] Pointfree composition for higher arity In-Reply-To: <3c6288ab1002171323x6cc1c0d7n8419aab00c5bc7a5@mail.gmail.com> References: <3c6288ab1002170731m1661c479r936f3e5b5ff8d89d@mail.gmail.com> <20100217154125.GA25561@home.embody.org> <5fdc56d71002170748x4288d907q92ec534694abfdf6@mail.gmail.com> <3c6288ab1002171323x6cc1c0d7n8419aab00c5bc7a5@mail.gmail.com> Message-ID: <5fdc56d71002171454u2a8f99ceq83c287d3a825e2c8@mail.gmail.com> Hi Sean Thanks for the comment. David Menendez pointed out on the other thread that they generalize nicely to functors: http://www.haskell.org/pipermail/haskell-cafe/2009-December/071428.html Typographically they are a pun on ML's composition operator (o), if you don't define o - (aka 'monocle' - little need as we've already got (.) ) then I'd imagine there won't be too many name clashes with people's existing code. 'Specs' was an obvious name for the family once you use them infix. Many of the combinator 'birds' that aren't already used by Haskell seem most useful for permuting other combinator birds rather than programming with - their argument orders not being ideal. The most useful ones I've found that expand to higher arities have the first argument as a 'combiner' (combining all the intermediate results), one or more 'functional' arguments (producing intermediate results from the 'data' arguments), then the 'data' arguments themselves. The liftM and liftA family are of this form, considering the functional type instances ((->) a): liftA :: (a -> ans) -> (r -> a) -> r -> ans liftA2 :: (a -> b -> ans) -> (r -> a) -> (r -> b) -> r -> ans liftA3 :: (a -> b -> c -> ans) -> (r -> a) -> (r -> b) -> (r -> c) -> r -> ans ... or the full general versions: liftA :: Applicative f => (a -> b) -> f a -> f b liftA2 :: Applicative f => (a -> b -> c) -> f a -> f b -> f c liftA3 :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d liftA for functions is bluebird liftA2 for functions is phoenix or starling' or Big Phi ---- An arity family of Starlings can be quite nice for manipulating records. starling :: (a -> b -> c) -> (a -> b) -> a -> c star :: (a -> r -> ans) -> (r -> a) -> r -> ans star2 :: (a -> b -> r -> ans) -> (r -> a) -> (r -> b) -> r -> ans star3 :: (a -> b -> c -> r -> ans) -> (r -> a) -> (r -> b) -> (r -> c) -> r -> ans star4 :: (a -> b -> c -> d -> r -> ans) -> (r -> a) -> (r -> b) -> (r -> c) -> (r -> d) -> r -> ans star5 :: (a -> b -> c -> d -> e -> r -> ans) -> (r -> a) -> (r -> b) -> (r -> c) -> (r -> d) -> (r -> e) -> r -> ans An example - tracking the source position in a parser: data SrcPos = SrcPos { src_line :: Int, src_column :: Int, src_tab_stop :: Int } incrCol :: SrcPos -> SrcPos incrCol = star (\i s -> s { src_column=i+1 }) src_column incrTab :: SrcPos -> SrcPos incrTab = star2 (\i t s -> s { src_column=i+t }) src_column src_tab_stop incrLine :: SrcPos -> SrcPos incrLine = star (\i s -> s { src_line =i+1, src_column=1 }) src_line ---- Permuted variants of cardinal-prime can be useful for adapting a function to a slightly different type. I originally called them combfi etc. 'f' to indicate where a function was applied, and 'i' where identity was applied; but I'm no so happy with the name now: combfi :: (c -> b -> d) -> (a -> c) -> a -> b -> d combfii :: (d -> b -> c -> e) -> (a -> d) -> a -> b -> c -> e combfiii :: (e -> b -> c -> d -> f) -> (a -> e) -> a -> b -> c -> d -> f I've sometimes used them to generalize a function's interface, e.g a pretty printer: f1 :: Doc -> Doc -> Doc adapted_f1 :: Num a => a -> Doc -> Doc adapted_f1 = f1 `combfi` (int . fromIntegral) ... not particularly compelling I'll admit. Slowly I'm synthesizing sets of 'em when they seem to apply to an interesting use. Actually finding valid uses and coining good names is harder than defining them. The 'specs' were lucky in that they pretty much named themselves. Best wishes Stephen From anotheraddress at gmx.de Wed Feb 17 18:06:58 2010 From: anotheraddress at gmx.de (Daniel =?iso-8859-15?q?Sch=FCssler?=) Date: Wed Feb 17 17:37:48 2010 Subject: [Haskell-cafe] What is the meaning of tilde ("~") symbol In-Reply-To: References: <4B76A310.9090406@gmail.com> <4B77F973.4090304@btinternet.com> Message-ID: <201002180006.59381.anotheraddress@gmx.de> On Sunday 14 February 2010 17:02:36 Henk-Jan van Tuyl wrote: > The symbols that are not specified in a library can be found here: > http://www.haskell.org/haskellwiki/Keywords > Hoogle used to show links to this page, when a keyword was searched, but > not anymore. > This isn't Haskell 98 only, is it? :) *Adds type families, fundeps and the arcane arrow notation* -- Daniel From limestrael at gmail.com Wed Feb 17 18:10:42 2010 From: limestrael at gmail.com (=?UTF-8?Q?Yves_Par=C3=A8s?=) Date: Wed Feb 17 17:41:27 2010 Subject: [Haskell-cafe] Threading and FFI In-Reply-To: References: <27611528.post@talk.nabble.com> <20100216172522.GC6832@kira.casa> <27612884.post@talk.nabble.com> <27613138.post@talk.nabble.com> <27621580.post@talk.nabble.com> Message-ID: <27631980.post@talk.nabble.com> Okay! So under UNIX, haskell threaded runtime uses pthreads, if I well understood. To sum up, in order to achieve what I want, I have no other choice than compiling with '-threading' and importing as 'safe' the functions which can make a 'sleep'. Thanks! Ben Franksen wrote: > > Yves Par?s wrote: >> I've also discovered something interesting: when I link with the >> 'threaded' runtime, but let the program use only one core (with '+RTS >> -N1'), the problem disappears. How comes? >> The whole thing remains a mystery, because I think what I'm trying to do >> is quite common... >> >> >> Yves Par?s wrote: >>> >>> There is a minimal code which produces this issue: >>> http://old.nabble.com/file/p27613138/func.c func.c >>> http://old.nabble.com/file/p27613138/main.hs main.hs >>> >>> >>> Yves Par?s wrote: >>>> >>>> Well I tried both 'unsafe' and 'safe', and actually I saw no >>>> difference... >>>> Even with 'safe', I see a huge difference between calling a C function >>>> which sleeps and another which doesn't. When there is a sleep, the >>>> other >>>> thread is really slower (it just prints numbers, and I look at which >>>> pace they're displayed). > > This is to be expected. From the docs > (http://www.haskell.org/ghc/docs/latest/html/libraries/base-4.2.0.0/Control-Concurrent.html#10): > > "The downside of having lightweight threads is that only one can run at a > time, so if one thread blocks in a foreign call, for example, the other > threads cannot continue. The GHC runtime works around this by making use > of > full OS threads where necessary. When the program is built with > the -threaded option (to link against the multithreaded version of the > runtime), a thread making a safe foreign call will not block the other > threads in the system; another OS thread will take over running Haskell > threads until the original call returns. The runtime maintains a pool of > these worker threads so that multiple Haskell threads can be involved in > external calls simultaneously." > > IIRC, with -threaded, the RTS spawns a separate OS thread for 'safe' > foreign > calls _in addition_ to the OS threads used for Haskell code (the number of > which you give with the +RTS -N option). > > Cheers > Ben > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > ----- Yves Par?s Live long and prosper -- View this message in context: http://old.nabble.com/Threading-and-FFI-tp27611528p27631980.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From leon.p.smith at gmail.com Wed Feb 17 20:40:16 2010 From: leon.p.smith at gmail.com (Leon Smith) Date: Wed Feb 17 20:11:03 2010 Subject: [Haskell-cafe] Re: Implementing "unionAll" In-Reply-To: References: Message-ID: On Wed, Feb 17, 2010 at 6:58 AM, Heinrich Apfelmus wrote: > Ah, I meant to use the ?union' ?from your previous message, but I think > that doesn't work because it doesn't have the crucial property that the case > > ? ?union (VIP x xs) ys = ... > > does not pattern match on the second argument. Ahh yes, the funny thing is that I tested the code in my previous message, and it worked in the infinite case. Then I replaced the union' to pattern match on the second argument as well, and tested it on only finite cases, and then released it. Thus, unionAll in data-ordlist-0.4.1 doesn't work on an infinite number of lists. So my original unionAll in data-ordlist-0.4 appears to work ok, my revised and simplified unionAll doesn't work at all. > The easiest solution is simply to define > > ? ?unionAll = nub . mergeAll > ? ? ? ?where > ? ? ? ?-- specialized definition of ?nub > ? ? ? ?nub = map head . groupBy (==) Incidentally, data-ordlist has a (slightly different) version of nub that does exactly what you want in this particular case. Check out the documentation for "nub" and "nubBy" > But you're probably concerned that filtering for duplicates afterwards > will be less efficient. After all, the (implicit) tree built by > mergeAll ?might needlessly compare a lot of equal elements. Well, yes and no. Efficiency is good, but this implementation does not match my intention. For example: unionAll [[1,1,2,2,2],[1,1,1,2]] == foldr union [] [...] == [1,1,1,2,2,2] The "union" function preserves strictly ascending lists, but it also works on multisets as well, returning an element as many times as the maximum number of times in either list. Thus, on an infinite number of lists, unionAll should return a particular element as many times as the maximum number of times it appears in any single list. On Wed, Feb 17, 2010 at 1:18 PM, Daniel Fischer wrote: > Am Mittwoch 17 Februar 2010 18:59:42 schrieb Ozgur Akgun: >> Ooops I thought the inner lists are possibly of infinite size. >> > > Both, I think. Yes, both the inner and outer lists of an input to unionAll might be infinite. It's just that foldr union [] works fine if the inner lists are infinite, but gets stuck in an infinite non-productive list if the outer list is infinite. Best, Leon From thomas.dubuisson at gmail.com Wed Feb 17 20:47:04 2010 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Wed Feb 17 20:17:49 2010 Subject: GUI (was: Re: [Haskell-cafe] DLL on Windows) In-Reply-To: <1266405430.30462.1360422343@webmail.messagingengine.com> References: <600376291002160633m638099cy846dd3770a3190cf@mail.gmail.com> <404396ef1002160837u172b5cdcs6531b7ec06985aae@mail.gmail.com> <600376291002160919hcb6e9c6o1a383eb96480364f@mail.gmail.com> <404396ef1002160957m6ae4370bxb3b0a1d65353c30b@mail.gmail.com> <4c44d90b1002161755n405fb1dck9343a05ca85b69aa@mail.gmail.com> <1266405430.30462.1360422343@webmail.messagingengine.com> Message-ID: <4c44d90b1002171747m1714f829hb497789ae5576e69@mail.gmail.com> On Wed, Feb 17, 2010 at 3:17 AM, Jeremy O'Donoghue wrote: > You're probably correct about the dependencies. I have never tried to > compile wxHaskell against GHC 6.12.1 > > I'm waiting for Haskell Platform to be released to make the required > changes since (working primarily on Windows) I just don't have time to > create a complete GHC 6.12 installation with most of the HP libraries > (some of which are a pain to get working on Windows). FYI, it also seems the current version of wxcore assumes something that isn't true about Cabal (again, I use Cabal 1.8.0.2). I just tested with ghc-6.10.4 + Cabal 1.8.0.2 + cabal-install 0.8.0 and received what is probably a well known complaint: [tommd@Mavlo ~]$ cabal install wx Resolving dependencies... [1 of 1] Compiling Main ( /tmp/wxcore-0.12.1.23133/wxcore-0.12.1.2/Setup.hs, /tmp/wxcore-0.12.1.23133/wxcore-0.12.1.2/dist/setup/Main.o ) /tmp/wxcore-0.12.1.23133/wxcore-0.12.1.2/Setup.hs:15:57: Couldn't match expected type `GenericPackageDescription' against inferred type `Either GenericPackageDescription PackageDescription' Expected type: (GenericPackageDescription, HookedBuildInfo) Inferred type: (Either GenericPackageDescription PackageDescription, HookedBuildInfo) In the `confHook' field of a record In the first argument of `defaultMainWithHooks', namely `simpleUserHooks {confHook = myConfHook}' /tmp/wxcore-0.12.1.23133/wxcore-0.12.1.2/Setup.hs:51:37: Couldn't match expected type `GenericPackageDescription' against inferred type `Either GenericPackageDescription PackageDescription' In the expression: pkg0 In the second argument of `confHook', namely `(pkg0, pbi)' In a stmt of a 'do' expression: lbi <- confHook simpleUserHooks (pkg0, pbi) flags cabal: Error: some packages failed to install: wx-0.12.1.2 depends on wxcore-0.12.1.2 which failed to install. wxcore-0.12.1.2 failed during the configure step. The exception was: ExitFailure 1 From joerg.rudnick at t-online.de Wed Feb 17 22:27:31 2010 From: joerg.rudnick at t-online.de (Nick Rudnick) Date: Wed Feb 17 21:58:22 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> Message-ID: <4B7CB3A3.3020505@t-online.de> I haven't seen anybody mentioning ?Joy of Cats? by Ad?mek, Herrlich & Strecker: It is available online, and is very well-equipped with thorough explanations, examples, exercises & funny illustrations, I would say best of university lecture style: http://katmat.math.uni-bremen.de/acc/. (Actually, the name of the book is a joke on the set theorists' book ?Joy of Set?, which again is a joke on ?Joy of Sex?, which I once found in my parents' bookshelf... ;-)) Another alternative: Personally, I had difficulties with the somewhat arbitrary terminology, at times a hindrance to intuitive understanding - and found intuitive access by programming examples, and the book was ?Computational Category Theory? by Rydeheart & Burstall, also now available online at http://www.cs.man.ac.uk/~david/categories/book/, done with the functional language ML. Later I translated parts of it to Haskell which was great fun, and the books content is more beginner level than any other book I've seen yet. The is also a programming language project dedicated to category theory, ?Charity?, at the university of Calgary: http://pll.cpsc.ucalgary.ca/charity1/www/home.html. Any volunteers in doing a RENAME REFACTORING of category theory together with me?? ;-)) Cheers, Nick Mark Spezzano wrote: > Hi all, > > I'm trying to learn Haskell and have come across Monads. I kind of understand monads now, but I would really like to understand where they come from. So I got a copy of Barr and Well's Category Theory for Computing Science Third Edition, but the book has really left me dumbfounded. It's a good book. But I'm just having trouble with the proofs in Chapter 1--let alone reading the rest of the text. > > Are there any references to things like "Hom Sets" and "Hom Functions" in the literature somewhere and how to use them? The only book I know that uses them is this one. > > Has anyone else found it frustratingly difficult to find details on easy-to-diget material on Category theory. The Chapter that I'm stuck on is actually labelled Preliminaries and so I reason that if I can't do this, then there's not much hope for me understanding the rest of the book... > > Maybe there are books on Discrete maths or Algebra or Set Theory that deal more with Hom Sets and Hom Functions? > > Thanks, > > Mark Spezzano. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From jeremy at n-heptane.com Wed Feb 17 23:44:02 2010 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Wed Feb 17 23:14:49 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: References: <1266355493-sup-6667@oz.taruti.net> <1266394750-sup-7721@oz.taruti.net> Message-ID: On Wed, Feb 17, 2010 at 3:54 PM, Jeremy Shaw wrote: > On Wed, Feb 17, 2010 at 1:27 PM, Bardur Arantsson wrote: > >> >> (Obviously, if people are using sendfile with something other than >>> happstack, >>> it does not help them, but it sounds like trying to fix things in >>> >> > sendfile is misguided anyway.) >> >>> >>> >> How so? As a user I expect sendfile to work and not semi-randomly block >> threads indefinitely. >> >> > Because it only addresses *one* case when this type of blocking can happen. > > Shouldn't hPut and friends also block indefinitely since they also use > threadWaitWrite? If so, what good is just fixing sendfile, when all other > network I/O will still block indefinitely? > > If things are 'fixed' at a higher-level, by using SO_KEEPALIVE, then does > sendfile really need a hack to deal with it? > > I think I understand the SO_KEEPALIVE + SO_ERROR solution, and that does not really fix things either. Setting SO_KEEPALIVE by itself does not cause the write select() to behave any differently. What it does do is cause the TCP stack to eventually send and empty packet to the remote host and hopefully get a response back. The response might be an error, or it might just be an ACK. But either way, I believe it is intended to cause the read select() to wakeup. But, in the case that started this discussion, we are already getting this information. So this won't help with that at all. The second part of the solution is to poll SO_ERROR to determine if something went wrong. This is an alternative to doing a read() on the socket and see if it returns 0 bytes. It is a nice alternative *because* it does not require a read(). However, it is still problematic. When you poll SO_ERROR, it will clear the error value, so there is a potential race condition if multiple threads are doing it. In happstack, we fork a new thread to handle each incoming connection. So at first it seems like we could just fork a second thread that polls the SO_ERROR option on the socket and kills the first thread if an error happens. Unfortunately, it is not that simple. The first thread might fork another thread that is actually doing the threadWaitWrite. Killing the parent thread will not kill that child thread. So, at present, I don't see a solution that is going to fix the problem in the rest of the IO code. There are multiple ways to hack only sendfile.. but that is only one place this error can happen. If this error truly never happens with hPut, then we should figure out why. If there is a solution that works for write() it should work for sendfile(), because the real issue is with the select() call anyway.. - jeremy -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100217/03887602/attachment.html From leon.p.smith at gmail.com Wed Feb 17 23:52:38 2010 From: leon.p.smith at gmail.com (Leon Smith) Date: Wed Feb 17 23:23:25 2010 Subject: [Haskell-cafe] Re: Implementing "unionAll" In-Reply-To: References: Message-ID: On Wed, Feb 17, 2010 at 6:58 AM, Heinrich Apfelmus wrote: > Ah, I meant to use the union' from your previous message, but I think > that doesn't work because it doesn't have the crucial property that the case > > union (VIP x xs) ys = ... > > does not pattern match on the second argument. Ahh yes, my original union' has a bit that looks like this union' (VIP x xs) (VIP y ys) = case cmp x y of LT -> VIP x (union' xs (VIP y ys)) EQ -> VIP x (union' xs ys) GT -> error "Data.List.Ordered.unionAll: assumption violated!" union' (VIP x xs) (Crowd ys) = VIP x (union' xs (Crowd ys)) For whatever reason, this works in the case of an infinite number of lists with my original version, but not the simplified version. By applying a standard transformation to make this lazier, we can rewrite these clauses as union' (VIP x xs) ys = VIP x $ case ys of Crowd _ -> union' xs ys VIP y yt -> case cmp x y of LT -> union' xs ys EQ -> union' xs yt GT -> error msg In the original case, we have this strictness property union' (VIP x xs) ? == ? The revised verison is a bit lazier: union' (VIP x xs) ? == VIP x ? And so the simplified unionAll now works again on an infinite number of lists. I've uploaded data-ordlist-0.4.2 to fix the bug introduced with data-ordlist-0.4.1, and added a regression test to the suite. Best, Leon From bulat.ziganshin at gmail.com Thu Feb 18 01:41:07 2010 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Feb 18 01:12:00 2010 Subject: [Haskell-cafe] Threading and FFI In-Reply-To: <27631980.post@talk.nabble.com> References: <27611528.post@talk.nabble.com> <20100216172522.GC6832@kira.casa> <27612884.post@talk.nabble.com> <27613138.post@talk.nabble.com> <27621580.post@talk.nabble.com> <27631980.post@talk.nabble.com> Message-ID: <648858494.20100218094107@gmail.com> Hello Yves, Thursday, February 18, 2010, 2:10:42 AM, you wrote: > Okay! So under UNIX, haskell threaded runtime uses pthreads, if I well > understood. not exactly. it still uses lightweight (green) threads, but starts additional OS threads as required to keep N haskell threads running. it's very smart > To sum up, in order to achieve what I want, I have no other choice than > compiling with '-threading' and importing as 'safe' the functions which can > make a 'sleep'. > Thanks! > Ben Franksen wrote: >> >> Yves Pares wrote: >>> I've also discovered something interesting: when I link with the >>> 'threaded' runtime, but let the program use only one core (with '+RTS >>> -N1'), the problem disappears. How comes? >>> The whole thing remains a mystery, because I think what I'm trying to do >>> is quite common... >>> >>> >>> Yves Pares wrote: >>>> >>>> There is a minimal code which produces this issue: >>>> http://old.nabble.com/file/p27613138/func.c func.c >>>> http://old.nabble.com/file/p27613138/main.hs main.hs >>>> >>>> >>>> Yves Pares wrote: >>>>> >>>>> Well I tried both 'unsafe' and 'safe', and actually I saw no >>>>> difference... >>>>> Even with 'safe', I see a huge difference between calling a C function >>>>> which sleeps and another which doesn't. When there is a sleep, the >>>>> other >>>>> thread is really slower (it just prints numbers, and I look at which >>>>> pace they're displayed). >> >> This is to be expected. From the docs >> (http://www.haskell.org/ghc/docs/latest/html/libraries/base-4.2.0.0/Control-Concurrent.html#10): >> >> "The downside of having lightweight threads is that only one can run at a >> time, so if one thread blocks in a foreign call, for example, the other >> threads cannot continue. The GHC runtime works around this by making use >> of >> full OS threads where necessary. When the program is built with >> the -threaded option (to link against the multithreaded version of the >> runtime), a thread making a safe foreign call will not block the other >> threads in the system; another OS thread will take over running Haskell >> threads until the original call returns. The runtime maintains a pool of >> these worker threads so that multiple Haskell threads can be involved in >> external calls simultaneously." >> >> IIRC, with -threaded, the RTS spawns a separate OS thread for 'safe' >> foreign >> calls _in addition_ to the OS threads used for Haskell code (the number of >> which you give with the +RTS -N option). >> >> Cheers >> Ben >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > ----- > Yves Pares > Live long and prosper -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From oleg at okmij.org Thu Feb 18 01:54:48 2010 From: oleg at okmij.org (oleg@okmij.org) Date: Thu Feb 18 01:27:53 2010 Subject: [Haskell-cafe] Re: Pointfree composition for higher arity Message-ID: <20100218065448.6717017415@Adric.ern.nps.edu> Sean Leather wrote: > (...) :: (c -> d) -> (a -> b -> c) -> a -> b -> d > (...) f g x y = f (g x y) > Does anybody else care about this? What are some alternative > solutions? Here is a different solution: http://okmij.org/ftp/Haskell/polyvariadic.html#polyvar-comp f:: a1->a2-> .... ->cp (where cp is not a function type) g:: cp->d f `mcomp` g:: a1->a2-> .... ->d Now that we know how to generically decide if a type is not a functional type, mcomp can be defined fully generically, for any type cp that is not a function. If there is interest, I can write that code. One particular application of the mcomp combinator is the prod combinator: Given two functions, f:: a1->a2->...->an->c |c,d non-exponential types g:: b1->b2->...->bn->d their product f `prod` g:: a1->a2->...->an->b1->b2->...->bn->(c,d) The number of as and bs is arbitrary. The definition of prod is very simple: > prod = (. ((. (,)) . mcomp)) . mcomp The web page http://okmij.org/ftp/Haskell/polyvariadic.html#categorical-max3 gives a few explanations and further examples. From qdunkan at gmail.com Thu Feb 18 02:32:44 2010 From: qdunkan at gmail.com (Evan Laforge) Date: Thu Feb 18 02:03:31 2010 Subject: [Haskell-cafe] Re: Implementing "unionAll" In-Reply-To: References: Message-ID: <2518b95d1002172332q6c9a438cq73753b7daa9b3c9b@mail.gmail.com> By purest coincidence I just wrote the exact same function (the simple mergeAll', not the VIP one). Well, extensionally the same... intensionally mine is 32 complicated lines and equivalent to the 3 line mergeAll'. I even thought of short solution by thinking that pulling the first element destroys the ascending lists property so it's equivalent to a normal sorted merge after that, and have no idea why I didn't just write it that way. Anyway, I'm dropping mine and downloading data-ordlist. Thanks for the library *and* the learning experience :) From limestrael at gmail.com Thu Feb 18 02:46:30 2010 From: limestrael at gmail.com (=?UTF-8?Q?Yves_Par=C3=A8s?=) Date: Thu Feb 18 02:17:15 2010 Subject: Re[Haskell-cafe] [2]: Threading and FFI In-Reply-To: <648858494.20100218094107@gmail.com> References: <27611528.post@talk.nabble.com> <20100216172522.GC6832@kira.casa> <27612884.post@talk.nabble.com> <27613138.post@talk.nabble.com> <27621580.post@talk.nabble.com> <27631980.post@talk.nabble.com> <648858494.20100218094107@gmail.com> Message-ID: <27635260.post@talk.nabble.com> Thank you all. But there are two things that remain obscure: First, there is my situation: int the main thread, I call to some C functions binded through FFI. All of them are marked 'unsafe', except one, which is internally supposed to make pauses with 'usleep'. I then execute in another haskell thread (with forkIO) some pure haskell actions. I then compile with the threaded RTS, and let at run the default behaviour which is to use one core. Question 1) What happens to the "unsafe" C functions? I that simply that the threaded RTS is unable to prevent them from blocking haskell threads (which in my case is a problem only for the function which pauses, since other C calls are fast)? Or they could provoke a hazardous issue, so I have to mark all the C functions as "safe" (which will be much slower) because ? Question 2) In the Control.Concurrent documentation, I understood that forkIO creates unbound threads whereas forkOS creates bound threads, but what is not very clear is: when does GHC threaded runtime launches as bound instead of unbound if this one has been started with forkIO? When it detects the thread calls to a C function? When it detects it calls to a "safe" C function (*)? When it detects another thread calls to a (safe) C function (which is my case)? (*) according to documentation it would be this case. However as I said my C calls are done in the MAIN thread. The other thread just executes casual haskell operations, however it is not blocked, which makes me think that even if I launch it with forkIO, it is launched as an bound thread. Bulat Ziganshin-2 wrote: > > Hello Yves, > > Thursday, February 18, 2010, 2:10:42 AM, you wrote: > >> Okay! So under UNIX, haskell threaded runtime uses pthreads, if I well >> understood. > > not exactly. it still uses lightweight (green) threads, but starts > additional OS threads as required to keep N haskell threads running. > it's very smart > > >> To sum up, in order to achieve what I want, I have no other choice than >> compiling with '-threading' and importing as 'safe' the functions which >> can >> make a 'sleep'. > >> Thanks! > ----- Yves Par?s Live long and prosper -- View this message in context: http://old.nabble.com/Threading-and-FFI-tp27611528p27635260.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From qdunkan at gmail.com Thu Feb 18 03:07:09 2010 From: qdunkan at gmail.com (Evan Laforge) Date: Thu Feb 18 02:37:53 2010 Subject: [Haskell-cafe] Re: Implementing "unionAll" In-Reply-To: <2518b95d1002172332q6c9a438cq73753b7daa9b3c9b@mail.gmail.com> References: <2518b95d1002172332q6c9a438cq73753b7daa9b3c9b@mail.gmail.com> Message-ID: <2518b95d1002180007g7782470fqa428ac8deeffc311@mail.gmail.com> BTW, I notice that your merges, like mine, are left-biased. This is a useful property (my callers require it), and doesn't seem to cost anything to implement, so maybe you could commit to it in the documentation? By left-biased I mean that when elements compare equal, pick the leftmost one, e.g. "mergeOn fst [(0, 'a')] [(0, 'b')] == [(0, 'a'), (0, 'b')]". And BTW again, here's something I've occasionally found useful: -- | Handy to merge or sort a descending list. reverse_compare :: (Ord a) => a -> a -> Ordering reverse_compare a b = case compare a b of LT -> GT EQ -> EQ GT -> LT From mike.pentney at physics.org Thu Feb 18 03:56:48 2010 From: mike.pentney at physics.org (Mike Pentney) Date: Thu Feb 18 03:27:37 2010 Subject: [Fwd: Re: [Haskell-cafe] Category Theory woes] Message-ID: <4B7D00D0.1090501@physics.org> As well as books and reading material online, nowadays you can also find video lectures...for example, the following was at the top of Googling "category theory video": http://golem.ph.utexas.edu/category/2007/09/the_catsters_on_youtube.html Cheers, Mike. Nick Rudnick wrote: > I haven't seen anybody mentioning ?Joy of Cats? by Ad?mek, Herrlich & > Strecker: > > It is available online, and is very well-equipped with thorough > explanations, examples, exercises & funny illustrations, I would say > best of university lecture style: > http://katmat.math.uni-bremen.de/acc/. (Actually, the name of the book > is a joke on the set theorists' book ?Joy of Set?, which again is a > joke on ?Joy of Sex?, which I once found in my parents' bookshelf... ;-)) > > Another alternative: Personally, I had difficulties with the somewhat > arbitrary terminology, at times a hindrance to intuitive understanding > - and found intuitive access by programming examples, and the book was > ?Computational Category Theory? by Rydeheart & Burstall, also now > available online at http://www.cs.man.ac.uk/~david/categories/book/, > done with the functional language ML. Later I translated parts of it > to Haskell which was great fun, and the books content is more beginner > level than any other book I've seen yet. > > The is also a programming language project dedicated to category > theory, ?Charity?, at the university of Calgary: > http://pll.cpsc.ucalgary.ca/charity1/www/home.html. > > Any volunteers in doing a RENAME REFACTORING of category theory > together with me?? ;-)) > > Cheers, > > Nick > From leather at cs.uu.nl Thu Feb 18 05:04:32 2010 From: leather at cs.uu.nl (Sean Leather) Date: Thu Feb 18 04:35:38 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <4B7CB3A3.3020505@t-online.de> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <4B7CB3A3.3020505@t-online.de> Message-ID: <3c6288ab1002180204q74df576fw761f408b1f839c54@mail.gmail.com> On Thu, Feb 18, 2010 at 04:27, Nick Rudnick wrote: > I haven't seen anybody mentioning ?Joy of Cats? by Ad?mek, Herrlich & > Strecker: > > It is available online, and is very well-equipped with thorough > explanations, examples, exercises & funny illustrations, I would say best of > university lecture style: http://katmat.math.uni-bremen.de/acc/. > (Actually, the name of the book is a joke on the set theorists' book ?Joy of > Set?, which again is a joke on ?Joy of Sex?, which I once found in my > parents' bookshelf... ;-)) > This book reads quite nicely! I love the illustrations that pervade the technical description, providing comedic relief. I might have to go back a re-learn CT... again. Excellent recommendation! For those looking for resources on category theory, here are my collected references: http://www.citeulike.org/user/spl/tag/category-theory Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100218/049799e1/attachment.html From apfelmus at quantentunnel.de Thu Feb 18 05:05:46 2010 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Thu Feb 18 04:36:53 2010 Subject: [Haskell-cafe] Re: Implementing "unionAll" In-Reply-To: References: Message-ID: Leon Smith wrote: > On Wed, Feb 17, 2010 at 6:58 AM, Heinrich Apfelmus > wrote: >> Ah, I meant to use the union' from your previous message, but I think >> that doesn't work because it doesn't have the crucial property that the case >> >> union (VIP x xs) ys = ... >> >> does not pattern match on the second argument. > > Ahh yes, my original union' has a bit that looks like this > > union' (VIP x xs) (VIP y ys) > = case cmp x y of > LT -> VIP x (union' xs (VIP y ys)) > EQ -> VIP x (union' xs ys) > GT -> error "Data.List.Ordered.unionAll: assumption violated!" > union' (VIP x xs) (Crowd ys) = VIP x (union' xs (Crowd ys)) > > For whatever reason, this works in the case of an infinite number of > lists with my original version, but not the simplified version. By > applying a standard transformation to make this lazier, we can > rewrite these clauses as > > union' (VIP x xs) ys > = VIP x $ case ys of > Crowd _ -> union' xs ys > VIP y yt -> case cmp x y of > LT -> union' xs ys > EQ -> union' xs yt > GT -> error msg Oops, I missed this simple rewrite, mainly because the GT case did not start with the VIP x constructor. :D Regards, Heinrich Apfelmus -- http://apfelmus.nfshost.com From ozgurakgun at gmail.com Thu Feb 18 05:26:02 2010 From: ozgurakgun at gmail.com (Ozgur Akgun) Date: Thu Feb 18 04:56:48 2010 Subject: [Haskell-cafe] Linear programming in Haskell In-Reply-To: References: <20100216195420.GA26057@kira.casa> <20100216203725.GA30360@kira.casa> Message-ID: <7be1feae1002180226t44681856m82c971a0d128d19@mail.gmail.com> I've no idea about the GLPK system. But, isn't it the case that you can transform any linear inequality into a linear equality and a slack (or excess) variable? That's actually what you *need to do* to turn the problem into the canonical form, so that simplex can handle it. 2010/2/17 Daniel Peebles > Interesting. Do you have any details on this? It seems like it would be > hard to express system of linear inequalities as a finite system of linear > equations. > > Thanks, > Dan > > 2010/2/17 Matthias G?rgens > > > As far as I can see, you'd use that for systems of linear equalities, but >> > for systems of linear inequalities with a linear objective function, >> it's >> > not suitable. I may be wrong though :) >> >> There's a linear [1] reduction from one problem to the other and vice >> versa. >> >> [1] The transformation itself is a linear function, and it takes O(n) >> time, too. >> > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- Ozgur Akgun -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100218/acac82a9/attachment.html From sargrigory at ya.ru Thu Feb 18 08:02:51 2010 From: sargrigory at ya.ru (Grigory Sarnitskiy) Date: Thu Feb 18 07:33:49 2010 Subject: [Haskell-cafe] Friedberg numberings. Message-ID: <106811266498171@webmail84.yandex.ru> Hello! The question is not about Haskell, but I don't know where else to ask. In the book "Computable functions" by Vereshchagin and Shen it is said that "it is possible to invent a programming language such that each programming problem has a unique solution in it". The author claims that this statement is a rewording of the theorem, that there is a universal computable function, such that any computable function has exactly one number. I wonder has such language been actually constructed? the book itself (look at the bottom of p 30 for the statement): http://books.google.ru/books?id=A6uvsks0abgC&pg=PA30#v=onepage&q=&f=false From pierreetienne.meunier at gmail.com Thu Feb 18 08:17:48 2010 From: pierreetienne.meunier at gmail.com (Pierre-Etienne Meunier) Date: Thu Feb 18 07:48:35 2010 Subject: [Haskell-cafe] Re : Friedberg numberings Message-ID: <067ACB7B-B69B-491B-934E-20E6AEC97698@gmail.com> Hi, In fact it is not quite hard to see that such a numbering exists : just take any numbering of all Turing machines, say {\phi_i}, then remove all indices i such that there is j Iteratee-parsec is a library which allows to have a parsec (3) parser in IterateeG monad. It contains 2 implementations: - John Lato's on public domain. It is based on monoid and design with short parsers in mind. - Mine on MIT. It is based on single-linked mutable list. It seems to be significantly faster for larger parsers - at least in some cases - but it requires a monad with references (such as for example IO or ST). Regards -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100218/644130a5/attachment.bin From joerg.rudnick at t-online.de Thu Feb 18 08:48:08 2010 From: joerg.rudnick at t-online.de (Nick Rudnick) Date: Thu Feb 18 08:19:00 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <3c6288ab1002180204q74df576fw761f408b1f839c54@mail.gmail.com> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <4B7CB3A3.3020505@t-online.de> <3c6288ab1002180204q74df576fw761f408b1f839c54@mail.gmail.com> Message-ID: <4B7D4518.3030003@t-online.de> IM(H??)O, a really introductive book on category theory still is to be written -- if category theory is really that fundamental (what I believe, due to its lifting of restrictions usually implicit at 'orthodox maths'), than it should find a reflection in our every day's common sense, shouldn't it? In this case, I would regard it as desirable to -- in best refactoring manner -- to identify a wording in this language instead of the abuse of terminology quite common in maths, e.g. * the definition of open/closed sets in topology with the boundary elements of a closed set to considerable extent regardable as facing to an ?outside? (so that reversing these terms could even appear more intuitive, or ?bordered? instead of closed and ?unbordered? instead of open), or * the abuse of abandoning imaginary notions in favour person's last names in tribute to successful mathematicians... Actually, that pupils get to know a certain lemma as ?Zorn's lemma? does not raise public conciousness of Mr. Zorn (even among mathematicians, I am afraid) very much, does it? * 'folkloristic' dropping of terminology -- even in Germany, where the term ?ring? seems to originate from, since at least a century nowbody has the least idea it once had an alternative meaning ?gang,band,group?, which still seems unsatisfactory... Here computing science has explored ways to do much better than this, and it might be time category theory is claimed by computer scientists in this regard. Once such a project has succeeded, I bet, mathematicians will pick up themselves these work to get into category theory... ;-) As an example, let's play a little: Arrows: Arrows are more fundamental than objects, in fact, categories may be defined with arrows only. Although I like the term arrow (more than 'morphism'), I intuitively would find the term ?reference? less contradictive with the actual intention, as this term * is very general, * reflects well dual asymmetry, * does harmoniously transcend the atomary/structured object perspective -- a an object may be in reference to another *by* substructure (in the beginning, I was quite confused lack of explicit explicatation in this regard, as ?arrow/morphism? at least to me impled objekt mapping XOR collection mapping). Categories: In every day's language, a category is a completely different thing, without the least association with a reference system that has a composition which is reflective and associative. To identify a more intuitive term, we can ponder its properties, * reflexivity: This I would interpret as ?the references of a category may be regarded as a certain generalization of id?, saying that references inside a category represent some kind of similarity (which in the most restrictive cases is equality). * associativity: This I would interpret as ?you can *fold* it?, i.e. the behaviour is invariant to the order of composing references to composite references -- leading to ?the behaviour is completely determined by the lower level reference structure? and therefore ?derivations from lower level are possible? Here, finding an appropriate term seems more delicate; maybe a neologism would do good work. Here one proposal: * consequence/?consequentiality? : Pro: Reflects well reflexivity, associativity and duality; describing categories as ?structures of (inner) consequence? seems to fit exceptionally well. The pictorial meaning of a ?con-sequence? may well reflect the graphical structure. Gives a fine picture of the ?intermediating forces? in observation and the ?psychologism? becoming possible (-> cf. CCCs, Toposes). Con: Personalized meaning has an association with somewhat unfriendly behaviour. Anybody to drop a comment on this? Cheers, Nick Sean Leather wrote: > On Thu, Feb 18, 2010 at 04:27, Nick Rudnick wrote: > > I haven't seen anybody mentioning ?Joy of Cats? by Ad?mek, > Herrlich & Strecker: > > It is available online, and is very well-equipped with thorough > explanations, examples, exercises & funny illustrations, I would > say best of university lecture style: > http://katmat.math.uni-bremen.de/acc/. (Actually, the name of the > book is a joke on the set theorists' book ?Joy of Set?, which > again is a joke on ?Joy of Sex?, which I once found in my parents' > bookshelf... ;-)) > > > This book reads quite nicely! I love the illustrations that pervade > the technical description, providing comedic relief. I might have to > go back a re-learn CT... again. Excellent recommendation! > > For those looking for resources on category theory, here are my > collected references: > http://www.citeulike.org/user/spl/tag/category-theory > > Sean > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100218/65203c04/attachment.html From ekmett at gmail.com Thu Feb 18 09:02:11 2010 From: ekmett at gmail.com (Edward Kmett) Date: Thu Feb 18 08:32:55 2010 Subject: [Haskell-cafe] The Related monad and constant values in type classes In-Reply-To: <3690ee141002170748t6a67fb46r5acf96f6aa34936f@mail.gmail.com> References: <3690ee141002170748t6a67fb46r5acf96f6aa34936f@mail.gmail.com> Message-ID: <7fb8f82f1002180602l7c92c821g9b679aa177bed308@mail.gmail.com> I've needed something similar in the past. I used it in the reflection library, and its present on its own on hackage as 'tagged'. http://hackage.haskell.org/packages/archive/tagged/0.0/doc/html/Data-Tagged.html I talked a bit about using it here: http://comonad.com/reader/2009/clearer-reflection/ -Edward Kmett 2010/2/17 Jonas Almstr?m Dureg?rd > Hi, > > This literate haskell file was intended to be a quick question about a > problem i have been pondering, but it developed into a short > presentation instead. What i want to know is if there is already > something like this (and suggestions for improvement of course). > > >{-#LANGUAGE GeneralizedNewtypeDeriving#-} > > Sometimes i find myself needing to associate a constant with a type > or, more precisely, with a type class instance. Something like this > would be nice: > > class Sized a where > size :: Int > > instance Sized Int where > size = 32 > > Of course this will not work since there is no way of knowing which > instance i refer to when i use "size". A common work-around is to use > a dummy parameter: > > >class SizedDummy a where > > sizeDummy :: a -> Int > > > >instance SizedDummy Int where > > sizeDummy = const 32 > > The size function is typically passed an undefined value. This is not > very pretty, and somewhat unsafe. Another workaround is to define a > newtype with a type parameter. > > >newtype SizeOf a = MkSize {toInt :: Int} > >class SizedNewType a where > > sizeNewType :: SizeOf a > > > >instance SizedNewType Int where > > sizeNewType = MkSize 32 > > If we want the size of a pair to be the sum of it's components, > something like this is needed: > > >instance (SizedNewType a, SizedNewType b) => SizedNewType (a,b) where > > sizeNewType = sizeNewType' sizeNewType sizeNewType where > > sizeNewType' :: SizeOf a -> SizeOf b -> SizeOf (a,b) > > sizeNewType' a b = MkSize $ toInt a + toInt b > > This is way to much code say that "size = size a + size b". A more > general solution can be achieved by making "Int" another type variable > of "SizeOf". I call the resulting type "Related": > > >newtype Related a b = Related {unrelated :: b} deriving > > (Eq,Ord,Show,Read,Bounded,Enum,Fractional,Num, > > Real,Integral,RealFrac,Floating,RealFloat) > > This type is highly reusable and the GeneralizedNewtypeDeriving > language extension is very practical (although the instances could be > written manually). It can also be used as an Identity monad: > > >instance Functor (Related a) where > > fmap f (Related a) = Related $ f a > > > >instance Monad (Related a) where > > return = Related > > (Related a) >>= f = f a > > This allows the Sized class and instances to be specified in a slim > fashion using a familiar monadic interface: > > >class Sized a where > > size :: Related a Int > > > >instance Sized Int where > > size = return 32 > > > >instance (Sized a, Sized b) => Sized (a,b) where > > size = do > > a <- return size :: Sized a => Related (a,b) (Related a Int) > > b <- return size :: Sized b => Related (a,b) (Related b Int) > > return $ unrelated a + unrelated b > > This still requires a lot of type signatures, some additional magic is > required. It is possible to write general versions of the type > signatures above, which allows the following instance definition for > (,,): > > >instance (Sized a, Sized b, Sized c) => Sized (a,b,c) where > > size = do > > a <- on3 size > > b <- on2 size > > c <- on1 size > > return $ a + b + c > > With the derivation of Num, this can be done even more compact: > > >instance (Sized a, Sized b, Sized c, Sized d) => Sized (a,b,c,d) where > > size = on1 size + on2 size + on3 size + on4 size > > The code for the onN functions: > > >rerelate :: Related a b -> Related c b > >rerelate = return . unrelated > > >on1 :: Related a v -> Related (x a) v > >on1 = rerelate > > >on2 :: Related a v -> Related (x a x0) v > >on2 = rerelate > > >on3 :: Related a v -> Related (x a x0 x1) v > >on3 = rerelate > > >on4 :: Related a v -> Related (x a x0 x1 x2) v > >on4 = rerelate > > > Regards, > Jonas Almstr?m Dureg?rd > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100218/6e042c11/attachment.html From haberg at math.su.se Thu Feb 18 09:32:05 2010 From: haberg at math.su.se (Hans Aberg) Date: Thu Feb 18 09:02:52 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <4B7D4518.3030003@t-online.de> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <4B7CB3A3.3020505@t-online.de> <3c6288ab1002180204q74df576fw761f408b1f839c54@mail.gmail.com> <4B7D4518.3030003@t-online.de> Message-ID: <2F93D0A8-E4D0-4AC0-82A3-599E036F1095@math.su.se> On 18 Feb 2010, at 14:48, Nick Rudnick wrote: > * the definition of open/closed sets in topology with the boundary > elements of a closed set to considerable extent regardable as facing > to an ?outside? (so that reversing these terms could even appear > more intuitive, or ?bordered? instead of closed and ?unbordered? > instead of open), I take "closed" as coming from being closed under limit operations - the origin from analysis. A closure operation c is defined by the property c(c(x)) = c(x). If one takes c(X) = the set of limit points of X, then it is the smallest closed set under this operation. The closed sets X are those that satisfy c(X) = X. Naming the complements of the closed sets open might have been introduced as an opposite of closed. Hans From daniel.is.fischer at web.de Thu Feb 18 09:55:37 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Feb 18 09:28:27 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <4B7D4518.3030003@t-online.de> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <3c6288ab1002180204q74df576fw761f408b1f839c54@mail.gmail.com> <4B7D4518.3030003@t-online.de> Message-ID: <201002181555.37468.daniel.is.fischer@web.de> Am Donnerstag 18 Februar 2010 14:48:08 schrieb Nick Rudnick: > even in Germany, where the > term ?ring? seems to originate from, since at least a century nowbody > has the least idea it once had an alternative meaning ?gang,band,group?, Wrong. The term "Ring" is still in use with that meaning in composites like Schmugglerring, Autoschieberring, ... From taruti at taruti.net Thu Feb 18 10:53:23 2010 From: taruti at taruti.net (Taru Karttunen) Date: Thu Feb 18 10:24:09 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: References: <1266355493-sup-6667@oz.taruti.net> <1266394750-sup-7721@oz.taruti.net> Message-ID: <1266508065-sup-8211@oz.taruti.net> Excerpts from Bardur Arantsson's message of Wed Feb 17 21:27:07 +0200 2010: > For sendfile, a timeout of 1 second would probably be fine. The *ONLY* > purpose of threadWaitWrite in the sendfile code is to avoid busy-waiting > on EAGAIN from the native sendfile. Of course this will kill connections for all clients that may have a two second network hickup. > How so? As a user I expect sendfile to work and not semi-randomly block > threads indefinitely. If you want sending something to terminate you will add a timeout to it. A nasty client may e.g. take one byte each minute and sending your file may take a few years. - Taru Karttunen From haskell at benmachine.co.uk Thu Feb 18 11:04:57 2010 From: haskell at benmachine.co.uk (Ben Millwood) Date: Thu Feb 18 10:35:43 2010 Subject: [Haskell-cafe] Re: Implementing "unionAll" In-Reply-To: <2518b95d1002180007g7782470fqa428ac8deeffc311@mail.gmail.com> References: <2518b95d1002172332q6c9a438cq73753b7daa9b3c9b@mail.gmail.com> <2518b95d1002180007g7782470fqa428ac8deeffc311@mail.gmail.com> Message-ID: On Thu, Feb 18, 2010 at 8:07 AM, Evan Laforge wrote: > And BTW again, here's something I've occasionally found useful: > > -- | Handy to merge or sort a descending list. > reverse_compare :: (Ord a) => a -> a -> Ordering > reverse_compare a b = case compare a b of > ? ?LT -> GT > ? ?EQ -> EQ > ? ?GT -> LT I wondered why there wasn't one of these in the standard library until someone pointed out to me that reverse_compare = flip compare which actually takes fewer characters to type :P From stephen.tetley at gmail.com Thu Feb 18 11:05:30 2010 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Thu Feb 18 10:36:14 2010 Subject: [Haskell-cafe] The Related monad and constant values in type classes In-Reply-To: <7fb8f82f1002180602l7c92c821g9b679aa177bed308@mail.gmail.com> References: <3690ee141002170748t6a67fb46r5acf96f6aa34936f@mail.gmail.com> <7fb8f82f1002180602l7c92c821g9b679aa177bed308@mail.gmail.com> Message-ID: <5fdc56d71002180805l15a5847fo18781ff4a98ebb53@mail.gmail.com> Hi Edward Does Tagged have a common synonym as its the 'opposite' of Const? I thought I'd seen the same construction used with Strafunski / StrategyLib, but if I did I can no longer find the examples. Thanks Stephen From joerg.rudnick at t-online.de Thu Feb 18 11:10:08 2010 From: joerg.rudnick at t-online.de (Nick Rudnick) Date: Thu Feb 18 10:40:59 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <201002181555.37468.daniel.is.fischer@web.de> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <3c6288ab1002180204q74df576fw761f408b1f839c54@mail.gmail.com> <4B7D4518.3030003@t-online.de> <201002181555.37468.daniel.is.fischer@web.de> Message-ID: <4B7D6660.5070701@t-online.de> Hi Daniel, ;-)) agreed, but is the word ?Ring? itself in use? The same about the English language... de.wikipedia says: ? Die Namensgebung /Ring/ bezieht sich nicht auf etwas anschaulich Ringf?rmiges, sondern auf einen organisierten Zusammenschluss von Elementen zu einem Ganzen. Diese Wortbedeutung ist in der deutschen Sprache ansonsten weitgehend verloren gegangen. Einige ?ltereVereinsbezeichnungen (wie z. B. Deutscher Ring , Wei?er Ring ) oder Ausdr?cke wie ?Verbrecherring? weisen noch auf diese Bedeutung hin. Das Konzept des Ringes geht auf Richard Dedekind zur?ck; die Bezeichnung /Ring/ wurde allerdings von David Hilbert eingef?hrt.? (http://de.wikipedia.org/wiki/Ringtheorie) How many students are wondering confused about what is ?the hollow? in a ring every year worlwide, since Hilbert made this unreflected wording, by just picking another term around ?collection?? Although not a mathematician, I've visited several maths lectures, for interest, having the same problem. Then I began asking everybody I could reach -- and even maths professors could not tell me why this thing is called a ?ring?. Thanks for your examples: A ?gang? {of smugglers|car thieves} shows even the original meaning -- once knowed -- does not reflect the characteristics of the mathematical structure. Cheers, Nick Daniel Fischer wrote: > Am Donnerstag 18 Februar 2010 14:48:08 schrieb Nick Rudnick: > >> even in Germany, where the >> term ?ring? seems to originate from, since at least a century nowbody >> has the least idea it once had an alternative meaning ?gang,band,group?, >> > > Wrong. The term "Ring" is still in use with that meaning in composites like > Schmugglerring, Autoschieberring, ... > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100218/6c0393e2/attachment.html From nccb2 at kent.ac.uk Thu Feb 18 11:33:19 2010 From: nccb2 at kent.ac.uk (Neil Brown) Date: Thu Feb 18 11:05:24 2010 Subject: [Haskell-cafe] CURL and threads In-Reply-To: <20100217210858.GA3577@localhost> References: <20100217173407.GA83448@office.redwerk.com> <20100217210858.GA3577@localhost> Message-ID: <4B7D6BCF.6050509@kent.ac.uk> Hi, Your code forks off N threads to do HTTP response checking, then waits for the reply (invokeThreads). Each thread (runHTTPThread) calls curlGetResponse and *immediately* sends the answer back down the channel to invokeThreads (checkAuthResponse) -- then waits for half a second before terminating. As soon as the original process (invokeThreads) has all N responses, it forks off N threads again. So if your code manages to process the N requests such that it can do them all in, say, 0.05 seconds, you'll have about ten times as many threads in your system as you intended (because they all hang around for 0.5 seconds after completing their work). I suspect what you intended to do was put that threadDelay call *before* sending back the response, which would prevent this leaking of threads. Some quick style suggestions: your recursion pattern in dumpChannel is easily replaced with replicateM, and your infinite recursion in invokeThreads could easily become the function "forever". Never recurse directly if a combinator can remove the need :-) Your code could easily be accomplished in CHP (http://hackage.haskell.org/package/chp). runParMapM would solve your exact problem easily; you could replace your code with: ==== module NTLMTest where import Control.Monad.Trans (liftIO) import Control.Applicative ((<$>)) import System.IO import Network.Curl import Control.Concurrent.CHP type ResponseState = Either Bool String isResponseOk :: String -> CurlResponse -> ResponseState isResponseOk username response = case respCurlCode response of CurlOK -> Left True _ -> Right $ username ++ " => " ++ respStatusLine response ++ " :: " ++ (show . respStatus $ response) -- Note: I re-ordered the parameters to this function checkAuthResponse :: String -> String -> String -> IO ResponseState checkAuthResponse url user passwd = isResponseOk user <$> curlGetResponse_ url [CurlHttpAuth [HttpAuthAny], CurlUserPwd $ user ++ ":" ++ passwd] url = "http://localhost:8082/" credentials = map (\i -> ("user" ++ show i,"123456")) [1..21] main = runCHP_ $ runParMapM (liftIO . uncurry (checkAuthResponse url)) credentials >>= mapM (liftIO . either (const $ return ()) putStrLn) ==== That above version will get all the responses in parallel and print them out once they are all done, and is quite short. This isn't what your original code did though -- that read the responses from a channel and printed them as they arrived. The below version is probably the closest CHP version to your original code: ==== module NTLMTest where import Control.Monad (replicateM_, (<=<)) import Control.Monad.Trans (liftIO) import Control.Applicative ((<$>)) import System.IO import Network.Curl import Control.Concurrent.CHP type ResponseState = Either Bool String isResponseOk :: String -> CurlResponse -> ResponseState isResponseOk username response = case respCurlCode response of CurlOK -> Left True _ -> Right $ username ++ " => " ++ respStatusLine response ++ " :: " ++ (show . respStatus $ response) -- Note: I re-ordered the parameters to this function checkAuthResponse :: String -> String -> String -> IO ResponseState checkAuthResponse url user passwd = isResponseOk user <$> curlGetResponse_ url [CurlHttpAuth [HttpAuthAny], CurlUserPwd $ user ++ ":" ++ passwd] url = "http://localhost:8082/" credentials = map (\i -> ("user" ++ show i,"123456")) [1..21] main = runCHP_ $ do chan <- anyToOneChannel runParallel_ $ dumpChannel (reader chan) : map (claim (writer chan) . writeValue <=< liftIO . uncurry (checkAuthResponse url)) credentials where dumpChannel :: Chanin ResponseState -> CHP () dumpChannel c = replicateM_ (length credentials) (readChannel c >>= liftIO . either (const $ return ()) putStrLn) ==== This version runs the dumpChannel procedure in parallel with a thread for each credential that writes the result to a shared channel (claiming it as it does so). Neither of my versions checks the credentials repeatedly like yours does, but you can easily add that in. If you're not a point-free fan (I find it irresistible these days), I can break those solutions down a bit into more functions. Hope that helps, Neil. Eugeny N Dzhurinsky wrote: > On Wed, Feb 17, 2010 at 07:34:07PM +0200, Eugene Dzhurinsky wrote: > >> Hopefully, someone could help me in overcoming my ignorance :) >> > > I realized that I can share the same Chan instance over all invocations in > main, and wrap internal function into withCurlDo to ensure only one IO action > gets executed with this library. Finally I've come with the following code, > which however still has some memory leaks. May be someone will get an idea > what's wrong below? > > ============================================================================================= > > module NTLMTest where > > import System.IO > import Network.Curl > import Control.Concurrent > import Control.Concurrent.Chan > > type ResponseState = Either Bool String > > type RespChannel = Chan ResponseState > > delay = 500 * 1000 > > isResponseOk :: String -> CurlResponse -> ResponseState > isResponseOk username response = case respCurlCode response of > CurlOK -> Left True > _ -> Right $ username ++ " => " ++ respStatusLine response ++ " :: " ++ (show . respStatus $ response) > > > checkAuthResponse :: RespChannel -> String -> String -> String -> IO () > checkAuthResponse state user passwd url = do > response <- curlGetResponse_ url [CurlHttpAuth [HttpAuthAny], CurlUserPwd $ user ++ ":" ++ passwd] > writeChan state $ isResponseOk user response > threadDelay $ delay > > runHTTPThread :: RespChannel -> (String,String) -> IO () > runHTTPThread state (user,passwd) = checkAuthResponse state user passwd url > > > url = "http://localhost:8082/" > credentials = map (\i -> ("user" ++ show i,"123456")) [1..21] > > main = do > chan <- newChan :: IO (RespChannel) > withCurlDo $ invokeThreads chan > where > invokeThreads chan = do > mapM_ ( \cred -> forkIO $ runHTTPThread chan cred ) credentials > dumpChannel chan $ length credentials > invokeThreads chan > dumpChannel :: RespChannel -> Int -> IO () > dumpChannel _chan n | n == 0 = return () > | otherwise = do state <- readChan _chan > case state of > (Left _) -> return () --putStrLn "OK" > (Right err) -> putStrLn err > dumpChannel _chan $ n-1 > > > ============================================================================================= > > Thank you in advance! > > > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From matthias.goergens at googlemail.com Thu Feb 18 11:46:50 2010 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Thu Feb 18 11:17:55 2010 Subject: [Haskell-cafe] Linear programming in Haskell In-Reply-To: References: <20100216195420.GA26057@kira.casa> <20100216203725.GA30360@kira.casa> Message-ID: The trick is to use only non-negative variables for the equations. (That's considered OK in linear programming. Though you may consider it cheating.) By the way, linear programming over rational numbers is in P. From matthias.goergens at googlemail.com Thu Feb 18 11:49:44 2010 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Thu Feb 18 11:20:50 2010 Subject: [Haskell-cafe] Linear programming in Haskell In-Reply-To: <7be1feae1002180226t44681856m82c971a0d128d19@mail.gmail.com> References: <20100216195420.GA26057@kira.casa> <20100216203725.GA30360@kira.casa> <7be1feae1002180226t44681856m82c971a0d128d19@mail.gmail.com> Message-ID: > But, isn't it the case that you can transform any linear inequality into a > linear equality and a slack (or excess) variable? That's actually what you > *need to do* to turn the problem into the canonical form, so that simplex > can handle it. Yes. The simplex is usually implemented in this form. If you just want to play around with linear programming in Haskell, you could try write an FFI wrapper aruond SCIP (http://scip.zib.de/). (Though the licence of scip is probably not what you want. But there are other solvers available, too.) The domain specific language (and compiler of the same name) ZIMPL may be worth a look for linear programming. (http://zimpl.zib.de/) From daniel.is.fischer at web.de Thu Feb 18 11:54:50 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Feb 18 11:27:31 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <4B7D6660.5070701@t-online.de> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <201002181555.37468.daniel.is.fischer@web.de> <4B7D6660.5070701@t-online.de> Message-ID: <201002181754.50858.daniel.is.fischer@web.de> Am Donnerstag 18 Februar 2010 17:10:08 schrieb Nick Rudnick: > Hi Daniel, > > ;-)) agreed, but is the word ?Ring? itself in use? Of course, many people wear rings on their fingers. Oh - you meant "in the sense of gang/group"? It still appears as part of the name of some groups as a word of its own, otherwise, I can at the moment only recall its use in compounds. > The same about the > English language... de.wikipedia says: > > ? Die Namensgebung /Ring/ bezieht sich nicht auf etwas anschaulich > Ringf?rmiges, sondern auf einen organisierten Zusammenschluss von > Elementen zu einem Ganzen. I don't know whether that's correct. It may be, but then the french "anneau" is a horrible mistranslation. > Diese Wortbedeutung ist in der deutschen > Sprache ansonsten weitgehend verloren gegangen. Einige > ?ltereVereinsbezeichnungen (wie z. B. Deutscher Ring > , Wei?er Ring ) oder > Ausdr?cke wie ?Verbrecherring? weisen noch auf diese Bedeutung hin. Das > Konzept des Ringes geht auf Richard Dedekind > zur?ck; die Bezeichnung /Ring/ wurde allerdings > von David Hilbert eingef?hrt.? > (http://de.wikipedia.org/wiki/Ringtheorie) > > How many students are wondering confused about what is ?the hollow? in a > ring every year worlwide, since Hilbert made this unreflected wording, You know, a "field" is a "K?rper" in german, ("corps" in french), a "Ring" is a "K?rper" with a hole in it (no division in general). > by just picking another term around ?collection?? Although not a > mathematician, I've visited several maths lectures, for interest, having > the same problem. Then I began asking everybody I could reach -- and > even maths professors could not tell me why this thing is called a > ?ring?. That's often a problem with things that were named by Germans in the nineteenth or early twentieth century. They had pretty undecipherable ways of choosing metaphors and coming up with weird associations. > > Thanks for your examples: A ?gang? {of smugglers|car thieves} shows even > the original meaning -- once knowed -- does not reflect the > characteristics of the mathematical structure. > > Cheers, > > Nick > > Daniel Fischer wrote: > > Am Donnerstag 18 Februar 2010 14:48:08 schrieb Nick Rudnick: > >> even in Germany, where the > >> term ?ring? seems to originate from, since at least a century nowbody > >> has the least idea it once had an alternative meaning > >> ?gang,band,group?, > > > > Wrong. The term "Ring" is still in use with that meaning in composites > > like Schmugglerring, Autoschieberring, ... From dev at mobileink.com Thu Feb 18 12:24:13 2010 From: dev at mobileink.com (Gregg Reynolds) Date: Thu Feb 18 11:55:04 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <4B7D4518.3030003@t-online.de> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <4B7CB3A3.3020505@t-online.de> <3c6288ab1002180204q74df576fw761f408b1f839c54@mail.gmail.com> <4B7D4518.3030003@t-online.de> Message-ID: <75cc17ac1002180924r6d8eb5f4r3a7ddebd9825c69f@mail.gmail.com> On Thu, Feb 18, 2010 at 7:48 AM, Nick Rudnick wrote: > IM(H??)O, a really introductive book on category theory still is to be > written -- if category theory is really that fundamental (what I believe, > due to its lifting of restrictions usually implicit at 'orthodox maths'), > than it should find a reflection in our every day's common sense, shouldn't > it? > > Goldblatt works for me. > > * the definition of open/closed sets in topology with the boundary elements > of a closed set to considerable extent regardable as facing to an ?outside? > (so that reversing these terms could even appear more intuitive, or > ?bordered? instead of closed and ?unbordered? instead of open), > Both have a border, just in different places. > As an example, let's play a little: > > Arrows: Arrows are more fundamental than objects, in fact, categories may > be defined with arrows only. Although I like the term arrow (more than > 'morphism'), I intuitively would find the term ?reference? less > contradictive with the actual intention, as this term > > Arrows don't refer. > Categories: In every day's language, a category is a completely different > thing, without the least > Not necesssarily (for Kantians, Aristoteleans?) If memory serves, MacLane says somewhere that he and Eilenberg picked the term "category" as an explicit play on the same term in philosophy. In general I find mathematical terminology well-chosen and revealing, if one takes the trouble to do a little digging. If you want to know what terminological chaos really looks like try linguistics. -g -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100218/4785e4ca/attachment.html From dagit at codersbase.com Thu Feb 18 12:47:30 2010 From: dagit at codersbase.com (Jason Dagit) Date: Thu Feb 18 12:18:19 2010 Subject: [Haskell-cafe] How can i run darcs in ghci? In-Reply-To: <1266307997-sup-2585@nixos> References: <1266302824-sup-6353@nixos> <1266307997-sup-2585@nixos> Message-ID: On Tue, Feb 16, 2010 at 12:17 AM, Marc Weber wrote: > > > Any help on how to load the .h is greatly appreciated. I tried -i > > with > > path to the src directory but it didn't work (should it?). > Try -I -i is used for .hs files only (?). > This seems like a missing feature in cabal or ghci. In the past darcs used a makefile and it was possible to type, 'make ghci' and you'd be dumped at the ghci prompt with everything ready. Perhaps the right way to get this feature is to write a plugin for ghci to add this. I'm thinking the plugin would use the cabal library to understand a .cabal file and then instruct ghci in how to load each module that is requested (making sure CPP and flags are dealt with correctly and dependency order is respected). When a .cabal file provides all the modules as a library (as is the case with darcs), you can install the library and then instruct ghci to load the right package. From inside ghci you can then :m + the modules you want to use. The downside to this is that only things exported from the modules are visible and every time you change the source you have to reinstall and restart ghci. So, something like this: cabal install foo-1.2 ghci -package foo-1.2 :m + Data.Foo I hope that helps, Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100218/5ac6004c/attachment.html From jonas.duregard at gmail.com Thu Feb 18 13:01:44 2010 From: jonas.duregard at gmail.com (=?ISO-8859-1?Q?Jonas_Almstr=F6m_Dureg=E5rd?=) Date: Thu Feb 18 12:32:28 2010 Subject: [Haskell-cafe] The Related monad and constant values in type classes In-Reply-To: <7fb8f82f1002180602l7c92c821g9b679aa177bed308@mail.gmail.com> References: <3690ee141002170748t6a67fb46r5acf96f6aa34936f@mail.gmail.com> <7fb8f82f1002180602l7c92c821g9b679aa177bed308@mail.gmail.com> Message-ID: <3690ee141002181001m45b6f775s8387a518531cc2b2@mail.gmail.com> Hi Edward, Nothing new under the sun it would seem :). Perhaps these functions could be useful in the Tagged library? >on1 :: Tagged a v -> Tagged (x a) v >on1 = retag > >on2 :: Tagged a v -> Tagged (x a x0) v >on2 = retag > >on3 :: Tagged a v -> Tagged (x a x0 x1) v >on3 = retag > >on4 :: Tagged a v -> Tagged (x a x0 x1 x2) v >on4 = retag They allow the user to perform operations on the type parameters of an instantiated type without adding a lot of additional type signatures etc., e.g. >instance SomeClass a => SomeClass [a] where > someFunction = on1 someFunction /Jonas 2010/2/18 Edward Kmett : > I've needed something similar in the past. > > I used it in the reflection library, and its present on its own on hackage > as 'tagged'. > > http://hackage.haskell.org/packages/archive/tagged/0.0/doc/html/Data-Tagged.html > > I talked a bit about using it here: > > http://comonad.com/reader/2009/clearer-reflection/ > > -Edward Kmett > > 2010/2/17 Jonas Almstr?m Dureg?rd >> >> Hi, >> >> This literate haskell file was intended to be a quick question about a >> problem i have been pondering, but it developed into a short >> presentation instead. What i want to know is if there is already >> something like this (and suggestions for improvement of course). >> >> >{-#LANGUAGE GeneralizedNewtypeDeriving#-} >> >> Sometimes i find myself needing to associate a constant with a type >> or, more precisely, with a type class instance. Something like this >> would be nice: >> >> class Sized a where >> ?size :: Int >> >> instance Sized Int where >> ?size = 32 >> >> Of course this will not work since there is no way of knowing which >> instance i refer to when i use "size". A common work-around is to use >> a dummy parameter: >> >> >class SizedDummy a where >> > ?sizeDummy :: a -> Int >> > >> >instance SizedDummy Int where >> > ?sizeDummy = const 32 >> >> The size function is typically passed an undefined value. This is not >> very pretty, and somewhat unsafe. Another workaround is to define a >> newtype with a type parameter. >> >> >newtype SizeOf a = MkSize {toInt :: Int} >> >class SizedNewType a where >> > ?sizeNewType :: SizeOf a >> > >> >instance SizedNewType Int where >> > ?sizeNewType = MkSize 32 >> >> If we want the size of a pair to be the sum of it's components, >> something like this is needed: >> >> >instance (SizedNewType a, SizedNewType b) => SizedNewType (a,b) where >> > ?sizeNewType = sizeNewType' sizeNewType sizeNewType where >> > ? ?sizeNewType' :: SizeOf a -> SizeOf b -> SizeOf (a,b) >> > ? ?sizeNewType' a b = MkSize $ toInt a + toInt b >> >> This is way to much code say that "size = size a + size b". A more >> general solution can be achieved by making "Int" another type variable >> of "SizeOf". I call the resulting type "Related": >> >> >newtype Related a b = Related {unrelated :: b} deriving >> > ? ? ? ? ?(Eq,Ord,Show,Read,Bounded,Enum,Fractional,Num, >> > ? ? ? ? ? Real,Integral,RealFrac,Floating,RealFloat) >> >> This type is highly reusable and the GeneralizedNewtypeDeriving >> language extension is very practical (although the instances could be >> written manually). It can also be used as an Identity monad: >> >> >instance Functor (Related a) where >> > ?fmap f (Related a) = Related $ f a >> > >> >instance Monad (Related a) where >> > ?return = Related >> > ?(Related a) >>= f = f a >> >> This allows the Sized class and instances to be specified in a slim >> fashion using a familiar monadic interface: >> >> >class Sized a where >> > ?size :: Related a Int >> > >> >instance Sized Int where >> > ?size = return 32 >> > >> >instance (Sized a, Sized b) => Sized (a,b) where >> > ?size = do >> > ? ?a <- return size :: Sized a => Related (a,b) (Related a Int) >> > ? ?b <- return size :: Sized b => Related (a,b) (Related b Int) >> > ? ?return $ unrelated a + unrelated b >> >> This still requires a lot of type signatures, some additional magic is >> required. It is possible to write general versions of the type >> signatures above, which allows the following instance definition for >> (,,): >> >> >instance (Sized a, Sized b, Sized c) => Sized (a,b,c) where >> > ?size = do >> > ? ?a <- on3 size >> > ? ?b <- on2 size >> > ? ?c <- on1 size >> > ? ?return $ a + b + c >> >> With the derivation of Num, this can be done even more compact: >> >> >instance (Sized a, Sized b, Sized c, Sized d) => Sized (a,b,c,d) where >> > ?size = on1 size + on2 size + on3 size + on4 size >> >> The code for the onN functions: >> >> >rerelate :: Related a b -> Related c b >> >rerelate = return . unrelated >> >> >on1 :: Related a v -> Related (x a) v >> >on1 = rerelate >> >> >on2 :: Related a v -> Related (x a x0) v >> >on2 = rerelate >> >> >on3 :: Related a v -> Related (x a x0 x1) v >> >on3 = rerelate >> >> >on4 :: Related a v -> Related (x a x0 x1 x2) v >> >on4 = rerelate >> >> >> Regards, >> Jonas Almstr?m Dureg?rd >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > From joerg.rudnick at t-online.de Thu Feb 18 13:19:36 2010 From: joerg.rudnick at t-online.de (Nick Rudnick) Date: Thu Feb 18 12:50:40 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <2F93D0A8-E4D0-4AC0-82A3-599E036F1095@math.su.se> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <4B7CB3A3.3020505@t-online.de> <3c6288ab1002180204q74df576fw761f408b1f839c54@mail.gmail.com> <4B7D4518.3030003@t-online.de> <2F93D0A8-E4D0-4AC0-82A3-599E036F1095@math.su.se> Message-ID: <4B7D84B8.3020605@t-online.de> Hi Hans, agreed, but, in my eyes, you directly point to the problem: * doesn't this just delegate the problem to the topic of limit operations, i.e., in how far is the term ?closed? here more perspicuous? * that's (for a very simple concept) the way that maths prescribes: + historical background: ?I take "closed" as coming from being closed under limit operations - the origin from analysis.? + definition backtracking: ?A closure operation c is defined by the property c(c(x)) = c(x). If one takes c(X) = the set of limit points of X, then it is the smallest closed set under this operation. The closed sets X are those that satisfy c(X) = X. Naming the complements of the closed sets open might have been introduced as an opposite of closed.? 418 bytes in my file system... how many in my brain...? Is it efficient, inevitable? The most fundamentalist justification I heard in this regard is: ?It keeps people off from thinking the could go without the definition...? Meanwhile, we backtrack definition trees filling books, no, even more... In my eyes, this comes equal to claiming: ?You have nothing to understand this beyond the provided authoritative definitions -- your understanding is done by strictly following these.? Back to the case of open/closed, given we have an idea about sets -- we in most cases are able to derive the concept of two disjunct sets facing each other ourselves, don't we? The only lore missing is just a Bool: Which term fits which idea? With a reliable terminology using ?bordered/unbordered?, there is no ambiguity, and we can pass on reading, without any additional effort. Picking such an opportunity thus may save a lot of time and even error -- allowing you to utilize your individual knowledge and experience. I have hope that this approach would be of great help in learning category theory. All the best, Nick Hans Aberg wrote: > On 18 Feb 2010, at 14:48, Nick Rudnick wrote: > >> * the definition of open/closed sets in topology with the boundary >> elements of a closed set to considerable extent regardable as facing >> to an ?outside? (so that reversing these terms could even appear more >> intuitive, or ?bordered? instead of closed and ?unbordered? instead >> of open), > > I take "closed" as coming from being closed under limit operations - > the origin from analysis. A closure operation c is defined by the > property c(c(x)) = c(x). If one takes c(X) = the set of limit points > of X, then it is the smallest closed set under this operation. The > closed sets X are those that satisfy c(X) = X. Naming the complements > of the closed sets open might have been introduced as an opposite of > closed. > > Hans > > > From gue.schmidt at web.de Thu Feb 18 13:50:00 2010 From: gue.schmidt at web.de (=?ISO-8859-1?Q?G=FCnther_Schmidt?=) Date: Thu Feb 18 13:21:15 2010 Subject: [Haskell-cafe] Re: Heterogeneous Data Structures - Nested Pairs and functional references In-Reply-To: References: <4B7AFC98.9080103@web.de> Message-ID: <4B7D8BD8.7050804@web.de> Hi Alexander, sry for being a bit thick, but how would this code be used? I'm unable to figure out the application yet. Could you give some examples how you use it? G?nther From joerg.rudnick at t-online.de Thu Feb 18 13:55:31 2010 From: joerg.rudnick at t-online.de (Nick Rudnick) Date: Thu Feb 18 13:26:30 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <75cc17ac1002180924r6d8eb5f4r3a7ddebd9825c69f@mail.gmail.com> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <4B7CB3A3.3020505@t-online.de> <3c6288ab1002180204q74df576fw761f408b1f839c54@mail.gmail.com> <4B7D4518.3030003@t-online.de> <75cc17ac1002180924r6d8eb5f4r3a7ddebd9825c69f@mail.gmail.com> Message-ID: <4B7D8D23.3020402@t-online.de> Gregg Reynolds wrote: > On Thu, Feb 18, 2010 at 7:48 AM, Nick Rudnick > > wrote: > > IM(H??)O, a really introductive book on category theory still is > to be written -- if category theory is really that fundamental > (what I believe, due to its lifting of restrictions usually > implicit at 'orthodox maths'), than it should find a reflection in > our every day's common sense, shouldn't it? > > > Goldblatt works for me. Accidentially, I have Goldblatt here, although I didn't read it before -- you agree with me it's far away from every day's common sense, even for a hobby coder?? I mean, this is not ?Head first categories?, is it? ;-)) With ?every day's common sense? I did not mean ?a mathematician's every day's common sense?, but that of, e.g., a housewife or a child... But I have became curious now for Goldblatt... > > > > * the definition of open/closed sets in topology with the boundary > elements of a closed set to considerable extent regardable as > facing to an ?outside? (so that reversing these terms could even > appear more intuitive, or ?bordered? instead of closed and > ?unbordered? instead of open), > > > Both have a border, just in different places. Which elements form the border of an open set?? > > > As an example, let's play a little: > > Arrows: Arrows are more fundamental than objects, in fact, > categories may be defined with arrows only. Although I like the > term arrow (more than 'morphism'), I intuitively would find the > term ?reference? less contradictive with the actual intention, as > this term > > Arrows don't refer. A *referrer* (object) refers to a *referee* (object) by a *reference* (arrow). > > > Categories: In every day's language, a category is a completely > different thing, without the least > > > Not necesssarily (for Kantians, Aristoteleans?) Are you sure...?? See http://en.wikipedia.org/wiki/Categories_(Aristotle) ... > If memory serves, MacLane says somewhere that he and Eilenberg > picked the term "category" as an explicit play on the same term in > philosophy. > In general I find mathematical terminology well-chosen and revealing, > if one takes the trouble to do a little digging. If you want to know > what terminological chaos really looks like try linguistics. ;-) For linguistics, granted... In regard of ?a little digging?, don't you think terminology work takes a great share, especially at interdisciplinary efforts? Wouldn't it be great to be able to drop, say 20% or even more, of such efforts and be able to progress more fluidly ? > > -g > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100218/324bac66/attachment.html From msmatsko at comcast.net Thu Feb 18 14:16:44 2010 From: msmatsko at comcast.net (Michael Matsko) Date: Thu Feb 18 13:47:27 2010 Subject: Fwd: [Haskell-cafe] Category Theory woes In-Reply-To: <1392759898.3984731266520578901.JavaMail.root@sz0009a.westchester.pa.mail.comcast.net> Message-ID: <1878594958.3984921266520604735.JavaMail.root@sz0009a.westchester.pa.mail.comcast.net> ----- Forwarded Message ----- From: "Michael Matsko" To: "Nick Rudnick" Sent: Thursday, February 18, 2010 2:16:18 PM GMT -05:00 US/Canada Eastern Subject: Re: [Haskell-cafe] Category Theory woes Gregg, ?? Topologically speaking, the border of an open set is called the boundary of the set.??The boundary is defined as the closure of the set?minus the set itself.? As an example consider the open interval (0,1) on the real line.? The closure of the set is [0,1], the closed interval on 0, 1.? The boundary would be the points 0 and 1. Mike Matsko ----- Original Message ----- From: "Nick Rudnick" To: "Gregg Reynolds" Cc: "Haskell Caf? List" Sent: Thursday, February 18, 2010 1:55:31 PM GMT -05:00 US/Canada Eastern Subject: Re: [Haskell-cafe] Category Theory woes Gregg Reynolds wrote: On Thu, Feb 18, 2010 at 7:48 AM, Nick Rudnick < joerg.rudnick@t-online.de > wrote: IM(H??)O, a really introductive book on category theory still is to be written -- if category theory is really that fundamental (what I believe, due to its lifting of restrictions usually implicit at 'orthodox maths'), than it should find a reflection in our every day's common sense, shouldn't it? Goldblatt works for me. Accidentially, I have Goldblatt here, although I didn't read it before -- you agree with me it's far away from every day's common sense, even for a hobby coder?? I mean, this is not ?Head first categories?, is it? ;-)) With ?every day's common sense? I did not mean ?a mathematician's every day's common sense?, but that of, e.g., a housewife or a child... But I have became curious now for Goldblatt... * the definition of open/closed sets in topology with the boundary elements of a closed set to considerable extent regardable as facing to an ?outside? (so that reversing these terms could even appear more intuitive, or ?bordered? instead of closed and ?unbordered? instead of open), Both have a border, just in different places. Which elements form the border of an open set?? As an example, let's play a little: Arrows: Arrows are more fundamental than objects, in fact, categories may be defined with arrows only. Although I like the term arrow (more than 'morphism'), I intuitively would find the term ?reference? less contradictive with the actual intention, as this term Arrows don't refer.? A *referrer* (object) refers to a *referee* (object) by a *reference* (arrow). Categories: In every day's language, a category is a completely different thing, without the least Not necesssarily (for Kantians, Aristoteleans?) Are you sure...?? See http://en.wikipedia.org/wiki/Categories_(Aristotle) ... ? If memory serves, MacLane says somewhere that he and Eilenberg picked the term "category" as an explicit play on the same term in philosophy. In general I find mathematical terminology well-chosen and revealing, if one takes the trouble to do a little digging.? If you want to know what terminological chaos really looks like try linguistics. ;-) For linguistics, granted... In regard of ?a little digging?, don't you think terminology work takes a great share, especially at interdisciplinary efforts? Wouldn't it be great to be able to drop, say 20% or even more, of such efforts and be able to progress more fluidly ? -g _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100218/2745cdf8/attachment.html From daniel.is.fischer at web.de Thu Feb 18 14:20:49 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Feb 18 13:53:30 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <4B7D84B8.3020605@t-online.de> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <2F93D0A8-E4D0-4AC0-82A3-599E036F1095@math.su.se> <4B7D84B8.3020605@t-online.de> Message-ID: <201002182020.49657.daniel.is.fischer@web.de> Am Donnerstag 18 Februar 2010 19:19:36 schrieb Nick Rudnick: > Hi Hans, > > agreed, but, in my eyes, you directly point to the problem: > > * doesn't this just delegate the problem to the topic of limit > operations, i.e., in how far is the term ?closed? here more perspicuous? It's fairly natural in German, abgeschlossen: closed, finished, complete; offen: open, ongoing. > > * that's (for a very simple concept) That concept (open and closed sets, topology more generally) is *not* very simple. It has many surprising aspects. > the way that maths prescribes: > + historical background: ?I take "closed" as coming from being closed > under limit operations - the origin from analysis.? > + definition backtracking: ?A closure operation c is defined by the > property c(c(x)) = c(x). Actually, that's incomplete, missing are - c(x) contains x - c(x) is minimal among the sets containing x with y = c(y). > If one takes c(X) = the set of limit points of Not limit points, "Ber?hrpunkte" (touching points). > X, then it is the smallest closed set under this operation. The closed > sets X are those that satisfy c(X) = X. Naming the complements of the > closed sets open might have been introduced as an opposite of closed.? > > 418 bytes in my file system... how many in my brain...? Is it efficient, > inevitable? The most fundamentalist justification I heard in this regard > is: ?It keeps people off from thinking the could go without the > definition...? Meanwhile, we backtrack definition trees filling books, > no, even more... In my eyes, this comes equal to claiming: ?You have > nothing to understand this beyond the provided authoritative definitions > -- your understanding is done by strictly following these.? But you can't understand it except by familiarising yourself with the definitions and investigating their consequences. The name of a concept can only help you remembering what the definition was. Choosing "obvious" names tends to be misleading, because there usually are things satisfying the definition which do not behave like the "obvious" name implies. > > Back to the case of open/closed, given we have an idea about sets -- we > in most cases are able to derive the concept of two disjunct sets facing > each other ourselves, don't we? The only lore missing is just a Bool: > Which term fits which idea? With a reliable terminology using > ?bordered/unbordered?, there is no ambiguity, and we can pass on > reading, without any additional effort. And we'd be very wrong. There are sets which are simultaneously open and closed. It is bad enough with the terminology as is, throwing in the boundary (which is an even more difficult concept than open/closed) would only make things worse. > > Picking such an opportunity thus may save a lot of time and even error > -- allowing you to utilize your individual knowledge and experience. I When learning a formal theory, individual knowledge and experience (except coming from similar enough disciplines) tend to be misleading more than helpful. > have hope that this approach would be of great help in learning category > theory. > > All the best, > > Nick > > Hans Aberg wrote: > > On 18 Feb 2010, at 14:48, Nick Rudnick wrote: > >> * the definition of open/closed sets in topology with the boundary > >> elements of a closed set to considerable extent regardable as facing > >> to an ?outside? (so that reversing these terms could even appear more > >> intuitive, or ?bordered? instead of closed and ?unbordered? instead > >> of open), > > > > I take "closed" as coming from being closed under limit operations - > > the origin from analysis. A closure operation c is defined by the > > property c(c(x)) = c(x). If one takes c(X) = the set of limit points > > of X, then it is the smallest closed set under this operation. The > > closed sets X are those that satisfy c(X) = X. Naming the complements > > of the closed sets open might have been introduced as an opposite of > > closed. > > > > Hans > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From daniel.is.fischer at web.de Thu Feb 18 14:31:02 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Feb 18 14:03:52 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <4B7D8D23.3020402@t-online.de> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <75cc17ac1002180924r6d8eb5f4r3a7ddebd9825c69f@mail.gmail.com> <4B7D8D23.3020402@t-online.de> Message-ID: <201002182031.03105.daniel.is.fischer@web.de> Am Donnerstag 18 Februar 2010 19:55:31 schrieb Nick Rudnick: > Gregg Reynolds wrote: > > On Thu, Feb 18, 2010 at 7:48 AM, Nick Rudnick > > > wrote: > > > > IM(H??)O, a really introductive book on category theory still is > > to be written -- if category theory is really that fundamental > > (what I believe, due to its lifting of restrictions usually > > implicit at 'orthodox maths'), than it should find a reflection in > > our every day's common sense, shouldn't it? > > > > > > Goldblatt works for me. > > Accidentially, I have Goldblatt here, although I didn't read it before > -- you agree with me it's far away from every day's common sense, even > for a hobby coder?? I mean, this is not ?Head first categories?, is it? > ;-)) With ?every day's common sense? I did not mean ?a mathematician's > every day's common sense?, but that of, e.g., a housewife or a child... Doesn't work. You need a lot of training in abstraction to learn very abstract concepts. Joe Sixpack's common sense isn't prepared for that. > > But I have became curious now for Goldblatt... > > > * the definition of open/closed sets in topology with the boundary > > elements of a closed set to considerable extent regardable as > > facing to an ?outside? (so that reversing these terms could even > > appear more intuitive, or ?bordered? instead of closed and > > ?unbordered? instead of open), > > > > > > Both have a border, just in different places. > > Which elements form the border of an open set?? The boundary of an open set is the boundary of its complement. The boundary may be empty (happens if and only if the set is simultaneously open and closed, "clopen", as some say). > > > As an example, let's play a little: > > > > Arrows: Arrows are more fundamental than objects, in fact, > > categories may be defined with arrows only. Although I like the > > term arrow (more than 'morphism'), I intuitively would find the > > term ?reference? less contradictive with the actual intention, as > > this term > > > > Arrows don't refer. > > A *referrer* (object) refers to a *referee* (object) by a *reference* > (arrow). > Doesn't work for me. Not in Ens (sets, maps), Grp (groups, homomorphisms), Top (topological spaces, continuous mappings), Diff (differential manifolds, smooth mappings), ... . From ajs at 2piix.com Thu Feb 18 15:11:01 2010 From: ajs at 2piix.com (Alexander Solla) Date: Thu Feb 18 14:41:46 2010 Subject: [Haskell-cafe] Re: Heterogeneous Data Structures - Nested Pairs and functional references In-Reply-To: <4B7D8BD8.7050804@web.de> References: <4B7AFC98.9080103@web.de> <4B7D8BD8.7050804@web.de> Message-ID: > > sry for being a bit thick, but how would this code be used? > > I'm unable to figure out the application yet. Could you give some > examples how you use it? > > > G?nther So, the type (View view) -- ignoring class instances -- is basically isomorphic to this (slightly simpler) type: data View = EmptyView | TextView String | ConcatView View View | NestViews View View View | ... instance Monoid View where ... Now, consider the problem of "generic programming" on the simpler type: you quantify over the data constructors "generically", and in doing so you gain "traversals" for the type.[1] You gain the same things by turning View into (View view) -- a functor, a foldable functor, and so on. When it comes time to "render" a format for a View (for example, a bit of Html from Text.XHtml.Strict), I use some higher order functions I'm already familiar with. Something like renderXHtml :: (View view) -> Html renderXHtml (ConcatViews l r) = fold $ renderXHtml (ConcatViews l r) renderXHtml (NestViews l m r) = fold $ renderXHtml (NestViews l m r) renderXHtml (TextView string) = stringToHtml string renderXHtml (PageView v_title, v_heading, v_header, v_footer, v_contents) = (the_title << (renderXHtml v_title)) +++ -- (We assume v_title is a TextView String) (body << ( renderXHtml v_header ) +++ (render_page_contents v_contents v_heading) +++ (renderXHtml v_footer) ) where render_page_contents contents heading = undefined -- takes a View and uses the page's heading View -- so I guess we assume v_heading is a function -- into a TextView ... You could potentially use (>>=) for this, directly. And if you were using the simpler type, you could do the same thing with Uniplate, for example. It's going to construct an automorphism for you. [1] Actually, it's "the other way around". But the container/ contained adjunction makes them equivalent. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100218/2bb431a9/attachment.html From joerg.rudnick at t-online.de Thu Feb 18 15:15:49 2010 From: joerg.rudnick at t-online.de (Nick Rudnick) Date: Thu Feb 18 14:46:48 2010 Subject: Fwd: [Haskell-cafe] Category Theory woes In-Reply-To: <1878594958.3984921266520604735.JavaMail.root@sz0009a.westchester.pa.mail.comcast.net> References: <1878594958.3984921266520604735.JavaMail.root@sz0009a.westchester.pa.mail.comcast.net> Message-ID: <4B7D9FF5.2030408@t-online.de> Hi Mike, so an open set does not contain elements constituting a border/boundary of it, does it? But a closed set does, doesn't it? Cheers, Nick Michael Matsko wrote: > > ----- Forwarded Message ----- > From: "Michael Matsko" > To: "Nick Rudnick" > Sent: Thursday, February 18, 2010 2:16:18 PM GMT -05:00 US/Canada Eastern > Subject: Re: [Haskell-cafe] Category Theory woes > > Gregg, > > > > Topologically speaking, the border of an open set is called the > boundary of the set. The boundary is defined as the closure of the > set minus the set itself. As an example consider the open interval > (0,1) on the real line. The closure of the set is [0,1], the closed > interval on 0, 1. The boundary would be the points 0 and 1. > > > > Mike Matsko > > > ----- Original Message ----- > From: "Nick Rudnick" > To: "Gregg Reynolds" > Cc: "Haskell Caf? List" > Sent: Thursday, February 18, 2010 1:55:31 PM GMT -05:00 US/Canada Eastern > Subject: Re: [Haskell-cafe] Category Theory woes > > Gregg Reynolds wrote: > > On Thu, Feb 18, 2010 at 7:48 AM, Nick Rudnick > > wrote: > > IM(H??)O, a really introductive book on category theory still > is to be written -- if category theory is really that > fundamental (what I believe, due to its lifting of > restrictions usually implicit at 'orthodox maths'), than it > should find a reflection in our every day's common sense, > shouldn't it? > > > Goldblatt works for me. > > Accidentially, I have Goldblatt here, although I didn't read it before > -- you agree with me it's far away from every day's common sense, even > for a hobby coder?? I mean, this is not ?Head first categories?, is > it? ;-)) With ?every day's common sense? I did not mean ?a > mathematician's every day's common sense?, but that of, e.g., a > housewife or a child... > > But I have became curious now for Goldblatt... > > > > > * the definition of open/closed sets in topology with the > boundary elements of a closed set to considerable extent > regardable as facing to an ?outside? (so that reversing these > terms could even appear more intuitive, or ?bordered? instead > of closed and ?unbordered? instead of open), > > > Both have a border, just in different places. > > Which elements form the border of an open set?? > > > > As an example, let's play a little: > > Arrows: Arrows are more fundamental than objects, in fact, > categories may be defined with arrows only. Although I like > the term arrow (more than 'morphism'), I intuitively would > find the term ?reference? less contradictive with the actual > intention, as this term > > Arrows don't refer. > > A *referrer* (object) refers to a *referee* (object) by a *reference* > (arrow). > > > > Categories: In every day's language, a category is a > completely different thing, without the least > > > Not necesssarily (for Kantians, Aristoteleans?) > > Are you sure...?? See > http://en.wikipedia.org/wiki/Categories_(Aristotle) ... > > If memory serves, MacLane says somewhere that he and Eilenberg > picked the term "category" as an explicit play on the same term in > philosophy. > > In general I find mathematical terminology well-chosen and > revealing, if one takes the trouble to do a little digging. If > you want to know what terminological chaos really looks like try > linguistics. > > ;-) For linguistics, granted... In regard of ?a little digging?, don't > you think terminology work takes a great share, especially at > interdisciplinary efforts? Wouldn't it be great to be able to drop, > say 20% or even more, of such efforts and be able to progress more > fluidly ? > > > -g > > > > _______________________________________________ Haskell-Cafe mailing > list Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100218/1526923c/attachment.html From ajs at 2piix.com Thu Feb 18 15:20:34 2010 From: ajs at 2piix.com (Alexander Solla) Date: Thu Feb 18 14:51:20 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <4B7D84B8.3020605@t-online.de> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <4B7CB3A3.3020505@t-online.de> <3c6288ab1002180204q74df576fw761f408b1f839c54@mail.gmail.com> <4B7D4518.3030003@t-online.de> <2F93D0A8-E4D0-4AC0-82A3-599E036F1095@math.su.se> <4B7D84B8.3020605@t-online.de> Message-ID: On Feb 18, 2010, at 10:19 AM, Nick Rudnick wrote: > Back to the case of open/closed, given we have an idea about sets -- > we in most cases are able to derive the concept of two disjunct sets > facing each other ourselves, don't we? The only lore missing is just > a Bool: Which term fits which idea? With a reliable terminology > using ?bordered/unbordered?, there is no ambiguity, and we can pass > on reading, without any additional effort. There are sets that only partially contain their boundary. They are neither open nor closed, in the usual topology. Consider (0,1] in the Real number line. It contains 1, a boundary point. It does not contain 0. It is not an open set OR a closed set in the usual topology for R. From haberg at math.su.se Thu Feb 18 15:47:02 2010 From: haberg at math.su.se (Hans Aberg) Date: Thu Feb 18 15:17:48 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <201002182020.49657.daniel.is.fischer@web.de> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <2F93D0A8-E4D0-4AC0-82A3-599E036F1095@math.su.se> <4B7D84B8.3020605@t-online.de> <201002182020.49657.daniel.is.fischer@web.de> Message-ID: On 18 Feb 2010, at 20:20, Daniel Fischer wrote: >> + definition backtracking: ?A closure operation c is defined by the >> property c(c(x)) = c(x). > > Actually, that's incomplete, ... That's right, it is just the idempotency relation. > ...missing are > - c(x) contains x > - c(x) is minimal among the sets containing x with y = c(y). It suffices*) with a lattice L with relation <= (inclusion in the case of sets) satifying i. x <= y implies c(x) <= c(y) ii. x <= c(x) for all x in L. iii. c(c(x)) = x. Hans *) The definition in a book on lattice theory by Balbes & Dwinger. From haberg at math.su.se Thu Feb 18 15:54:24 2010 From: haberg at math.su.se (Hans Aberg) Date: Thu Feb 18 15:25:08 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <4B7D84B8.3020605@t-online.de> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <4B7CB3A3.3020505@t-online.de> <3c6288ab1002180204q74df576fw761f408b1f839c54@mail.gmail.com> <4B7D4518.3030003@t-online.de> <2F93D0A8-E4D0-4AC0-82A3-599E036F1095@math.su.se> <4B7D84B8.3020605@t-online.de> Message-ID: <86FF9BCF-06AE-4AF2-B2CC-4C44DEE3515D@math.su.se> On 18 Feb 2010, at 19:19, Nick Rudnick wrote: > agreed, but, in my eyes, you directly point to the problem: > > * doesn't this just delegate the problem to the topic of limit > operations, i.e., in how far is the term ?closed? here more > perspicuous? > > * that's (for a very simple concept) the way that maths prescribes: > + historical background: ?I take "closed" as coming from being > closed under limit operations - the origin from analysis.? > + definition backtracking: ?A closure operation c is defined by the > property c(c(x)) = c(x). If one takes c(X) = the set of limit points > of X, then it is the smallest closed set under this operation. The > closed sets X are those that satisfy c(X) = X. Naming the > complements of the closed sets open might have been introduced as an > opposite of closed.? > > 418 bytes in my file system... how many in my brain...? Is it > efficient, inevitable? Yes, it is efficient conceptually. The idea of closed sets let to topology, and in combination with abstractions of differential geometry led to cohomology theory which needed category theory solving problems in number theory, used in a computer language called Haskell using a feature called Currying, named after a logician and mathematician, though only one person. Hans From ben.franksen at online.de Thu Feb 18 16:00:11 2010 From: ben.franksen at online.de (Ben Franksen) Date: Thu Feb 18 15:31:16 2010 Subject: [Haskell-cafe] Re: Re[2]: Threading and FFI References: <27611528.post@talk.nabble.com> <20100216172522.GC6832@kira.casa> <27612884.post@talk.nabble.com> <27613138.post@talk.nabble.com> <27621580.post@talk.nabble.com> <27631980.post@talk.nabble.com> <648858494.20100218094107@gmail.com> <27635260.post@talk.nabble.com> Message-ID: Yves Par?s wrote: > But there are two things that remain obscure: > First, there is my situation: int the main thread, I call to some C > functions binded through FFI. All of them are marked 'unsafe', except one, > which is internally supposed to make pauses with 'usleep'. > I then execute in another haskell thread (with forkIO) some pure haskell > actions. > I then compile with the threaded RTS, and let at run the default behaviour > which is to use one core. > > Question 1) What happens to the "unsafe" C functions? I that simply that > the threaded RTS is unable to prevent them from blocking haskell threads > (which in my case is a problem only for the function which pauses, since > other C calls are fast)? Yes. "unsafe" FFI calls are executed just as a Haskell function. Thta means the underlying OS thread that happens to run the Haskell thread which contains the unsafe FFI call will block and thus all other activity that is scheduled to be run by this OS thread. Note: With unbound threads (those created by forkIO) it might happen at any time that the RTS choses to reschedule your Haskell thread onto another OS thread. > Or they could provoke a hazardous issue, so I > have to mark all the C functions as "safe" (which will be much slower) > because ? You can leave them "unsafe" if you are sure that 1) they do not call (back) any function in your program 2) they do not block (or not long enough that it bothers you) Otherwise they are no less safe that the "safe" calls. If (1) is not fulfilled bad things might (that is, probably will) happen. Thus, if you are not sure, chose "safe". > Question 2) In the Control.Concurrent documentation, I understood that > forkIO creates unbound threads whereas forkOS creates bound threads, but > what is not very clear is: when does GHC threaded runtime launches as > bound instead of unbound if this one has been started with forkIO? Never. Bound thread are ONLY needed if you (that is, some foreign functions you use) rely on thread-local storage. > When it > detects the thread calls to a C function? When it detects it calls to a > "safe" C function (*)? When it detects another thread calls to a (safe) C > function (which is my case)? In no case will forkIO create a bounded thread. Period. Bound threads are created with forkOS. If runtime is threaded and FFI call is marked safe and Haskell thread is unbound, then calls to such a function will be executed from SOME extra OS thread that is managed completely behind the scenes. > (*) according to documentation it would be this case. However as I said my > C calls are done in the MAIN thread. This doesn't make a difference. Main thread in Haskell is treated as any other thread (except with regard to program termination; imagine it has an invisible exit() call at the end). > The other thread just executes casual > haskell operations, however it is not blocked, which makes me think that > even if I launch it with forkIO, it is launched as an bound thread. No. Bound thread means something different. It means that Haskell (green) thread is BOUND (fixed) to an OS thread. This is very bad for performance and only serves one purpose: to enable interoperation with broken C libraries (i.e. those which use thread local storage, a bad, bad, bad thing IMVHO). Cheers Ben From daniel.is.fischer at web.de Thu Feb 18 16:06:22 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Feb 18 15:39:02 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <201002182020.49657.daniel.is.fischer@web.de> Message-ID: <201002182206.23446.daniel.is.fischer@web.de> Am Donnerstag 18 Februar 2010 21:47:02 schrieb Hans Aberg: > On 18 Feb 2010, at 20:20, Daniel Fischer wrote: > >> + definition backtracking: ?A closure operation c is defined by the > >> property c(c(x)) = c(x). > > > > Actually, that's incomplete, ... > > That's right, it is just the idempotency relation. > > > ...missing are > > - c(x) contains x > > - c(x) is minimal among the sets containing x with y = c(y). > > It suffices*) with a lattice L with relation <= (inclusion in the case > of sets) satifying > i. x <= y implies c(x) <= c(y) > ii. x <= c(x) for all x in L. > iii. c(c(x)) = x. Typo, iii. c(c(x)) = c(x), of course. If we replace "set" by "lattice element" and "contains" by ">=", the definitions are equivalent. The one you quoted is better, though. > > Hans > > *) The definition in a book on lattice theory by Balbes & Dwinger. From v.dijk.bas at gmail.com Thu Feb 18 16:13:46 2010 From: v.dijk.bas at gmail.com (Bas van Dijk) Date: Thu Feb 18 15:44:50 2010 Subject: [Haskell-cafe] Pointfree composition for higher arity In-Reply-To: <3c6288ab1002171323x6cc1c0d7n8419aab00c5bc7a5@mail.gmail.com> References: <3c6288ab1002170731m1661c479r936f3e5b5ff8d89d@mail.gmail.com> <20100217154125.GA25561@home.embody.org> <5fdc56d71002170748x4288d907q92ec534694abfdf6@mail.gmail.com> <3c6288ab1002171323x6cc1c0d7n8419aab00c5bc7a5@mail.gmail.com> Message-ID: On Wed, Feb 17, 2010 at 10:23 PM, Sean Leather wrote: >> -- oo :: (c -> d) -> (a -> b -> c) -> a -> b -> d >> oo :: (Category cat) => cat c d -> (a -> cat b c) -> a -> cat b d >> oo = (.) . (.) I think at NL-FP day 2008 at Utrecht somebody called '(.) . (.)' the 'boob' operator... it was late and we had a few beers... oh wel, Bas From tux_rocker at reinier.de Thu Feb 18 16:14:07 2010 From: tux_rocker at reinier.de (Reinier Lamers) Date: Thu Feb 18 15:45:16 2010 Subject: [Haskell-cafe] darcs 2.4 release candidate 2 Message-ID: <201002182214.21113.tux_rocker@reinier.de> Hi all, The darcs team would like to announce the immediate availability of darcs 2.4 release candidate 2. darcs 2.4 will contain many improvements and bugfixes compared to darcs 2.3.1. Highlights are the faster operation of record, revert and related commands, and the experimental interactive hunk editing. This beta is your chance to test-drive these improvements and make darcs even better. Compared to darcs 2.4 beta 3, the performance of "darcs check" and "darcs repair" has been brought up to the level of darcs 2.3.1.` The easiest way to install darcs is using the Haskell Platform [1]. If you have installed the Haskell Platform or cabal-install, you can install this beta release by doing: $ cabal update $ cabal install --reinstall darcs-beta Alternatively, you can download the tarball from http://darcs.net/releases/darcs-beta-2.3.99.2.tar.gz , and build it by hand as explained in the README file. Interactive hunk editing ------------------------ To try out interactive hunk editing, press 'e' when you are prompted with a hunk patch by 'darcs record'. You will then be shown an editor screen in which you can edit the state you want to record between the last two ruler lines. You can find more information about the hunk editing feature on http://wiki.darcs.net/HunkEditor . Reporting bugs -------------- If you have an issue with darcs 2.4 release candidate 2, you can report it via the web on http://bugs.darcs.net/ . You can also report bugs by email to bugs@darcs.net. What's New ---------- A list of important changes since 2.3.1 is as follows (please let me know if there's something you miss!): * Use fast index-based diffing everywhere (Petr) * Interactive patch splitting (Ganesh) * An 'optimize --upgrade' option to convert to hashed format in-place (Eric) * Hunk matching (Kamil Dworakowski, tat.wright) * Progress reporting is no longer deceptive (Roman) * A 'remove --recursive' option to remove a directory tree from revision control (Roman) * 'show files' accepts arguments to show a subset of tracked files (Luca) * A '--remote-darcs' flag for pushing to a host where darcs isn't called darcs * Many miscellaneous Windows improvements (Salvatore, Petr and others) * 'darcs send' now mentions the repository name in the email body (Joachim) * Handle files with boring names in the repository correctly (Petr) * Fix parsing of .authorspellings file (Tom??) * Various sane new command-line option names (Florent) * Remove the '--checkpoint' option (Petr) * Use external libraries for all UTF-8 handling (Eric, Reinier) * Use the Haskell zlib package exclusively for compression (Petr) A list of issues resolved since 2.3.1: * 183: do not sort changes --summary output * 223: add --remote-darcs flag to specify name of remote darcs executable * 291: provide (basic) interactive patch splitting * 540: darcs remove --recursive * 835: 'show files' with arguments * 1122: get --complete should not offer to create a lazy repository * 1216: list Match section in ToC * 1224: refuse to convert a repo that's already in darcs-2 format * 1300: logfile deleted on unsucessful record * 1308: push should warn about unpulled patches before patch-selection * 1336: sane error message on --last "" (empty string to numbers parser) * 1362: mention repo name in mail send body * 1377: getProgname for local darcs instances * 1392: use parsec to parse .authorspelling * 1424: darcs get wrongly reports "using lazy repository" if you ctrl-c old-fashioned get * 1447: different online help for send/apply --cc * 1488: fix crash in whatsnew when invoked in non-tracked directory * 1548: show contents requires at least one argument * 1554: allow opt-out of -threaded (fix ARM builds) * 1563: official thank-you page * 1578: don't put newlines in the Haskeline prompts * 1583: on darcs get, suggest upgrading source repo to hashed * 1584: provide optimize --upgrade command * 1588: add --skip-conflicts option * 1594: define PREPROCHTML in makefile * 1620: make amend leave a log file when it should * 1636: hunk matching * 1643: optimize --upgrade should do optimize * 1652: suggest cabal update before cabal install * 1659: make restrictBoring take recorded state into account * 1677: create correct hashes for empty directories in index * 1681: preserve log on amend failure * 1709: fix short version of progress reporting * 1712: correctly report number of patches to pull * 1720: fix cabal haddock problem * 1731: fix performance regression in check and repair * 1741: fix --list-options when option has multiple names Kind Regards, the darcs release manager, Reinier Lamers [1]: You can download the Haskell platform from http://hackage.haskell.org/platform/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part. Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100218/58e97c90/attachment.bin From dev at mobileink.com Thu Feb 18 16:15:47 2010 From: dev at mobileink.com (Gregg Reynolds) Date: Thu Feb 18 15:46:30 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <201002182031.03105.daniel.is.fischer@web.de> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <75cc17ac1002180924r6d8eb5f4r3a7ddebd9825c69f@mail.gmail.com> <4B7D8D23.3020402@t-online.de> <201002182031.03105.daniel.is.fischer@web.de> Message-ID: <75cc17ac1002181315t57e0a0eua1878a19a2b176a7@mail.gmail.com> On Thu, Feb 18, 2010 at 1:31 PM, Daniel Fischer wrote: > Am Donnerstag 18 Februar 2010 19:55:31 schrieb Nick Rudnick: > > Gregg Reynolds wrote: > > > -- you agree with me it's far away from every day's common sense, even > > for a hobby coder?? I mean, this is not ?Head first categories?, is it? > > ;-)) With ?every day's common sense? I did not mean ?a mathematician's > > every day's common sense?, but that of, e.g., a housewife or a child... > > Doesn't work. You need a lot of training in abstraction to learn very > abstract concepts. Joe Sixpack's common sense isn't prepared for that. > > True enough, but I also tend to think that with a little imagination even many of the most abstract concepts can be illustrated with intuitive, concrete examples, and it's a fun (to me) challenge to try come up with them. For example, associativity can be nicely illustrated in terms of donning socks and shoes - it's not hard to imagine putting socks into shoes before putting feet into socks. A little weird, but easily understandable. My guess is that with a little effort one could find good concrete examples of at least category, functor, and natural transformation. Hmm, how is a cake-mixer like a cement-mixer? They're structurally and functionally isomorphic. Objects in the category Mixer? > > > Both have a border, just in different places. > > > > Which elements form the border of an open set?? > > The boundary of an open set is the boundary of its complement. > The boundary may be empty (happens if and only if the set is simultaneously > open and closed, "clopen", as some say). > > Right, that was what I meant; the point being that "boundary" (or border, or periphery or whatever) is not sufficient to capture the idea of closed v. open. -g -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100218/b162d86e/attachment.html From msmatsko at comcast.net Thu Feb 18 16:16:49 2010 From: msmatsko at comcast.net (Michael Matsko) Date: Thu Feb 18 15:47:31 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <4B7D9FF5.2030408@t-online.de> Message-ID: <813798396.4030621266527809066.JavaMail.root@sz0009a.westchester.pa.mail.comcast.net> Nick, ???That is correct.? An open set contains no point on its boundary.? ???A closed set?contains its boundary, i.e. for a closed set c, Closure(c) = c.? ???Note that for a general set, which is neither closed or open (say the half closed interval (0,1]), may contain points on its boundary.? Every set contains its interior, which is the part of the set without its boundary and is contained in its closure - for a given set x, Interior(x) is a subset of x is a subset of Closure(x).? Mike ? ----- Original Message ----- From: "Nick Rudnick" To: "Michael Matsko" Cc: haskell-cafe@haskell.org Sent: Thursday, February 18, 2010 3:15:49 PM GMT -05:00 US/Canada Eastern Subject: Re: Fwd: [Haskell-cafe] Category Theory woes Hi Mike, so an open set does not contain elements constituting a border/boundary of it, does it? But a closed set does, doesn't it? Cheers, ??? Nick Michael Matsko wrote: ----- Forwarded Message ----- From: "Michael Matsko" To: "Nick Rudnick" Sent: Thursday, February 18, 2010 2:16:18 PM GMT -05:00 US/Canada Eastern Subject: Re: [Haskell-cafe] Category Theory woes Gregg, ?? Topologically speaking, the border of an open set is called the boundary of the set.??The boundary is defined as the closure of the set?minus the set itself.? As an example consider the open interval (0,1) on the real line.? The closure of the set is [0,1], the closed interval on 0, 1.? The boundary would be the points 0 and 1. Mike Matsko ----- Original Message ----- From: "Nick Rudnick" To: "Gregg Reynolds" Cc: "Haskell Caf? List" Sent: Thursday, February 18, 2010 1:55:31 PM GMT -05:00 US/Canada Eastern Subject: Re: [Haskell-cafe] Category Theory woes Gregg Reynolds wrote: On Thu, Feb 18, 2010 at 7:48 AM, Nick Rudnick < joerg.rudnick@t-online.de > wrote: IM(H??)O, a really introductive book on category theory still is to be written -- if category theory is really that fundamental (what I believe, due to its lifting of restrictions usually implicit at 'orthodox maths'), than it should find a reflection in our every day's common sense, shouldn't it? Goldblatt works for me. Accidentially, I have Goldblatt here, although I didn't read it before -- you agree with me it's far away from every day's common sense, even for a hobby coder?? I mean, this is not ?Head first categories?, is it? ;-)) With ?every day's common sense? I did not mean ?a mathematician's every day's common sense?, but that of, e.g., a housewife or a child... But I have became curious now for Goldblatt... * the definition of open/closed sets in topology with the boundary elements of a closed set to considerable extent regardable as facing to an ?outside? (so that reversing these terms could even appear more intuitive, or ?bordered? instead of closed and ?unbordered? instead of open), Both have a border, just in different places. Which elements form the border of an open set?? As an example, let's play a little: Arrows: Arrows are more fundamental than objects, in fact, categories may be defined with arrows only. Although I like the term arrow (more than 'morphism'), I intuitively would find the term ?reference? less contradictive with the actual intention, as this term Arrows don't refer.? A *referrer* (object) refers to a *referee* (object) by a *reference* (arrow). Categories: In every day's language, a category is a completely different thing, without the least Not necesssarily (for Kantians, Aristoteleans?) Are you sure...?? See http://en.wikipedia.org/wiki/Categories_(Aristotle) ... ? If memory serves, MacLane says somewhere that he and Eilenberg picked the term "category" as an explicit play on the same term in philosophy. In general I find mathematical terminology well-chosen and revealing, if one takes the trouble to do a little digging.? If you want to know what terminological chaos really looks like try linguistics. ;-) For linguistics, granted... In regard of ?a little digging?, don't you think terminology work takes a great share, especially at interdisciplinary efforts? Wouldn't it be great to be able to drop, say 20% or even more, of such efforts and be able to progress more fluidly ? -g _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100218/53bb6d90/attachment-0001.html From haberg at math.su.se Thu Feb 18 16:28:44 2010 From: haberg at math.su.se (Hans Aberg) Date: Thu Feb 18 15:59:30 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <201002182206.23446.daniel.is.fischer@web.de> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <201002182020.49657.daniel.is.fischer@web.de> <201002182206.23446.daniel.is.fischer@web.de> Message-ID: <5CA0F323-51C9-4DE5-B36D-E9CCD5BBF018@math.su.se> On 18 Feb 2010, at 22:06, Daniel Fischer wrote: >>> ...missing are >>> - c(x) contains x >>> - c(x) is minimal among the sets containing x with y = c(y). >> >> It suffices*) with a lattice L with relation <= (inclusion in the >> case >> of sets) satifying >> i. x <= y implies c(x) <= c(y) >> ii. x <= c(x) for all x in L. >> iii. c(c(x)) = x. > > Typo, iii. c(c(x)) = c(x), of course. Sure. > If we replace "set" by "lattice element" and "contains" by ">=", the > definitions are equivalent. Right. > The one you quoted is better, though. It is a powerful concept. I think of a function closure as what one gets when adding all an expression binds to, though I'm not sure that is why it is called a closure. Hans From joerg.rudnick at t-online.de Thu Feb 18 16:54:03 2010 From: joerg.rudnick at t-online.de (Nick Rudnick) Date: Thu Feb 18 16:25:04 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <813798396.4030621266527809066.JavaMail.root@sz0009a.westchester.pa.mail.comcast.net> References: <813798396.4030621266527809066.JavaMail.root@sz0009a.westchester.pa.mail.comcast.net> Message-ID: <4B7DB6FB.8050005@t-online.de> Hi Mike, of course... But in the same spirit, one could introduce a straightforward extension, ?partially bordered?, which would be as least as good as ?clopen?... ;-) I must admit we've come a little off the topic -- how to introduce to category theory. The intent was to present some examples that mathematical terminology culture is not that exemplary as one should expect, but to motivate an open discussion about how one might ?rename refactor? category theory (of 2:48 PM). I would be very interested in other people's proposals... :-) Michael Matsko wrote: > > Nick, > > > > That is correct. An open set contains no point on its boundary. > > > > A closed set contains its boundary, i.e. for a closed set c, > Closure(c) = c. > > > > Note that for a general set, which is neither closed or open (say > the half closed interval (0,1]), may contain points on its boundary. > Every set contains its interior, which is the part of the set without > its boundary and is contained in its closure - for a given set x, > Interior(x) is a subset of x is a subset of Closure(x). > > > > Mike > > > ----- Original Message ----- > From: "Nick Rudnick" > To: "Michael Matsko" > Cc: haskell-cafe@haskell.org > Sent: Thursday, February 18, 2010 3:15:49 PM GMT -05:00 US/Canada Eastern > Subject: Re: Fwd: [Haskell-cafe] Category Theory woes > > Hi Mike, > > so an open set does not contain elements constituting a > border/boundary of it, does it? > > But a closed set does, doesn't it? > > Cheers, > > Nick > > Michael Matsko wrote: > > > ----- Forwarded Message ----- > From: "Michael Matsko" > To: "Nick Rudnick" > Sent: Thursday, February 18, 2010 2:16:18 PM GMT -05:00 US/Canada > Eastern > Subject: Re: [Haskell-cafe] Category Theory woes > > Gregg, > > > > Topologically speaking, the border of an open set is called the > boundary of the set. The boundary is defined as the closure of > the set minus the set itself. As an example consider the open > interval (0,1) on the real line. The closure of the set is [0,1], > the closed interval on 0, 1. The boundary would be the points 0 > and 1. > > > > Mike Matsko > > > ----- Original Message ----- > From: "Nick Rudnick" > To: "Gregg Reynolds" > Cc: "Haskell Caf? List" > Sent: Thursday, February 18, 2010 1:55:31 PM GMT -05:00 US/Canada > Eastern > Subject: Re: [Haskell-cafe] Category Theory woes > > Gregg Reynolds wrote: > > On Thu, Feb 18, 2010 at 7:48 AM, Nick Rudnick > > > wrote: > > IM(H??)O, a really introductive book on category theory > still is to be written -- if category theory is really > that fundamental (what I believe, due to its lifting of > restrictions usually implicit at 'orthodox maths'), than > it should find a reflection in our every day's common > sense, shouldn't it? > > > Goldblatt works for me. > > Accidentially, I have Goldblatt here, although I didn't read it > before -- you agree with me it's far away from every day's common > sense, even for a hobby coder?? I mean, this is not ?Head first > categories?, is it? ;-)) With ?every day's common sense? I did not > mean ?a mathematician's every day's common sense?, but that of, > e.g., a housewife or a child... > > But I have became curious now for Goldblatt... > > > > > * the definition of open/closed sets in topology with the > boundary elements of a closed set to considerable extent > regardable as facing to an ?outside? (so that reversing > these terms could even appear more intuitive, or > ?bordered? instead of closed and ?unbordered? instead of > open), > > > Both have a border, just in different places. > > Which elements form the border of an open set?? > > > > As an example, let's play a little: > > Arrows: Arrows are more fundamental than objects, in fact, > categories may be defined with arrows only. Although I > like the term arrow (more than 'morphism'), I intuitively > would find the term ?reference? less contradictive with > the actual intention, as this term > > Arrows don't refer. > > A *referrer* (object) refers to a *referee* (object) by a > *reference* (arrow). > > > > Categories: In every day's language, a category is a > completely different thing, without the least > > > Not necesssarily (for Kantians, Aristoteleans?) > > Are you sure...?? See > http://en.wikipedia.org/wiki/Categories_(Aristotle) ... > > If memory serves, MacLane says somewhere that he and > Eilenberg picked the term "category" as an explicit play on > the same term in philosophy. > > In general I find mathematical terminology well-chosen and > revealing, if one takes the trouble to do a little digging. > If you want to know what terminological chaos really looks > like try linguistics. > > ;-) For linguistics, granted... In regard of ?a little digging?, > don't you think terminology work takes a great share, especially > at interdisciplinary efforts? Wouldn't it be great to be able to > drop, say 20% or even more, of such efforts and be able to > progress more fluidly ? > > > -g > > > > _______________________________________________ Haskell-Cafe > mailing list Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100218/6f7208f8/attachment.html From ajs at 2piix.com Thu Feb 18 16:59:31 2010 From: ajs at 2piix.com (Alexander Solla) Date: Thu Feb 18 16:30:16 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <5CA0F323-51C9-4DE5-B36D-E9CCD5BBF018@math.su.se> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <201002182020.49657.daniel.is.fischer@web.de> <201002182206.23446.daniel.is.fischer@web.de> <5CA0F323-51C9-4DE5-B36D-E9CCD5BBF018@math.su.se> Message-ID: <35C5F45B-547B-4F98-97B9-527DA8402C6D@2piix.com> On Feb 18, 2010, at 1:28 PM, Hans Aberg wrote: > It is a powerful concept. I think of a function closure as what one > gets when adding all an expression binds to, though I'm not sure > that is why it is called a closure. Its because a monadic morphism into the same type carrying around data is a closure operator on the type. It's basically a direct sum of the "inner" type, and the "data" type. From joerg.rudnick at t-online.de Thu Feb 18 17:02:48 2010 From: joerg.rudnick at t-online.de (Nick Rudnick) Date: Thu Feb 18 16:33:35 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <86FF9BCF-06AE-4AF2-B2CC-4C44DEE3515D@math.su.se> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <4B7CB3A3.3020505@t-online.de> <3c6288ab1002180204q74df576fw761f408b1f839c54@mail.gmail.com> <4B7D4518.3030003@t-online.de> <2F93D0A8-E4D0-4AC0-82A3-599E036F1095@math.su.se> <4B7D84B8.3020605@t-online.de> <86FF9BCF-06AE-4AF2-B2CC-4C44DEE3515D@math.su.se> Message-ID: <4B7DB908.90400@t-online.de> Hans Aberg wrote: > On 18 Feb 2010, at 19:19, Nick Rudnick wrote: > >> agreed, but, in my eyes, you directly point to the problem: >> >> * doesn't this just delegate the problem to the topic of limit >> operations, i.e., in how far is the term ?closed? here more perspicuous? >> >> * that's (for a very simple concept) the way that maths prescribes: >> + historical background: ?I take "closed" as coming from being closed >> under limit operations - the origin from analysis.? >> + definition backtracking: ?A closure operation c is defined by the >> property c(c(x)) = c(x). If one takes c(X) = the set of limit points >> of X, then it is the smallest closed set under this operation. The >> closed sets X are those that satisfy c(X) = X. Naming the complements >> of the closed sets open might have been introduced as an opposite of >> closed.? >> >> 418 bytes in my file system... how many in my brain...? Is it >> efficient, inevitable? > > Yes, it is efficient conceptually. The idea of closed sets let to > topology, and in combination with abstractions of differential > geometry led to cohomology theory which needed category theory solving > problems in number theory, used in a computer language called Haskell > using a feature called Currying, named after a logician and > mathematician, though only one person. It is SUCCESSFUL, NO MATTER... :-) But I spoke about efficiency, in the Pareto sense (http://en.wikipedia.org/wiki/Pareto_efficiency)... Can we say that the way in which things are done now cannot be improved?? Hans, you were the most specific response to my actual intention -- could I clear up the reference thing for you? All the best, Nick > > Hans > > > From joerg.rudnick at t-online.de Thu Feb 18 17:08:16 2010 From: joerg.rudnick at t-online.de (Nick Rudnick) Date: Thu Feb 18 16:39:04 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <4B7CB3A3.3020505@t-online.de> <3c6288ab1002180204q74df576fw761f408b1f839c54@mail.gmail.com> <4B7D4518.3030003@t-online.de> <2F93D0A8-E4D0-4AC0-82A3-599E036F1095@math.su.se> <4B7D84B8.3020605@t-online.de> Message-ID: <4B7DBA50.1060804@t-online.de> Hi Alexander, my actual posting was about rename refactoring category theory; closed/open was just presented as an example for suboptimal terminology in maths. But of course, bordered/unbordered would be extended by e.g. ?partially bordered? and the same holds. Cheers, Nick Alexander Solla wrote: > > On Feb 18, 2010, at 10:19 AM, Nick Rudnick wrote: > >> Back to the case of open/closed, given we have an idea about sets -- >> we in most cases are able to derive the concept of two disjunct sets >> facing each other ourselves, don't we? The only lore missing is just >> a Bool: Which term fits which idea? With a reliable terminology using >> ?bordered/unbordered?, there is no ambiguity, and we can pass on >> reading, without any additional effort. > > > There are sets that only partially contain their boundary. They are > neither open nor closed, in the usual topology. Consider (0,1] in the > Real number line. It contains 1, a boundary point. It does not > contain 0. It is not an open set OR a closed set in the usual > topology for R. From haberg at math.su.se Thu Feb 18 17:22:08 2010 From: haberg at math.su.se (Hans Aberg) Date: Thu Feb 18 16:52:52 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <4B7DB908.90400@t-online.de> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <4B7CB3A3.3020505@t-online.de> <3c6288ab1002180204q74df576fw761f408b1f839c54@mail.gmail.com> <4B7D4518.3030003@t-online.de> <2F93D0A8-E4D0-4AC0-82A3-599E036F1095@math.su.se> <4B7D84B8.3020605@t-online.de> <86FF9BCF-06AE-4AF2-B2CC-4C44DEE3515D@math.su.se> <4B7DB908.90400@t-online.de> Message-ID: On 18 Feb 2010, at 23:02, Nick Rudnick wrote: >>> 418 bytes in my file system... how many in my brain...? Is it >>> efficient, inevitable? >> >> Yes, it is efficient conceptually. The idea of closed sets let to >> topology, and in combination with abstractions of differential >> geometry led to cohomology theory which needed category theory >> solving problems in number theory, used in a computer language >> called Haskell using a feature called Currying, named after a >> logician and mathematician, though only one person. > It is SUCCESSFUL, NO MATTER... :-) > > But I spoke about efficiency, in the Pareto sense (http://en.wikipedia.org/wiki/Pareto_efficiency > )... Can we say that the way in which things are done now cannot be > improved?? > > Hans, you were the most specific response to my actual intention -- > could I clear up the reference thing for you? That seems to be an economic theory version of utilitarianism - the problem is that when dealing with concepts there may be no optimizing function to agree upon. There is an Occam's razor one may try to apply in the case of axiomatic systems, but one then finds it may be more practical with one that is not minimal. As for the naming problem, it is more of a linguistic problem: the names were somehow handed by tradition, and it may be difficult to change them. For example, there is a rumor that "kangaroo" means "I do not understand" in a native language; assuming this to be true, it might be difficult to change it. Mathematicians though stick to their own concepts and definitions individually. For example, I had conversations with one who calls monads "triads", and then one has to cope with that. Hans From joerg.rudnick at t-online.de Thu Feb 18 17:43:11 2010 From: joerg.rudnick at t-online.de (Nick Rudnick) Date: Thu Feb 18 17:14:04 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <75cc17ac1002181315t57e0a0eua1878a19a2b176a7@mail.gmail.com> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <75cc17ac1002180924r6d8eb5f4r3a7ddebd9825c69f@mail.gmail.com> <4B7D8D23.3020402@t-online.de> <201002182031.03105.daniel.is.fischer@web.de> <75cc17ac1002181315t57e0a0eua1878a19a2b176a7@mail.gmail.com> Message-ID: <4B7DC27F.10100@t-online.de> Gregg Reynolds wrote: > On Thu, Feb 18, 2010 at 1:31 PM, Daniel Fischer > > wrote: > > Am Donnerstag 18 Februar 2010 19:55:31 schrieb Nick Rudnick: > > Gregg Reynolds wrote: > > > > > -- you agree with me it's far away from every day's common > sense, even > > for a hobby coder?? I mean, this is not ?Head first categories?, > is it? > > ;-)) With ?every day's common sense? I did not mean ?a > mathematician's > > every day's common sense?, but that of, e.g., a housewife or a > child... > > Doesn't work. You need a lot of training in abstraction to learn very > abstract concepts. Joe Sixpack's common sense isn't prepared for that. > > > True enough, but I also tend to think that with a little imagination > even many of the most abstract concepts can be illustrated with > intuitive, concrete examples, and it's a fun (to me) challenge to try > come up with them. For example, associativity can be nicely > illustrated in terms of donning socks and shoes - it's not hard to > imagine putting socks into shoes before putting feet into socks. A > little weird, but easily understandable. My guess is that with a > little effort one could find good concrete examples of at least > category, functor, and natural transformation. Hmm, how is a > cake-mixer like a cement-mixer? They're structurally and functionally > isomorphic. Objects in the category Mixer? :-) This comes close to what I mean -- the beauty of category theory does not end at the borders of mathematical subjects... IMHO we are just beginning to discovery of the categorical world beyond mathematics, and I think many findings original to computer science, but less to maths may be of value then. And I am definitely more optimistic on ?Joe Sixpack's common sense?, which still surpasses a good lot of things possible with AI -- no categories at all there?? I can't believe... > > > > > Both have a border, just in different places. > > > > Which elements form the border of an open set?? > > The boundary of an open set is the boundary of its complement. > The boundary may be empty (happens if and only if the set is > simultaneously > open and closed, "clopen", as some say). > > Right, that was what I meant; the point being that "boundary" (or > border, or periphery or whatever) is not sufficient to capture the > idea of closed v. open. ;-)) I did not claim ?bordered? is the best choice, I just said closed/open is NOT... IMHO this also does not affect what I understand as a refactoring -- just imagine Coq had a refactoring browser; all combinations of terms are possible as before, aren't they? But it was not my aim to begin enumerating all variations of ?bordered?, ?unbordered?, ?partially ordered? and STOP... Should I come QUICKLY with a pendant to ?clopen? now? This would be ?MATHS STYLE?...! I neither say finding an appropriate word here is a quickshot, nor I claim trying so is ridiculous, as it is impossible. I think it is WORK, which is to be done in OPEN DISCUSSION -- and that, at the long end, the result might be rewarding, similar as the effort put into a rename refactoring will reveal rewarding. ;-)) Trying a refactored category theory (with a dictionary in the appendix...) might open access to many interesting people and subjects otherwise out of reach. And deeply contemplating terminology cannot hurt, at the least... All the best, Nick -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100218/e7266ef7/attachment.html From ajs at 2piix.com Thu Feb 18 17:47:39 2010 From: ajs at 2piix.com (Alexander Solla) Date: Thu Feb 18 17:18:23 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <4B7DBA50.1060804@t-online.de> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <4B7CB3A3.3020505@t-online.de> <3c6288ab1002180204q74df576fw761f408b1f839c54@mail.gmail.com> <4B7D4518.3030003@t-online.de> <2F93D0A8-E4D0-4AC0-82A3-599E036F1095@math.su.se> <4B7D84B8.3020605@t-online.de> <4B7DBA50.1060804@t-online.de> Message-ID: On Feb 18, 2010, at 2:08 PM, Nick Rudnick wrote: > my actual posting was about rename refactoring category theory; > closed/open was just presented as an example for suboptimal > terminology in maths. But of course, bordered/unbordered would be > extended by e.g. ?partially bordered? and the same holds. And my point was that your terminology was suboptimal for just the same reasons. The difficulty of mathematics is hardly the funny names. Perhaps you're not familiar with the development of Category theory. Hans Aberg gave a brief development. Basically, Category theory is the RESULT of the refactoring you're asking about. Category theory's beginnings are found in work on differential topology (where functors and higher order constructs took on a life of their own), and the unification of topology, lattice theory, and universal algebra (in order to ground that higher order stuff). Distinct models and notions of computation were unified, using arrows and objects. Now, you could have a legitimate gripe about current category theory terminology. But I am not so sure. We can "simplify" lots of things. Morphisms can become arrows or functions. Auto- can become "self-". "Homo-" can become "same-". Functors can become "Category arrows". Does it help? You tell me. But if we're ever going to do anything interesting with Category theory, we're going to have to go into the realm of dealing with SOME kind of algebra. We need examples, and the mathematically tractable ones have names like "group", "monoid", "ring", "field", "sigma- algebras", "lattices", "logics", "topologies", "geometries". They are arbitrary names, grounded in history. Any other choice is just as arbitrary, if not more so. The closest thing algebras have to a unique name is their signature -- basically their axiomatization -- or a long descriptive name in terms of arbitrary names and adjectives ("the Cartesian product of a Cartesian closed category and a groupoid with groupoid addition induced by...."). The case for Pareto efficiency is here: is changing the name of these kinds of structures wholesale a win for efficiency? The answer is "no". Everybody would have to learn the new, arbitrary names, instead of just some people having to learn the old arbitrary names. Let's compare this to the "monad fallacy". It is said every beginner Haskell programmer write a monad tutorial, and often falls into the "monad fallacy" of thinking that there is only one interpretation for monadism. Monads are relatively straightforward. Their power comes from the fact that many different kinds of things are "monadic" -- sequencing, state, function application. What name should we use for monads instead? Which interpretation must we favor, despite the fact that others will find it counter-intuitive? Or should we choose to not favor one, and just pick a new arbitrary name? From limestrael at gmail.com Thu Feb 18 17:53:23 2010 From: limestrael at gmail.com (=?UTF-8?Q?Yves_Par=C3=A8s?=) Date: Thu Feb 18 17:24:06 2010 Subject: Re[Haskell-cafe] [2]: Threading and FFI In-Reply-To: References: <27611528.post@talk.nabble.com> <20100216172522.GC6832@kira.casa> <27612884.post@talk.nabble.com> <27613138.post@talk.nabble.com> <27621580.post@talk.nabble.com> <27631980.post@talk.nabble.com> <648858494.20100218094107@gmail.com> <27635260.post@talk.nabble.com> Message-ID: <27647126.post@talk.nabble.com> Ben Franksen wrote: >You can leave them "unsafe" if you are sure that > >1) they do not call (back) any function in your program >2) they do not block (or not long enough that it bothers you) > >Otherwise they are no less safe that the "safe" calls. If (1) is not >fulfilled bad things might (that is, probably will) happen. Thus, if you >are not sure, chose "safe". Okay. Since I know which functions call back to haskell code and which make pauses, I know what need to be safe and what can be let safely unsafe (^^). > Bound thread are ONLY needed if you (that is, some foreign functions > you use) rely on thread-local storage. Yes, but since the main thread (if I understood well) is bound, if I call to C functions which rely on thread-local storage (like OpenGL functions, according to GHC Control.Concurrent doc) in this thread I should have no problem, shouldn't I? And if I choose to call these functions from outside the main thread it'll have to be from a thread launched with forkOS? (The C functions I call in my real code actually use OpenGL internally) > If runtime is threaded and FFI call is marked safe and Haskell thread is > unbound, then calls to such a function will be executed from SOME extra OS > thread that is managed completely behind the scenes. Okay, that's what I didn't understand! Only the call to my safe function will be done in an external bound thread, not the whole thread in which the call is done. So, to sum up, my program will run this way (not necessarily in this order): My main is launched in a bound thread. My casual haskell I/O operations (read and print from and to the terminal) are launched in an unbound thread. Whenever my main thread reaches the call to my safe C function which 'sleeps', it launches it in another bound thread. Am I right or is it no that easy to foresee the behaviour of my program? ----- Yves Par?s Live long and prosper -- View this message in context: http://old.nabble.com/Threading-and-FFI-tp27611528p27647126.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From msmatsko at comcast.net Thu Feb 18 17:55:07 2010 From: msmatsko at comcast.net (Michael Matsko) Date: Thu Feb 18 17:25:49 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <1007694281.4062411266533457650.JavaMail.root@sz0009a.westchester.pa.mail.comcast.net> Message-ID: <599576217.4064141266533707972.JavaMail.root@sz0009a.westchester.pa.mail.comcast.net> Nick, Actually, clopen is a set that is both closed and open. Not one that is neither. Except in the case of half-open intervals, I can't remember talking much in topology about sets with a partial boundary. Category theory-wise. No one seems to have mentioned MacLane's "Categories for the Working Mathematician." Although, I don't seem to recall instant enlightenment when I picked it up. Mike ----- Original Message ----- From: "Nick Rudnick" To: "Michael Matsko" Cc: haskell-cafe@haskell.org Sent: Thursday, February 18, 2010 4:54:03 PM GMT -05:00 US/Canada Eastern Subject: Re: [Haskell-cafe] Category Theory woes Hi Mike, of course... But in the same spirit, one could introduce a straightforward extension, ?partially bordered?, which would be as least as good as ?clopen?... ;-) I must admit we've come a little off the topic -- how to introduce to category theory. The intent was to present some examples that mathematical terminology culture is not that exemplary as one should expect, but to motivate an open discussion about how one might ?rename refactor? category theory (of 2:48 PM). I would be very interested in other people's proposals... :-) Michael Matsko wrote: Nick, That is correct. An open set contains no point on its boundary. A closed set contains its boundary, i.e. for a closed set c, Closure(c) = c. Note that for a general set, which is neither closed or open (say the half closed interval (0,1]), may contain points on its boundary. Every set contains its interior, which is the part of the set without its boundary and is contained in its closure - for a given set x, Interior(x) is a subset of x is a subset of Closure(x). Mike ----- Original Message ----- From: "Nick Rudnick" To: "Michael Matsko" Cc: haskell-cafe@haskell.org Sent: Thursday, February 18, 2010 3:15:49 PM GMT -05:00 US/Canada Eastern Subject: Re: Fwd: [Haskell-cafe] Category Theory woes Hi Mike, so an open set does not contain elements constituting a border/boundary of it, does it? But a closed set does, doesn't it? Cheers, Nick Michael Matsko wrote: ----- Forwarded Message ----- From: "Michael Matsko" To: "Nick Rudnick" Sent: Thursday, February 18, 2010 2:16:18 PM GMT -05:00 US/Canada Eastern Subject: Re: [Haskell-cafe] Category Theory woes Gregg, Topologically speaking, the border of an open set is called the boundary of the set. The boundary is defined as the closure of the set minus the set itself. As an example consider the open interval (0,1) on the real line. The closure of the set is [0,1], the closed interval on 0, 1. The boundary would be the points 0 and 1. Mike Matsko ----- Original Message ----- From: "Nick Rudnick" To: "Gregg Reynolds" Cc: "Haskell Caf? List" Sent: Thursday, February 18, 2010 1:55:31 PM GMT -05:00 US/Canada Eastern Subject: Re: [Haskell-cafe] Category Theory woes Gregg Reynolds wrote: On Thu, Feb 18, 2010 at 7:48 AM, Nick Rudnick < joerg.rudnick@t-online.de > wrote: IM(H??)O, a really introductive book on category theory still is to be written -- if category theory is really that fundamental (what I believe, due to its lifting of restrictions usually implicit at 'orthodox maths'), than it should find a reflection in our every day's common sense, shouldn't it? Goldblatt works for me. Accidentially, I have Goldblatt here, although I didn't read it before -- you agree with me it's far away from every day's common sense, even for a hobby coder?? I mean, this is not ?Head first categories?, is it? ;-)) With ?every day's common sense? I did not mean ?a mathematician's every day's common sense?, but that of, e.g., a housewife or a child... But I have became curious now for Goldblatt... * the definition of open/closed sets in topology with the boundary elements of a closed set to considerable extent regardable as facing to an ?outside? (so that reversing these terms could even appear more intuitive, or ?bordered? instead of closed and ?unbordered? instead of open), Both have a border, just in different places. Which elements form the border of an open set?? As an example, let's play a little: Arrows: Arrows are more fundamental than objects, in fact, categories may be defined with arrows only. Although I like the term arrow (more than 'morphism'), I intuitively would find the term ?reference? less contradictive with the actual intention, as this term Arrows don't refer. A *referrer* (object) refers to a *referee* (object) by a *reference* (arrow). Categories: In every day's language, a category is a completely different thing, without the least Not necesssarily (for Kantians, Aristoteleans?) Are you sure...?? See http://en.wikipedia.org/wiki/Categories_(Aristotle) ... If memory serves, MacLane says somewhere that he and Eilenberg picked the term "category" as an explicit play on the same term in philosophy. In general I find mathematical terminology well-chosen and revealing, if one takes the trouble to do a little digging. If you want to know what terminological chaos really looks like try linguistics. ;-) For linguistics, granted... In regard of ?a little digging?, don't you think terminology work takes a great share, especially at interdisciplinary efforts? Wouldn't it be great to be able to drop, say 20% or even more, of such efforts and be able to progress more fluidly ? -g _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100218/d5357650/attachment.html From joerg.rudnick at t-online.de Thu Feb 18 18:05:18 2010 From: joerg.rudnick at t-online.de (Nick Rudnick) Date: Thu Feb 18 17:36:15 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <4B7CB3A3.3020505@t-online.de> <3c6288ab1002180204q74df576fw761f408b1f839c54@mail.gmail.com> <4B7D4518.3030003@t-online.de> <2F93D0A8-E4D0-4AC0-82A3-599E036F1095@math.su.se> <4B7D84B8.3020605@t-online.de> <86FF9BCF-06AE-4AF2-B2CC-4C44DEE3515D@math.su.se> <4B7DB908.90400@t-online.de> Message-ID: <4B7DC7AE.9000004@t-online.de> Hans Aberg wrote: > On 18 Feb 2010, at 23:02, Nick Rudnick wrote: > >>>> 418 bytes in my file system... how many in my brain...? Is it >>>> efficient, inevitable? >>> >>> Yes, it is efficient conceptually. The idea of closed sets let to >>> topology, and in combination with abstractions of differential >>> geometry led to cohomology theory which needed category theory >>> solving problems in number theory, used in a computer language >>> called Haskell using a feature called Currying, named after a >>> logician and mathematician, though only one person. >> It is SUCCESSFUL, NO MATTER... :-) >> >> But I spoke about efficiency, in the Pareto sense >> (http://en.wikipedia.org/wiki/Pareto_efficiency)... Can we say that >> the way in which things are done now cannot be improved?? >> >> Hans, you were the most specific response to my actual intention -- >> could I clear up the reference thing for you? > > That seems to be an economic theory version of utilitarianism - the > problem is that when dealing with concepts there may be no optimizing > function to agree upon. There is an Occam's razor one may try to apply > in the case of axiomatic systems, but one then finds it may be more > practical with one that is not minimal. Exactly. By this I justify my questioning of inviolability of the state of art of maths terminology -- an open discussion should be allowed at any time... > > As for the naming problem, it is more of a linguistic problem: the > names were somehow handed by tradition, and it may be difficult to > change them. For example, there is a rumor that "kangaroo" means "I do > not understand" in a native language; assuming this to be true, it > might be difficult to change it. Completely d'accord. This is indeed a strong problem, and I fully agree if you say that, for maths, trying this is for people with fondness for speaker's corner... :-)) But for category theory, a subject (too!) many people are complaining about, blind for its beauty, a such book -- ideally in children's language and illustrations, of course with a dictionary to original terminology in the appendix! -- could be of great positive influence on category theory itself. And the deep contemplation encompassing the *collective* creation should be most rewarding in itself -- a journey without haste into the depths of the subject. > > Mathematicians though stick to their own concepts and definitions > individually. For example, I had conversations with one who calls > monads "triads", and then one has to cope with that. Yes. But isn't it also an enrichment by some way? All the best, Nick From ok at cs.otago.ac.nz Thu Feb 18 18:24:23 2010 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Thu Feb 18 17:55:09 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <201002181555.37468.daniel.is.fischer@web.de> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <3c6288ab1002180204q74df576fw761f408b1f839c54@mail.gmail.com> <4B7D4518.3030003@t-online.de> <201002181555.37468.daniel.is.fischer@web.de> Message-ID: <2E4494E6-120F-4975-8DB2-0FBA55FB3432@cs.otago.ac.nz> On Feb 19, 2010, at 3:55 AM, Daniel Fischer wrote: > Am Donnerstag 18 Februar 2010 14:48:08 schrieb Nick Rudnick: >> even in Germany, where the >> term ?ring? seems to originate from, since at least a century nowbody >> has the least idea it once had an alternative meaning >> ?gang,band,group?, > > Wrong. The term "Ring" is still in use with that meaning in > composites like > Schmugglerring, Autoschieberring, ... The mathematical ring is OED ring n1 sense 12. The group of people sense is sense 11, immediately above it. "Drug ring" is still in use. I'd always assumed "ring" was generalised from Z[n]. From joerg.rudnick at t-online.de Thu Feb 18 18:39:34 2010 From: joerg.rudnick at t-online.de (Nick Rudnick) Date: Thu Feb 18 18:17:34 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <4B7CB3A3.3020505@t-online.de> <3c6288ab1002180204q74df576fw761f408b1f839c54@mail.gmail.com> <4B7D4518.3030003@t-online.de> <2F93D0A8-E4D0-4AC0-82A3-599E036F1095@math.su.se> <4B7D84B8.3020605@t-online.de> <4B7DBA50.1060804@t-online.de> Message-ID: <4B7DCFB6.9010702@t-online.de> Alexander Solla wrote: > > On Feb 18, 2010, at 2:08 PM, Nick Rudnick wrote: > >> my actual posting was about rename refactoring category theory; >> closed/open was just presented as an example for suboptimal >> terminology in maths. But of course, bordered/unbordered would be >> extended by e.g. ?partially bordered? and the same holds. > > And my point was that your terminology was suboptimal for just the > same reasons. The difficulty of mathematics is hardly the funny names. :-) Criticism... Criticism is good at this place... Opens up things... > > Perhaps you're not familiar with the development of Category theory. > Hans Aberg gave a brief development. Basically, Category theory is > the RESULT of the refactoring you're asking about. Category theory's > beginnings are found in work on differential topology (where functors > and higher order constructs took on a life of their own), and the > unification of topology, lattice theory, and universal algebra (in > order to ground that higher order stuff). Distinct models and notions > of computation were unified, using arrows and objects. > > Now, you could have a legitimate gripe about current category theory > terminology. But I am not so sure. We can "simplify" lots of > things. Morphisms can become arrows or functions. Auto- can become > "self-". "Homo-" can become "same-". Functors can become "Category > arrows". Does it help? You tell me. I think I understand what you mean and completely agree... The project in my imagination is different, I read on... > > But if we're ever going to do anything interesting with Category > theory, we're going to have to go into the realm of dealing with SOME > kind of algebra. We need examples, and the mathematically tractable > ones have names like "group", "monoid", "ring", "field", > "sigma-algebras", "lattices", "logics", "topologies", "geometries". > They are arbitrary names, grounded in history. Any other choice is > just as arbitrary, if not more so. The closest thing algebras have to > a unique name is their signature -- basically their axiomatization -- > or a long descriptive name in terms of arbitrary names and adjectives > ("the Cartesian product of a Cartesian closed category and a groupoid > with groupoid addition induced by...."). The case for Pareto > efficiency is here: is changing the name of these kinds of structures > wholesale a win for efficiency? The answer is "no". Everybody would > have to learn the new, arbitrary names, instead of just some people > having to learn the old arbitrary names. Ok... > > Let's compare this to the "monad fallacy". It is said every beginner > Haskell programmer write a monad tutorial, and often falls into the > "monad fallacy" of thinking that there is only one interpretation for > monadism. Monads are relatively straightforward. Their power comes > from the fact that many different kinds of things are "monadic" -- > sequencing, state, function application. What name should we use for > monads instead? Which interpretation must we favor, despite the fact > that others will find it counter-intuitive? Or should we choose to > not favor one, and just pick a new arbitrary name? The short answer: If the work I imagine would be done by exchanging here a word and there on the quick -- it would be again maths style, with difference only in justifying it with naivity instead of resignation. The idea I have is different: DEEP CONTEMPLATION stands in the beginning, gathering the constructive criticism of the sharpest minds possible, hard discussions and debates full of temperament -- all of this already rewarding in itself. The participants are united in the spirit to create a masterpiece, and to explore details in depths for which time was missing before. It could be great fun for everybody to improve one's deep intuition of category theory. This book might be comparable to a programming language, hypertext like a wikibook and maybe in development forever. It will have an appendix (or later a special mode) with a translation of all new termini into the original ones. I do believe deeply that this is possible. By all criticism on Bourbaki -- I was among the generation of pupils taught set theory in elementary school; looking back, I regard it as a rewarding effort. Why should category theory not be able to achieve the same, maybe with other means than plastic chips? All the best, Nick From ok at cs.otago.ac.nz Thu Feb 18 18:52:21 2010 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Thu Feb 18 18:23:08 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <4B7CB3A3.3020505@t-online.de> <3c6288ab1002180204q74df576fw761f408b1f839c54@mail.gmail.com> <4B7D4518.3030003@t-online.de> <2F93D0A8-E4D0-4AC0-82A3-599E036F1095@math.su.se> <4B7D84B8.3020605@t-online.de> <86FF9BCF-06AE-4AF2-B2CC-4C44DEE3515D@math.su.se> <4B7DB908.90400@t-online.de> Message-ID: On Feb 19, 2010, at 11:22 AM, Hans Aberg wrote: > As for the naming problem, it is more of a linguistic problem: the > names were somehow handed by tradition, and it may be difficult to > change them. For example, there is a rumor that "kangaroo" means "I > do not understand" in a native language; assuming this to be true, > it might be difficult to change it. OED entry for kangaroo, n; etymology: [Stated to have been the name in a native Australian language. Cook and Banks believed it to be the name given to the animal by the natives at Endeavour River, Queensland, and there is later affirmation of its use elsewhere. On the other hand, there are express statements to the contrary (see quotations below), showing that the word, if ever current in this sense, was merely local, or had become obsolete. The common assertion that it really means ?I don't understand? (the supposed reply of the native to his questioner) seems to be of recent origin and lacks confirmation. ...] Turning to the Wikipedia article, we find "The word kangaroo derives from the Guugu Yimidhirr word gangurru, referring to a grey kangaroo" and "A common myth about the kangaroo's English name is that 'kangaroo' was a Guugu Yimidhirr phrase for "I don't understand you." According to this legend, Captain James Cook and naturalist Sir Joseph Banks were exploring the area when they happened upon the animal. They asked a nearby local what the creatures were called. The local responded "Kangaroo", meaning "I don't understand you", which Cook took to be the name of the creature. The Kangaroo myth was debunked in the 1970s by linguist John B. Haviland in his research with the Guugu Yimidhirr people." See the wikipedia page for references, especially Haviland's article. It's time this urban legend was forgotten. From daniel.is.fischer at web.de Thu Feb 18 18:55:27 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Feb 18 18:28:07 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <2E4494E6-120F-4975-8DB2-0FBA55FB3432@cs.otago.ac.nz> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <201002181555.37468.daniel.is.fischer@web.de> <2E4494E6-120F-4975-8DB2-0FBA55FB3432@cs.otago.ac.nz> Message-ID: <201002190055.27480.daniel.is.fischer@web.de> Am Freitag 19 Februar 2010 00:24:23 schrieb Richard O'Keefe: > On Feb 19, 2010, at 3:55 AM, Daniel Fischer wrote: > > Am Donnerstag 18 Februar 2010 14:48:08 schrieb Nick Rudnick: > >> even in Germany, where the > >> term ?ring? seems to originate from, since at least a century nowbody > >> has the least idea it once had an alternative meaning > >> ?gang,band,group?, > > > > Wrong. The term "Ring" is still in use with that meaning in > > composites like > > Schmugglerring, Autoschieberring, ... > > The mathematical ring is OED ring n1 sense 12. > The group of people sense is sense 11, immediately above it. > "Drug ring" is still in use. > I'd always assumed "ring" was generalised from Z[n]. As in "cyclic group", arrange the numbers in a ring like on a clockface? Maybe. As far as I know, the term "ring" (in the mathematical sense) first appears in chapter 9 - Die Zahlringe des K?rpers - of Hilbert's "Die Theorie der algebraischen Zahlk?rper". Unfortunately, Hilbert gives no hint why he chose that name (Dedekind, who coined the term "K?rper", called these structures "Ordnung" [order]). From joerg.rudnick at t-online.de Thu Feb 18 19:49:05 2010 From: joerg.rudnick at t-online.de (Nick Rudnick) Date: Thu Feb 18 19:20:00 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <201002182020.49657.daniel.is.fischer@web.de> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <2F93D0A8-E4D0-4AC0-82A3-599E036F1095@math.su.se> <4B7D84B8.3020605@t-online.de> <201002182020.49657.daniel.is.fischer@web.de> Message-ID: <4B7DE001.4010007@t-online.de> Daniel Fischer wrote: > Am Donnerstag 18 Februar 2010 19:19:36 schrieb Nick Rudnick: > >> Hi Hans, >> >> agreed, but, in my eyes, you directly point to the problem: >> >> * doesn't this just delegate the problem to the topic of limit >> operations, i.e., in how far is the term ?closed? here more perspicuous? >> > > It's fairly natural in German, abgeschlossen: closed, finished, complete; > offen: open, ongoing. > > >> * that's (for a very simple concept) >> > > That concept (open and closed sets, topology more generally) is *not* very > simple. It has many surprising aspects. > ?concept? is a word of many meanings; to become more specific: Its *definition* is... > >> the way that maths prescribes: >> + historical background: ?I take "closed" as coming from being closed >> under limit operations - the origin from analysis.? >> + definition backtracking: ?A closure operation c is defined by the >> property c(c(x)) = c(x). >> > > Actually, that's incomplete, missing are > - c(x) contains x > - c(x) is minimal among the sets containing x with y = c(y). > Even more workload to master... This strengthens the thesis that definition recognition requires a considerable amount of one's effort... >> If one takes c(X) = the set of limit points of >> > > Not limit points, "Ber?hrpunkte" (touching points). > > >> X, then it is the smallest closed set under this operation. The closed >> sets X are those that satisfy c(X) = X. Naming the complements of the >> closed sets open might have been introduced as an opposite of closed.? >> >> 418 bytes in my file system... how many in my brain...? Is it efficient, >> inevitable? The most fundamentalist justification I heard in this regard >> is: ?It keeps people off from thinking the could go without the >> definition...? Meanwhile, we backtrack definition trees filling books, >> no, even more... In my eyes, this comes equal to claiming: ?You have >> nothing to understand this beyond the provided authoritative definitions >> -- your understanding is done by strictly following these.? >> > > But you can't understand it except by familiarising yourself with the > definitions and investigating their consequences. > The name of a concept can only help you remembering what the definition > was. Choosing "obvious" names tends to be misleading, because there usually > are things satisfying the definition which do not behave like the "obvious" > name implies. > So if you state that the used definitions are completely unpredictable so that they have to be studied completely -- which already ignores that human brain is an analogous ?machine? --, you, by information theory, imply that these definitions are somewhat arbitrary, don't you? This in my eyes would contradict the concept such definition systems have about themselves. To my best knowledge it is one of the best known characteristics of category theory that it revealed in how many cases maths is a repetition of certain patterns. Speaking categorically it is good practice to transfer knowledge from on domain to another, once the required isomorphisms could be established. This way, category theory itself has successfully torn down borders between several subdisciplines of maths and beyond. I just propose to expand the same to common sense matters... >> Back to the case of open/closed, given we have an idea about sets -- we >> in most cases are able to derive the concept of two disjunct sets facing >> each other ourselves, don't we? The only lore missing is just a Bool: >> Which term fits which idea? With a reliable terminology using >> ?bordered/unbordered?, there is no ambiguity, and we can pass on >> reading, without any additional effort. >> > > And we'd be very wrong. There are sets which are simultaneously open and > closed. It is bad enough with the terminology as is, throwing in the > boundary (which is an even more difficult concept than open/closed) would > only make things worse. > Really? As ?open == not closed? can similarly be implied, bordered/unbordered even in this concern remains at least equal... >> Picking such an opportunity thus may save a lot of time and even error >> -- allowing you to utilize your individual knowledge and experience. I >> > > When learning a formal theory, individual knowledge and experience (except > coming from similar enough disciplines) tend to be misleading more than > helpful. > Why does the opposite work well for computing science? All the best, Nick -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100218/476d200d/attachment-0001.html From leon.p.smith at gmail.com Thu Feb 18 19:51:02 2010 From: leon.p.smith at gmail.com (Leon Smith) Date: Thu Feb 18 19:21:46 2010 Subject: [Haskell-cafe] Re: Implementing "unionAll" In-Reply-To: <2518b95d1002172332q6c9a438cq73753b7daa9b3c9b@mail.gmail.com> References: <2518b95d1002172332q6c9a438cq73753b7daa9b3c9b@mail.gmail.com> Message-ID: On Thu, Feb 18, 2010 at 2:32 AM, Evan Laforge wrote: > By purest coincidence I just wrote the exact same function (the simple > mergeAll', not the VIP one). ?Well, extensionally the same... > intensionally mine is 32 complicated lines and equivalent to the 3 > line mergeAll'. ?I even thought of short solution by thinking that > pulling the first element destroys the ascending lists property so > it's equivalent to a normal sorted merge after that, and have no idea > why I didn't just write it that way. Well, the three line version wasn't my first implementation, by any stretch of the imagination. I know I had tried to implement mergeAll at least once, if not two or three times before coming up with the foldr-based implementation. However, I can't find any of them; they may well be lost to the sands of time. Incidentally, that implementation also appears in Melissa O'Neill's "Genuine Sieve of Eratosthenes", in an alternate prime sieve by Richard Bird that appears at the end. > Anyway, I'm dropping mine and downloading data-ordlist. ?Thanks for > the library *and* the learning experience :) Thanks! > BTW, I notice that your merges, like mine, are left-biased. ?This is a > useful property (my callers require it), and doesn't seem to cost > anything to implement, so maybe you could commit to it in the > documentation? Yes, the description of the module explicitly states that all functions are left-biased; if you have suggestions about how to improve the documentation in content or organization, I am interested in hearing them. Best, Leon From ajs at 2piix.com Thu Feb 18 20:09:35 2010 From: ajs at 2piix.com (Alexander Solla) Date: Thu Feb 18 19:40:23 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <4B7DE001.4010007@t-online.de> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <2F93D0A8-E4D0-4AC0-82A3-599E036F1095@math.su.se> <4B7D84B8.3020605@t-online.de> <201002182020.49657.daniel.is.fischer@web.de> <4B7DE001.4010007@t-online.de> Message-ID: On Feb 18, 2010, at 4:49 PM, Nick Rudnick wrote: > Why does the opposite work well for computing science? Does it? I remember a peer trying to convince me to use "the factory pattern" in a language that supports functors. I told him I would do my task my way, and he could change it later if he wanted. He told me an hour later he tried a trivial implementation, and found that the source was twice as long as my REAL implementation, split across multiple files in an unattractive way, all while losing conceptual clarity. He immediately switched to using functors too. He didn't even know he wanted a functor, because the name "factory" clouded his interpretation. Software development is full of people inventing creative new ways to use the wrong tool for the job. From joerg.rudnick at t-online.de Thu Feb 18 20:20:28 2010 From: joerg.rudnick at t-online.de (Nick Rudnick) Date: Thu Feb 18 19:51:19 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <2F93D0A8-E4D0-4AC0-82A3-599E036F1095@math.su.se> <4B7D84B8.3020605@t-online.de> <201002182020.49657.daniel.is.fischer@web.de> <4B7DE001.4010007@t-online.de> Message-ID: <4B7DE75C.2030206@t-online.de> Hi Alexander, please be more specific -- what is your proposal? Seems as if you had more to say... Nick Alexander Solla wrote: > > On Feb 18, 2010, at 4:49 PM, Nick Rudnick wrote: > >> Why does the opposite work well for computing science? > > Does it? I remember a peer trying to convince me to use "the factory > pattern" in a language that supports functors. I told him I would do > my task my way, and he could change it later if he wanted. He told me > an hour later he tried a trivial implementation, and found that the > source was twice as long as my REAL implementation, split across > multiple files in an unattractive way, all while losing conceptual > clarity. He immediately switched to using functors too. He didn't > even know he wanted a functor, because the name "factory" clouded his > interpretation. > > Software development is full of people inventing creative new ways to > use the wrong tool for the job. > From leon.p.smith at gmail.com Thu Feb 18 20:22:08 2010 From: leon.p.smith at gmail.com (Leon Smith) Date: Thu Feb 18 19:52:51 2010 Subject: [Haskell-cafe] Re: Implementing "unionAll" In-Reply-To: <2518b95d1002180007g7782470fqa428ac8deeffc311@mail.gmail.com> References: <2518b95d1002172332q6c9a438cq73753b7daa9b3c9b@mail.gmail.com> <2518b95d1002180007g7782470fqa428ac8deeffc311@mail.gmail.com> Message-ID: On Thu, Feb 18, 2010 at 3:07 AM, Evan Laforge wrote: > BTW, I notice that your merges, like mine, are left-biased. ?This is a > useful property (my callers require it), and doesn't seem to cost > anything to implement, so maybe you could commit to it in the > documentation? Also, I did briefly consider giving up left bias. GHC has an optimization strategy that seeks to reduce pattern matching, and due to interactions with this I could have saved a few kilobytes of -O2 object code size by giving up left-bias. For example: module MergeLeft where mergeBy :: (a -> a -> Ordering) -> [a] -> [a] -> [a] mergeBy cmp = loop where loop [] ys = ys loop xs [] = xs loop (x:xs) (y:ys) = case cmp x y of GT -> y : loop (x:xs) ys _ -> x : loop xs (y:ys) compiles ghc-6.12.1 -O2 to a 4208 byte object file for x64 ELF. By changing the very last line to: _ -> x : loop (y:ys) xs I get a 3336 byte object file instead, but of course this is no longer left- (or right-) biased. Repeat this strategy across the entire module, and you can save 3 kilobytes or so. However, in today's modern computing environment, left-bias is clearly a greater benefit to more people. If you are curious why, I suggest taking a look at GHC's core output for each of these two variants. The hackage package "ghc-core" makes this a little bit more pleasant, as it can pretty-print it for you. It's amazing to think that this library, at 55k (Optimized -O2 for x64), would take up most of the memory of my very first computer, a Commodore 64. Of course, I'm sure there are many others on this list who's first computers had a small fraction of 64k of memory to play with. :-) From joerg.rudnick at t-online.de Thu Feb 18 20:48:59 2010 From: joerg.rudnick at t-online.de (Nick Rudnick) Date: Thu Feb 18 20:19:45 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <201002182031.03105.daniel.is.fischer@web.de> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <75cc17ac1002180924r6d8eb5f4r3a7ddebd9825c69f@mail.gmail.com> <4B7D8D23.3020402@t-online.de> <201002182031.03105.daniel.is.fischer@web.de> Message-ID: <4B7DEE0B.7050309@t-online.de> Hi, wow, a topic specific response, at last... But I wish you would be more specific... ;-) >> A *referrer* (object) refers to a *referee* (object) by a *reference* >> (arrow). >> > > Doesn't work for me. Not in Ens (sets, maps), Grp (groups, homomorphisms), > Top (topological spaces, continuous mappings), Diff (differential > manifolds, smooth mappings), ... . > Why not begin with SET and functions... Every human has a certain age, so that there is a function, ageOf:: Human-> Int, which can be regarded as a certain way of a reference relationship between Human and Int, in that by agoOf, * Int reflects a certain aspect of Human, and, on the other hand, * the structure of Human can be traced to Int. Please tell me the aspect you feel uneasy with, and please give me your opinion, whether (in case of accepting this) you would rather choose to consider Human as referrer and Int as referee of the opposite -- for I think this is a deep question. Thank you in advance, Nick -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100218/55c51614/attachment.html From qdunkan at gmail.com Thu Feb 18 21:25:20 2010 From: qdunkan at gmail.com (Evan Laforge) Date: Thu Feb 18 20:56:03 2010 Subject: [Haskell-cafe] Re: Implementing "unionAll" In-Reply-To: References: <2518b95d1002172332q6c9a438cq73753b7daa9b3c9b@mail.gmail.com> <2518b95d1002180007g7782470fqa428ac8deeffc311@mail.gmail.com> Message-ID: <2518b95d1002181825i73b79054tcfe7a31136b5e5cb@mail.gmail.com> On Thu, Feb 18, 2010 at 5:22 PM, Leon Smith wrote: > On Thu, Feb 18, 2010 at 3:07 AM, Evan Laforge wrote: >> BTW, I notice that your merges, like mine, are left-biased. ?This is a >> useful property (my callers require it), and doesn't seem to cost >> anything to implement, so maybe you could commit to it in the >> documentation? Ohh, I see it now, I just wasn't looking at the module doc. > Also, I did briefly consider giving up left bias. ?GHC has an > optimization strategy that seeks to reduce pattern matching, ?and due > to interactions with this I could have saved a few kilobytes of -O2 > object code size by giving up left-bias. Interesting... but left bias is so useful I think it's worth a few extra k. > If you are curious why, ?I suggest taking a look at GHC's core output > for each of these two variants. ? The hackage package "ghc-core" > makes this a little bit more pleasant, ?as it can pretty-print it for > you. I can see there's one extra case in the first one, and I can tell the last case is the 'loop' case including the case on Ordering, but I admit I don't understand what the previous cases are doing. Core is really hard for me to read. > It's amazing to think that this library, ?at 55k (Optimized -O2 for > x64), ?would take up most of the memory of my very first computer, ?a > Commodore 64. ? Of course, ?I'm sure there are many others on this > list who's first computers had a small fraction of 64k of memory to > play with. ?:-) It's not even that much assembly. I intended to write a small quick program... then I did it in haskell, and then I linked in the GHC API (fatal blow). Now the stripped optimized binary is 22MB (optimization doesn't seem to have an effect on size). The non-haskell UI part is 367k... From ok at cs.otago.ac.nz Thu Feb 18 23:07:45 2010 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Thu Feb 18 22:38:29 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <4B7DEE0B.7050309@t-online.de> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <75cc17ac1002180924r6d8eb5f4r3a7ddebd9825c69f@mail.gmail.com> <4B7D8D23.3020402@t-online.de> <201002182031.03105.daniel.is.fischer@web.de> <4B7DEE0B.7050309@t-online.de> Message-ID: <681D5A1F-0BAC-4ECA-8A1D-2D5C1DB00F5E@cs.otago.ac.nz> On Feb 19, 2010, at 2:48 PM, Nick Rudnick wrote: > Please tell me the aspect you feel uneasy with, and please give me > your opinion, whether (in case of accepting this) you would rather > choose to consider Human as referrer and Int as referee of the > opposite -- for I think this is a deep question. I've read enough philosophy to be wary of treating "reference" as a simple concept. And linguistically, "referees" are people you find telling rugby players "naughty naughty". Don't you mean "referrer" and "referent"? Of course a basic point about language is that the association between sounds and meanings is (for the most part) arbitrary. Why should the terminology of mathematics be any different? Why is a "small dark floating cloud, indicating rain", called a "water-dog"? Water, yes, but dog? Why are the brackets at each end of a fire-place called "fire-dogs"? Why are unusually attractive women called "foxes" (the females of that species being "vixens", and both sexes smelly)? What's the logic in doggedness being a term of praise but bitchiness of opprobrium? We can hope for mathematical terms to be used consistently, but asking for them to be transparent is probably too much to hope for. (We can and should use intention-revealing names in a program, but doing it across the totality of all programs is something never achieved and probably never achievable.) From drcygnus at gmail.com Fri Feb 19 01:23:34 2010 From: drcygnus at gmail.com (Jonathan Daugherty) Date: Fri Feb 19 00:54:17 2010 Subject: [Haskell-cafe] ANNOUNCE: vty-ui 0.3 Message-ID: I'm happy to announce the release of vty-ui 0.3. Get it from Hackage: http://hackage.haskell.org/package/vty-ui Or get the source with darcs: http://repos.codevine.org/vty-ui Project homepage: http://codevine.org/vty-ui/ This version of vty-ui features a richer rendering engine, generalized text transformations, and a more functional style. If you've written any applications to use vty-ui, your type signatures and usage of a few of the built-in widget types will need to change but the API is largely the same. In particular, the largest change was a refactoring inspired by Luke Palmer's blog post, "Haskell Antipattern: Existential Typeclass," which targeted vty-ui (among other libraries) in its treatment of the topic: http://lukepalmer.wordpress.com/2010/01/24/haskell-antipattern-existential-typeclass/ Here's a summary of changes: General * Replace Widget type class with a concrete Widget type * Move text widget into Graphics.Vty.Widgets.Text * Add support for generalized text "formatters" * Replace WrappedText widget type with a text-wrapping formatter * Provide a regex-based text-highlighting formatter (see the demo for an example) * Refactor the rendering engine to provide "address" information so you can get coordinates and size for rendered widgets * Add a few QuickCheck tests (and related fixes) Enjoy! -- Jonathan Daugherty From haberg at math.su.se Fri Feb 19 04:16:03 2010 From: haberg at math.su.se (Hans Aberg) Date: Fri Feb 19 03:48:53 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <4B7CB3A3.3020505@t-online.de> <3c6288ab1002180204q74df576fw761f408b1f839c54@mail.gmail.com> <4B7D4518.3030003@t-online.de> <2F93D0A8-E4D0-4AC0-82A3-599E036F1095@math.su.se> <4B7D84B8.3020605@t-online.de> <86FF9BCF-06AE-4AF2-B2CC-4C44DEE3515D@math.su.se> <4B7DB908.90400@t-online.de> Message-ID: <634C0295-62ED-4659-9285-A89F3E47A207@math.su.se> On 19 Feb 2010, at 00:52, Richard O'Keefe wrote: > Turning to the Wikipedia article, we find > "The word kangaroo derives from the Guugu Yimidhirr word gangurru, > referring to a grey kangaroo" Thanks, particularly for giving the name of the native language. Hope the Wikipedia article can be trusted. :-) > It's time this urban legend was forgotten. Not at all, there are sites specializing in such http://www.snopes.com/ http://www.snopes.com/inboxer/hoaxes/computer.asp Hans From haberg at math.su.se Fri Feb 19 04:19:12 2010 From: haberg at math.su.se (Hans Aberg) Date: Fri Feb 19 03:49:54 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <4B7DC7AE.9000004@t-online.de> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <4B7CB3A3.3020505@t-online.de> <3c6288ab1002180204q74df576fw761f408b1f839c54@mail.gmail.com> <4B7D4518.3030003@t-online.de> <2F93D0A8-E4D0-4AC0-82A3-599E036F1095@math.su.se> <4B7D84B8.3020605@t-online.de> <86FF9BCF-06AE-4AF2-B2CC-4C44DEE3515D@math.su.se> <4B7DB908.90400@t-online.de> <4B7DC7AE.9000004@t-online.de> Message-ID: <89B10534-1DAA-4807-AD07-6D5AC43D5011@math.su.se> On 19 Feb 2010, at 00:05, Nick Rudnick wrote: >> Mathematicians though stick to their own concepts and definitions >> individually. For example, I had conversations with one who calls >> monads "triads", and then one has to cope with that. > Yes. But isn't it also an enrichment by some way? Yes, one must be able to choose notation that fits with the notions. A similar situation exists in the case of computer languages, having their own syntax. Hans From haberg at math.su.se Fri Feb 19 04:42:59 2010 From: haberg at math.su.se (Hans Aberg) Date: Fri Feb 19 04:13:50 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <201002190055.27480.daniel.is.fischer@web.de> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <201002181555.37468.daniel.is.fischer@web.de> <2E4494E6-120F-4975-8DB2-0FBA55FB3432@cs.otago.ac.nz> <201002190055.27480.daniel.is.fischer@web.de> Message-ID: <6A9959C4-273B-4AB1-BFA1-8E6D6C59AF8B@math.su.se> On 19 Feb 2010, at 00:55, Daniel Fischer wrote: >> I'd always assumed "ring" was generalised from Z[n]. > > As in "cyclic group", arrange the numbers in a ring like on a > clockface? > Maybe. As far as I know, the term "ring" (in the mathematical sense) > first > appears in chapter 9 - Die Zahlringe des K?rpers - of Hilbert's "Die > Theorie der algebraischen Zahlk?rper". Unfortunately, Hilbert gives > no hint > why he chose that name (Dedekind, who coined the term "K?rper", called > these structures "Ordnung" [order]). The Wikipedia article "Ring" says he used it for a specific one where the elements somehow cycled back. Hans From lobachev at Mathematik.Uni-Marburg.de Fri Feb 19 05:46:29 2010 From: lobachev at Mathematik.Uni-Marburg.de (Oleg Lobachev) Date: Fri Feb 19 05:17:10 2010 Subject: [Haskell-cafe] Cabal broken on Mac OS X? Message-ID: Hello all, I suspect that it's me and not the cabal, but everything looks fine and still fails. Would someone mind to tell me, what am I doing wrong? $ cabal -V cabal-install version 0.6.2 using version 1.6.0.3 of the Cabal library $ ghc -V The Glorious Glasgow Haskell Compilation System, version 6.12.1 $ which ghc /usr/bin/ghc $ which cabal /usr/local/bin/cabal $ cabal install cabal-install cabal: failed to parse output of 'ghc-pkg dump' That's the problem! As it is Mac OS X 10.6.2, here is some information on the architecture and the executables used: $ uname -v Darwin Kernel Version 10.2.0: Tue Nov 3 10:37:10 PST 2009; root:xnu-1486.2.11~1/RELEASE_I386 $ file /Library/Frameworks/GHC.framework/Versions/612/usr/lib/ghc-6.12.1/ghc /Library/Frameworks/GHC.framework/Versions/612/usr/lib/ghc-6.12.1/ghc: Mach-O executable i386 $ file `which cabal` /usr/local/bin/cabal: Mach-O executable i386 $ file `which ls` /bin/ls: Mach-O universal binary with 2 architectures /bin/ls (for architecture x86_64): Mach-O 64-bit executable x86_64 /bin/ls (for architecture i386): Mach-O executable i386 $ ghc --make hello.hs [1 of 1] Compiling Main ( hello.hs, hello.o ) Linking hello ... $ ./hello Hello world! $ file ./hello ./hello: Mach-O executable i386 The output of ghc-pkg dump is here: http://www.mathematik.uni-marburg.de/~lobachev/tmp/ghc-pkg.txt I have installed the Haskell Platform and then the new GHC via official pkg files. Greetings, Oleg From daniel.is.fischer at web.de Fri Feb 19 06:12:11 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Fri Feb 19 05:44:49 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <6A9959C4-273B-4AB1-BFA1-8E6D6C59AF8B@math.su.se> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <201002190055.27480.daniel.is.fischer@web.de> <6A9959C4-273B-4AB1-BFA1-8E6D6C59AF8B@math.su.se> Message-ID: <201002191212.12115.daniel.is.fischer@web.de> Am Freitag 19 Februar 2010 10:42:59 schrieb Hans Aberg: > On 19 Feb 2010, at 00:55, Daniel Fischer wrote: > >> I'd always assumed "ring" was generalised from Z[n]. > > > > As in "cyclic group", arrange the numbers in a ring like on a > > clockface? > > Maybe. As far as I know, the term "ring" (in the mathematical sense) > > first > > appears in chapter 9 - Die Zahlringe des K?rpers - of Hilbert's "Die > > Theorie der algebraischen Zahlk?rper". Unfortunately, Hilbert gives > > no hint > > why he chose that name (Dedekind, who coined the term "K?rper", called > > these structures "Ordnung" [order]). > > The Wikipedia article "Ring" says he used it for a specific one where > the elements somehow cycled back. > > Hans Yes. And I deem a) the english wikipedia a more reliable source of information [concerning things mathematical] than the german, b) Harvey Cohn more trustworthy than either wikipedia. But a quick look at Hilbert's paper didn't reveal the property Cohn mentioned (according to wp) and no explanation of Hilbert why he chose the term. So I remain in doubt. Cheers, Daniel From maciej.podgurski at googlemail.com Fri Feb 19 06:21:30 2010 From: maciej.podgurski at googlemail.com (Maciej Podgurski) Date: Fri Feb 19 05:52:44 2010 Subject: [Haskell-cafe] Cabal update problem Message-ID: <4B7E743A.5050908@googlemail.com> Hi, after updating to cabal-install-0.8.0/Cabal-1.8.0.2 with GHC 6.10.4, I always get an error when updating the package list: > cabal update Downloading the latest package list from hackage.haskell.org cabal: Codec.Compression.Zlib: premature end of compressed stream Is there a way to fix this without rebuilding from the latest darcs repo? Best wishes, Maciej From bugspynet at gmail.com Fri Feb 19 06:32:16 2010 From: bugspynet at gmail.com (Gabi) Date: Fri Feb 19 06:02:58 2010 Subject: [Haskell-cafe] Why is Haskell used so little in the industry? Message-ID: <22d241861002190332q28708b4al48e5b03ac6c5c3e2@mail.gmail.com> I posted a question about it in StackOverflow (http://stackoverflow.com/questions/2284875/why-is-haskell-used-so-little-in-the-industry) Haskell gets some beating there. Please Hasellers, join the discussion and give your opinion there. -- Regards, Gabi http://bugspy.net From Christian.Maeder at dfki.de Fri Feb 19 06:35:43 2010 From: Christian.Maeder at dfki.de (Christian Maeder) Date: Fri Feb 19 06:06:27 2010 Subject: [Haskell-cafe] Re: Cabal broken on Mac OS X? In-Reply-To: References: Message-ID: <4B7E778F.8000505@dfki.de> Oleg Lobachev schrieb: > Hello all, > > I suspect that it's me and not the cabal, but everything looks fine and still fails. Would someone mind to tell me, what am I doing wrong? > > $ cabal -V > cabal-install version 0.6.2 > using version 1.6.0.3 of the Cabal library This version of cabal cannot handle ghc-6.12.1 packages. You need (to hand-install) cabal-install-0.8.0 for ghc-6.12.1 first. (There is no haskell-platform for ghc-6.12.1, yet) Cheers Christian > $ ghc -V > The Glorious Glasgow Haskell Compilation System, version 6.12.1 > $ which ghc > /usr/bin/ghc > $ which cabal > /usr/local/bin/cabal > $ cabal install cabal-install > cabal: failed to parse output of 'ghc-pkg dump' > > That's the problem! As it is Mac OS X 10.6.2, here is some information on the architecture and the executables used: > > $ uname -v > Darwin Kernel Version 10.2.0: Tue Nov 3 10:37:10 PST 2009; root:xnu-1486.2.11~1/RELEASE_I386 > $ file /Library/Frameworks/GHC.framework/Versions/612/usr/lib/ghc-6.12.1/ghc > /Library/Frameworks/GHC.framework/Versions/612/usr/lib/ghc-6.12.1/ghc: Mach-O executable i386 > $ file `which cabal` > /usr/local/bin/cabal: Mach-O executable i386 > $ file `which ls` > /bin/ls: Mach-O universal binary with 2 architectures > /bin/ls (for architecture x86_64): Mach-O 64-bit executable x86_64 > /bin/ls (for architecture i386): Mach-O executable i386 > $ ghc --make hello.hs > [1 of 1] Compiling Main ( hello.hs, hello.o ) > Linking hello ... > $ ./hello > Hello world! > $ file ./hello > ./hello: Mach-O executable i386 > > The output of ghc-pkg dump is here: http://www.mathematik.uni-marburg.de/~lobachev/tmp/ghc-pkg.txt > > I have installed the Haskell Platform and then the new GHC via official pkg files. > > Greetings, > Oleg From agocorona at gmail.com Fri Feb 19 06:43:40 2010 From: agocorona at gmail.com (Alberto G. Corona ) Date: Fri Feb 19 06:14:24 2010 Subject: [Haskell-cafe] fast, strongly typed heterogeneous collections Message-ID: Hi What is the speed of hProjectByLabel/s in Data.HList.Record? . The documentation in hackage does not mention it. Perhaps this is because Hlist is designed for supposedly short records and this does not matter too much. looking at the code I guess that everything in HList is O(n) because it uses type-level list structure, but I think that nothing prevents from using a type level balanced tree, Data.Map style, instead. This would permit to implement large heterogeneous Maps with fast access and strongly typed. AFAIK, the alternative is to use a fast data container with data elements encapsulated within Data.Dynamic, that is weakly typed, produces type errors at runtime, which is unsatisfactory and dangerous. Any comments? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100219/e2313f1d/attachment.html From haberg at math.su.se Fri Feb 19 06:53:56 2010 From: haberg at math.su.se (Hans Aberg) Date: Fri Feb 19 06:24:40 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <201002191212.12115.daniel.is.fischer@web.de> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <201002190055.27480.daniel.is.fischer@web.de> <6A9959C4-273B-4AB1-BFA1-8E6D6C59AF8B@math.su.se> <201002191212.12115.daniel.is.fischer@web.de> Message-ID: <78943F1B-26BA-4E1F-BB3B-9A4AF73C634A@math.su.se> On 19 Feb 2010, at 12:12, Daniel Fischer wrote: >>> ...As far as I know, the term "ring" (in the mathematical sense) >>> first >>> appears in chapter 9 - Die Zahlringe des K?rpers - of Hilbert's "Die >>> Theorie der algebraischen Zahlk?rper". Unfortunately, Hilbert gives >>> no hint >>> why he chose that name (Dedekind, who coined the term "K?rper", >>> called >>> these structures "Ordnung" [order]). >> >> The Wikipedia article "Ring" says he used it for a specific one where >> the elements somehow cycled back. > > Yes. And I deem a) the english wikipedia a more reliable source of > information [concerning things mathematical] than the german, b) > Harvey > Cohn more trustworthy than either wikipedia. But a quick look at > Hilbert's > paper didn't reveal the property Cohn mentioned (according to wp) > and no > explanation of Hilbert why he chose the term. So I remain in doubt. The term "group" was introduced ?variste Galois, though he meant what we call a cancellative monoid, but since they are finite, have inverses. So perhaps Hilbert made play on that word: a group is a small number of people, a ring larger, like a gang. Hans From Christian.Maeder at dfki.de Fri Feb 19 06:57:14 2010 From: Christian.Maeder at dfki.de (Christian Maeder) Date: Fri Feb 19 06:27:55 2010 Subject: [Haskell-cafe] Re: Cabal update problem In-Reply-To: <4B7E743A.5050908@googlemail.com> References: <4B7E743A.5050908@googlemail.com> Message-ID: <4B7E7C9A.1050004@dfki.de> Maciej Podgurski schrieb: > Hi, > > after updating to cabal-install-0.8.0/Cabal-1.8.0.2 with GHC 6.10.4, I > always get an error when updating the package list: > > > cabal update > Downloading the latest package list from hackage.haskell.org > cabal: Codec.Compression.Zlib: premature end of compressed stream > > Is there a way to fix this without rebuilding from the latest darcs repo? Does removing ~/.cabal/packages/hackage.haskell.org/00-index.tar.gz help? Did you overwrite your old cabal-binary. If not, does this binary also fail? (I think everything under ~/.cabal/packages/hackage.haskell.org can be savely deleted and will be downloaded again if needed.) Which architecture you're on? Cheers Christian > > > Best wishes, > > Maciej From sergueyz at gmail.com Fri Feb 19 07:20:30 2010 From: sergueyz at gmail.com (Serguey Zefirov) Date: Fri Feb 19 06:51:11 2010 Subject: [Haskell-cafe] fast, strongly typed heterogeneous collections In-Reply-To: References: Message-ID: <600376291002190420l7abcf646xd8b7cbc3858d4214@mail.gmail.com> 2010/2/19 Alberto G. Corona : > What is the speed of?hProjectByLabel/s in Data.HList.Record??. The > documentation in hackage does not mention it. Perhaps this is because Hlist > is designed for supposedly short records and this does not matter too much. > looking at the code I guess that everything in HList is O(n) because it uses > type-level list structure, but I think that nothing prevents from using a > type level balanced tree, Data.Map style, instead. GHC could inline most of what looks like O(n). And, actually, what looks like O(n) at the compile time is O(1) at runtime. This is so because it is really hard to create types at runtime. ;) From valery.vv at gmail.com Fri Feb 19 07:55:06 2010 From: valery.vv at gmail.com (Valery V. Vorotyntsev) Date: Fri Feb 19 07:25:49 2010 Subject: [Haskell-cafe] Cabal update problem In-Reply-To: <4B7E743A.5050908@googlemail.com> References: <4B7E743A.5050908@googlemail.com> Message-ID: > after updating to cabal-install-0.8.0/Cabal-1.8.0.2 with GHC 6.10.4, I > always get an error when updating the package list: > > ? > cabal update > ? Downloading the latest package list from hackage.haskell.org > ? cabal: Codec.Compression.Zlib: premature end of compressed stream Would you please send the output of `cabal update -v3' command? -- vvv From maciej.podgurski at googlemail.com Fri Feb 19 08:41:53 2010 From: maciej.podgurski at googlemail.com (Maciej Podgurski) Date: Fri Feb 19 08:12:39 2010 Subject: [Haskell-cafe] Re: Cabal update problem In-Reply-To: <4B7E7C9A.1050004@dfki.de> References: <4B7E743A.5050908@googlemail.com> <4B7E7C9A.1050004@dfki.de> Message-ID: <4B7E9521.6030007@googlemail.com> Am 19.02.2010 12:57 schrieb Christian Maeder: > Maciej Podgurski schrieb: > >> Hi, >> >> after updating to cabal-install-0.8.0/Cabal-1.8.0.2 with GHC 6.10.4, I >> always get an error when updating the package list: >> >> > cabal update >> Downloading the latest package list from hackage.haskell.org >> cabal: Codec.Compression.Zlib: premature end of compressed stream >> >> Is there a way to fix this without rebuilding from the latest darcs repo? >> > > Does removing ~/.cabal/packages/hackage.haskell.org/00-index.tar.gz > help? Did you overwrite your old cabal-binary. If not, does this binary > also fail? > Removing this file doesn't help. The old version was cabal-install-0.6.2 + Cabal-1.6.0.2 with GHC 6.10.3. I deleted it because I changed to GHC 6.10.4, but it worked fine 2 days ago. > (I think everything under ~/.cabal/packages/hackage.haskell.org can be > savely deleted and will be downloaded again if needed.) > > Which architecture you're on? > Windows XP Best wishes, Maciej > Cheers Christian > > >> Best wishes, >> >> Maciej >> > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-caf From maciej.podgurski at googlemail.com Fri Feb 19 08:44:27 2010 From: maciej.podgurski at googlemail.com (Maciej Podgurski) Date: Fri Feb 19 08:15:16 2010 Subject: [Haskell-cafe] Cabal update problem In-Reply-To: References: <4B7E743A.5050908@googlemail.com> Message-ID: <4B7E95BB.2000803@googlemail.com> Am 19.02.2010 13:55 schrieb Valery V. Vorotyntsev: >> after updating to cabal-install-0.8.0/Cabal-1.8.0.2 with GHC 6.10.4, I >> always get an error when updating the package list: >> >> > cabal update >> Downloading the latest package list from hackage.haskell.org >> cabal: Codec.Compression.Zlib: premature end of compressed stream >> > > Would you please send the output of `cabal update -v3' command? > > Downloading the latest package list from hackage.haskell.org Sending: GET /packages/archive/00-index.tar.gz HTTP/1.1 Host: hackage.haskell.org User-Agent: cabal-install/0.8.0 Creating new connection to hackage.haskell.org Received: HTTP/1.1 200 OK Date: Fri, 19 Feb 2010 13:28:11 GMT Server: Apache/2.2.9 (Debian) mod_python/3.3.1 Python/2.5.2 Last-Modified: Fri, 19 Feb 2010 11:18:51 GMT ETag: "1bda0c4-167869-47ff23f7fdcc0" Accept-Ranges: bytes Content-Length: 1472617 Content-Type: application/x-tar Content-Encoding: x-gzip Downloaded to C:\Dokumente und Einstellungen\Maciej\Anwendungsdaten\cabal\packages\hackage.haskell.org\00-index.tar.gz cabal: Codec.Compression.Zlib: premature end of compressed stream Best wishes, Maciej From daniel.is.fischer at web.de Fri Feb 19 09:03:16 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Fri Feb 19 08:35:54 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <4B7DE001.4010007@t-online.de> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <201002182020.49657.daniel.is.fischer@web.de> <4B7DE001.4010007@t-online.de> Message-ID: <201002191503.16350.daniel.is.fischer@web.de> Am Freitag 19 Februar 2010 01:49:05 schrieb Nick Rudnick: > Daniel Fischer wrote: > > Am Donnerstag 18 Februar 2010 19:19:36 schrieb Nick Rudnick: > >> Hi Hans, > >> > >> agreed, but, in my eyes, you directly point to the problem: > >> > >> * doesn't this just delegate the problem to the topic of limit > >> operations, i.e., in how far is the term ?closed? here more > >> perspicuous? > > > > It's fairly natural in German, abgeschlossen: closed, finished, > > complete; offen: open, ongoing. > > > >> * that's (for a very simple concept) > > > > That concept (open and closed sets, topology more generally) is *not* > > very simple. It has many surprising aspects. > > ?concept? is a word of many meanings; to become more specific: Its > *definition* is... > It isn't. You can make it look simple (Given a topology T, a set V is called "open in T", if V is an element of T.) by moving all of the difficult parts to the other definitions, but the entire group of definitions contains a nontrivial amount of difficulties (I've seen fairly bright students take a couple of weeks to wrap their head well around it, even though they've been familiar with the stuff in the context of euclidean space.). > >> the way that maths prescribes: > >> + historical background: ?I take "closed" as coming from being closed > >> under limit operations - the origin from analysis.? > >> + definition backtracking: ?A closure operation c is defined by the > >> property c(c(x)) = c(x). > > > > Actually, that's incomplete, missing are > > - c(x) contains x > > - c(x) is minimal among the sets containing x with y = c(y). > > Even more workload to master... This strengthens the thesis that > definition recognition requires a considerable amount of one's effort... > I don't know what "recognition" should mean here, but certainly, understanding a definition, its (near but not trivial) consequences and its purpose requires considerable effort. Especially if it's an abstract and very general definition. > >> If one takes c(X) = the set of limit points of > > > > Not limit points, "Ber?hrpunkte" (touching points). > > > >> X, then it is the smallest closed set under this operation. The > >> closed sets X are those that satisfy c(X) = X. Naming the complements > >> of the closed sets open might have been introduced as an opposite of > >> closed.? > >> > >> 418 bytes in my file system... how many in my brain...? Is it > >> efficient, inevitable? The most fundamentalist justification I heard > >> in this regard is: ?It keeps people off from thinking the could go > >> without the definition...? Meanwhile, we backtrack definition trees > >> filling books, no, even more... In my eyes, this comes equal to > >> claiming: ?You have nothing to understand this beyond the provided > >> authoritative definitions -- your understanding is done by strictly > >> following these.? > > > > But you can't understand it except by familiarising yourself with the > > definitions and investigating their consequences. > > The name of a concept can only help you remembering what the > > definition was. Choosing "obvious" names tends to be misleading, > > because there usually are things satisfying the definition which do > > not behave like the "obvious" name implies. > > So if you state that the used definitions are completely unpredictable I don't. > so that they have to be studied completely Many definitions contain details which you probably wouldn't think about before you've banged your head against a wall very hard several times because you didn't know such details even existed. If you decide to ignore the hard work and experience that have gone into the carefully crafted definitions, you are bound to make the same mistakes, run up the same blind alleys as those who have shaped the definition to what it now is. > -- which already ignores that human brain is an analogous ?machine? --, What is an "analogous machine", and why would such a machine not be suitable for studying definitions? > you, by information theory, > imply that these definitions are somewhat arbitrary, don't you? In a sense, of course the definitions are completely arbitrary. You could go ahead and define whatever you wish. But of course, some definitions are more useful than others, so the definitions in use aren't very arbitrary, they're mostly the ones determined to be most useful. The names given to the defined concepts are more arbitrary. You could call an open set a Pangalactic Gargleblaster and a closed set a Ravenous Bugblatter Beast of Traal. Mathematically, it would make no difference. It would just be harder to remember which was which. A good name invokes enough imagery to remind the hearer/reader what the definition was [not the details, but the general idea], but not so much as to give false ideas about the consequences of the definition. > This in > my eyes would contradict the concept such definition systems have about > themselves. > > To my best knowledge it is one of the best known characteristics of > category theory that it revealed in how many cases maths is a repetition > of certain patterns. Backwards. Category Theory is a product of the realisation how often certain patterns appear in different guise in different parts of mathematics. Of course, once started, it revealed many more. > Speaking categorically it is good practice to > transfer knowledge from on domain to another, once the required > isomorphisms could be established. This way, category theory itself has > successfully torn down borders between several subdisciplines of maths > and beyond. > > I just propose to expand the same to common sense matters... > > >> Back to the case of open/closed, given we have an idea about sets -- > >> we in most cases are able to derive the concept of two disjunct sets > >> facing each other ourselves, don't we? The only lore missing is just > >> a Bool: Which term fits which idea? With a reliable terminology using > >> ?bordered/unbordered?, there is no ambiguity, and we can pass on > >> reading, without any additional effort. > > > > And we'd be very wrong. There are sets which are simultaneously open > > and closed. It is bad enough with the terminology as is, throwing in > > the boundary (which is an even more difficult concept than > > open/closed) would only make things worse. > > Really? As ?open == not closed? can similarly be implied, > bordered/unbordered even in this concern remains at least equal... > I'm not saying current terminology is optimal - it isn't. But to replace established terminology, the proposed replacement should be clearly superior. I don't think bordered/unbordered fits that criterion (especially, since the topologigal term is boundary, not border). > >> Picking such an opportunity thus may save a lot of time and even > >> error -- allowing you to utilize your individual knowledge and > >> experience. I > > > > When learning a formal theory, individual knowledge and experience > > (except coming from similar enough disciplines) tend to be misleading > > more than helpful. > > Why does the opposite work well for computing science? Does it? > > All the best, > > Nick To you too, Daniel From lobachev at Mathematik.Uni-Marburg.de Fri Feb 19 09:23:35 2010 From: lobachev at Mathematik.Uni-Marburg.de (Oleg Lobachev) Date: Fri Feb 19 08:54:21 2010 Subject: [Haskell-cafe] Re: Cabal broken on Mac OS X? In-Reply-To: <4B7E778F.8000505@dfki.de> References: <4B7E778F.8000505@dfki.de> Message-ID: <8A07BE66-2908-4146-8B85-4A0E596830ED@Mathematik.Uni-Marburg.de> Hello, On Feb 19, 2010, at 12:35 , Christian Maeder wrote: >> I suspect that it's me and not the cabal, but everything looks fine and still fails. Would someone mind to tell me, what am I doing wrong? >> >> $ cabal -V >> cabal-install version 0.6.2 >> using version 1.6.0.3 of the Cabal library > > This version of cabal cannot handle ghc-6.12.1 packages. > You need (to hand-install) cabal-install-0.8.0 for ghc-6.12.1 first. > (There is no haskell-platform for ghc-6.12.1, yet) Ok, thank you. The following is for people having the same problem. I ended headshooting both GHC versions. Then I installed the latest Haskell Platform with GHC-6.10.4. With it cabal works and can be updated. Still, the automagically installed version of cabal is not the newest. But one can use http://hackage.haskell.org/packages/archive/cabal-install/0.8.0/cabal-install-0.8.0.tar.gz to build the latest one. (Actually, I merely wanted to try Agda...) Greetings, Oleg From Christian.Maeder at dfki.de Fri Feb 19 09:29:53 2010 From: Christian.Maeder at dfki.de (Christian Maeder) Date: Fri Feb 19 09:00:34 2010 Subject: [Haskell-cafe] Re: Cabal update problem In-Reply-To: <4B7E9521.6030007@googlemail.com> References: <4B7E743A.5050908@googlemail.com> <4B7E7C9A.1050004@dfki.de> <4B7E9521.6030007@googlemail.com> Message-ID: <4B7EA061.5090305@dfki.de> Sorry, I've got no further idea (except reinstalling everything). http://hackage.haskell.org/trac/hackage/ticket/562 may be related. Did your installation of cabal-install-0.8.0 also reinstall HTTP and zlib packages? Good luck Christian Maciej Podgurski schrieb: > Am 19.02.2010 12:57 schrieb Christian Maeder: >> Maciej Podgurski schrieb: >> >>> Hi, >>> >>> after updating to cabal-install-0.8.0/Cabal-1.8.0.2 with GHC 6.10.4, I >>> always get an error when updating the package list: >>> >>> > cabal update >>> Downloading the latest package list from hackage.haskell.org >>> cabal: Codec.Compression.Zlib: premature end of compressed stream >>> >>> Is there a way to fix this without rebuilding from the latest darcs >>> repo? >>> >> >> Does removing ~/.cabal/packages/hackage.haskell.org/00-index.tar.gz >> help? Did you overwrite your old cabal-binary. If not, does this binary >> also fail? >> > > Removing this file doesn't help. The old version was cabal-install-0.6.2 > + Cabal-1.6.0.2 with GHC 6.10.3. I deleted it because I changed to GHC > 6.10.4, but it worked fine 2 days ago. > >> (I think everything under ~/.cabal/packages/hackage.haskell.org can be >> savely deleted and will be downloaded again if needed.) >> >> Which architecture you're on? >> > > Windows XP > > > Best wishes, > > Maciej > >> Cheers Christian >> >> >>> Best wishes, >>> >>> Maciej >>> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-caf > From daniel.is.fischer at web.de Fri Feb 19 09:33:36 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Fri Feb 19 09:06:14 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <4B7DEE0B.7050309@t-online.de> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <201002182031.03105.daniel.is.fischer@web.de> <4B7DEE0B.7050309@t-online.de> Message-ID: <201002191533.36847.daniel.is.fischer@web.de> Am Freitag 19 Februar 2010 02:48:59 schrieb Nick Rudnick: > Hi, > > wow, a topic specific response, at last... But I wish you would be more > specific... ;-) > > >> A *referrer* (object) refers to a *referee* (object) by a *reference* > >> (arrow). > > > > Doesn't work for me. Not in Ens (sets, maps), Grp (groups, > > homomorphisms), Top (topological spaces, continuous mappings), Diff > > (differential manifolds, smooth mappings), ... . > > Why not begin with SET and functions... Sorry, too many Bourbakists in my ancestry, Ens == SET (french: ensemble). > > Every human has a certain age, so that there is a function, ageOf:: > Human-> Int, which can be regarded as a certain way of a reference > relationship between Human and Int, in that by agoOf, I fail to see a reference here. In particular, I don't see how the one object (set of humans) refers to the other object (set of integers). I suppose the word reference doesn't mean the same for us. For me, a reference is an alias (as in e.g. Java's reference types) or a mention/allusion/citation (as in e.g. "The first verse of this poem is a reference to Macbeth's famous monologue 'Is this a dagger ...'"), a couple of other things I can't now put into english words. None of which I deem similar to a function from one set to another. > > * Int reflects a certain aspect of Human, Okay. > and, on the other hand, > * the structure of Human can be traced to Int. I don't understand that. > > Please tell me the aspect you feel uneasy with, and please give me your > opinion, whether (in case of accepting this) you would rather choose to > consider Human as referrer and Int as referee of the opposite -- for I > think this is a deep question. > > Thank you in advance, > > Nick From maciej.podgurski at googlemail.com Fri Feb 19 10:11:33 2010 From: maciej.podgurski at googlemail.com (Maciej Podgurski) Date: Fri Feb 19 09:42:20 2010 Subject: [Haskell-cafe] Re: Cabal update problem In-Reply-To: <4B7EA061.5090305@dfki.de> References: <4B7E743A.5050908@googlemail.com> <4B7E7C9A.1050004@dfki.de> <4B7E9521.6030007@googlemail.com> <4B7EA061.5090305@dfki.de> Message-ID: <4B7EAA25.1080602@googlemail.com> Am 19.02.2010 15:29 schrieb Christian Maeder: > Sorry, I've got no further idea (except reinstalling everything). > > http://hackage.haskell.org/trac/hackage/ticket/562 > may be related. > > Did your installation of cabal-install-0.8.0 also reinstall HTTP and > zlib packages? > Yes, I installed the latest versions of that packages. Now I tried to gradually go back to the versions before (HTTP-4000.0.9 to 4000.0.7 and zlib-0.5.2.0 to 0.5.0.0), without any success. Finally cabal-install made it at version 0.6.2, so the problem really seems to be at cabal-install-0.8.0. > Good luck > Christian > > Maciej Podgurski schrieb: > >> Am 19.02.2010 12:57 schrieb Christian Maeder: >> >>> Maciej Podgurski schrieb: >>> >>> >>>> Hi, >>>> >>>> after updating to cabal-install-0.8.0/Cabal-1.8.0.2 with GHC 6.10.4, I >>>> always get an error when updating the package list: >>>> >>>> > cabal update >>>> Downloading the latest package list from hackage.haskell.org >>>> cabal: Codec.Compression.Zlib: premature end of compressed stream >>>> >>>> Is there a way to fix this without rebuilding from the latest darcs >>>> repo? >>>> >>>> >>> Does removing ~/.cabal/packages/hackage.haskell.org/00-index.tar.gz >>> help? Did you overwrite your old cabal-binary. If not, does this binary >>> also fail? >>> >>> >> Removing this file doesn't help. The old version was cabal-install-0.6.2 >> + Cabal-1.6.0.2 with GHC 6.10.3. I deleted it because I changed to GHC >> 6.10.4, but it worked fine 2 days ago. >> >> >>> (I think everything under ~/.cabal/packages/hackage.haskell.org can be >>> savely deleted and will be downloaded again if needed.) >>> >>> Which architecture you're on? >>> >>> >> Windows XP >> >> >> Best wishes, >> >> Maciej >> >> >>> Cheers Christian >>> >>> >>> >>>> Best wishes, >>>> >>>> Maciej >>>> >>>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-caf >>> From nenekotan at gmail.com Fri Feb 19 10:50:54 2010 From: nenekotan at gmail.com (Bas van Gijzel) Date: Fri Feb 19 10:21:37 2010 Subject: [Haskell-cafe] Re: Cabal update problem In-Reply-To: <4B7EAA25.1080602@googlemail.com> References: <4B7E743A.5050908@googlemail.com> <4B7E7C9A.1050004@dfki.de> <4B7E9521.6030007@googlemail.com> <4B7EA061.5090305@dfki.de> <4B7EAA25.1080602@googlemail.com> Message-ID: I had the same problem on Windows XP when doing cabal install cabal-install. I fixed it by just replacing the cabal-install executable by the old one used in the haskell platform. Cheers, Bas On 19 February 2010 16:11, Maciej Podgurski wrote: > Am 19.02.2010 15:29 schrieb Christian Maeder: > > Sorry, I've got no further idea (except reinstalling everything). >> >> http://hackage.haskell.org/trac/hackage/ticket/562 >> may be related. >> >> Did your installation of cabal-install-0.8.0 also reinstall HTTP and >> zlib packages? >> >> > > Yes, I installed the latest versions of that packages. Now I tried to > gradually go back to the versions before (HTTP-4000.0.9 to 4000.0.7 and > zlib-0.5.2.0 to 0.5.0.0), without any success. Finally cabal-install made it > at version 0.6.2, so the problem really seems to be at cabal-install-0.8.0. > > > Good luck >> Christian >> >> Maciej Podgurski schrieb: >> >> >>> Am 19.02.2010 12:57 schrieb Christian Maeder: >>> >>> >>>> Maciej Podgurski schrieb: >>>> >>>> >>>>> Hi, >>>>> >>>>> after updating to cabal-install-0.8.0/Cabal-1.8.0.2 with GHC 6.10.4, I >>>>> always get an error when updating the package list: >>>>> >>>>> > cabal update >>>>> Downloading the latest package list from hackage.haskell.org >>>>> cabal: Codec.Compression.Zlib: premature end of compressed stream >>>>> >>>>> Is there a way to fix this without rebuilding from the latest darcs >>>>> repo? >>>>> >>>>> >>>> Does removing ~/.cabal/packages/hackage.haskell.org/00-index.tar.gz >>>> help? Did you overwrite your old cabal-binary. If not, does this binary >>>> also fail? >>>> >>>> >>> Removing this file doesn't help. The old version was cabal-install-0.6.2 >>> + Cabal-1.6.0.2 with GHC 6.10.3. I deleted it because I changed to GHC >>> 6.10.4, but it worked fine 2 days ago. >>> >>> >>> >>>> (I think everything under ~/.cabal/packages/hackage.haskell.org can be >>>> savely deleted and will be downloaded again if needed.) >>>> >>>> Which architecture you're on? >>>> >>>> >>> Windows XP >>> >>> >>> Best wishes, >>> >>> Maciej >>> >>> >>> >>>> Cheers Christian >>>> >>>> >>>> >>>>> Best wishes, >>>>> >>>>> Maciej >>>>> >>>>> >>>> _______________________________________________ >>>> Haskell-Cafe mailing list >>>> Haskell-Cafe@haskell.org >>>> http://www.haskell.org/mailman/listinfo/haskell-caf >>>> >>>> >>> _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- http://adoseoflogic.blogspot.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100219/b02a2a57/attachment.html From maciej.podgurski at googlemail.com Fri Feb 19 11:15:56 2010 From: maciej.podgurski at googlemail.com (Maciej Podgurski) Date: Fri Feb 19 10:46:47 2010 Subject: [Haskell-cafe] Re: Cabal update problem In-Reply-To: References: <4B7E743A.5050908@googlemail.com> <4B7E7C9A.1050004@dfki.de> <4B7E9521.6030007@googlemail.com> <4B7EA061.5090305@dfki.de> <4B7EAA25.1080602@googlemail.com> Message-ID: <4B7EB93C.8090408@googlemail.com> But the platform only includes cabal-install-0.6.2. My intention was getting the merge-all-package-documentation-into-single-html feature :-) Best wishes, Maciej Am 19.02.2010 16:50 schrieb Bas van Gijzel: > I had the same problem on Windows XP when doing cabal install cabal-install. > I fixed it by just replacing the cabal-install executable by the old one > used in the haskell platform. > > Cheers, > > Bas > > On 19 February 2010 16:11, Maciej Podgurski > wrote: > >> Am 19.02.2010 15:29 schrieb Christian Maeder: >> >> Sorry, I've got no further idea (except reinstalling everything). >>> http://hackage.haskell.org/trac/hackage/ticket/562 >>> may be related. >>> >>> Did your installation of cabal-install-0.8.0 also reinstall HTTP and >>> zlib packages? >>> >>> >> Yes, I installed the latest versions of that packages. Now I tried to >> gradually go back to the versions before (HTTP-4000.0.9 to 4000.0.7 and >> zlib-0.5.2.0 to 0.5.0.0), without any success. Finally cabal-install made it >> at version 0.6.2, so the problem really seems to be at cabal-install-0.8.0. >> >> >> Good luck >>> Christian >>> >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > > From d.kahlenberg at googlemail.com Fri Feb 19 12:18:36 2010 From: d.kahlenberg at googlemail.com (Daniel Kahlenberg) Date: Fri Feb 19 11:49:24 2010 Subject: [Haskell-cafe] Re: Cabal update problem In-Reply-To: <4B7EB93C.8090408@googlemail.com> References: <4B7E743A.5050908@googlemail.com> <4B7E7C9A.1050004@dfki.de> <4B7E9521.6030007@googlemail.com> <4B7EA061.5090305@dfki.de> <4B7EAA25.1080602@googlemail.com> <4B7EB93C.8090408@googlemail.com> Message-ID: <4B7EC7EC.4070005@googlemail.com> Hello, I guess I did the follwoing to bypass this problems. With the platform provided* cabal.exe at first place in the PATH variable, I run: - cabal update - cabal install cabal-install-0.6.4 The only thing remaining was, I had the Cabal-1.8.0.2 and related entries in my local package.conf file then, from the former installation of cabal-install-0.8.0 - which failed when doing `cabal update` as you described. I decided to remove those entries/packages, although they seemed to cause no issues, when blindly testing some package installations with cabal-install-0.6.4. Cheers Daniel * folder %HASKELL_PLATFORM%\extralibs\bin Am 19.02.2010 17:15, schrieb Maciej Podgurski: > But the platform only includes cabal-install-0.6.2. My intention was > getting the merge-all-package-documentation-into-single-html feature :-) > > > Best wishes, > > Maciej > > > Am 19.02.2010 16:50 schrieb Bas van Gijzel: >> I had the same problem on Windows XP when doing cabal install >> cabal-install. >> I fixed it by just replacing the cabal-install executable by the old one >> used in the haskell platform. >> >> Cheers, >> >> Bas >> >> On 19 February 2010 16:11, Maciej Podgurski >> >> wrote: >> >>> Am 19.02.2010 15:29 schrieb Christian Maeder: >>> >>> Sorry, I've got no further idea (except reinstalling everything). >>>> http://hackage.haskell.org/trac/hackage/ticket/562 >>>> may be related. >>>> >>>> Did your installation of cabal-install-0.8.0 also reinstall HTTP and >>>> zlib packages? >>>> >>>> >>> Yes, I installed the latest versions of that packages. Now I tried to >>> gradually go back to the versions before (HTTP-4000.0.9 to 4000.0.7 and >>> zlib-0.5.2.0 to 0.5.0.0), without any success. Finally cabal-install >>> made it >>> at version 0.6.2, so the problem really seems to be at >>> cabal-install-0.8.0. >>> >>> >>> Good luck >>>> Christian >>>> >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >> >> >> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From jeremy at n-heptane.com Fri Feb 19 13:12:54 2010 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Fri Feb 19 12:43:35 2010 Subject: [Haskell-cafe] sendfile leaking descriptors on Linux? In-Reply-To: References: Message-ID: Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: Server.hs Type: text/x-haskell Size: 1261 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100219/d8ef03f4/Server.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: client.c Type: text/x-csrc Size: 1414 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100219/d8ef03f4/client.bin From benjamin.franksen at bessy.de Fri Feb 19 13:49:26 2010 From: benjamin.franksen at bessy.de (Ben Franksen) Date: Fri Feb 19 13:20:29 2010 Subject: [Haskell-cafe] Re: darcs 2.4 release candidate 2 References: <201002182214.21113.tux_rocker@reinier.de> Message-ID: Hi All This rc release is still notably slower on some operations than older releases. My test case is a large project named RTEMS (a real-time OS), that we wish to import into darcs (at work) to better track our own additions and modifications. To repeat, download two adjacent releases, e.g. wget http://www.rtems.org/ftp/pub/rtems/4.9.0/rtems-4.8.1.tar.bz2 wget http://www.rtems.org/ftp/pub/rtems/4.9.0/rtems-4.9.0.tar.bz2 unpack, initialize darcs and record in the 4.8.1 tree, then copy _darcs to the 4.9.0 version and try to record -l or whatsnew -l. I have two darcs versions installed: ben@sarun[1]: .../rtems/rtems-4.9.0 > /usr/local/bin/darcs --version 2.2.1 (release) ben@sarun[1]: .../rtems/rtems-4.9.0 > darcs --version 2.3.99.2 (release candidate 2) ben@sarun[1]: .../rtems/rtems-4.9.0 > time /usr/local/bin/darcs whatsnew -l # ...long output elided... /usr/local/bin/darcs whatsnew -l 381,45s user 6,34s system 92% cpu 7:00,90 total whereas with 2.3.99.2 it goes ben@sarun[1]: .../rtems/rtems-4.9.0 > time darcs whatsnew -l Well, it is still running after 18 minutes! Top reports something like PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 5702 ben 20 0 1112m 933m 3628 R 92.2 28.3 18:26.08 darcs One point to notice is that 2.3.99.2 has not yet reported any progress, whereas 2.2.1 almost immediately starts reporting something about pristine trees followed by the usual number/number stuff; and the numbers continually rise. The situation with record is similar. I admit that the huge RTEMS tree with over 7000 changes between the two releases is challenging. However, earlier releases can do it (though it takes long, much longer than with, say, mercurial). At work I tried it with 2.3.1 (on a fast 4 processor machine) and it recorded all the changes in about one minute. I think this regression should be fixed before 2.4 is released. Cheers Ben Reinier Lamers wrote: > The darcs team would like to announce the immediate availability of darcs > 2.4 release candidate 2. darcs 2.4 will contain many improvements and > bugfixes compared to darcs 2.3.1. Highlights are the faster operation of > record, revert and related commands, and the experimental interactive hunk > editing. This beta is your chance to test-drive these improvements and > make darcs even better. From benjamin.franksen at bessy.de Fri Feb 19 14:14:18 2010 From: benjamin.franksen at bessy.de (Ben Franksen) Date: Fri Feb 19 13:45:24 2010 Subject: [Haskell-cafe] Re: darcs 2.4 release candidate 2 References: <201002182214.21113.tux_rocker@reinier.de> Message-ID: Ben Franksen wrote: > ben@sarun[1]: .../rtems/rtems-4.9.0 > time darcs whatsnew -l > > Well, it is still running after 18 minutes! Top reports something like > > PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND > 5702 ben 20 0 1112m 933m 3628 R 92.2 28.3 18:26.08 darcs FYI, I finally killed it: ben@sarun[1]: .../rtems/rtems-4.9.0 > time darcs whatsnew -l withSignalsHandled: Interrupted! darcs whatsnew -l 2307,92s user 17,33s system 88% cpu 43:49,89 total Cheers Ben From benjamin.franksen at bessy.de Fri Feb 19 15:45:59 2010 From: benjamin.franksen at bessy.de (Ben Franksen) Date: Fri Feb 19 15:17:08 2010 Subject: [Haskell-cafe] Re: darcs 2.4 release candidate 2 References: <201002182214.21113.tux_rocker@reinier.de> Message-ID: Ben Franksen wrote: > ben@sarun[1]: .../rtems/rtems-4.9.0 > /usr/local/bin/darcs --version > 2.2.1 (release) > ben@sarun[1]: .../rtems/rtems-4.9.0 > time /usr/local/bin/darcs whatsnew > -l > # ...long output elided... > /usr/local/bin/darcs whatsnew -l 381,45s user 6,34s system 92% cpu > 7:00,90 total Just installed 2.3.1 and tried the same: ben@sarun[1]: .../rtems/rtems-4.9.0 > darcs --version 2.3.1 (release) ben@sarun[1]: .../rtems/rtems-4.9.0 > time darcs whatsnew -l # ...long output elided... darcs whatsnew -l 239,41s user 4,74s system 85% cpu 4:44,33 total Note the differences in user and system time. Darcs-2.3.1 is indeed faster than 2.2.1 (but you already knew that). Cheers Ben From alexey.skladnoy at gmail.com Fri Feb 19 16:09:18 2010 From: alexey.skladnoy at gmail.com (Khudyakov Alexey) Date: Fri Feb 19 15:38:43 2010 Subject: [Haskell-cafe] fast, strongly typed heterogeneous collections In-Reply-To: <600376291002190420l7abcf646xd8b7cbc3858d4214@mail.gmail.com> References: <600376291002190420l7abcf646xd8b7cbc3858d4214@mail.gmail.com> Message-ID: <201002200009.18868.alexey.skladnoy@gmail.com> ? ????????? ?? 19 ??????? 2010 15:20:30 Serguey Zefirov ???????: > > And, actually, what looks like O(n) at the compile time is O(1) at > runtime. This is so because it is really hard to create types at > runtime. ;) What did you mean by "really hard"? One have to use black magic and ask demons for help or possible but very difficult. From benjovi at gmx.net Fri Feb 19 16:19:41 2010 From: benjovi at gmx.net (Benedikt Huber) Date: Fri Feb 19 15:50:30 2010 Subject: [Haskell-cafe] Re: fast, strongly typed heterogeneous collections In-Reply-To: References: Message-ID: <4B7F006D.90003@gmx.net> Alberto G. Corona schrieb: > Hi > > What is the speed of hProjectByLabel/s in Data.HList.Record? . The > documentation in hackage > does > not mention it. Perhaps this is because Hlist is designed for supposedly > short records and this does not matter too much. > looking at the code I guess that everything in HList is O(n) because it > uses type-level list structure, but I think that nothing prevents from > using a type level balanced tree, Data.Map style, instead. > > This would permit to implement large heterogeneous Maps with fast access > and strongly typed. AFAIK, the alternative is to use a fast data > container with data elements encapsulated within Data.Dynamic, that is > weakly typed, produces type errors at runtime, which is unsatisfactory > and dangerous. > > > Any comments? Hi Alberto, I think this idea isn't unreasonable, and I am curious whether it would pay off in practice. I think you are right with your O(n) guess for the standard HList implementation. Rebalancing the trees at the type level and mirroring the rebalancing efficiently at the term level could be a little bit tricky though. Btw, I found type-level functions to be more comfortable than type classes when playing with heterogenous lists. cheers, benedikt > > > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From perikov at gmail.com Fri Feb 19 16:26:42 2010 From: perikov at gmail.com (Pavel Perikov) Date: Fri Feb 19 15:57:26 2010 Subject: [Haskell-cafe] Scarry parallel garbage collection behavior (6.12.1, Mac OSX) Message-ID: <42C6FD61-DDAA-49E1-A798-24A06D02BFE5@gmail.com> Hi, list. This is a long post, sorry. The bottom line: specifying +RTS -Nn where n > number of cores slows the program compiled with 6.12.1 by orders of magnitude under Mac OSX. Turning off parallel garbage collections with -qg resolves the problem. Independent verification is appreciated. I have a very simple program: import Control.Parallel main=do let s = s1 `par` ( s2 `pseq` s1 + s2) s1 = sum [1..10000000] s2 = sum [1..10000005] print s compiled with ghc -O -threaded running it with without any options time ./clocktime produces the following times: real 0m3.779s user 0m3.644s sys 0m0.053s Giving -N option to RTS (or -N2, I have two core macbook) shows decent speedup: 100000060000015 real 0m2.678s user 0m4.762s sys 0m0.043s though increase in processor time by 30% seems suspicious. Things become weird if I increase the number of threads. I couldn't expect any further speedup for this task but what I get is absolutely unexpected: time ./clocktime +RTS -N3 100000060000015 real 0m57.071s user 1m40.910s sys 0m0.921s Almost a minute!! Adding more threads does not help either :) time ./clocktime +RTS -N4 100000060000015 real 1m48.281s user 3m10.832s sys 0m1.590s A bit of playing with Instruments/DTrace shows that runaway garbage collection puts the program on its knees. I the case of -N1 the top time consumers look like this: Self % Total % Self Run % Running % # Self # Samples ms Self Run ms Running Parent % Library Source Path Symbol Name 12.8 12.8 408 clocktime __gmpz_add 10.7 10.7 341 clocktime integer_cmm_plusIntegerzh 10 10 321 clocktime allocateLocal etc. This looks absolutely reasonable. Going to -N2 changes the picture to: Self % Total % Self Run % Running % # Self # Samples ms Self Run ms Running Parent % Library Source Path Symbol Name 15.6 15.6 989 clocktime gcWorkerThread 11.6 11.6 736 clocktime waitForGcThreads 9.5 9.5 603 clocktime scavenge_until_all_done 7.4 7.4 471 clocktime setContextSwitches 6.2 6.2 396 clocktime __gmpz_add -N3 Is awful: Self % Total % Self Run % Running % # Self # Samples ms Self Run ms Running Parent % Library Source Path Symbol Name 51.7 51.7 29514 clocktime gcWorkerThread 25.5 25.5 14591 clocktime scavenge_until_all_done 7.2 7.2 4114 clocktime waitForGcThreads 5.5 5.5 3180 clocktime GarbageCollect 5.2 5.2 2998 clocktime setContextSwitches 0.4 0.4 240 clocktime integer_cmm_plusIntegerzh Pavel From sergueyz at gmail.com Fri Feb 19 16:40:15 2010 From: sergueyz at gmail.com (Serguey Zefirov) Date: Fri Feb 19 16:10:55 2010 Subject: [Haskell-cafe] fast, strongly typed heterogeneous collections In-Reply-To: <201002200009.18868.alexey.skladnoy@gmail.com> References: <600376291002190420l7abcf646xd8b7cbc3858d4214@mail.gmail.com> <201002200009.18868.alexey.skladnoy@gmail.com> Message-ID: <600376291002191340p49b7cd41j6227fa406a7ae9f2@mail.gmail.com> 2010/2/19 Khudyakov Alexey : >> And, actually, what looks like O(n) at the compile time is O(1) at >> runtime. This is so because it is really hard to create types at >> runtime. ;) > > What did you mean by "really hard"? One have to use black magic and ask demons > for help or possible but very difficult. You could create only certain kind of types in runtime< ones like Peano numbers. I think that complexity of creating, managing and using those numbers (or trees) in runtime with strong type checking at compile time obviously makes creating types at runtime very hard. At least it isn't convenient. From paul at cogito.org.uk Fri Feb 19 17:20:55 2010 From: paul at cogito.org.uk (Paul Johnson) Date: Fri Feb 19 16:51:40 2010 Subject: [Haskell-cafe] What happened in Ohloh? Message-ID: <4B7F0EC7.7010003@cogito.org.uk> If you go to http://www.ohloh.net/languages/compare?l0=haskell&measure=projects and look at the number (not percentage) of Haskell projects you see it rise exponentially until the start of 2008 and then suddenly drop away. Does anyone know what happened? Assuming this is just an artefact because they aren't scanning Haskell project hosts, can we get them to fix it? I'd like to use this kind of graph at work as evidence that Haskell is on a growth trajectory. Paul. From gwern0 at gmail.com Fri Feb 19 17:27:39 2010 From: gwern0 at gmail.com (Gwern Branwen) Date: Fri Feb 19 16:58:19 2010 Subject: [Haskell-cafe] What happened in Ohloh? In-Reply-To: <4B7F0EC7.7010003@cogito.org.uk> References: <4B7F0EC7.7010003@cogito.org.uk> Message-ID: On Fri, Feb 19, 2010 at 5:20 PM, Paul Johnson wrote: > If you go to > http://www.ohloh.net/languages/compare?l0=haskell&measure=projects and look > at the number (not percentage) of Haskell projects you see it rise > exponentially until the start of 2008 and then suddenly drop away. ?Does > anyone know what happened? ?Assuming this is just an artefact because they > aren't scanning Haskell project hosts, can we get them to fix it? I believe in early 2008 Don Stewart was on a kick where he used tailor to convert Darcs repos of Haskell projects to Git repos (which Ohloh understands), and he's stopped doing that. The fix would involve making their software understand darcs; their response hasn't been too enthusiastic or helpful (basically, 'if you guys do all the work and meet our idiosyncratic standards, maybe we'll use it'): http://www.ohloh.net/forums/3491/topics/1138?page=2 > I'd like to use this kind of graph at work as evidence that Haskell is on a > growth trajectory. > > Paul. -- gwern From dons at galois.com Fri Feb 19 17:29:06 2010 From: dons at galois.com (Don Stewart) Date: Fri Feb 19 16:59:50 2010 Subject: [Haskell-cafe] What happened in Ohloh? In-Reply-To: <4B7F0EC7.7010003@cogito.org.uk> References: <4B7F0EC7.7010003@cogito.org.uk> Message-ID: <20100219222906.GA24712@whirlpool.galois.com> paul: > If you go to > http://www.ohloh.net/languages/compare?l0=haskell&measure=projects and > look at the number (not percentage) of Haskell projects you see it rise > exponentially until the start of 2008 and then suddenly drop away. Does > anyone know what happened? Assuming this is just an artefact because > they aren't scanning Haskell project hosts, can we get them to fix it? They aren't scanning darcs repos, and I stopped doing nightly cron job conversions from git to darcs. In that time, the number of haskell projects has grown fairly rapidly: http://galois.com/~dons/images/hackage-daily-graph.png (daily upload moving average). It took off in 2008. -- Don From dons at galois.com Fri Feb 19 17:31:03 2010 From: dons at galois.com (Don Stewart) Date: Fri Feb 19 17:01:47 2010 Subject: [Haskell-cafe] What happened in Ohloh? In-Reply-To: <4B7F0EC7.7010003@cogito.org.uk> References: <4B7F0EC7.7010003@cogito.org.uk> Message-ID: <20100219223103.GB24712@whirlpool.galois.com> paul: > I'd like to use this kind of graph at work as evidence that Haskell is > on a growth trajectory. You might be more interested in data from Hackage: http://www.galois.com/blog/2009/03/23/one-million-haskell-downloads/ runched when we passed the 1M downloads mark a year ago (closer to 2M downloads now). We've also got just shy of 2000 packages on Hackage, up from 1100 a year ago (~3 new packages a day) -- Don From gue.schmidt at web.de Fri Feb 19 21:33:16 2010 From: gue.schmidt at web.de (=?ISO-8859-15?Q?G=FCnther_Schmidt?=) Date: Fri Feb 19 21:04:19 2010 Subject: [Haskell-cafe] Haskell - Heterogeneous Data Structures - Nested Pairs and functional references Message-ID: <4B7F49EC.4030304@web.de> Hallo Heinrich, entschuldige bitte wenn ich Dich ausserhalb der Cafe-Liste kontaktiere, aber so langsam wird's mir peinlich.... Auf meinen Post "Heterogeneous Data Structures - Nested Pairs and functional references" vom 16.02.2010 in der Cafe-Liste habe ich eine interessante Antwort erhalten von Alexander Solla, die ich nicht verstanden haben. Als ich nachgehakt habe, hat er freundlicherweise sofort eine Antwort geliefert die ich noch weniger verstanden habe ... Jetzt trau' ich mich nicht mehr nochmals zu fragen, denn ich glaube ich w?rd's wieder nicht verstehen. Kannst Du mir vielleicht erkl?ren was er mir da eigentlich geschickt hat? Gr??e G?nther From corentin.dupont at gmail.com Fri Feb 19 22:14:17 2010 From: corentin.dupont at gmail.com (Dupont Corentin) Date: Fri Feb 19 21:44:56 2010 Subject: [Haskell-cafe] games of chance In-Reply-To: References: Message-ID: <18a05e6b1002191914r3d7d7fe6vc2805b0a2c91fe69@mail.gmail.com> Hello, are you aware of a framework to find probabilities in a given game of chance, in Haskell? l would like to compute probabilities like: "roll 3 dices, sum the result, then roll 3 other dices, sum the result, what is the probability to obtain the same sum?" Cheers, Corentin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100219/54db9ffd/attachment.html From mwassell at bigpond.net.au Fri Feb 19 22:26:03 2010 From: mwassell at bigpond.net.au (Mark Wassell) Date: Fri Feb 19 21:56:48 2010 Subject: [Haskell-cafe] games of chance In-Reply-To: <18a05e6b1002191914r3d7d7fe6vc2805b0a2c91fe69@mail.gmail.com> References: <18a05e6b1002191914r3d7d7fe6vc2805b0a2c91fe69@mail.gmail.com> Message-ID: <4B7F564B.1060901@bigpond.net.au> Take a look at: http://hackage.haskell.org/package/probability and http://web.engr.oregonstate.edu/~erwig/pfp/ Mark Dupont Corentin wrote: > > Hello, > are you aware of a framework to find probabilities in a given game of > chance, in Haskell? > > l would like to compute probabilities like: > "roll 3 dices, sum the result, then roll 3 other dices, sum the result, > what is the probability to obtain the same sum?" > > Cheers, > Corentin > > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From wren at freegeek.org Fri Feb 19 23:42:03 2010 From: wren at freegeek.org (wren ng thornton) Date: Fri Feb 19 23:04:46 2010 Subject: [Haskell-cafe] Pointfree composition for higher arity In-Reply-To: <3c6288ab1002170731m1661c479r936f3e5b5ff8d89d@mail.gmail.com> References: <3c6288ab1002170731m1661c479r936f3e5b5ff8d89d@mail.gmail.com> Message-ID: <4B7F681B.1090302@freegeek.org> Sean Leather wrote: > The second option approaches the ideal pointfreeness (or pointlessness if > you prefer), but I'd like to go farther: > > (...) :: (c -> d) -> (a -> b -> c) -> a -> b -> d >> (...) f g x y = f (g x y) >> infixr 9 ... I go with infixl 8 personally. It seems to play better with some of the other composition combinators. In a somewhat different vein than Oleg's proposed general composition, I've particularly enjoyed Matt Hellige's pointless fun combinators[0]. I have a version which also adds a strict application combinator in my desiderata package[1] so we can say things like: foo $:: bar ~> baz !~> bif which translates to: \a b -> bif (foo (bar a) (baz $! b)) These combinators are especially good when you don't just have a linear chain of functions. [0] http://matt.immute.net/content/pointless-fun [1] http://community.haskell.org/~wren/wren-extras/src/Data/Function/Pointless.hs -- Live well, ~wren From heringtonlacey at mindspring.com Sat Feb 20 03:43:24 2010 From: heringtonlacey at mindspring.com (Dean Herington) Date: Sat Feb 20 03:14:11 2010 Subject: Re[Haskell-cafe] [2]: Threading and FFI In-Reply-To: <27647126.post@talk.nabble.com> References: <27611528.post@talk.nabble.com> <20100216172522.GC6832@kira.casa> <27612884.post@talk.nabble.com> <27613138.post@talk.nabble.com> <27621580.post@talk.nabble.com> <27631980.post@talk.nabble.com> <648858494.20100218094107@gmail.com> <27635260.post@talk.nabble.com> <27647126.post@talk.nabble.com> Message-ID: At 2:53 PM -0800 2/18/10, Yves Par?s wrote: >Ben Franksen wrote: >>You can leave them "unsafe" if you are sure that >> >>1) they do not call (back) any function in your program >>2) they do not block (or not long enough that it bothers you) >> >>Otherwise they are no less safe that the "safe" calls. If (1) is not >>fulfilled bad things might (that is, probably will) happen. Thus, if you >>are not sure, chose "safe". > >Okay. Since I know which functions call back to haskell code and which make >pauses, I know what need to be safe and what can be let safely unsafe (^^). Think of it as "which foreign functions need to be called *safe*ly (because they may call back or block) and which can be called *unsafe*ly (because they don't). > >> Bound thread are ONLY needed if you (that is, some foreign functions >> you use) rely on thread-local storage. > >Yes, but since the main thread (if I understood well) is bound, if I call to >C functions which rely on thread-local storage (like OpenGL functions, >according to GHC Control.Concurrent doc) in this thread I should have no >problem, shouldn't I? >And if I choose to call these functions from outside the main thread it'll >have to be from a thread launched with forkOS? (The C functions I call in my >real code actually use OpenGL internally) Careful. If you're calling foreign functions that rely on thread-local storage, you must call them using the same OS thread (to provide them with the correct thread state), which means using the same, *bound*, Haskell thread. It wouldn't work to call them from both the main Haskell thread and another Haskell thread, even if the latter were a bound thread, as there would be two copies of thread-local storage at play. > >> If runtime is threaded and FFI call is marked safe and Haskell thread is >> unbound, then calls to such a function will be executed from SOME extra OS >> thread that is managed completely behind the scenes. > >Okay, that's what I didn't understand! Only the call to my safe function >will be done in an external bound thread, not the whole thread in which the >call is done. Note that "bound"edness is a property of a Haskell thread, not an OS thread. The phrase "external bound thread" is not sensible. >So, to sum up, my program will run this way (not necessarily in this order): >My main is launched in a bound thread. Yes. >My casual haskell I/O operations (read and print from and to the terminal) >are launched in an unbound thread. This phrasing also seems a bit confused. You may perform Haskell I/O operations in any Haskell thread, and they will be carried out in some OS thread (which one doesn't matter). >Whenever my main thread reaches the call to my safe C function which >'sleeps', it launches it in another bound thread. No. Because the main thread is a bound thread, it carries out all of its foreign calls using the same OS thread. >Am I right or is it no that easy to foresee the behaviour of my program? The existence of both Haskell and OS threads can be confusing. The key is that, to make a foreign call, a Haskell thread needs an OS thread as a vehicle. Normally (that is, when any OS thread will do) the Haskell thread may (and should, for better performance) be unbound. When the OS-defined per-thread state is important, the Haskell thread must be bound so that it always uses the same OS thread (but it's up to you to use the same Haskell thread!). Hope this helps. Dean From uzytkownik2 at gmail.com Sat Feb 20 04:52:10 2010 From: uzytkownik2 at gmail.com (Maciej Piechotka) Date: Sat Feb 20 04:23:00 2010 Subject: [Haskell-cafe] Re: Threading and FFI In-Reply-To: <27611528.post@talk.nabble.com> References: <27611528.post@talk.nabble.com> Message-ID: <1266659529.5427.25.camel@picard> Sorry I start spin-off of thread but all over the haskell code is idiom: throwErrorIfMinus1_ $ someCode args However this code is dependent on errno, which is thread dependent. Is GHC making sure that errno set from C call is propagated back into correct thread? Are there any requirements regarding safeness/unsafeness of such propagation (and if there are shouldn't they be added to various places where it is simply said that safe call simply does not call back into Haskell). Regards -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100220/e8184cc9/attachment.bin From andrewcoppin at btinternet.com Sat Feb 20 05:30:10 2010 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sat Feb 20 05:00:43 2010 Subject: [Haskell-cafe] Computing sums Message-ID: <4B7FB9B2.4060100@btinternet.com> The other day, I found myself writing the following code: data Property x y = forall s. Property s (x -> s -> s) (s -> y) step :: x -> Property x y -> Property x y step x (Property s f g) = Property (f x s) f g read :: Property x y -> y read (Property s _ g) = g s pure :: (x -> y) -> Property x y pure f = Property undefined const f fold :: (x -> y -> y) -> y -> Property x y fold f y = Property y f id fold1 :: (x -> x -> x) -> Property x x fold1 f = Property Nothing (\x mx -> maybe (Just x) (Just . f) mx) fromJust (>==>) :: Property x y -> Property y z -> Property x z p0 >==> p1 = Property (p0,p1) (\x (q0,q1) -> let w0 = step x q0 in (w0, step (read w0) q1)) (\(_,q1) -> (read q1)) (>==<) :: Property x y -> Property x y' -> Property x (y,y') p0 >==< p1 = Property (p0,p1) (\x (q0,q1) -> (step x q0, step x q1)) (\(q0,q1) -> (read q0, read q1)) sum = fold (+) 0 count = pure (const 1) >==> sum minimum = fold1 min maximum = fold1 max Have I just invented arrows? (And if so, why is the above code nowhere to be seen in the libraries?) From lrpalmer at gmail.com Sat Feb 20 05:45:22 2010 From: lrpalmer at gmail.com (Luke Palmer) Date: Sat Feb 20 05:16:00 2010 Subject: [Haskell-cafe] Computing sums In-Reply-To: <4B7FB9B2.4060100@btinternet.com> References: <4B7FB9B2.4060100@btinternet.com> Message-ID: <7ca3f0161002200245w65bac629w1ec00be6b11a6534@mail.gmail.com> On Sat, Feb 20, 2010 at 3:30 AM, Andrew Coppin wrote: > Have I just invented arrows? No... you have a data type which is *an* Arrow (probably/almost). The pure implementation bugs me because of its use of undefined. Might still be okay though. I would be more comfortable if it could not output until it has *some* input; i.e. data Property' a b = forall s. Property' s (a -> s -> (b,s)) Anyway, for yours: try to implement (.) :: Property b c -> Property a b -> Property a c, and first :: Property a b -> Property (a,c) (b,c). Then you will have an arrow. This is a Causal Commutative Arrow, even, similar to the kinds of things that are done in Yampa. It might be more recognizable as the non-recursive version of: newtype Property a b = Property b (a -> Property a b) Luke From andrewcoppin at btinternet.com Sat Feb 20 05:47:30 2010 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sat Feb 20 05:18:01 2010 Subject: [Haskell-cafe] A small oversight Message-ID: <4B7FBDC2.8090606@btinternet.com> I just discovered the highly useful function Data.Function.on. I vaguely recall a few people muttering a couple of years back that this would be a useful thing to have, but I had no idea it was in the standard libraries now. Anyway, while using it, I discovered a small omission from the Haskell libraries: We have min, max, minimum and maximum. We also have minimumBy and maximumBy. But there's no sign of minBy or maxBy. You can do, for example, (min `on` postcode) customer1 customer2 but that gives you the lowest postcode, not the customer to which this postcode belongs. By contrast, minimumBy (compare `on` postcode) [customer1, customer2] gives you the corresponding customer. But it seems silly to have to actually construct a list just for this. So... is there any danger of getting minBy and maxBy added? (I don't actually know off the top of my head where min and max are defined - the Prelude?) Also, constructions like sortBy (compare `on` foo) must surely be very common. Perhaps it would be an idea to define a family of functions like sortOn :: (Ord y) => (x -> y) -> [x] -> [x] sortOn foo = sortBy (compare `on` foo) Just an idea. Finally, take a look at this: newtype SwapOrd x = SwapOrd (unswap_ord :: x) deriving Eq instance Ord x => Ord (SwapOrd x) where compare x y = swap_ord $ compare x y swap_ord :: Ordering -> Ordering swap_ord o = case o of EQ -> EQ GT -> LT LT -> GT Just in case you wanted to sort things in reverse order. I think having swap_ord would be nice if nothing else... From holgersiegel74 at yahoo.de Sat Feb 20 05:53:49 2010 From: holgersiegel74 at yahoo.de (Holger Siegel) Date: Sat Feb 20 05:24:31 2010 Subject: [Haskell-cafe] A small oversight In-Reply-To: <4B7FBDC2.8090606@btinternet.com> References: <4B7FBDC2.8090606@btinternet.com> Message-ID: <1266663229.5806.3.camel@cornfed> Am Samstag, den 20.02.2010, 10:47 +0000 schrieb Andrew Coppin: > I just discovered the highly useful function Data.Function.on. I vaguely > recall a few people muttering a couple of years back that this would be > a useful thing to have, but I had no idea it was in the standard > libraries now. > > Anyway, while using it, I discovered a small omission from the Haskell > libraries: We have min, max, minimum and maximum. We also have minimumBy > and maximumBy. But there's no sign of minBy or maxBy. You can do, for > example, > > (min `on` postcode) customer1 customer2 > > but that gives you the lowest postcode, not the customer to which this > postcode belongs. By contrast, > > minimumBy (compare `on` postcode) [customer1, customer2] > > gives you the corresponding customer. But it seems silly to have to > actually construct a list just for this. So... is there any danger of > getting minBy and maxBy added? (I don't actually know off the top of my > head where min and max are defined - the Prelude?) minBy and maxBy are already defined in Data.List - but they are local to minimumBy and maximumBy. From matthias.goergens at googlemail.com Sat Feb 20 05:56:46 2010 From: matthias.goergens at googlemail.com (=?ISO-8859-1?Q?Matthias_G=F6rgens?=) Date: Sat Feb 20 05:27:46 2010 Subject: [Haskell-cafe] A small oversight In-Reply-To: <4B7FBDC2.8090606@btinternet.com> References: <4B7FBDC2.8090606@btinternet.com> Message-ID: > Also, constructions like > > ?sortBy (compare `on` foo) > > must surely be very common. Just as a data point: I use constructions like the above very often. (Perhaps someone more enlightened than me can point out the connection to arrows?) Data.Function.on is surprisingly useful in some other contexts, too. Matthias. From andrewcoppin at btinternet.com Sat Feb 20 06:00:05 2010 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sat Feb 20 05:30:37 2010 Subject: [Haskell-cafe] Computing sums In-Reply-To: <7ca3f0161002200245w65bac629w1ec00be6b11a6534@mail.gmail.com> References: <4B7FB9B2.4060100@btinternet.com> <7ca3f0161002200245w65bac629w1ec00be6b11a6534@mail.gmail.com> Message-ID: <4B7FC0B5.50001@btinternet.com> Luke Palmer wrote: > On Sat, Feb 20, 2010 at 3:30 AM, Andrew Coppin > wrote: > >> Have I just invented arrows? >> > > No... you have a data type which is *an* Arrow (probably/almost). Well, OK, that's kind of what I meant. ;-) > The > pure implementation bugs me because of its use of undefined. Might > still be okay though. I would be more comfortable if it could not > output until it has *some* input; Yes, this irritates me also. > i.e. > > data Property' a b = forall s. Property' s (a -> s -> (b,s)) > Hmm. I hadn't thought of that. I will work though the consequences and see what happens... > Anyway, for yours: try to implement (.) :: Property b c -> Property a > b -> Property a c, and first :: Property a b -> Property (a,c) (b,c). > Then you will have an arrow. > (.) = flip (>==>) first p = p >==< pure id > This is a Causal Commutative Arrow, even, similar to the kinds of > things that are done in Yampa. It might be more recognizable as the > non-recursive version of: > > newtype Property a b = Property b (a -> Property a b) > ...OK, I'm lost... From paul at cogito.org.uk Sat Feb 20 06:09:26 2010 From: paul at cogito.org.uk (Paul Johnson) Date: Sat Feb 20 05:40:16 2010 Subject: [Haskell-cafe] What happened in Ohloh? In-Reply-To: <20100219223103.GB24712@whirlpool.galois.com> References: <4B7F0EC7.7010003@cogito.org.uk> <20100219223103.GB24712@whirlpool.galois.com> Message-ID: <4B7FC2E6.3060302@cogito.org.uk> On 19/02/10 22:31, Don Stewart wrote: > paul: > >> I'd like to use this kind of graph at work as evidence that Haskell is >> on a growth trajectory. >> > You might be more interested in data from Hackage: > > http://www.galois.com/blog/2009/03/23/one-million-haskell-downloads/ > > runched when we passed the 1M downloads mark a year ago (closer to 2M > downloads now). > > We've also got just shy of 2000 packages on Hackage, up from 1100 a year > ago (~3 new packages a day) > Thanks Don. I've already used this data in presentations. I don't want to use the Hackage upload graph you posted because a) its got more to do with the growth of Hackage than the growth of Haskell, and b) it levels off. I need something with more visual punch. This is always a problem, related to the "Why is Haskell so little used in Industry" question. Decision makers use a simple chain of reasoning: I've never heard of it => academic language => can't hire programmers => unsupportable software. Maybe I should write a "guide to Haskell advocacy in the workplace". Would there be any interest? From andrewcoppin at btinternet.com Sat Feb 20 06:11:46 2010 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sat Feb 20 05:42:17 2010 Subject: [Haskell-cafe] Computing sums In-Reply-To: <4B7FC0B5.50001@btinternet.com> References: <4B7FB9B2.4060100@btinternet.com> <7ca3f0161002200245w65bac629w1ec00be6b11a6534@mail.gmail.com> <4B7FC0B5.50001@btinternet.com> Message-ID: <4B7FC372.1050904@btinternet.com> >> Anyway, for yours: try to implement (.) :: Property b c -> Property a >> b -> Property a c, and first :: Property a b -> Property (a,c) (b,c). >> Then you will have an arrow. > > (.) = flip (>==>) > > first p = p >==< pure id No, not quite. \p -> p >==< pure id :: Property a b -> Property a (b, a) What you want is first p = (pure fst >==> p) >==< (pure snd) which has the required type. From stephen.tetley at gmail.com Sat Feb 20 06:25:11 2010 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Sat Feb 20 05:55:50 2010 Subject: [Haskell-cafe] Computing sums In-Reply-To: <4B7FB9B2.4060100@btinternet.com> References: <4B7FB9B2.4060100@btinternet.com> Message-ID: <5fdc56d71002200325t91fb0ddxdad572c70a334887@mail.gmail.com> Hi Andrew "Spot the difference" data Property x y = forall s. Property s (x -> s -> s) (s -> y) data Fold b c = forall a. F (a -> b -> a) a (a -> c) The later is from: http://squing.blogspot.com/2008/11/beautiful-folding.html Max Rabkin's is is closer to the original argument ordering of foldl. Best wishes Stephen From limestrael at gmail.com Sat Feb 20 06:44:54 2010 From: limestrael at gmail.com (=?UTF-8?Q?Yves_Par=C3=A8s?=) Date: Sat Feb 20 06:15:32 2010 Subject: Re[Haskell-cafe] [2]: Threading and FFI In-Reply-To: References: <27611528.post@talk.nabble.com> <20100216172522.GC6832@kira.casa> <27612884.post@talk.nabble.com> <27613138.post@talk.nabble.com> <27621580.post@talk.nabble.com> <27631980.post@talk.nabble.com> <648858494.20100218094107@gmail.com> <27635260.post@talk.nabble.com> <27647126.post@talk.nabble.com> Message-ID: <27665592.post@talk.nabble.com> Dean Herington wrote: >Careful. If you're calling foreign functions >that rely on thread-local storage, you must call >them using the same OS thread (to provide them >with the correct thread state), which means using >the same, *bound*, Haskell thread. It wouldn't >work to call them from both the main Haskell >thread and another Haskell thread, even if the >latter were a bound thread, as there would be two >copies of thread-local storage at play. That's alright. I'm used to putting all the related calls in the same thread as long as it is possible. It'd seem unlogical to me -- conceptually speaking -- to spread OpenGL calls between several threads. I understand better, now. Actually, I think I was getting worked up for nothing ^^. Just one last remark: when I moved all my OpenGL calls from the main thread to an unbound thread. I thought it'd not work -- because I assumed I would have to launch it in a bound thread -- and however it went right... ----- Yves Par?s Live long and prosper -- View this message in context: http://old.nabble.com/Threading-and-FFI-tp27611528p27665592.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From andrewcoppin at btinternet.com Sat Feb 20 07:10:47 2010 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sat Feb 20 06:41:19 2010 Subject: [Haskell-cafe] Computing sums In-Reply-To: <5fdc56d71002200325t91fb0ddxdad572c70a334887@mail.gmail.com> References: <4B7FB9B2.4060100@btinternet.com> <5fdc56d71002200325t91fb0ddxdad572c70a334887@mail.gmail.com> Message-ID: <4B7FD147.7070300@btinternet.com> Stephen Tetley wrote: > Hi Andrew > > "Spot the difference" > > data Property x y = forall s. Property s (x -> s -> s) (s -> y) > data Fold b c = forall a. F (a -> b -> a) a (a -> c) > > > The later is from: > http://squing.blogspot.com/2008/11/beautiful-folding.html > > Max Rabkin's is is closer to the original argument ordering of foldl. > Hmm. So somebody else has come up with the exact same solution to the same problem. My problem isn't exactly the same though. I'm interested in computing a "property" of a list, and recomputing it as elements are appended to the list. My "Property" structure provides an efficient way to do this, and to do so composibly. (E.g., if I want the maximum of the mean or something. Maximum and mean are both folds.) PS. Epic, epic comment spam. From max.rabkin at gmail.com Sat Feb 20 07:38:53 2010 From: max.rabkin at gmail.com (Max Rabkin) Date: Sat Feb 20 07:09:51 2010 Subject: [Haskell-cafe] Computing sums In-Reply-To: <4B7FD147.7070300@btinternet.com> References: <4B7FB9B2.4060100@btinternet.com> <5fdc56d71002200325t91fb0ddxdad572c70a334887@mail.gmail.com> <4B7FD147.7070300@btinternet.com> Message-ID: On Sat, Feb 20, 2010 at 9:10 PM, Andrew Coppin wrote: > PS. Epic, epic comment spam. Yeah, sorry. Every now and again I decide I should deal with it. Then I rediscover that it takes about four clicks to delete each comment. Basically, I leave my blog alone until I have something (hopefully) interesting to write. --Max From haskell at benmachine.co.uk Sat Feb 20 07:39:24 2010 From: haskell at benmachine.co.uk (Ben Millwood) Date: Sat Feb 20 07:10:05 2010 Subject: [Haskell-cafe] A small oversight In-Reply-To: <4B7FBDC2.8090606@btinternet.com> References: <4B7FBDC2.8090606@btinternet.com> Message-ID: I can't answer your question (about getting minBy into the libraries) but I thought I'd point out some tricks: On Sat, Feb 20, 2010 at 10:47 AM, Andrew Coppin wrote: > Also, constructions like > > ?sortBy (compare `on` foo) > > must surely be very common. Common enough that Data.Ord introduces comparing: comparing :: (Ord a) => (b -> a) -> b -> b -> Ordering comparing = (compare `on`) see http://hackage.haskell.org/packages/archive/base/latest/doc/html/Data-Ord.html#v%3Acomparing But it would still be useful to have sortOn et al to capture the common technique when your sorting property is potentially expensive (sortOn length, for example): sortOn f = map fst . sortBy (comparing snd) . map (\x -> (x, f x)) a technique which I believe is called a Schwarzian transform. > Finally, take a look at this: > > ?newtype SwapOrd x = SwapOrd (unswap_ord :: x) deriving Eq > > ?instance Ord x => Ord (SwapOrd x) where > ? compare x y = swap_ord $ compare x y > > ?swap_ord :: Ordering -> Ordering > ?swap_ord o = case o of > ? EQ -> EQ > ? GT -> LT > ? LT -> GT > > Just in case you wanted to sort things in reverse order. I think having > swap_ord would be nice if nothing else... > swap_ord (compare x y) = compare y x, so usually flip compare fills this requirement :) From andrewcoppin at btinternet.com Sat Feb 20 07:45:21 2010 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sat Feb 20 07:15:52 2010 Subject: [Haskell-cafe] A small oversight In-Reply-To: References: <4B7FBDC2.8090606@btinternet.com> Message-ID: <4B7FD961.90706@btinternet.com> Ben Millwood wrote: > I can't answer your question (about getting minBy into the libraries) > but I thought I'd point out some tricks: > > On Sat, Feb 20, 2010 at 10:47 AM, Andrew Coppin > wrote: > >> Also, constructions like >> >> sortBy (compare `on` foo) >> >> must surely be very common. >> > > Common enough that Data.Ord introduces comparing: > > comparing :: (Ord a) => (b -> a) -> b -> b -> Ordering > comparing = (compare `on`) > Heh. I didn't even notice that Data.Ord existed... > But it would still be useful to have sortOn et al to capture the > common technique when your sorting property is potentially expensive > (sortOn length, for example): > > sortOn f = map fst . sortBy (comparing snd) . map (\x -> (x, f x)) > > a technique which I believe is called a Schwarzian transform. > Yes, that looks quite useful... > swap_ord (compare x y) = compare y x, so usually flip compare fills > this requirement :) > *facepalm* Damnit, why didn't *I* think of that?? From me at mornfall.net Sat Feb 20 09:01:09 2010 From: me at mornfall.net (Petr Rockai) Date: Sat Feb 20 08:31:31 2010 Subject: [Haskell-cafe] Re: darcs 2.4 release candidate 2 In-Reply-To: (Ben Franksen's message of "Fri, 19 Feb 2010 19:49:26 +0100") References: <201002182214.21113.tux_rocker@reinier.de> Message-ID: <873a0wxaze.fsf@twilight.int.mornfall.net.> Hi, Ben Franksen writes: > This rc release is still notably slower on some operations than older > releases. My test case is a large project named RTEMS (a real-time OS), > that we wish to import into darcs (at work) to better track our own > additions and modifications. > > To repeat, download two adjacent releases, e.g. > > wget http://www.rtems.org/ftp/pub/rtems/4.9.0/rtems-4.8.1.tar.bz2 > wget http://www.rtems.org/ftp/pub/rtems/4.9.0/rtems-4.9.0.tar.bz2 > > unpack, initialize darcs and record in the 4.8.1 tree, then copy _darcs to > the 4.9.0 version and try to record -l or whatsnew -l. [snip] I am not sure about 2.4, but if this is an important usecase for you, I might have some good news. I have cobbled together a simple replacement for the current "summary" code in darcs whatsnew (right now it does not handle moves, but that should be relatively easy to add that without much performance impact). The code in this form never looks *into* files, it just looks at their hashes (which are cached in the index), and for the look-for-adds case, for their presence in the "unrecorded" state (i.e. if they'd be there without look-for-adds). In your rtems example, I get following: with totally cold cache and no index (rm -f _darcs/index ; echo 3 > /proc/sys/vm/drop_caches) about 12 seconds, hot cache & up-to-date index, less than one second. The reported list looks vaguely correct. Unfortunately, this is not going to help you for record -lam "new release" -- which will still need to construct the whole huge patch in memory (and fail). I will eventually look into that problem as well, but this is likely going to be much harder. > I think this regression should be fixed before 2.4 is released. Either way, I am not sure how serious this is wrt 2.4. I guess we could manage a rewrite of the summary code, but that would probably require another full beta cycle. I would be willing to list this under known issues, advising people that really need this to stick with 2.3.1 for now and upgrade to 2.5 which will hopefully improve matters in this respect (also for rec -lam). Yours, Petr. From daniel.is.fischer at web.de Sat Feb 20 11:02:32 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sat Feb 20 10:35:08 2010 Subject: [Haskell-cafe] A small oversight In-Reply-To: References: <4B7FBDC2.8090606@btinternet.com> Message-ID: <201002201702.33347.daniel.is.fischer@web.de> Am Samstag 20 Februar 2010 13:39:24 schrieb Ben Millwood: > a technique which I believe is called a Schwarzian transform. Schwartzian transform, with a tz. After Randal L. Schwartz. From jesper.louis.andersen at gmail.com Sat Feb 20 12:31:37 2010 From: jesper.louis.andersen at gmail.com (Jesper Louis Andersen) Date: Sat Feb 20 12:02:36 2010 Subject: [Haskell-cafe] ANN: HaskellTorrent v0.0 Message-ID: <56a0a2841002200931m1701b0h9621f57378f193c1@mail.gmail.com> Hello, I am happy to announce HaskellTorrent v0.0, a concurrent bittorrent client. The current release is a rather early preview release: it can download torrents and seed them, but currently there are many optimizations and tweaks needed before it is ready for day-to-day use. In particular, we are not yet fully compliant with the bittorrent specification and need proper clients to connect to in order to operate. Basically, you install the cabal package and then run HaskellTorrent foo.torrent and it will then download the contents of the torrent to the current directory. We would like to hear about any kind of problems you might encounter. Send them to jesper.louis.andersen@gmail.com for now. We have only tested the software on GHC 6.10.4 and 6.12.1, mostly on Unix platforms. It is known to work on Debian/Unstable with GHC610 and GHC612. If you want to hack code, get in touch with me. There are something for any level of skill to do. *** HaskellTorrent is using the CML library to get concurrency. It easily runs some 200-300 processes when it operates and its process model is somewhat loosely inspired by the model of Erlang. Looking forward, the next goal is to optimize concurrency, memory usage and CPU usage in the client. It currently hogs resources due to naive data structure choices and some expensive correctness assertions. *** Links of interest: http://hackage.haskell.org/package/HaskellTorrent http://github.com/jlouis/haskell-torrent *** This release was brought to you by: Alex Mason: A lot of Wireprotocol and BCode serialization work through the use of the cereal package. Astro: GHC 6.12 support. Support for multi-file torrents. In addition, patches were contributed by: Jesper Louis Andersen John Gunderman Thomas Christensen -- J. From sjoerd at w3future.com Sat Feb 20 13:29:09 2010 From: sjoerd at w3future.com (Sjoerd Visscher) Date: Sat Feb 20 12:59:52 2010 Subject: [Haskell-cafe] Restricted categories Message-ID: Hi all, I want restricted categories, just like the rmonad package provides restricted monads. The ultimate goal is to have a product category: http://en.wikipedia.org/wiki/Product_category > {-# LANGUAGE TypeOperators, TypeFamilies, MultiParamTypeClasses, FlexibleInstances, FlexibleContexts, ScopedTypeVariables, UndecidableInstances #-} > import Prelude hiding ((.), id, fst, snd) > import qualified Prelude First lets create a clone of Data.Suitable from the rmonad package, but this time for types with two arguments: > class Suitable2 m a b where > data Constraints m a b > constraints :: m a b -> Constraints m a b > withResConstraints :: forall m a b. Suitable2 m a b => (Constraints m a b -> m a b) -> m a b > withResConstraints f = f (constraints undefined :: Constraints m a b) > withConstraintsOf :: Suitable2 m a b => m a b -> (Constraints m a b -> k) -> k > withConstraintsOf v f = f (constraints v) Now we can define a restricted category: > class RCategory (~>) where > id :: Suitable2 (~>) a a => a ~> a > (.) :: (Suitable2 (~>) b c, Suitable2 (~>) a b, Suitable2 (~>) a c) => b ~> c -> a ~> b -> a ~> c (->) (or "Hask") is an instance of this class: > instance Suitable2 (->) a b where > data Constraints (->) a b = HaskConstraints > constraints _ = HaskConstraints > instance RCategory (->) where > id = Prelude.id > (.) = (Prelude..) Now on to the product category. Objects of the product category are types that are an instance of IsProduct: > class IsProduct p where > type Fst p :: * > type Snd p :: * > fst :: p -> Fst p > snd :: p -> Snd p For example: > instance IsProduct (a, b) where > type Fst (a, b) = a > type Snd (a, b) = b > fst = Prelude.fst > snd = Prelude.snd Arrows from the product of category c1 and category c2 are a pair of arrows, one from c1 and one from c2: > data (c1 :***: c2) a b = c1 (Fst a) (Fst b) :***: c2 (Snd a) (Snd b) The instance for Suitable2 restricts objects to IsProduct, and requires the Fst and Snd parts of the objects to be suitable in c1 resp. c2: > instance (IsProduct a, IsProduct b, Suitable2 c1 (Fst a) (Fst b), Suitable2 c2 (Snd a) (Snd b)) => Suitable2 (c1 :***: c2) a b where > data Constraints (c1 :***: c2) a b = (IsProduct a, IsProduct b, Suitable2 c1 (Fst a) (Fst b), Suitable2 c2 (Snd a) (Snd b)) => ProdConstraints > constraints _ = ProdConstraints Finally the RCategory instance: > instance (RCategory c1, RCategory c2) => RCategory (c1 :***: c2) where > id = withResConstraints $ \ProdConstraints -> id :***: id > -- f@(f1 :***: f2) . g@(g1 :***: g2) = > -- withResConstraints $ \ProdConstraints -> > -- withConstraintsOf f $ \ProdConstraints -> > -- withConstraintsOf g $ \ProdConstraints -> > -- (f1 . g1) :***: (f2 . g2) Here I am running into problems. I get this error: Could not deduce (Suitable2 c2 (Snd a) (Snd b), Suitable2 c1 (Fst a) (Fst b)) from the context (IsProduct b, IsProduct c, Suitable2 c1 (Fst b) (Fst c), Suitable2 c2 (Snd b) (Snd c)) arising from a use of `withConstraintsOf' In the first argument of `($)', namely `withConstraintsOf g' I don't understand this, as I thought the constraints the error is complaining about is just what withConstraintsOf g should provide. I guess there's something about the Suitable trick that I don't understand, or possibly the type families Fst and Snd are biting me. Who can help me out? Thanks. greetings, Sjoerd From joerg.rudnick at t-online.de Sat Feb 20 13:34:46 2010 From: joerg.rudnick at t-online.de (Nick Rudnick) Date: Sat Feb 20 13:05:39 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <201002182020.49657.daniel.is.fischer@web.de> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <2F93D0A8-E4D0-4AC0-82A3-599E036F1095@math.su.se> <4B7D84B8.3020605@t-online.de> <201002182020.49657.daniel.is.fischer@web.de> Message-ID: <4B802B46.4060401@t-online.de> A place in the hall of fame and thank you for mentioning clopen... ;-) Just wanting to present open/closed as and example of improvable maths terminology, I oversaw this even more evident defect in it and even copied it into my improvement proposal, bordered/unbordered: It is questionable style to name two properties, if they can occur combined, as an antagonistic pair...! Acccordingly, it is more elegant to draw such terms from independent domains. This subject seems to drive me crazy... I actually pondered on improvement, and came to: ?faceless? in replacement of ?open? Rough explanation: The ?limit? of a closed set can by the limit of another closed set that may even share only this limit -- a faceless set has -- under the given perspective -- no such part to ?face? to beyond. Any comments? But the big question is now: What (non antagonistic) name can be found for the other property?? Any ideas...?? Cheers, Nick Ergonomic terminology comes not for free, giving a quick answer here would be ?maths style? with replacing Michael Matsko wrote: > Nick, > > Actually, clopen is a set that is both closed and open. Not one > that is neither. Except in the case of half-open intervals, I can't > remember talking much in topology about sets with a partial boundary. > Alexander Solla wrote: > > Clopen means a set is both closed and open, not that it's "partially > bordered". Daniel Fischer wrote: > > And we'd be very wrong. There are sets which are simultaneously open and > closed. It is bad enough with the terminology as is, throwing in the > boundary (which is an even more difficult concept than open/closed) would > only make things worse. > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100220/1164b04d/attachment.html From joerg.rudnick at t-online.de Sat Feb 20 14:13:30 2010 From: joerg.rudnick at t-online.de (Nick Rudnick) Date: Sat Feb 20 13:44:13 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <681D5A1F-0BAC-4ECA-8A1D-2D5C1DB00F5E@cs.otago.ac.nz> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <75cc17ac1002180924r6d8eb5f4r3a7ddebd9825c69f@mail.gmail.com> <4B7D8D23.3020402@t-online.de> <201002182031.03105.daniel.is.fischer@web.de> <4B7DEE0B.7050309@t-online.de> <681D5A1F-0BAC-4ECA-8A1D-2D5C1DB00F5E@cs.otago.ac.nz> Message-ID: <4B80345A.6090204@t-online.de> Richard O'Keefe wrote: > > On Feb 19, 2010, at 2:48 PM, Nick Rudnick wrote: >> Please tell me the aspect you feel uneasy with, and please give me >> your opinion, whether (in case of accepting this) you would rather >> choose to consider Human as referrer and Int as referee of the >> opposite -- for I think this is a deep question. > I've read enough philosophy to be wary of treating "reference" > as a simple concept. And linguistically, "referees" are people > you find telling rugby players "naughty naughty". Don't you > mean "referrer" and "referent"? > Yes, thanks. I am not a native English speaker, and in my mother tongue, > a referent is somebody who refers, so I missed the guess... Such > statements are exactly what I was looking for... So, as a reference is > directed, it is possible to distinguish > > referrer ::= the one which does refer to s.th. > > referent ::= one which is referred to by s.th. > > Of course a basic point about language is that the association > between sounds and meanings is (for the most part) arbitrary. I would rather like to say it is not strictly determined, as an evolutionary tendence towards, say ergonomy, cannot be overlooked, can it? > Why should the terminology of mathematics be any different? ;-) Realizing an evolutionary tendence towards ergonony, is my subject... > Why is a "small dark floating cloud, indicating rain", called > a "water-dog"? Water, yes, but dog? Why are the brackets at > each end of a fire-place called "fire-dogs"? Why are unusually > attractive women called "foxes" (the females of that species > being "vixens", and both sexes smelly)? :-)) The shape of the genitals, which might come into associative imagination of the hopeful observer?? (The same with cats, bears, etc.) [... desperately afraid of getting kicked out of this mailing list ;-))] Thanks for this beautiful example and, honestly, again I ask again whether we may regard this as ?just noise?: In contrary, aren't such usages not paradigmatical examples of memes, which as products of memetic evolution, should be studied for their motivational value? Let me guess: Our cerebral language system is highly coupled with our intentional system, so that it helps learning to have motivating ?animation? enclosed... Isn't this in use in contemporary learning environments...? The problem I see is that common maths claims an exception in claiming that, in it's domain, namings are no more than noise -- possible motivated by an extreme rejection of anything between ?strictly formally determined? and ?noise?. This standpoint again does not realize the developments in foundations of mathematics of at least the century ago -- put roughly, this comes close to Hilbert's programme... To my mind, any of the breakthroughs of the last decades -- like incompleteness, strange attractors, algorithmic information theory, CCCs, and not the least computing science itself with metaprogramming, soft computing, its linear types/modes and monads (!) -- have to do with constructs which emancipate such claims of ex ante predetermination. Isn't category theory pretty much a part of all this? > What's the logic in > doggedness being a term of praise but bitchiness of opprobrium? Sexism...?? > We can hope for mathematical terms to be used consistently, > but asking for them to be transparent is probably too much to > hope for. (We can and should use intention-revealing names > in a program, but doing it across the totality of all programs > is something never achieved and probably never achievable.) We have jokers: Evolutionary media, like markdown or even stylesheet may allow us to switch and translate in a moment, and many more useful gimmicks... Online collaboration platforms... And we can stay pragmatical: If we can reach a (broad, to my estimate...) public, which originally would have to say ?the book has really left me dumbfounded? (so the originator of this thread) and offer them an entertaining intuitive way -- why not even in a self-configurable way? -- category theory could be introduced to contemporary culture. Personally, I can't accept statements like (in another posting) ?You need a lot of training in abstraction to learn very abstract concepts. Joe Sixpack's common sense isn't prepared for that.? Instead, I think that there is good evidence to believe that there are lots of isomorphisms to be found between every day's life and terminology and concepts category theory -- *not* to be confused with its *applications to maths*... And, to close in your figurative style: Which woman gets hurt by a change of clothes? Cheers, Nick From apfelmus at quantentunnel.de Sat Feb 20 13:25:05 2010 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Sat Feb 20 15:31:03 2010 Subject: [Haskell-cafe] Re: Heterogeneous Data Structures - Nested Pairs and functional references In-Reply-To: References: <4B7AFC98.9080103@web.de> <4B7D8BD8.7050804@web.de> Message-ID: Alexander Solla wrote: > > So, the type (View view) -- ignoring class instances -- is basically > isomorphic to this (slightly simpler) type: > > data View = EmptyView | TextView String | ConcatView View View | > NestViews View View View | ... > instance Monoid View where ... > > Now, consider the problem of "generic programming" on the simpler > type: you quantify over the data constructors "generically", and in > doing so you gain "traversals" for the type.[1] You gain the same > things by turning View into (View view) -- a functor, a foldable > functor, and so on. When it comes time to "render" a format for a View > (for example, a bit of Html from Text.XHtml.Strict), I use some higher > order functions I'm already familiar with. Something like > > renderXHtml :: (View view) -> Html > renderXHtml (ConcatViews l r) = fold $ renderXHtml (ConcatViews l r) > renderXHtml (NestViews l m r) = fold $ renderXHtml (NestViews l m r) > renderXHtml (TextView string) = stringToHtml string > renderXHtml (PageView v_title, v_heading, v_header, v_footer, v_contents) = > (the_title << (renderXHtml v_title)) +++ -- (We assume > v_title is a TextView String) > (body << ( renderXHtml v_header ) +++ > (render_page_contents v_contents v_heading) +++ > (renderXHtml v_footer) ) > where render_page_contents contents heading = undefined But isn't the line renderXHtml (ConcatView l r) = fold $ renderXHtml (ConcatViews l r) a type error? I'm assuming Data.Foldable.fold :: (Foldable m, Monoid t) => m t -> t being applied to the result type of renderXHtml which is Html and not of the form m t . Your intention reminds me of the use of type variables to get functor-like behavior for free, like in data RGB' a = RGB a a a -- auxiliary type constructor type RGB = RGB' Int -- what we're interested in instance Functor RGB' where fmap f (RGB x y z) = RGB (f x) (f y) (f z) mapRGB :: (Int -> Int) -> RGB -> RGB mapRGB = fmap but I don't quite see what you're doing with the free monad here, Alexander? Regards, Heinrich Apfelmus -- http://apfelmus.nfshost.com From ajs at 2piix.com Sat Feb 20 16:03:54 2010 From: ajs at 2piix.com (Alexander Solla) Date: Sat Feb 20 15:34:31 2010 Subject: [Haskell-cafe] Restricted categories In-Reply-To: References: Message-ID: On Feb 20, 2010, at 10:29 AM, Sjoerd Visscher wrote: > I don't understand this, as I thought the constraints the error is > complaining about is just what withConstraintsOf g should provide. > I guess there's something about the Suitable trick that I don't > understand, or possibly the type families Fst and Snd are biting me. > > Who can help me out? Thanks. You specifically ask withConstraintsOf to accept only Suitable2's when you say > withConstraintsOf :: Suitable2 m a b => m a b -> (Constraints m a b - > > k) -> k But you aren't saying that the argument of withConstraintsOf IS a Suitable2, when you say: > instance (RCategory c1, RCategory c2) => RCategory (c1 :***: c2) where > id = withResConstraints $ \ProdConstraints -> id :***: id > -- f@(f1 :***: f2) . g@(g1 :***: g2) = > -- withResConstraints $ \ProdConstraints -> > -- withConstraintsOf f $ \ProdConstraints -> > -- withConstraintsOf g $ \ProdConstraints -> > -- (f1 . g1) :***: (f2 . g2) You need to make a type class instance for Suitable2 for whatever type \ProdConstraints -> ... represents. For comparison, try: > data Unordered = A | B | C > A <= B No instance for (Ord Unordered) arising from a use of `<=' at :1:0-5 Possible fix: add an instance declaration for (Ord Unordered) In the expression: A <= B In the definition of `it': it = A <= B and now: > data Ordered = A | B | C deriving (Show, Eq, Ord) -- (easier than writing an instance for Eq, Ord) > A <= B True From matt at immute.net Sat Feb 20 16:22:09 2010 From: matt at immute.net (Matt Hellige) Date: Sat Feb 20 15:52:46 2010 Subject: [Haskell-cafe] Pointfree composition for higher arity In-Reply-To: <4B7F681B.1090302@freegeek.org> References: <3c6288ab1002170731m1661c479r936f3e5b5ff8d89d@mail.gmail.com> <4B7F681B.1090302@freegeek.org> Message-ID: <5959041b1002201322q4f05ce3dyf60e2c6a4cb6137b@mail.gmail.com> On Fri, Feb 19, 2010 at 10:42 PM, wren ng thornton wrote: > Sean Leather wrote: >> >> The second option approaches the ideal pointfreeness (or pointlessness if >> you prefer), but I'd like to go farther: >> >> (...) :: (c -> d) -> (a -> b -> c) -> a -> b -> d >>> >>> (...) f g x y = f (g x y) >>> infixr 9 ... > > I go with infixl 8 personally. It seems to play better with some of the > other composition combinators. > > In a somewhat different vein than Oleg's proposed general composition, I've > particularly enjoyed Matt Hellige's pointless fun combinators[0]. I have a > version which also adds a strict application combinator in my desiderata > package[1] so we can say things like: > > ? ?foo $:: bar ~> baz !~> bif > > which translates to: > > ? ?\a b -> bif (foo (bar a) (baz $! b)) > > These combinators are especially good when you don't just have a linear > chain of functions. > Thanks! I'm glad to know that people have found this approach useful. In cases where it works, I find it somewhat cleaner than families of combinators with (what I find to be) rather obscure names, or much worse, impenetrable sections of (.). We can write the original example in this style: fun = someFun someDefault $:: id ~> id ~> runFun but unfortunately, while it's both pointfree and fairly clear, it isn't really an improvement over the pointful version, IMHO. Matt From uzytkownik2 at gmail.com Sat Feb 20 18:38:46 2010 From: uzytkownik2 at gmail.com (Maciej Piechotka) Date: Sat Feb 20 18:09:18 2010 Subject: [Haskell-cafe] ANNOUNCE: ioctl 0.0.1 Message-ID: <1266709126.29755.44.camel@picard> A package for type-safe I/O control. Currently only ioctl is supported. Currently simply a extract from my tuntap fork TODO: - Return the integer as well as structure (will break the API) - Port for Windows Network.Socket.IOCtl (as soon as I manage to setup some sane environment on this platform) - Wrapping around DeviceIoControl Example (in hsc): data NotRead = NotRead instance NotRead Int where ioctlReq _ = #const FIONREAD notRead s = ioctlsocket' s NotRead Regards -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100220/c5d7525b/attachment.bin From ajs at 2piix.com Sat Feb 20 19:04:20 2010 From: ajs at 2piix.com (Alexander Solla) Date: Sat Feb 20 18:35:00 2010 Subject: [Haskell-cafe] Re: Heterogeneous Data Structures - Nested Pairs and functional references In-Reply-To: References: <4B7AFC98.9080103@web.de> <4B7D8BD8.7050804@web.de> Message-ID: On Feb 20, 2010, at 10:25 AM, Heinrich Apfelmus wrote: > But isn't the line > > renderXHtml (ConcatView l r) = fold $ renderXHtml (ConcatViews l r) > > a type error? I'm assuming > > Data.Foldable.fold :: (Foldable m, Monoid t) => m t -> t > > being applied to the result type of renderXHtml which is Html and > not of the form m t . Yup, that's a type error. I mean to fold the View (in this case a ConcatView) into a monoid. I think I meant > foldMap renderXHtml (ConcatViews l r) > Your intention reminds me of the use of type variables to get > functor-like behavior for free, like in > > data RGB' a = RGB a a a -- auxiliary type constructor > type RGB = RGB' Int -- what we're interested in > > but I don't quite see what you're doing with the free monad here, > Alexander? As you noticed, I am seeking that functorial behavior in order to gain some genericity. bind and return do encode some logic about the nature of monadic adjunction, which I am relying on theoretically. I could have used a Functor instance just as easily, but I would have lost my "intention" of defining co-equalizers implicitly. (http://en.wikipedia.org/wiki/Beck%27s_monadicity_theorem ) Also, it was easier to write a monad instance than an Applicative instance, at least on my first try. ;-) From wren at freegeek.org Sat Feb 20 20:41:26 2010 From: wren at freegeek.org (wren ng thornton) Date: Sat Feb 20 20:04:07 2010 Subject: [Haskell-cafe] Pointfree composition for higher arity In-Reply-To: <5959041b1002201322q4f05ce3dyf60e2c6a4cb6137b@mail.gmail.com> References: <3c6288ab1002170731m1661c479r936f3e5b5ff8d89d@mail.gmail.com> <4B7F681B.1090302@freegeek.org> <5959041b1002201322q4f05ce3dyf60e2c6a4cb6137b@mail.gmail.com> Message-ID: <4B808F46.5080303@freegeek.org> Matt Hellige wrote: > Thanks! I'm glad to know that people have found this approach useful. > In cases where it works, I find it somewhat cleaner than families of > combinators with (what I find to be) rather obscure names, or much > worse, impenetrable sections of (.). We can write the original example > in this style: > fun = someFun someDefault $:: id ~> id ~> runFun > but unfortunately, while it's both pointfree and fairly clear, it > isn't really an improvement over the pointful version, IMHO. For something this simple it's not too helpful. But, one of the places it really shines is when dealing with newtypes in order to clean up the wrapping/unwrapping so they don't obscure the code. -- Live well, ~wren From joerg.rudnick at t-online.de Sat Feb 20 21:32:33 2010 From: joerg.rudnick at t-online.de (Nick Rudnick) Date: Sat Feb 20 21:03:25 2010 Subject: [Haskell-cafe] Restricted categories In-Reply-To: References: Message-ID: <4B809B41.5040706@t-online.de> Alexander Solla wrote: > You specifically ask withConstraintsOf to accept only Suitable2's when > you say >> withConstraintsOf :: Suitable2 m a b => m a b -> (Constraints m a b >> -> k) -> k > > But you aren't saying that the argument of withConstraintsOf IS a > Suitable2, when you say: >> instance (RCategory c1, RCategory c2) => RCategory (c1 :***: c2) where >> id = withResConstraints $ \ProdConstraints -> id :***: id >> -- f@(f1 :***: f2) . g@(g1 :***: g2) = >> -- withResConstraints $ \ProdConstraints -> >> -- withConstraintsOf f $ \ProdConstraints -> >> -- withConstraintsOf g $ \ProdConstraints -> >> -- (f1 . g1) :***: (f2 . g2) As I understand, Sjoerd expects this to be done at the definition of (.) in the type class RCategory, so that an instance method can relay on the constraints collected by it: > class RCategory (~>) where > id :: Suitable2 (~>) a a => a ~> a > (.) :: (Suitable2 (~>) b c, Suitable2 (~>) a b, Suitable2 (~>) a c) => b ~> c -> a ~> b -> a ~> c > A simple example: class Show el=> ExceptionNote el where comment:: Show exception=> exception-> el-> String instance ExceptionNote Int where comment exception refId = show refId ++ ": " ++ show exception Here you don't need to constrain ?exception? to be of ?Show? at the instance declaration. So it does not appear wrong for Sjoerd to expect f and g to already be of Suitable2... This is exciting stuff, I am really a little astonished about the giant leap Haskell has made since my efforts to translate the examples of Rydeheart & Burstall, which actually was my intro to categories, from ML to Haskell. This looks very elegant... Maybe it's time for a second edition of the unique approach of Rydeheart & Burstall on basis of Haskell? Wow, really cool stuff... :-) Cheers, Nick -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100220/6df22f3d/attachment.html From ajs at 2piix.com Sun Feb 21 00:05:44 2010 From: ajs at 2piix.com (Alexander Solla) Date: Sat Feb 20 23:36:26 2010 Subject: [Haskell-cafe] Restricted categories In-Reply-To: <4B809B41.5040706@t-online.de> References: <4B809B41.5040706@t-online.de> Message-ID: On Feb 20, 2010, at 6:32 PM, Nick Rudnick wrote: > A simple example: > class Show el=> ExceptionNote el where > comment:: Show exception=> exception-> el-> String > > instance ExceptionNote Int where > comment exception refId = show refId ++ ": " ++ show exception > > Here you don't need to constrain ?exception? to be of ?Show? at the > instance declaration. So it does not appear wrong for Sjoerd to > expect f and g to already be of Suitable2... There really are instances missing. The context is coming from here: > The instance for Suitable2 restricts objects to IsProduct, and > requires the Fst and Snd parts of the objects to be suitable in c1 > resp. c2: > >> instance (IsProduct a, IsProduct b, Suitable2 c1 (Fst a) (Fst b), >> Suitable2 c2 (Snd a) (Snd b)) => Suitable2 (c1 :***: c2) a b where >> data Constraints (c1 :***: c2) a b = (IsProduct a, IsProduct b, >> Suitable2 c1 (Fst a) (Fst b), Suitable2 c2 (Snd a) (Snd b)) => >> ProdConstraints >> constraints _ = ProdConstraints Given types A and B, the product A x B has a type Fst which is A, and a type Snd which is B -- by construction: > class IsProduct p where > type Fst p :: * > type Snd p :: * > fst :: p -> Fst p > snd :: p -> Snd p So, if we have two products named a and b, and a = A + B, b = C + D (letting the first type in the addition be Fst, and the latter be Snd in each), a x b has four "components": (A x C) + (B x C) + (A x D) + (B x D). a x b = (A | B) x (C | D) = (Fst a | Snd a) x (Fst b | Snd b) = (Fst a, Fst b) + (Snd a, Fst b) + (Fst a, Snd b) + (Snd a, Snd b) This really comes down to the semantics of Suitability2, but I think Sjoerd made a logic mistake, and is trying to make a product out of a pair of products, in stead of a pair of categories. From leon.p.smith at gmail.com Sun Feb 21 01:59:20 2010 From: leon.p.smith at gmail.com (Leon Smith) Date: Sun Feb 21 01:30:00 2010 Subject: [Haskell-cafe] A small oversight In-Reply-To: <4B7FBDC2.8090606@btinternet.com> References: <4B7FBDC2.8090606@btinternet.com> Message-ID: On Sat, Feb 20, 2010 at 5:47 AM, Andrew Coppin wrote: > ?sortOn :: (Ord y) => (x -> y) -> [x] -> [x] > ?sortOn foo = sortBy (compare `on` foo) Incidentally, this function is provided as Data.List.Ordered.sortOn' in the data-ordlist package... On Sat, Feb 20, 2010 at 7:39 AM, Ben Millwood wrote: > But it would still be useful to have sortOn et al to capture the > common technique when your sorting property is potentially expensive > (sortOn length, for example): > > sortOn f = map fst . sortBy (comparing snd) . map (\x -> (x, f x)) > > a technique which I believe is called a Schwar[t]zian transform. An older name for this technique is "decorate-sort-undecorate". Data-ordlist also provides this as Data.List.Ordered.sortOn http://hackage.haskell.org/package/data-ordlist Best, Leon From spam at scientician.net Sun Feb 21 02:21:00 2010 From: spam at scientician.net (Bardur Arantsson) Date: Sun Feb 21 03:06:38 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: References: Message-ID: Jeremy Shaw wrote: > Hello, > > I think to make progress on this bug we really need a failing test case that > other people can reproduce. > > I have hacked up small server that should reproduce the error (using fdWrite > instead of sendfile). And a small C client which is intended to reproduce > the error -- but doesn't. > > I have attached both. > > The server tries to write a whole lot of 'a' characters to the client. The > client does not consume any of them. This causes the server to block on the > threadWaitWrite. > > No matter how I kill the client, threadWaitWrite always wakes up. Are you running the client and server on different physical machines? If so, have you tried simply yanking the connection? Your client isn't dropping the connection hard -- if you kill the client (even with a -9) your OS cleans up any open sockets it has. On well-behaved OS'es that cleanup usually involves properly shutting down the connection somehow. Different OS'es have different ideas about what constitutes "properly shutting down the connection" -- some simply don't. My hypothesis is that the PS3 doesn't properly shut down the connection, but simply sends a RST (or maybe a FIN) and drops any further packets. I'll do a Wireshark dump after posting this to see if I can see what it's doing at the TCP level -- I'm not optimistic about seeing the exact moment when the "leak" occurs, but maybe the general pattern can yield some useful ideas. I have no idea how to test this without using an actual PS3. > So, we > need to figure out exactly what the PS3 is doing differently that causes > threadWaitWrite to not wakeup.. Does it matter? I can reproduce this reliably within a few minutes of testing. Note that this doesn't happen *every* time the PS3 disconnects and reconnects, it just happens some of the time. It's enough to eat up MAX_FDs file descriptors in a few hours of playing media normally. If I do a lot of seeking (forces a disconnect+reconnect) through the movie, at least one file descriptor usually leaks within a few minutes. > If we don't know why it is failing, then I > don't think we can properly fix it. I'm more pragmatic: If, after applying a fix, I cannot reproduce this problem within a few hours (or so) or running my media server, I'd say it's fixed. As long as the modifications to the sendfile library don't change its behavior in other ways, I don't see the problem. P.S. Does anyone else out there have a PS3 to test with? From spam at scientician.net Sun Feb 21 02:28:38 2010 From: spam at scientician.net (Bardur Arantsson) Date: Sun Feb 21 03:13:53 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: <1266508065-sup-8211@oz.taruti.net> References: <1266355493-sup-6667@oz.taruti.net> <1266394750-sup-7721@oz.taruti.net> <1266508065-sup-8211@oz.taruti.net> Message-ID: Taru Karttunen wrote: > Excerpts from Bardur Arantsson's message of Wed Feb 17 21:27:07 +0200 2010: >> For sendfile, a timeout of 1 second would probably be fine. The *ONLY* >> purpose of threadWaitWrite in the sendfile code is to avoid busy-waiting >> on EAGAIN from the native sendfile. > > Of course this will kill connections for all clients that may have a > two second network hickup. > I'm not talking about killing the connection. I'm talking about retrying sendfile() if threadWaitWrite has been waiting for more than 1 second. If the connection *has already been closed* (as detected by the OS), then sendfile() will fail with EBADF, and we're good. If the connection *hasn't been closed*, there are two cases: a) Sendfile can send more data, in which case it does and we go back to sleep on a threadWaitWrite. b) Sendfile cannot send more data... in which case the sendfile library gets an EAGAIN and goes back to sleep on a threadWaitWrite. I don't see how that would lead to anything like what you describe. >> How so? As a user I expect sendfile to work and not semi-randomly block >> threads indefinitely. > > If you want sending something to terminate you will add a timeout to > it. A nasty client may e.g. take one byte each minute and sending your > file may take a few years. > This can always happen. The timeout here is at the application level (e.g. "has this connection been open too long") and sendfile shouldn't concern itself with such things. The point with my proposed fix is that sendfile will be reacting to the OS's detection of a dropped connection ASAP (plus 1 second) rather than just hanging. Cheers, From ppkkgm at gmail.com Sun Feb 21 06:27:48 2010 From: ppkkgm at gmail.com (Donghee Nah) Date: Sun Feb 21 05:58:23 2010 Subject: [Haskell-cafe] Linux ghci vs Windows ghci In-Reply-To: <4f56deb71002210322w3c35889ev2a9e689584f23d6d@mail.gmail.com> References: <4f56deb71002210322w3c35889ev2a9e689584f23d6d@mail.gmail.com> Message-ID: <4f56deb71002210327q1407ba35s12cae0b137def8c0@mail.gmail.com> I'm using Windows 7 32bit Host OS(ghc 6.8.3) and Virtualbox Archlinux Guest OS(ghc 6.8.4) I feel that ghci code executing speed in guest os is 1.5~2x faster than host os The code: let t n = do {if n `mod` 100000 == 0 then print n else return ()} >> t (n+1) t 1 any clue? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100221/9ba04389/attachment.html From magnus at therning.org Sun Feb 21 07:36:21 2010 From: magnus at therning.org (Magnus Therning) Date: Sun Feb 21 07:07:05 2010 Subject: [Haskell-cafe] Parsing of bytestrings with non-String errors? Message-ID: <4B8128C5.6030105@therning.org> I've looked at polyparse and attoparsec and they seem to have in common that the error always is a String. My current ideas for a project would be a lot easier if I could just return some other type, something that I can pattern match on. Is there a parser combinator library out there that works on bytestrings and allows using a custom error type? Or maybe there's some very basic reason why String is so commonly used? /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100221/6f01bf02/signature.bin From ketil at malde.org Sun Feb 21 07:58:32 2010 From: ketil at malde.org (Ketil Malde) Date: Sun Feb 21 07:29:23 2010 Subject: [Haskell-cafe] Linux ghci vs Windows ghci In-Reply-To: <4f56deb71002210327q1407ba35s12cae0b137def8c0@mail.gmail.com> (Donghee Nah's message of "Sun, 21 Feb 2010 20:27:48 +0900") References: <4f56deb71002210322w3c35889ev2a9e689584f23d6d@mail.gmail.com> <4f56deb71002210327q1407ba35s12cae0b137def8c0@mail.gmail.com> Message-ID: <87k4u6924n.fsf@malde.org> Donghee Nah writes: > I feel that ghci code executing speed in guest os is 1.5~2x faster than host > os > > The code: > let t n = do {if n `mod` 100000 == 0 then print n else return ()} >> t (n+1) > t 1 > > any clue? Speed of the terminal? Cost of syscalls (user/kernel transitions)? -k -- If I haven't seen further, it is by standing in the footprints of giants From malcolm.wallace at cs.york.ac.uk Sun Feb 21 09:21:56 2010 From: malcolm.wallace at cs.york.ac.uk (Malcolm Wallace) Date: Sun Feb 21 08:52:32 2010 Subject: [Haskell-cafe] Parsing of bytestrings with non-String errors? In-Reply-To: <4B8128C5.6030105@therning.org> References: <4B8128C5.6030105@therning.org> Message-ID: <4EAC452E-9396-4672-85B3-A2EC95F2DC3A@cs.york.ac.uk> > Is there a parser combinator library out there that works on > bytestrings and > allows using a custom error type? The HuttonMeijerWallace combinators (distributed with polyparse) have the custom error type, but not the bytestrings. > Or maybe there's some very basic reason why String is so commonly > used? I don't think there is any deep reason. Strings are convenient, that is all. My guesstimate would be that if you take (e.g.) the polyparse combinators, and manually rewrite String everywhere to a parameter e, (only when it represents an error of course), it would take you maybe an hour in total, including fixing up any site you missed that the typechecker catches for you. Regards, Malcolm From knyttv at gmail.com Sun Feb 21 10:30:00 2010 From: knyttv at gmail.com (=?utf-8?Q?Vojt=C4=9Bch_Knyttl?=) Date: Sun Feb 21 10:00:37 2010 Subject: [Haskell-cafe] STArray newListArray Message-ID: Hello, I am trying to create STArray with newListArray like this: la x y = newListArray ((1,1),(x,y)) [(x'+y') | x' <- [1..x], y' <- [1..y]] ? but it does not work: No instance for (MArray a Field m) I tried to define the type like this, but it would not work either: la :: Int -> Int -> STArray (Int,Int) Field It is obvious that I don't get the syntax of using it, so I will appreciate any suggestions. V. K. From artyom.kazak at gmail.com Sun Feb 21 10:45:22 2010 From: artyom.kazak at gmail.com (Artyom Kazak) Date: Sun Feb 21 10:16:00 2010 Subject: [Haskell-cafe] GHC RTS question Message-ID: <88bdc6651002210745p6629e363se0a5c70e039dd2e6@mail.gmail.com> Hello everybody! I want to write a little program, that will receive a string as command-line argument and write it in the file. But if this string contains '+RTS', GHC runtime won't pass the rest of the string to my program. What can I do to avoid this? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100221/dbbd5389/attachment.html From andrewcoppin at btinternet.com Sun Feb 21 11:02:22 2010 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sun Feb 21 10:32:57 2010 Subject: [Haskell-cafe] Profiling Message-ID: <4B81590E.6070001@btinternet.com> Two small questions: 1. Is Thread Scope any use for profiling single-threaded programs? 2. I tried to compile my program with -prof, but GHC just whines at me that the packages I'm using haven't been compiled for profiling. Do I really need to go recompile every single package I'm using with profiling support before I can profile my program? How do I tell Cabal to install the necessary code? (I really hope this doesn't involve uninstalling and reinstalling everything...) From felipe.lessa at gmail.com Sun Feb 21 11:05:08 2010 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sun Feb 21 10:35:47 2010 Subject: [Haskell-cafe] GHC RTS question In-Reply-To: <88bdc6651002210745p6629e363se0a5c70e039dd2e6@mail.gmail.com> References: <88bdc6651002210745p6629e363se0a5c70e039dd2e6@mail.gmail.com> Message-ID: <20100221160508.GB4401@kira.casa> On Sun, Feb 21, 2010 at 05:45:22PM +0200, Artyom Kazak wrote: > Hello everybody! > I want to write a little program, that will receive a string as command-line > argument and write it in the file. But if this string contains '+RTS', GHC > runtime won't pass the rest of the string to my program. > What can I do to avoid this? Use -RTS, as in $ ghc -V The Glorious Glasgow Haskell Compilation System, version 6.10.4 $ ghc +RTS -V ghc: no input files Usage: For basic information, try the `--help' option. $ ghc +RTS -RTS -V The Glorious Glasgow Haskell Compilation System, version 6.10.4 -- Felipe. From daniel.is.fischer at web.de Sun Feb 21 11:11:14 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sun Feb 21 10:43:46 2010 Subject: [Haskell-cafe] STArray newListArray In-Reply-To: References: Message-ID: <201002211711.15409.daniel.is.fischer@web.de> Am Sonntag 21 Februar 2010 16:30:00 schrieb Vojt?ch Knyttl: > Hello, > > I am trying to create STArray with newListArray like this: > la x y = newListArray ((1,1),(x,y)) [(x'+y') | x' <- [1..x], y' <- > [1..y]] > > ? but it does not work: > No instance for (MArray a Field m) > > I tried to define the type like this, but it would not work either: > la :: Int -> Int -> STArray (Int,Int) Field STArrays have a "state parameter", newListArray ((1,1),(x,y)) [(x'+y') | x' <- [1 .. x], y' <- [1 .. y]] has type forall s. ST s (STArray s (Int,Int) Int) So la :: forall s. Int -> Int -> ST s (STArray s (Int,Int) Int) la x y = newListArray ((1,1),(x,y)) [(x'+y') | x' <- [1 .. x], y' <- [1 .. y]] You can use STArrays only in the ST monad, there you'd do something like runST (do arr <- la 23 25 use arr return result) > > It is obvious that I don't get the syntax of using it, so I will > appreciate any suggestions. > > V. K. From daniel.is.fischer at web.de Sun Feb 21 11:13:25 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sun Feb 21 10:46:52 2010 Subject: [Haskell-cafe] GHC RTS question In-Reply-To: <88bdc6651002210745p6629e363se0a5c70e039dd2e6@mail.gmail.com> References: <88bdc6651002210745p6629e363se0a5c70e039dd2e6@mail.gmail.com> Message-ID: <201002211713.26123.daniel.is.fischer@web.de> Am Sonntag 21 Februar 2010 16:45:22 schrieb Artyom Kazak: > Hello everybody! > I want to write a little program, that will receive a string as > command-line argument and write it in the file. But if this string > contains '+RTS', GHC runtime won't pass the rest of the string to my > program. > What can I do to avoid this? Enclose it in double quotes (perhaps single quotes would also work) $ ./proggy "argwith +RTS in" harmlessArg otherHarmlessArg From haskell at benmachine.co.uk Sun Feb 21 11:33:56 2010 From: haskell at benmachine.co.uk (Ben Millwood) Date: Sun Feb 21 11:04:32 2010 Subject: [Haskell-cafe] STArray newListArray In-Reply-To: References: Message-ID: 2010/2/21 Vojt?ch Knyttl : > Hello, > > I am trying to create STArray with newListArray like this: > la x y = newListArray ((1,1),(x,y)) [(x'+y') | x' <- [1..x], y' <- [1..y]] > > ? but it does not work: > No instance for (MArray a Field m) Notice that newListArray has a monadic return type: newListArray :: (MArray a e m, Ix i) => (i, i) -> [e] -> m (a i e) with MArray a e m requiring Monad m. So newListArray returns your STArray in a monad. That pretty much has to be the ST monad, but that's not in scope, so you need to import Control.Monad.ST before the MArray (STArray s) e (ST s) instance is usable. > I tried to define the type like this, but it would not work either: > la :: Int -> Int -> STArray (Int,Int) Field > The kind for STArray here is slightly off. STArray needs three type parameters, not two. This is linked to the fact that ST is not a monad, but (ST s) is - the extra parameter is essential to ST, to ensure the mutability doesn't "leak out". You probably want: la :: Integer -> Integer -> ST s (STArray s (Integer, Integer) Field) From patai_gergely at fastmail.fm Sun Feb 21 12:08:05 2010 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Sun Feb 21 11:38:39 2010 Subject: [Haskell-cafe] Profiling Message-ID: <1266772085.20269.1361103821@webmail.messagingengine.com> > I tried to compile my program with -prof, but GHC just whines at me > that the packages I'm using haven't been compiled for profiling. Do I > really need to go recompile every single package I'm using with > profiling support before I can profile my program? How do I tell Cabal > to install the necessary code? (I really hope this doesn't involve > uninstalling and reinstalling everything...) Almost. You don't need to uninstall anything, just run cabal install --reinstall -p for every relevant package. Gergely -- http://www.fastmail.fm - mmm... Fastmail... From thomas.dubuisson at gmail.com Sun Feb 21 12:11:51 2010 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Sun Feb 21 11:42:26 2010 Subject: [Haskell-cafe] Profiling In-Reply-To: <4B81590E.6070001@btinternet.com> References: <4B81590E.6070001@btinternet.com> Message-ID: <4c44d90b1002210911u392a9cebyfec2c60e425b6d54@mail.gmail.com> > How do I tell Cabal to install the necessary code? set: "library-profiling: True" in your ~/.cabal/config file and never deal with this again (for any new packages you install). use --reinstall -p to updat existing packages. Thomas From artyom.kazak at gmail.com Sun Feb 21 12:20:43 2010 From: artyom.kazak at gmail.com (Artyom Kazak) Date: Sun Feb 21 11:51:19 2010 Subject: [Haskell-cafe] GHC RTS question In-Reply-To: <201002211713.26123.daniel.is.fischer@web.de> References: <88bdc6651002210745p6629e363se0a5c70e039dd2e6@mail.gmail.com> <201002211713.26123.daniel.is.fischer@web.de> Message-ID: <88bdc6651002210920o7bae3b56u13eadf18600b1f7c@mail.gmail.com> > Enclose it in double quotes (perhaps single quotes would also work) No, I want my program to work the same way as UNIX "echo" does. Without any double quotes. From andrewcoppin at btinternet.com Sun Feb 21 12:22:07 2010 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sun Feb 21 11:52:41 2010 Subject: [Haskell-cafe] Profiling In-Reply-To: <1266772085.20269.1361103821@webmail.messagingengine.com> References: <1266772085.20269.1361103821@webmail.messagingengine.com> Message-ID: <4B816BBF.2070000@btinternet.com> Patai Gergely wrote: >> I tried to compile my program with -prof, but GHC just whines at me >> that the packages I'm using haven't been compiled for profiling. Do I >> really need to go recompile every single package I'm using with >> profiling support before I can profile my program? How do I tell Cabal >> to install the necessary code? (I really hope this doesn't involve >> uninstalling and reinstalling everything...) >> > Almost. You don't need to uninstall anything, just run cabal install > --reinstall -p for every relevant package. > Oh, right. So I actually need cabal.exe to do this then? From donn at avvanta.com Sun Feb 21 12:50:30 2010 From: donn at avvanta.com (Donn Cave) Date: Sun Feb 21 12:21:05 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? References: <1266355493-sup-6667@oz.taruti.net><1266394750-sup-7721@oz.taruti.net><1266508065-sup-8211@oz.taruti.net> Message-ID: <20100221175030.7D7F493C40@mail.avvanta.com> Quoth Bardur Arantsson , > Taru Karttunen wrote: >> Excerpts from Bardur Arantsson's message of Wed Feb 17 21:27:07 +0200 2010: >>> For sendfile, a timeout of 1 second would probably be fine. The *ONLY* >>> purpose of threadWaitWrite in the sendfile code is to avoid busy-waiting >>> on EAGAIN from the native sendfile. >> >> Of course this will kill connections for all clients that may have a >> two second network hickup. >> > > I'm not talking about killing the connection. I'm talking about retrying > sendfile() if threadWaitWrite has been waiting for more than 1 second. > > If the connection *has already been closed* (as detected by the OS), > then sendfile() will fail with EBADF, and we're good. ... > I don't see how that would lead to anything like what you describe. If I understand correctly, we're talking about what it means for the OS to detect a closed connection. The proposal I think was to change the socket options to add keepalive, and to set a short timeout. This will indeed allow the OS to discover connections that didn't properly close, but are effectively closed in the sense that they are no use any more - disconnected cable, or it sounds like the PS3 may routinely do this out of negligence. The problem is that this definition of `closed' is, precisely, `failed to respond within 2 seconds.' If there is no observable difference between a connection that has been abandoned by the PS3, and a connection that just suffered a momentary lapse, then there's no way to catch the former without making connections more fragile. Donn Cave donn@avvanta.com From sjoerd at w3future.com Sun Feb 21 13:08:21 2010 From: sjoerd at w3future.com (Sjoerd Visscher) Date: Sun Feb 21 12:38:57 2010 Subject: [Haskell-cafe] Restricted categories In-Reply-To: References: Message-ID: <75929A74-BDF6-43D8-A84C-A6E78DCC5C23@w3future.com> Ok, I've got product categories working: > {-# LANGUAGE TypeOperators, TypeFamilies, MultiParamTypeClasses, ScopedTypeVariables, FlexibleContexts, FlexibleInstances, GADTs, RankNTypes, UndecidableInstances #-} > import Prelude hiding ((.), id, fst, snd) > import qualified Prelude Suitable2 could be simplified to one type argument (but it is still different from Data.Suitable, because m is of kind * -> * -> *) > class Suitable2 m a where > data Constraints m a > constraints :: m a a -> Constraints m a > withResConstraints :: forall m a. Suitable2 m a => (Constraints m a -> m a a) -> m a a > withResConstraints f = f (constraints undefined :: Constraints m a) > class RCategory (~>) where > id :: Suitable2 (~>) a => a ~> a > (.) :: (Suitable2 (~>) a, Suitable2 (~>) b, Suitable2 (~>) c) => b ~> c -> a ~> b -> a ~> c > instance Suitable2 (->) a where > data Constraints (->) a = HaskConstraints > constraints _ = HaskConstraints > instance RCategory (->) where > id = Prelude.id > (.) = (Prelude..) > class IsProduct p where > type Fst p :: * > type Snd p :: * > fst :: p -> Fst p > snd :: p -> Snd p > instance IsProduct (a, b) where > type Fst (a, b) = a > type Snd (a, b) = b > fst = Prelude.fst > snd = Prelude.snd Adding the restrictions to the constructor made all further problems in the definition of (.) go away: > -- Product category > data (c1 :***: c2) a b = (IsProduct a, IsProduct b, Suitable2 c1 (Fst a), Suitable2 c1 (Fst b), Suitable2 c2 (Snd a), Suitable2 c2 (Snd b)) > => c1 (Fst a) (Fst b) :***: c2 (Snd a) (Snd b) > instance (IsProduct a, Suitable2 c1 (Fst a), Suitable2 c2 (Snd a)) => Suitable2 (c1 :***: c2) a where > data Constraints (c1 :***: c2) a = (IsProduct a, Suitable2 c1 (Fst a), Suitable2 c2 (Snd a)) => ProdConstraints > constraints _ = ProdConstraints > instance (RCategory c1, RCategory c2) => RCategory (c1 :***: c2) where > id = withResConstraints $ \ProdConstraints -> id :***: id > (f1 :***: f2) . (g1 :***: g2) = (f1 . g1) :***: (f2 . g2) Let's test this: > (@*) :: ((->) :***: (->)) (a, b) (c, d) -> (a, b) -> (c, d) > (f :***: g) @* (x, y) = (f x, g y) > test1 = ((+10) :***: (*2)) @* (1, 2) -- (11, 4) So that works, but using type families Fst and Snd gives problems if you start to use this (see below). Here's a functor definition. To allow to define the identity functor, the actual functor itself is not the instance, but a placeholder type is used. The type family F turns the placeholder into the actual functor. The use of type families also means you have to pass a type witness of the placeholder to the fmap function (here called (%)). > type family F (ftag :: * -> *) a :: * > class (RCategory (Dom ftag), RCategory (Cod ftag)) => CFunctor ftag where > type Dom ftag :: * -> * -> * > type Cod ftag :: * -> * -> * > (%) :: (Suitable2 (Dom ftag) a, Suitable2 (Dom ftag) b) => ftag x -> Dom ftag a b -> Cod ftag (F ftag a) (F ftag b) Two examples: > data Opt a = Opt > type instance F Opt a = Maybe a > instance CFunctor Opt where > type Dom Opt = (->) > type Cod Opt = (->) > (Opt % f) Nothing = Nothing > (Opt % f) (Just x) = Just (f x) So (Opt % (*2)) has type: Num a => Maybe a -> Maybe a. > data Id ((~>) :: * -> * -> *) a = Id > type instance F (Id (~>)) a = a > instance (RCategory (~>)) => CFunctor (Id (~>)) where > type Dom (Id (~>)) = (~>) > type Cod (Id (~>)) = (~>) > Id % f = f The diagonal functor works nicely too: > data Diag ((~>) :: * -> * -> *) a = Diag > type instance F (Diag (~>)) a = (a, a) > instance (RCategory (~>)) => CFunctor (Diag (~>)) where > type Dom (Diag (~>)) = (~>) > type Cod (Diag (~>)) = (~>) :***: (~>) > Diag % f = f :***: f > test2 = (Diag % (*2)) @* (1, 5) -- (2, 10) But with the projection functors things start to break down. They can be defined, but not used: > data ProjL (c1 :: * -> * -> *) (c2 :: * -> * -> *) a = ProjL > type instance F (ProjL c1 c2) a = Fst a > instance (RCategory c1, RCategory c2) => CFunctor (ProjL c1 c2) where > type Dom (ProjL c1 c2) = c1 :***: c2 > type Cod (ProjL c1 c2) = c1 > ProjL % (f :***: g) = f > data ProjR (c1 :: * -> * -> *) (c2 :: * -> * -> *) a = ProjR > type instance F (ProjR c1 c2) a = Snd a > instance (RCategory c1, RCategory c2) => CFunctor (ProjR c1 c2) where > type Dom (ProjR c1 c2) = c1 :***: c2 > type Cod (ProjR c1 c2) = c2 > ProjR % (f :***: g) = g Here's an example, but GHCI does not know what a is, and so throws a bunch of errors about Fst a and Snd a. test3 = (ProjL % ((+10) :***: (*2))) 1 -- Should evalutate to 11, but doesn't compile. When trying to define the product functor, I run into another problem: data (w1 :*: w2) a = (forall x. w1 x) :*: (forall x. w2 x) type instance F (f1 :*: f2) a = (F f1 (Fst a), F f2 (Snd a)) instance (CFunctor f1, CFunctor f2) => CFunctor (f1 :*: f2) where type Dom (f1 :*: f2) = Dom f1 :***: Dom f2 type Cod (f1 :*: f2) = Cod f1 :***: Cod f2 (w1 :*: w2) % (f1 :***: f2) = (w1 % f1) :***: (w2 % f2) There is no proof that from a Suitable2 (Dom f) a, the functor produces a Suitable2 (Cod f) (F f a), i.e. I need something like: instance (CFunctor f, Suitable2 (Dom f) a) => Suitable2 (Cod f) (F f a) This proof is also needed for functor composition: data Comp g h a = Comp (forall x. g x) (forall x. h x) type instance F (Comp g h) a = F g (F h a) instance (CFunctor g, CFunctor h, Cod h ~ Dom g) => CFunctor (Comp g h) where type Dom (Comp g h) = Dom h type Cod (Comp g h) = Cod g Comp g h % f = g % (h % f) So for now the choice is between being able to define the product category, or dropping the Suitable2 restriction, and being able to do: -- Natural transformations type f :~> g = forall c (~>). (CFunctor f, CFunctor g, Dom f ~ Dom g, (~>) ~ Cod f, (~>) ~ Cod g) => F f c ~> F g c class (CFunctor f, CFunctor g) => Adjunction f g | f -> g, g -> f where unit :: (Dom f ~ Cod g, Cod f ~ Dom g) => f _x -> g _y -> Id (Cod g) :~> Comp g f counit :: (Dom f ~ Cod g, Cod f ~ Dom g) => f _x -> g _y -> Comp f g :~> Id (Cod f) leftAdjunct :: (Dom f ~ Cod g, Cod f ~ Dom g) => f _x -> g _y -> Cod f (F f a) b -> Cod g a (F g b) rightAdjunct :: (Dom f ~ Cod g, Cod f ~ Dom g) => f _x -> g _y -> Cod g a (F g b) -> Cod f (F f a) b unit f g = leftAdjunct f g id counit f g = rightAdjunct f g id leftAdjunct f g h = (g % h) . unit f g rightAdjunct f g h = counit f g . (f % h) data InitialProperty x u a = InitialProperty (Cod u x (F u a)) (forall y. Cod u x (F u y) -> Dom u a y) data TerminalProperty x u a = TerminalProperty (Cod u (F u a) x) (forall y. Cod u (F u y) x -> Dom u y a) adjTerminalProperty :: (Adjunction f g, Dom f ~ Cod g, Cod f ~ Dom g) => f _x -> g _y -> TerminalProperty x f (F g x) adjTerminalProperty f g = TerminalProperty (counit f g) (leftAdjunct f g) adjInitialProperty :: (Adjunction f g, Dom f ~ Cod g, Cod f ~ Dom g) => f _x -> g _y -> InitialProperty x g (F f x) adjInitialProperty f g = InitialProperty (unit f g) (rightAdjunct f g) Which, besides having to pass around the functor type witnesses everywhere, is quite nice I think. But if anyone has an idea how to provide proof that Suitable2 (Cod f) (F f a) when Suitable2 (Dom f) a, I would like to hear it! greetings, Sjoerd From daniel.is.fischer at web.de Sun Feb 21 13:25:31 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sun Feb 21 12:59:16 2010 Subject: [Haskell-cafe] GHC RTS question In-Reply-To: <88bdc6651002210920o7bae3b56u13eadf18600b1f7c@mail.gmail.com> References: <88bdc6651002210745p6629e363se0a5c70e039dd2e6@mail.gmail.com> <201002211713.26123.daniel.is.fischer@web.de> <88bdc6651002210920o7bae3b56u13eadf18600b1f7c@mail.gmail.com> Message-ID: <201002211925.31945.daniel.is.fischer@web.de> Am Sonntag 21 Februar 2010 18:20:43 schrieb Artyom Kazak: > > Enclose it in double quotes (perhaps single quotes would also work) > > No, I want my program to work the same way as UNIX "echo" does. > Without any double quotes. Okay, what about "If you absolutely positively want all the rest of the options in a command line to go to the program (and not the RTS), use a ??RTS." $ ./prog +RTS --RTS +RTS ? (BTW, enclosing in quotes doesn't work anyway if the argument consists *only* of "+RTS", same as with echo, echo "-e" doesn't output '-e' either). From daniel.is.fischer at web.de Sun Feb 21 13:30:34 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sun Feb 21 13:03:06 2010 Subject: [Haskell-cafe] Profiling In-Reply-To: <4B816BBF.2070000@btinternet.com> References: <1266772085.20269.1361103821@webmail.messagingengine.com> <4B816BBF.2070000@btinternet.com> Message-ID: <201002211930.34606.daniel.is.fischer@web.de> Am Sonntag 21 Februar 2010 18:22:07 schrieb Andrew Coppin: > Patai Gergely wrote: > >> I tried to compile my program with -prof, but GHC just whines at me > >> that the packages I'm using haven't been compiled for profiling. Do I > >> really need to go recompile every single package I'm using with > >> profiling support before I can profile my program? How do I tell > >> Cabal to install the necessary code? (I really hope this doesn't > >> involve uninstalling and reinstalling everything...) > > > > Almost. You don't need to uninstall anything, just run cabal install > > --reinstall -p for every relevant package. > > Oh, right. So I actually need cabal.exe to do this then? No, you can also $ ./runghc ./Setup.[l]hs configure --enable-library-profiling --user -- prefix=$HOME/.cabal $ ./runghc ./Setup.[l]hs build $ ./runghc ./Setup.[l]hs haddock --hyperlink-source $ ./runghc ./Setup.[l]hs install It's just more typing [protip: create a batch file (that is the Windows analogue of a shell-script, isn't it?)]. From artyom.kazak at gmail.com Sun Feb 21 13:58:12 2010 From: artyom.kazak at gmail.com (Artyom Kazak) Date: Sun Feb 21 13:28:47 2010 Subject: [Haskell-cafe] GHC RTS question In-Reply-To: <201002211925.31945.daniel.is.fischer@web.de> References: <88bdc6651002210745p6629e363se0a5c70e039dd2e6@mail.gmail.com> <201002211713.26123.daniel.is.fischer@web.de> <88bdc6651002210920o7bae3b56u13eadf18600b1f7c@mail.gmail.com> <201002211925.31945.daniel.is.fischer@web.de> Message-ID: <88bdc6651002211058n6af64adewb04ef8918f06cb7f@mail.gmail.com> 2010/2/21 Daniel Fischer : > Am Sonntag 21 Februar 2010 18:20:43 schrieb Artyom Kazak: >> > Enclose it in double quotes (perhaps single quotes would also work) >> >> No, I want my program to work the same way as UNIX "echo" does. >> Without any double quotes. > > Okay, what about > > "If you absolutely positively want all the rest of the options in a command > line to go to the program (and not the RTS), use a ??RTS." > > $ ./prog +RTS --RTS +RTS > > ? (BTW, enclosing in quotes doesn't work anyway if the argument consists > *only* of "+RTS", same as with echo, echo "-e" doesn't output '-e' either). > > So, if I type "./prog +RTS --RTS +RTS", the output will be "+RTS". But I want the output to be equal to the input IN ALL CASES, without any quotes, additional options, etc. I want all the command line to go to my program. How can I do it? (The only way I know now - hacking the GHC. If there are no other ways, I'll do it.) From batterseapower at hotmail.com Sun Feb 21 14:10:10 2010 From: batterseapower at hotmail.com (Max Bolingbroke) Date: Sun Feb 21 13:40:43 2010 Subject: [Haskell-cafe] GHC RTS question In-Reply-To: <88bdc6651002211058n6af64adewb04ef8918f06cb7f@mail.gmail.com> References: <88bdc6651002210745p6629e363se0a5c70e039dd2e6@mail.gmail.com> <201002211713.26123.daniel.is.fischer@web.de> <88bdc6651002210920o7bae3b56u13eadf18600b1f7c@mail.gmail.com> <201002211925.31945.daniel.is.fischer@web.de> <88bdc6651002211058n6af64adewb04ef8918f06cb7f@mail.gmail.com> Message-ID: <9d4d38821002211110s74151211k7adc18f5343c17ae@mail.gmail.com> On 21 February 2010 18:58, Artyom Kazak wrote: > So, if I type "./prog +RTS --RTS +RTS", the output will be "+RTS". But > I want the output to be equal to the input IN ALL CASES, without any > quotes, additional options, etc. I want all the command line to go to > my program. How can I do it? (The only way I know now - hacking the > GHC. If there are no other ways, I'll do it.) You might be able to get somewhere by writing a custom "main" function in C and linking it in. According to http://haskell.org/ghc/docs/latest/html/users_guide/options-phases.html if a lib specified with the -l option during compilation contains a "main", that will be used in preference to the one from HSrts. You could presumably just extend argv with the "+RTS" "--RTS" entries and then call into the one from HSrts, so this might even be quite easy. Cheers, Max From acowley at seas.upenn.edu Sun Feb 21 14:15:00 2010 From: acowley at seas.upenn.edu (Anthony Cowley) Date: Sun Feb 21 13:45:37 2010 Subject: [Haskell-cafe] GHC RTS question In-Reply-To: <88bdc6651002211058n6af64adewb04ef8918f06cb7f@mail.gmail.com> References: <88bdc6651002210745p6629e363se0a5c70e039dd2e6@mail.gmail.com> <201002211713.26123.daniel.is.fischer@web.de> <88bdc6651002210920o7bae3b56u13eadf18600b1f7c@mail.gmail.com> <201002211925.31945.daniel.is.fischer@web.de> <88bdc6651002211058n6af64adewb04ef8918f06cb7f@mail.gmail.com> Message-ID: <81addec71002211115v657ad55bk35e3d6b430d6e2af@mail.gmail.com> On Sun, Feb 21, 2010 at 1:58 PM, Artyom Kazak wrote: > So, if I type "./prog +RTS --RTS +RTS", the output will be "+RTS". But > I want the output to be equal to the input IN ALL CASES, without any > quotes, additional options, etc. I want all the command line to go to > my program. How can I do it? (The only way I know now - hacking the > GHC. If there are no other ways, I'll do it.) How about a wrapper script? Something like, #! /usr/bin/env bash ./prog --RTS $* Just use that as the front-end to your Haskell program. Anthony From daniel.is.fischer at web.de Sun Feb 21 14:12:11 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sun Feb 21 13:47:21 2010 Subject: [Haskell-cafe] GHC RTS question In-Reply-To: <88bdc6651002211058n6af64adewb04ef8918f06cb7f@mail.gmail.com> References: <88bdc6651002210745p6629e363se0a5c70e039dd2e6@mail.gmail.com> <201002211925.31945.daniel.is.fischer@web.de> <88bdc6651002211058n6af64adewb04ef8918f06cb7f@mail.gmail.com> Message-ID: <201002212012.12654.daniel.is.fischer@web.de> Am Sonntag 21 Februar 2010 19:58:12 schrieb Artyom Kazak: > 2010/2/21 Daniel Fischer : > > Am Sonntag 21 Februar 2010 18:20:43 schrieb Artyom Kazak: > >> > Enclose it in double quotes (perhaps single quotes would also work) > >> > >> No, I want my program to work the same way as UNIX "echo" does. > >> Without any double quotes. > > > > Okay, what about > > > > "If you absolutely positively want all the rest of the options in a > > command line to go to the program (and not the RTS), use a ??RTS." > > > > $ ./prog +RTS --RTS +RTS > > > > ? (BTW, enclosing in quotes doesn't work anyway if the argument > > consists *only* of "+RTS", same as with echo, echo "-e" doesn't output > > '-e' either). > > So, if I type "./prog +RTS --RTS +RTS", the output will be "+RTS". But > I want the output to be equal to the input IN ALL CASES, without any > quotes, additional options, etc. I want all the command line to go to > my program. How can I do it? (The only way I know now - hacking the > GHC. If there are no other ways, I'll do it.) Shell wrapper: $ cat wopTest ./opTest +RTS --RTS $@ $ cat opTest.hs module Main (main) where import System.Environment (getArgs) main = mapM_ print =<< getArgs $ ./wopTest +RTS -sstderr -RTS "+RTS" "-sstderr" "-RTS" Other than that, hacking GHC is the only way I can think of either, since looking for RTS-options is a fixed (and generally necessary) part of the RTS. But why do you want that behaviour so much that you'd be willing to hack GHC? From knyttv at gmail.com Sun Feb 21 15:26:31 2010 From: knyttv at gmail.com (=?utf-8?Q?Vojt=C4=9Bch_Knyttl?=) Date: Sun Feb 21 14:57:10 2010 Subject: [Haskell-cafe] STArray newListArray In-Reply-To: References: Message-ID: Ok, the problem was the Monad, which I still don't get completely, because I continue like this: data Field = W|B|H|D deriving (Eq,Show) pas :: ST s (STArray s (Int, Int) Field) -> ST s (STArray s (Int, Int) Field) pas b = do writeArray b (1,1) W And still getting: Couldn't match expected type `STArray s (Int, Int) Field' against inferred type `Field' Thanks. On Feb 21, 2010, at 5:33, Ben Millwood wrote: > 2010/2/21 Vojt?ch Knyttl : >> Hello, >> >> I am trying to create STArray with newListArray like this: >> la x y = newListArray ((1,1),(x,y)) [(x'+y') | x' <- [1..x], y' <- [1..y]] >> >> ? but it does not work: >> No instance for (MArray a Field m) > > Notice that newListArray has a monadic return type: > > newListArray :: (MArray a e m, Ix i) => (i, i) -> [e] -> m (a i e) > > with MArray a e m requiring Monad m. > So newListArray returns your STArray in a monad. That pretty much has > to be the ST monad, but that's not in scope, so you need to import > Control.Monad.ST before the MArray (STArray s) e (ST s) instance is > usable. > >> I tried to define the type like this, but it would not work either: >> la :: Int -> Int -> STArray (Int,Int) Field >> > > The kind for STArray here is slightly off. STArray needs three type > parameters, not two. > This is linked to the fact that ST is not a monad, but (ST s) is - the > extra parameter is essential to ST, to ensure the mutability doesn't > "leak out". > You probably want: > > la :: Integer -> Integer -> ST s (STArray s (Integer, Integer) Field) From andrewcoppin at btinternet.com Sun Feb 21 15:44:57 2010 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sun Feb 21 15:15:31 2010 Subject: [Haskell-cafe] Profiling In-Reply-To: <201002211930.34606.daniel.is.fischer@web.de> References: <1266772085.20269.1361103821@webmail.messagingengine.com> <4B816BBF.2070000@btinternet.com> <201002211930.34606.daniel.is.fischer@web.de> Message-ID: <4B819B49.2010500@btinternet.com> Daniel Fischer wrote: > Am Sonntag 21 Februar 2010 18:22:07 schrieb Andrew Coppin: > >> Oh, right. So I actually need cabal.exe to do this then? > > No, you can also > > $ ./runghc ./Setup.[l]hs configure --enable-library-profiling --user -- > prefix=$HOME/.cabal > $ ./runghc ./Setup.[l]hs build > $ ./runghc ./Setup.[l]hs haddock --hyperlink-source > $ ./runghc ./Setup.[l]hs install > > It's just more typing. What does the --hyperlink-source bit do? For that matter, what do --user and --prefix do? > a batch file (that is the Windows analogue of a shell-script, isn't it?)]. > If by "analogue" you mean "thing that's similar but with approximately 1/100th the expressive power", then yes. :-D From stephen.tetley at gmail.com Sun Feb 21 15:55:38 2010 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Sun Feb 21 15:26:13 2010 Subject: [Haskell-cafe] Profiling In-Reply-To: <4B819B49.2010500@btinternet.com> References: <1266772085.20269.1361103821@webmail.messagingengine.com> <4B816BBF.2070000@btinternet.com> <201002211930.34606.daniel.is.fischer@web.de> <4B819B49.2010500@btinternet.com> Message-ID: <5fdc56d71002211255p24cf5abdo60f63837ec5da678@mail.gmail.com> 2010/2/21 Andrew Coppin : > Daniel Fischer wrote: > > What does the --hyperlink-source bit do? Hello Andrew It generates marked up source code via hs-colour. Best wishes Stephen From gladstein at gladstein.com Sun Feb 21 15:57:45 2010 From: gladstein at gladstein.com (gladstein@gladstein.com) Date: Sun Feb 21 15:28:19 2010 Subject: [Haskell-cafe] grapefruit on windows or osX Message-ID: <20100221135745.75469f813b58c2e0e98e8a30424d5d59.60f1960477.wbe@email05.secureserver.net> I'm unable to get grapefruit going on osx or windows because (I think) I can't get the underlying GTK installed. Most recently I can't install gtk2hs over 6.10.4 because the installer tells me my haskell install isn't working and I should reinstall 6.10.1. It invites me to continue anyway and fix the DLL path myself. I continued and it doesn't work; cabal install grapefruit-ui-gtk still fails because it can't find a version of 'gtk'. The gtk demo program does work. Is the situation impossible, or do I just have to somehow tell something about some path? Hope that's all clear, and thanks in advance. From daniel.is.fischer at web.de Sun Feb 21 15:51:03 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sun Feb 21 15:28:34 2010 Subject: [Haskell-cafe] STArray newListArray In-Reply-To: References: Message-ID: <201002212151.04537.daniel.is.fischer@web.de> Am Sonntag 21 Februar 2010 21:26:31 schrieb Vojt?ch Knyttl: > Ok, the problem was the Monad, which I still don't get completely, > because I continue like this: > > data Field = W|B|H|D deriving (Eq,Show) > > pas :: ST s (STArray s (Int, Int) Field) -> ST s (STArray s (Int, Int) > Field) pas b = do writeArray b (1,1) W Here, b has type (STArray s (Int,Int) Field), and writeArray has type ghci> :t writeArray writeArray :: (MArray a e m, Ix i) => a i e -> i -> e -> m () , in this case (STArray s (Int,Int) Field -> (Int,Int) -> Field -> ST s (), so the signature ought to be pas :: STArray s (Int,Int) Field -> ST s () It's new[List]Array, readArray, writeArray etc which have a type of ... -> ST s something the array itself doesn't. > > And still getting: > Couldn't match expected type `STArray s (Int, Int) Field' > against inferred type `Field' That's puzzling. I'd expect a different error message. > > Thanks. From benjamin.franksen at bessy.de Sun Feb 21 15:32:30 2010 From: benjamin.franksen at bessy.de (Ben Franksen) Date: Sun Feb 21 15:33:57 2010 Subject: [Haskell-cafe] Re: darcs 2.4 release candidate 2 References: <201002182214.21113.tux_rocker@reinier.de> Message-ID: And here are the numbers for record -lam: ben@sarun[1]: .../rtems/rtems-4.9.0 > darcs --version 2.3.1 (release) ben@sarun[1]: .../rtems/rtems-4.9.0 > time darcs record -lam'import release 4.9.0' Finished recording patch 'import release 4.9.0' darcs record -lam'import release 4.9.0' 143,33s user 6,57s system 69% cpu 3:34,22 total vs. ben@sarun[1]: .../rtems/rtems-4.9.0 > /home/ben/.cabal/bin/darcs --version 2.3.99.2 (release candidate 2) ben@sarun[1]: .../rtems/rtems-4.9.0 > time /home/ben/.cabal/bin/darcs record -lam'import release 4.9.0' withSignalsHandled: Interrupted! /home/ben/.cabal/bin/darcs record -lam'import release 4.9.0' 1549,45s user 11,81s system 94% cpu 27:40,50 total (killed by me) Re Petr Rockai: No this isn't critical for us at the moment, so I don't need a workaround. I still think regressions of such a scale should be considered a bug. Cheers Ben From daniel.is.fischer at web.de Sun Feb 21 16:11:18 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sun Feb 21 15:43:50 2010 Subject: [Haskell-cafe] Profiling In-Reply-To: <4B819B49.2010500@btinternet.com> References: <1266772085.20269.1361103821@webmail.messagingengine.com> <201002211930.34606.daniel.is.fischer@web.de> <4B819B49.2010500@btinternet.com> Message-ID: <201002212211.19986.daniel.is.fischer@web.de> Am Sonntag 21 Februar 2010 21:44:57 schrieb Andrew Coppin: > Daniel Fischer wrote: > > Am Sonntag 21 Februar 2010 18:22:07 schrieb Andrew Coppin: > >> Oh, right. So I actually need cabal.exe to do this then? > > > > No, you can also > > > > $ ./runghc ./Setup.[l]hs configure --enable-library-profiling --user > > -- prefix=$HOME/.cabal > > $ ./runghc ./Setup.[l]hs build > > $ ./runghc ./Setup.[l]hs haddock --hyperlink-source > > $ ./runghc ./Setup.[l]hs install > > > > It's just more typing. > > What does the --hyperlink-source bit do? Stephen already answered that one. > For that matter, what do --user and --prefix do? The flag --user allows dependencies to be satisfied from the user package database, --prefix says where to put stuff. Of course all these options are optional, you can omit them (except --enable-library-profiling, because that's your target) and use only the global package database. One thing, though: if you do it manually, you have to reinstall the packages in the correct order (if x depends on y, you can't build x for profiling unless y is already built for profiling), cabal takes care of all that for you, so the clever method is indeed using cabal. > > > a batch file (that is the Windows analogue of a shell-script, isn't > > it?)]. > > If by "analogue" you mean "thing that's similar but with approximately > 1/100th the expressive power", then yes. :-D > 1/100th is enough for this. From andrewcoppin at btinternet.com Sun Feb 21 16:27:29 2010 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sun Feb 21 15:57:36 2010 Subject: [Haskell-cafe] Profiling In-Reply-To: <5fdc56d71002211255p24cf5abdo60f63837ec5da678@mail.gmail.com> References: <1266772085.20269.1361103821@webmail.messagingengine.com> <4B816BBF.2070000@btinternet.com> <201002211930.34606.daniel.is.fischer@web.de> <4B819B49.2010500@btinternet.com> <5fdc56d71002211255p24cf5abdo60f63837ec5da678@mail.gmail.com> Message-ID: <4B81A541.5040203@btinternet.com> >> What does the --hyperlink-source bit do? >> > > Hello Andrew > > It generates marked up source code via hs-colour. > I'm presuming this only works if hs-colour is installed first though? Or is it statically linked into the Haddock binary? From benjamin.franksen at bessy.de Sun Feb 21 15:41:33 2010 From: benjamin.franksen at bessy.de (Ben Franksen) Date: Sun Feb 21 16:07:09 2010 Subject: [Haskell-cafe] Re: darcs 2.4 release candidate 2 References: <201002182214.21113.tux_rocker@reinier.de> Message-ID: Ben Franksen wrote: > The situation with record is similar. > > I admit that the huge RTEMS tree with over 7000 changes between the two > releases is challenging. However, earlier releases can do it (though it > takes long, much longer than with, say, mercurial). Just for comparison, here are the numbers for mercurial: ben@sarun[1]: .../rtems/rtems-4.9.0 > hg --version Mercurial Distributed SCM (version 0.9.5) ben@sarun[1]: .../rtems/rtems-4.9.0 > hg log changeset: 0:8b3cbc67b25f user: ben@sarun date: Sun Feb 21 21:29:10 2010 +0100 summary: import release 4.8.1 ben@sarun[1]: .../rtems/rtems-4.9.0 > time (hg addremove && hg commit -m'import release 4.9.0') # ... long output elided ... (; hg addremove && hg commit -m'import release 4.9.0'; ) 9,20s user 1,15s system 92% cpu 11,181 total Cheers Ben From stephen.tetley at gmail.com Sun Feb 21 16:38:41 2010 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Sun Feb 21 16:09:15 2010 Subject: [Haskell-cafe] Profiling In-Reply-To: <4B81A541.5040203@btinternet.com> References: <1266772085.20269.1361103821@webmail.messagingengine.com> <4B816BBF.2070000@btinternet.com> <201002211930.34606.daniel.is.fischer@web.de> <4B819B49.2010500@btinternet.com> <5fdc56d71002211255p24cf5abdo60f63837ec5da678@mail.gmail.com> <4B81A541.5040203@btinternet.com> Message-ID: <5fdc56d71002211338u47778dafjd34b438aaf06614@mail.gmail.com> Hi Andrew It needs installing. Its well worth it though, an invaluable tool. Thanks Malcolm and Bjorn! On 21 February 2010 21:27, Andrew Coppin wrote: > I'm presuming this only works if hs-colour is installed first though? Or is > it statically linked into the Haddock binary? From jeremy at n-heptane.com Sun Feb 21 16:45:27 2010 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Sun Feb 21 16:16:14 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: <20100221175030.7D7F493C40@mail.avvanta.com> References: <1266355493-sup-6667@oz.taruti.net><1266394750-sup-7721@oz.taruti.net><1266508065-sup-8211@oz.taruti.net> <20100221175030.7D7F493C40@mail.avvanta.com> Message-ID: <77FAF8ED-CE5C-44F6-9219-B60688CB39A4@n-heptane.com> On Feb 21, 2010, at 11:50 AM, Donn Cave wrote: > > The problem is that this definition of `closed' is, precisely, > `failed to respond within 2 seconds.' If there is no observable > difference between a connection that has been abandoned by the PS3, > and a connection that just suffered a momentary lapse, then there's > no way to catch the former without making connections more fragile. No. (i think) What happens is the PS3 has closed the connection, and if you attempt to send any more packets the PS3 will tell you it has closed the connection and the write() / sendfile() call will raise SIGPIPE. The problem is we never try to send those packets, because we are sitting at threadWaitWrite waiting to write -- and there is nothing that is going to happen that will cause that call to select () (by threadWaitWrite) to actually wakeup. I believe the proposal is to add a 2 second time out to the threadWaitWrite call. If it wakes up and can't write (because the remote side has lost connections, etc) then it will just go back to sleep. But if it wakes up, tries to write, and then gets sigPIPE, then it knows the connection is actually dead and will clean up after itself. The problem is that we have not successfully figure out what is causing this issue in the first place. I wrote a haskell server and a C client to try to emulate the situation which causes threadWaitWrite to never wake-up.. but I could not actually get that to happen. So for the PS3 client is the only thing that causes it. I think that applying a fix with out really understanding the problem is asking for trouble. Among other things, since the problem is with threadWaitWrite (not sendfile), then the same issue ought to exist when we are calling hPutStr, etc, since they ultimately call threadWaitWrite as well. If hPut never has this problem, then we should understand why and use the same solution for sendfile. If hPut does have this problem, then fixing just sendfile isn't much of a solution. So far there is: - no way for anyone besides Bardur to reproduce the problem - no sound explanation for why the PS3 client causes the error, but nothing else does - no proof that this error does or does not affect all the normal I/ O functions in Haskell (hPut, etc). - jeremy -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100221/eb401da4/attachment.html From ben.franksen at online.de Sun Feb 21 15:51:31 2010 From: ben.franksen at online.de (Ben Franksen) Date: Sun Feb 21 16:20:58 2010 Subject: [Haskell-cafe] Re: Re[2]: Threading and FFI References: <27611528.post@talk.nabble.com> <20100216172522.GC6832@kira.casa> <27612884.post@talk.nabble.com> <27613138.post@talk.nabble.com> <27621580.post@talk.nabble.com> <27631980.post@talk.nabble.com> <648858494.20100218094107@gmail.com> <27635260.post@talk.nabble.com> <27647126.post@talk.nabble.com> <27665592.post@talk.nabble.com> Message-ID: Yves Par?s wrote: > Just one last remark: when I moved all my OpenGL calls from the main > thread to an unbound thread. I thought it'd not work -- because I assumed > I would have to launch it in a bound thread -- and however it went > right... You were just lucky the RTS accidentally delegated all your OpenGL calls to the same OS thread. It might turn out bad next time you run the program, or on another machine, or after adding more threads. Been there... Cheers Ben From permeakra at gmail.com Sun Feb 21 16:55:05 2010 From: permeakra at gmail.com (Permjacov Evgeniy) Date: Sun Feb 21 16:25:44 2010 Subject: [Haskell-cafe] Re: Parsing of bytestrings with non-String errors? In-Reply-To: <20100221205745.C576532466C@www.haskell.org> References: <20100221205745.C576532466C@www.haskell.org> Message-ID: <4B81ABB9.4000106@gmail.com> On 02/21/2010 11:57 PM, haskell-cafe-request@haskell.org wrote: > Message: 2 > Date: Sun, 21 Feb 2010 12:36:21 +0000 > From: Magnus Therning > Subject: [Haskell-cafe] Parsing of bytestrings with non-String errors? > To: haskell-cafe > Message-ID: <4B8128C5.6030105@therning.org> > Content-Type: text/plain; charset="utf-8" > > I've looked at polyparse and attoparsec and they seem to have in common that > the error always is a String. My current ideas for a project would be a lot > easier if I could just return some other type, something that I can pattern > match on. > > Is there a parser combinator library out there that works on bytestrings and > allows using a custom error type? > > Or maybe there's some very basic reason why String is so commonly used? > > You can try to play with ParsecT / ErrorT From shumovichy at gmail.com Sun Feb 21 17:07:43 2010 From: shumovichy at gmail.com (Yuras Shumovich) Date: Sun Feb 21 16:38:22 2010 Subject: [Haskell-cafe] grapefruit on windows or osX In-Reply-To: <20100221135745.75469f813b58c2e0e98e8a30424d5d59.60f1960477.wbe@email05.secureserver.net> References: <20100221135745.75469f813b58c2e0e98e8a30424d5d59.60f1960477.wbe@email05.secureserver.net> Message-ID: <1d6a9f301002211407k3da97fd4kd51fd1573f19738d@mail.gmail.com> If you are using binary gtk2hs installer for windows, then you have to install the same ghc version the installer was built for. As I know there are no gtk2hs build for ghc-6.10.4. You can build it manually (using msys), but it is complicated task. 2010/2/21 : > I'm unable to get grapefruit going on osx or windows because (I think) I > can't get the underlying GTK installed. > > Most recently I can't install gtk2hs over 6.10.4 because the installer > tells me my haskell install isn't working and I should reinstall 6.10.1. > It invites me to continue anyway and fix the DLL path myself. > > I continued and it doesn't work; cabal install grapefruit-ui-gtk still > fails because it can't find a version of 'gtk'. The gtk demo program > does work. > > Is the situation impossible, or do I just have to somehow tell something > about some path? > > Hope that's all clear, and thanks in advance. > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From corentin.dupont at gmail.com Sun Feb 21 17:13:14 2010 From: corentin.dupont at gmail.com (Dupont Corentin) Date: Sun Feb 21 16:43:48 2010 Subject: [Haskell-cafe] games of chance In-Reply-To: <4B7F564B.1060901@bigpond.net.au> References: <18a05e6b1002191914r3d7d7fe6vc2805b0a2c91fe69@mail.gmail.com> <4B7F564B.1060901@bigpond.net.au> Message-ID: <18a05e6b1002211413y2b0bf492n6580ac3e5e6e6507@mail.gmail.com> Thanks a lot Mark. Corentin On Sat, Feb 20, 2010 at 4:26 AM, Mark Wassell wrote: > Take a look at: > > http://hackage.haskell.org/package/probability > > and > > http://web.engr.oregonstate.edu/~erwig/pfp/ > > Mark > > > Dupont Corentin wrote: > >> >> Hello, >> are you aware of a framework to find probabilities in a given game of >> chance, in Haskell? >> >> l would like to compute probabilities like: >> "roll 3 dices, sum the result, then roll 3 other dices, sum the result, >> what is the probability to obtain the same sum?" >> >> Cheers, >> Corentin >> >> >> >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100221/b00541b6/attachment.html From haskell at benmachine.co.uk Sun Feb 21 17:21:11 2010 From: haskell at benmachine.co.uk (Ben Millwood) Date: Sun Feb 21 16:51:45 2010 Subject: [Haskell-cafe] GHC RTS question In-Reply-To: <9d4d38821002211110s74151211k7adc18f5343c17ae@mail.gmail.com> References: <88bdc6651002210745p6629e363se0a5c70e039dd2e6@mail.gmail.com> <201002211713.26123.daniel.is.fischer@web.de> <88bdc6651002210920o7bae3b56u13eadf18600b1f7c@mail.gmail.com> <201002211925.31945.daniel.is.fischer@web.de> <88bdc6651002211058n6af64adewb04ef8918f06cb7f@mail.gmail.com> <9d4d38821002211110s74151211k7adc18f5343c17ae@mail.gmail.com> Message-ID: On Sun, Feb 21, 2010 at 7:10 PM, Max Bolingbroke wrote: > > You might be able to get somewhere by writing a custom "main" function > in C and linking it in. According to > http://haskell.org/ghc/docs/latest/html/users_guide/options-phases.html > if a lib specified with the -l option during compilation contains a > "main", that will be used in preference to the one from HSrts. > I think the neater way of doing this would be to use the FFI, with a foreign export declaration making your haskell main available to a wrapper C file, which would then initialise the RTS with a slightly-modified argc and argv. See http://www.haskell.org/ghc/docs/latest/html/users_guide/ffi-ghc.html for details on how to do that. I also think it's strange, though, that adding RTS hooks is not optional. GHC should support some method of disabling them, in my opinion. From zao at acc.umu.se Sun Feb 21 18:30:57 2010 From: zao at acc.umu.se (Lars Viklund) Date: Sun Feb 21 18:02:29 2010 Subject: [Haskell-cafe] Re: Re[2]: Threading and FFI In-Reply-To: References: <27611528.post@talk.nabble.com> <20100216172522.GC6832@kira.casa> <27612884.post@talk.nabble.com> <27613138.post@talk.nabble.com> <27621580.post@talk.nabble.com> <27631980.post@talk.nabble.com> <648858494.20100218094107@gmail.com> <27635260.post@talk.nabble.com> <27647126.post@talk.nabble.com> <27665592.post@talk.nabble.com> Message-ID: <4B81C231.70304@acc.umu.se> On 02/21/2010 09:51 PM, Ben Franksen wrote: > Yves Par?s wrote: >> Just one last remark: when I moved all my OpenGL calls from the main >> thread to an unbound thread. I thought it'd not work -- because I assumed >> I would have to launch it in a bound thread -- and however it went >> right... > > You were just lucky the RTS accidentally delegated all your OpenGL calls to > the same OS thread. It might turn out bad next time you run the program, or > on another machine, or after adding more threads. Been there... I've been hacking on a DirectX binding recently where just about all calls have thread affinity as well. The effect of running calls on the wrong thread there was (on my machine, running Seven) making the whole Windows GUI flicker. I wouldn't be surprised if it'd crash on other platforms. Remember, undefined behaviour is not always kind enough to fail hard. From lennart at augustsson.net Sun Feb 21 18:55:30 2010 From: lennart at augustsson.net (Lennart Augustsson) Date: Sun Feb 21 18:26:06 2010 Subject: [Haskell-cafe] GHC RTS question In-Reply-To: References: <88bdc6651002210745p6629e363se0a5c70e039dd2e6@mail.gmail.com> <201002211713.26123.daniel.is.fischer@web.de> <88bdc6651002210920o7bae3b56u13eadf18600b1f7c@mail.gmail.com> <201002211925.31945.daniel.is.fischer@web.de> <88bdc6651002211058n6af64adewb04ef8918f06cb7f@mail.gmail.com> <9d4d38821002211110s74151211k7adc18f5343c17ae@mail.gmail.com> Message-ID: Supply a fix for the problem, and it will probably get included. There has probably been little demand for this feature so far. -- Lennart On Sun, Feb 21, 2010 at 10:21 PM, Ben Millwood wrote: > On Sun, Feb 21, 2010 at 7:10 PM, Max Bolingbroke > wrote: >> >> You might be able to get somewhere by writing a custom "main" function >> in C and linking it in. According to >> http://haskell.org/ghc/docs/latest/html/users_guide/options-phases.html >> if a lib specified with the -l option during compilation contains a >> "main", that will be used in preference to the one from HSrts. >> > > I think the neater way of doing this would be to use the FFI, with a > foreign export declaration making your haskell main available to a > wrapper C file, which would then initialise the RTS with a > slightly-modified argc and argv. > See http://www.haskell.org/ghc/docs/latest/html/users_guide/ffi-ghc.html > for details on how to do that. > > I also think it's strange, though, that adding RTS hooks is not > optional. GHC should support some method of disabling them, in my > opinion. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ivan.miljenovic at gmail.com Sun Feb 21 19:05:48 2010 From: ivan.miljenovic at gmail.com (Ivan Miljenovic) Date: Sun Feb 21 18:36:21 2010 Subject: [Haskell-cafe] GHC RTS question In-Reply-To: References: <88bdc6651002210745p6629e363se0a5c70e039dd2e6@mail.gmail.com> <201002211713.26123.daniel.is.fischer@web.de> <88bdc6651002210920o7bae3b56u13eadf18600b1f7c@mail.gmail.com> <201002211925.31945.daniel.is.fischer@web.de> <88bdc6651002211058n6af64adewb04ef8918f06cb7f@mail.gmail.com> <9d4d38821002211110s74151211k7adc18f5343c17ae@mail.gmail.com> Message-ID: On 22 February 2010 10:55, Lennart Augustsson wrote: > Supply a fix for the problem, and it will probably get included. > There has probably been little demand for this feature so far. But it is a little bit weird where if you have an application that you release into production (which, admittedly, I've never done), then end users are able to fiddle with settings which they shouldnt' really touch (though there's not really that much that I can see that they'd be able to do wrong with just RTS settings...). -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com Joan Crawford - "I, Joan Crawford, I believe in the dollar. Everything I earn, I spend." - http://www.brainyquote.com/quotes/authors/j/joan_crawford.html From ok at cs.otago.ac.nz Sun Feb 21 19:37:00 2010 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Sun Feb 21 19:07:37 2010 Subject: [Haskell-cafe] Category Theory woes In-Reply-To: <4B80345A.6090204@t-online.de> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <75cc17ac1002180924r6d8eb5f4r3a7ddebd9825c69f@mail.gmail.com> <4B7D8D23.3020402@t-online.de> <201002182031.03105.daniel.is.fischer@web.de> <4B7DEE0B.7050309@t-online.de> <681D5A1F-0BAC-4ECA-8A1D-2D5C1DB00F5E@cs.otago.ac.nz> <4B80345A.6090204@t-online.de> Message-ID: On Feb 21, 2010, at 8:13 AM, Nick Rudnick wrote: >> Of course a basic point about language is that the association >> between sounds and meanings is (for the most part) arbitrary. > I would rather like to say it is not strictly determined, as an > evolutionary tendence towards, say ergonomy, cannot be overlooked, > can it? I see no evolutionary tendency towards "ergonomy" in the world's languages. *Articulatory economy*, yes. Bits are always eroding off words. But as for any other kind of "ergonomy", well, people have been talking for a very long time, so such a tendency should have had *some* effect by now, surely? While there seem to be some deep unities, the world's languages are a very diverse lot. Let's face it, who really _needs_ a paucal number? Or 12 noun classes? Or 16 cases? Maori manages just fine without any of those things. >> Why should the terminology of mathematics be any different? > ;-) Realizing an evolutionary tendence towards ergonony, is my > subject... Does such a tendency exist? If it does, why should we aid and abet a tendency which, to the extent it exists in biology, excels in producing parasites? > Thanks for this beautiful example and, honestly, again I ask again > whether we may regard this as ?just noise?: In contrary, aren't such > usages not paradigmatical examples of memes, which as products of > memetic evolution, should be studied for their motivational value? Quite possibly. But ergonomics is *not* the driver. > The problem I see is that common maths claims an exception in > claiming that, in it's domain, namings are no more than noise No such thing. Quick now, what semantics is transparently revealed in the names "birch, beech, spruce, fir, oak"? To a native speaker of English, these things mean what they mean by convention and nothing else. (If we can trust the OED etymology, "beech" may have originally meant "a tree with edible fruit", but this is very far from transparent to a native speaker of modern English. And spruce trees are so called not because they are particularly spruce but because they came from Prussia, again, very far from transparent to a native speaker of M.E.) > > And, to close in your figurative style: > > Which woman gets hurt by a change of clothes? The one whose new clothes fit her worse, of course. From donn at avvanta.com Sun Feb 21 19:39:24 2010 From: donn at avvanta.com (Donn Cave) Date: Sun Feb 21 19:09:58 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? References: <1266355493-sup-6667@oz.taruti.net><1266394750-sup-7721@oz.taruti.net><1266508065-sup-8211@oz.taruti.net> <20100221175030.7D7F493C40@mail.avvanta.com><77FAF8ED-CE5C-44F6-9219-B60688CB39A4@n-heptane.com> Message-ID: <20100222003924.6E28893C2E@mail.avvanta.com> Quoth Jeremy Shaw , ... > What happens is the PS3 has closed the connection, and if you attempt > to send any more packets the PS3 will tell you it has closed the > connection and the write() / sendfile() call will raise SIGPIPE. ... > So far there is: > > - no way for anyone besides Bardur to reproduce the problem > - no sound explanation for why the PS3 client causes the error, > but nothing else does I think in fact this invalidates your premise. If the PS3 really closed its connection in the standard fashion, then it would be trivial to reproduce this problem with any other peer. Evidently it doesn't, at least in this particular case, and that's why people are talking about TCP keep-alives, which address the defunct peer problem (within two hours, normally.) Donn Cave donn@avvanta.com From jeremy at n-heptane.com Sun Feb 21 20:17:06 2010 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Sun Feb 21 19:47:41 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: <20100222003924.6E28893C2E@mail.avvanta.com> References: <1266394750-sup-7721@oz.taruti.net> <1266508065-sup-8211@oz.taruti.net> <20100221175030.7D7F493C40@mail.avvanta.com> <77FAF8ED-CE5C-44F6-9219-B60688CB39A4@n-heptane.com> <20100222003924.6E28893C2E@mail.avvanta.com> Message-ID: On Sun, Feb 21, 2010 at 6:39 PM, Donn Cave wrote: > Quoth Jeremy Shaw , > ... > > What happens is the PS3 has closed the connection, and if you attempt > > to send any more packets the PS3 will tell you it has closed the > > connection and the write() / sendfile() call will raise SIGPIPE. > ... > > So far there is: > > > > - no way for anyone besides Bardur to reproduce the problem > > - no sound explanation for why the PS3 client causes the error, > > but nothing else does > > I think in fact this invalidates your premise. If the PS3 really > closed its connection in the standard fashion, then it would be trivial > to reproduce this problem with any other peer. Evidently it doesn't, > at least in this particular case, and that's why people are talking > about TCP keep-alives, which address the defunct peer problem (within > two hours, normally.) The PS3 does do something though. If we were doing a write *and* read select on the socket, the read select would wakeup. So, it is trying to notify us that something has happened, but we are not seeing it because we are only looking at the write select(). But I can not explain what the PS3 client is doing differently than the other clients such that it does not cause the threadWaitWrite to wakeup. Additionally, it is not clear that setting SO_KEEPALIVE will actually fix anything. The documentation that I have read indicates that that may only cause the read select() to wakeup not the write select(). Well, that is no good, because that is supposedly what is happening with the PS3 client already. Anyway, part of the annoyance here is that in this particular case we shouldn't need any timeouts to 'guess' that the client is 'probably dead'. The client seems to be telling us that it has disconnected, but we are not looking in the right place. And if we did try to write we would get a sigPIPE error. It is not the case the the client is unresponsive -- it is quite responsive. The problem is that we are not looking in the right place for that response. But, 'looking in the right place' is tricky. How do you tell hPut that it should wakeup from threadWaitWrite if the Handle happens to be backed by a socket, and threadWaitRead has data available? That does not even always indicate an error condition, it can be a perfectly valid situation. Well, before I think about that, I want to know what the PS3 client is doing differently such that it is the only client that seems to exhibit this behavior at the moment. If we do not understand the real difference between what the PS3 and the C client are doing, then I don't think we can expect to arrive at an appropriate fix. - jeremy -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100221/c2a469ed/attachment.html From dons at galois.com Sun Feb 21 20:57:25 2010 From: dons at galois.com (Don Stewart) Date: Sun Feb 21 20:28:02 2010 Subject: [Haskell-cafe] Some great results on fused code with the LLVM backend Message-ID: <20100222015725.GA1870@whirlpool.galois.com> I tried out some of the vector and uvector fusion benchmarks with the new LLVM backend http://donsbot.wordpress.com/2010/02/21/smoking-fast-haskell-code-using-ghcs-new-llvm-codegen/ and got some great results for the tight loops generated through fusion. Up to 2x faster than gcc -O3 in some cases. The LLVM backend looks very promising -- considering we've not even begun to explore the optimization pipeline at the level. -- Don From ezyang at MIT.EDU Mon Feb 22 02:15:28 2010 From: ezyang at MIT.EDU (Edward Z. Yang) Date: Mon Feb 22 01:46:02 2010 Subject: [Haskell-cafe] Optimizing hash array mapped tries Message-ID: <1266821677-sup-1773@ezyang> Hello all, I spent this weekend attempting to impement Phil Bagwell's Hash Array Mapped Tries in Haskell. You can view the fruits of this work at this repository: http://github.com/ezyang/hamt Unfortunately, I'm getting pretty abysmal performance out of the implementation I wrote, so I'm hoping to get some performance tuning insights here. My cost centers look about like this: time% alloc% i-Full-update HAMT 29.1 31.4 lookup' HAMT 13.7 4.3 main Main 12.8 19.7 subkey HAMT 11.5 10.0 i-Bitmap HAMT 9.4 12.0 i-Full HAMT 8.1 12.9 insert' HAMT 5.1 0.6 popCount PopCount 4.7 1.0 And my GC stats look like: ./HAMTTest 256000 +RTS -t 275576630962922 <> + 0:03.16 ./IntMapTest 256000 +RTS -t -710684043813 <> + 0:01.18 IntMap is included for comparison. The HAMT does about x3-5 worse than IntMap, and uses about x4 more memory (and gets correspondingly penalized when garbage collection occurs). My observations/suspicions are as such: * i-Full-update essentially copies a 32-size vector, with a change to one element. I think I am getting brutally punished for this, in terms of both memory usage as well as runtime. What I'm curious is whether or not this is intrinsic to the algorithm, or if it's something special that GHC is doing. * Bagwell suggests that each node in the Array-Mapped Trie should take only two words. I think I'm losing another two words to storing bounds information in vector, as well as the costs of boxing (though I can't tell if GHC is boxing or not). I've done some playing around with the data declaration, but it's current form seems to result in the fastest implementation. I wonder if this is what is causing the x4 ballooning of memory, or if it's something else. I haven't tried rewriting the code to use GHC's arrays. * Increasing the heap size seems to generally improve the performance the HAMT; a 1G heap on a 512K sample set reduces the difference to about x1.5-2 slower. It's hard to tell if the memory allocation system is working for or against me. What bothers me is even if I could magically wave away all GC time in HAMT, it would only barely win against IntMap. Maybe the algorithm is simply not as good as a good ole' Patricia Trie; but then again, maybe not. Comments and suggestions greatly appreciated. Thanks, Edward From kolar at fit.vutbr.cz Mon Feb 22 02:57:41 2010 From: kolar at fit.vutbr.cz (=?ISO-8859-2?Q?Du=B9an_Kol=E1=F8?=) Date: Mon Feb 22 02:28:18 2010 Subject: [Haskell-cafe] Installing wx via cabal Message-ID: <4B8238F5.1000400@fit.vutbr.cz> Dear all, Running cabal install --global wx stops very soon with the following error. Building wxcore-0.12.1.2... [ 1 of 22] Compiling Graphics.UI.WXCore.WxcObject ( src/haskell/Graphics/UI/WXCore/WxcObject.hs, dist/build/Graphics/UI/WXCore/WxcObject.o ) [ 2 of 22] Compiling Graphics.UI.WXCore.WxcDefs ( src/haskell/Graphics/UI/WXCore/WxcDefs.hs, dist/build/Graphics/UI/WXCore/WxcDefs.o ) [ 3 of 22] Compiling Graphics.UI.WXCore.WxcClassTypes ( src/haskell/Graphics/UI/WXCore/WxcClassTypes.hs, dist/build/Graphics/UI/WXCore/WxcClassTypes.o ) [ 4 of 22] Compiling Graphics.UI.WXCore.WxcTypes ( src/haskell/Graphics/UI/WXCore/WxcTypes.hs, dist/build/Graphics/UI/WXCore/WxcTypes.o ) [ 5 of 22] Compiling Graphics.UI.WXCore.WxcClassesAL ( src/haskell/Graphics/UI/WXCore/WxcClassesAL.hs, dist/build/Graphics/UI/WXCore/WxcClassesAL.o ) ghc: out of memory (requested 1048576 bytes) cabal: Error: some packages failed to install: It seems quite strange as the machine seems to have 16GB RAM and a free swap, can I somehow put options or so? I have ghc 10.4. installed. Thanks Dusan From noteed at gmail.com Mon Feb 22 02:59:44 2010 From: noteed at gmail.com (minh thu) Date: Mon Feb 22 02:30:36 2010 Subject: [Haskell-cafe] Re: [Haskell] Functional Programming User Group Ghent In-Reply-To: <8B6A33CA-B550-4B44-96D8-C8CE9B6959C6@gmail.com> References: <8B6A33CA-B550-4B44-96D8-C8CE9B6959C6@gmail.com> Message-ID: <40a414c21002212359y2e263991kd141ff5e816c4518@mail.gmail.com> [moving to caf? from haskell] 2010/2/21 Jeroen Janssen : > Dear all, > We are in the progress of starting up a Functional Programming User Group in > Ghent. The basic idea of the group is to have occasional informal meetings > where people can give talks, where we have invited speakers, where we go to > a bar to chat about all things Functional Programming, to organize Haskell > Hacking events etc. > To see if enough people would be interested in such a group, and to make the > organizing process of the first meeting easier, we would like to ask anyone > interested to tick off the dates he/she is available on the Doodle-page > provided below. Note that the indicated time is only a rough guideline; if > you would prefer another time of day, you can indicate this in the Comments > section of the Doodle. > http://www.doodle.com/xq2i5hsueidwkh2f > If enough people are interested, and a date is decided upon, we will e-mail > the Haskell list once more to confirm the date and give anyone who was > interested, but could not fill in the doodle, a chance to be present. Also, > this ensures that you do not have to leave your e-mail address on Doodle. > If you have any questions, do not hecessitate to contact one of us at either > Bart.Coppens@UGent.be > jejansse@gmail.com > Kind Regards, > Bart Coppens > Jeroen Janssen Hi Jeroen, Great, a fp user group in Belgium! Alas my dutch is too rusty too even understand the Doodle poll description. Is the group planned only for dutch-speaking programmers ? Cheers, Thu From noteed at gmail.com Mon Feb 22 03:05:09 2010 From: noteed at gmail.com (minh thu) Date: Mon Feb 22 02:36:03 2010 Subject: [Haskell-cafe] GHC RTS question In-Reply-To: References: <88bdc6651002210745p6629e363se0a5c70e039dd2e6@mail.gmail.com> <201002211713.26123.daniel.is.fischer@web.de> <88bdc6651002210920o7bae3b56u13eadf18600b1f7c@mail.gmail.com> <201002211925.31945.daniel.is.fischer@web.de> <88bdc6651002211058n6af64adewb04ef8918f06cb7f@mail.gmail.com> <9d4d38821002211110s74151211k7adc18f5343c17ae@mail.gmail.com> Message-ID: <40a414c21002220005l6ca3339na6cd23263e9c6d52@mail.gmail.com> 2010/2/22 Ivan Miljenovic : > On 22 February 2010 10:55, Lennart Augustsson wrote: >> Supply a fix for the problem, and it will probably get included. >> There has probably been little demand for this feature so far. > > But it is a little bit weird where if you have an application that you > release into production (which, admittedly, I've never done), then end > users are able to fiddle with settings which they shouldnt' really > touch (though there's not really that much that I can see that they'd > be able to do wrong with just RTS settings...). Isn't the same situation with java, or even with any application using some config files, or with dynamic libraries ? Cheers, Thu From jejansse at gmail.com Mon Feb 22 03:34:26 2010 From: jejansse at gmail.com (Jeroen Janssen) Date: Mon Feb 22 03:05:01 2010 Subject: [Haskell-cafe] Re: [Haskell] Functional Programming User Group Ghent In-Reply-To: <40a414c21002212359y2e263991kd141ff5e816c4518@mail.gmail.com> References: <8B6A33CA-B550-4B44-96D8-C8CE9B6959C6@gmail.com> <40a414c21002212359y2e263991kd141ff5e816c4518@mail.gmail.com> Message-ID: <201002220934.26144.jejansse@gmail.com> On Monday 22 February 2010 08:59:44 minh thu wrote: > [moving to caf? from haskell] > > 2010/2/21 Jeroen Janssen : > > Dear all, > > We are in the progress of starting up a Functional Programming User Group > > in Ghent. The basic idea of the group is to have occasional informal > > meetings where people can give talks, where we have invited speakers, > > where we go to a bar to chat about all things Functional Programming, to > > organize Haskell Hacking events etc. > > To see if enough people would be interested in such a group, and to make > > the organizing process of the first meeting easier, we would like to ask > > anyone interested to tick off the dates he/she is available on the > > Doodle-page provided below. Note that the indicated time is only a rough > > guideline; if you would prefer another time of day, you can indicate this > > in the Comments section of the Doodle. > > http://www.doodle.com/xq2i5hsueidwkh2f > > If enough people are interested, and a date is decided upon, we will > > e-mail the Haskell list once more to confirm the date and give anyone who > > was interested, but could not fill in the doodle, a chance to be present. > > Also, this ensures that you do not have to leave your e-mail address on > > Doodle. If you have any questions, do not hecessitate to contact one of > > us at either Bart.Coppens@UGent.be > > jejansse@gmail.com > > Kind Regards, > > Bart Coppens > > Jeroen Janssen > > Hi Jeroen, > > Great, a fp user group in Belgium! Alas my dutch is too rusty too even > understand the Doodle poll description. Is the group planned only for > dutch-speaking programmers ? Hi Thu, We're not planning it as a strictly Dutch-speaking event, so you are more than welcome. I will update the Doodle so it is in English, my apologies! Kind Regards, Jeroen. From roma at ro-che.info Mon Feb 22 03:36:56 2010 From: roma at ro-che.info (Roman Cheplyaka) Date: Mon Feb 22 03:08:14 2010 Subject: [Haskell-cafe] GHC RTS question In-Reply-To: <81addec71002211115v657ad55bk35e3d6b430d6e2af@mail.gmail.com> References: <88bdc6651002210745p6629e363se0a5c70e039dd2e6@mail.gmail.com> <201002211713.26123.daniel.is.fischer@web.de> <88bdc6651002210920o7bae3b56u13eadf18600b1f7c@mail.gmail.com> <201002211925.31945.daniel.is.fischer@web.de> <88bdc6651002211058n6af64adewb04ef8918f06cb7f@mail.gmail.com> <81addec71002211115v657ad55bk35e3d6b430d6e2af@mail.gmail.com> Message-ID: <20100222083656.GA14436@flit> * Anthony Cowley [2010-02-21 14:15:00-0500] > On Sun, Feb 21, 2010 at 1:58 PM, Artyom Kazak wrote: > > So, if I type "./prog +RTS --RTS +RTS", the output will be "+RTS". But > > I want the output to be equal to the input IN ALL CASES, without any > > quotes, additional options, etc. I want all the command line to go to > > my program. How can I do it? (The only way I know now - hacking the > > GHC. If there are no other ways, I'll do it.) > > How about a wrapper script? Something like, > > #! /usr/bin/env bash > ./prog --RTS $* > > Just use that as the front-end to your Haskell program. If you want Haskell program to get exactly the same arguments that were passed to the wrapper, use ./prog --RTS "$@" Otherwise it will work wrong if arguments contain quoted field separators (e.g. spaces). -- Roman I. Cheplyaka :: http://ro-che.info/ "Don't let school get in the way of your education." - Mark Twain From leather at cs.uu.nl Mon Feb 22 04:37:19 2010 From: leather at cs.uu.nl (Sean Leather) Date: Mon Feb 22 04:08:13 2010 Subject: [Haskell-cafe] Re: [Haskell] Functional Programming User Group Ghent In-Reply-To: <201002220934.26144.jejansse@gmail.com> References: <8B6A33CA-B550-4B44-96D8-C8CE9B6959C6@gmail.com> <40a414c21002212359y2e263991kd141ff5e816c4518@mail.gmail.com> <201002220934.26144.jejansse@gmail.com> Message-ID: <3c6288ab1002220137q393dc3e5w10e20a9d0aa62069@mail.gmail.com> > > Great, a fp user group in Belgium! Alas my dutch is too rusty too even > > understand the Doodle poll description. Is the group planned only for > > dutch-speaking programmers ? > > We're not planning it as a strictly Dutch-speaking event, so you are more > than > welcome. I will update the Doodle so it is in English, my apologies! > I think the Dutch Haskell Users Group [1] has met with great success by establishing English as the lingua franca from the beginning. My impressions are that we attract numerous foreign visitors (including university staff and students) and that we have not discouraged very many native Dutch speakers. Of course, being a foreigner who also has trouble with the local language, I admit being somewhat biased in this matter. Regards, Sean [1] http://www.haskell.org/haskellwiki/Dutch_HUG -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100222/1a2d0bb2/attachment.html From jeremy.odonoghue at gmail.com Mon Feb 22 05:32:11 2010 From: jeremy.odonoghue at gmail.com (Jeremy O'Donoghue) Date: Mon Feb 22 05:02:44 2010 Subject: [Haskell-cafe] Installing wx via cabal In-Reply-To: <4B8238F5.1000400@fit.vutbr.cz> References: <4B8238F5.1000400@fit.vutbr.cz> Message-ID: <1266834731.10735.1361209715@webmail.messagingengine.com> Hi Dusan, I've never seen this problem, and I have far less than 16GB (it works for me on a 2MB Windows XP laptop). One thing I have never tried is compiling on a 64 bit system. Can you tell me any more about your system (Windows/Mac/Linux, 32 or 64 bit OS). GHC 6.10.4 (which is the version I assume you mean) is supposed to be supported. You can mail me off-list to investigate further, as details may not be so interesting to list subscribers. If we find anything significant, we can post this to list later. Regards Jeremy On Mon, 22 Feb 2010 08:57 +0100, "Du?an Kol??" wrote: > Dear all, > > Running cabal install --global wx stops very soon with the following > error. > > Building wxcore-0.12.1.2... > [ 1 of 22] Compiling Graphics.UI.WXCore.WxcObject ( > src/haskell/Graphics/UI/WXCore/WxcObject.hs, > dist/build/Graphics/UI/WXCore/WxcObject.o ) > [ 2 of 22] Compiling Graphics.UI.WXCore.WxcDefs ( > src/haskell/Graphics/UI/WXCore/WxcDefs.hs, > dist/build/Graphics/UI/WXCore/WxcDefs.o ) > [ 3 of 22] Compiling Graphics.UI.WXCore.WxcClassTypes ( > src/haskell/Graphics/UI/WXCore/WxcClassTypes.hs, > dist/build/Graphics/UI/WXCore/WxcClassTypes.o ) > [ 4 of 22] Compiling Graphics.UI.WXCore.WxcTypes ( > src/haskell/Graphics/UI/WXCore/WxcTypes.hs, > dist/build/Graphics/UI/WXCore/WxcTypes.o ) > [ 5 of 22] Compiling Graphics.UI.WXCore.WxcClassesAL ( > src/haskell/Graphics/UI/WXCore/WxcClassesAL.hs, > dist/build/Graphics/UI/WXCore/WxcClassesAL.o ) > ghc: out of memory (requested 1048576 bytes) > cabal: Error: some packages failed to install: > > It seems quite strange as the machine seems to have 16GB RAM and a free > swap, can I somehow put options or so? I have ghc 10.4. installed. > > Thanks > > Dusan > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Jeremy O'Donoghue jeremy.odonoghue@gmail.com From mail at joachim-breitner.de Mon Feb 22 06:21:48 2010 From: mail at joachim-breitner.de (Joachim Breitner) Date: Mon Feb 22 05:52:22 2010 Subject: [Haskell-cafe] Linux ghci vs Windows ghci In-Reply-To: <87k4u6924n.fsf@malde.org> References: <4f56deb71002210322w3c35889ev2a9e689584f23d6d@mail.gmail.com> <4f56deb71002210327q1407ba35s12cae0b137def8c0@mail.gmail.com> <87k4u6924n.fsf@malde.org> Message-ID: <1266837708.3785.8.camel@localhost> Hi, Am Sonntag, den 21.02.2010, 13:58 +0100 schrieb Ketil Malde: > Donghee Nah writes: > > I feel that ghci code executing speed in guest os is 1.5~2x faster than host > > os > > > > The code: > > let t n = do {if n `mod` 100000 == 0 then print n else return ()} >> t (n+1) > > t 1 > > > > any clue? > > Speed of the terminal? Cost of syscalls (user/kernel transitions)? also note that I observed similar things with Win32 code vs. Linux code when compiling stuff unoptimized. See http://www.joachim-breitner.de/blog/archives/358-Building-arbtt-for-Windows.html the first three paragraphs. But I don?t know why that is. Greetings, Joachim -- Joachim "nomeata" Breitner mail: mail@joachim-breitner.de | ICQ# 74513189 | GPG-Key: 4743206C JID: nomeata@joachim-breitner.de | http://www.joachim-breitner.de/ Debian Developer: nomeata@debian.org -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: Dies ist ein digital signierter Nachrichtenteil Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100222/37541fba/attachment.bin From Christian.Maeder at dfki.de Mon Feb 22 06:30:46 2010 From: Christian.Maeder at dfki.de (Christian Maeder) Date: Mon Feb 22 06:01:20 2010 Subject: [Haskell-cafe] Re: Installing wx via cabal In-Reply-To: <4B8238F5.1000400@fit.vutbr.cz> References: <4B8238F5.1000400@fit.vutbr.cz> Message-ID: <4B826AE6.3050608@dfki.de> Du?an Kol?? schrieb: > Dear all, > > Running cabal install --global wx stops very soon with the following > error. > > Building wxcore-0.12.1.2... [...] > dist/build/Graphics/UI/WXCore/WxcClassesAL.o ) > ghc: out of memory (requested 1048576 bytes) > cabal: Error: some packages failed to install: > > It seems quite strange as the machine seems to have 16GB RAM and a free > swap, can I somehow put options or so? I have ghc 10.4. installed. You may set the environment variable GHCRTS to allow more memory: export GHCRTS='-M3g' Type "ghc +RTS -?" to see more options" Cheers Christian From jesper.louis.andersen at gmail.com Mon Feb 22 07:42:24 2010 From: jesper.louis.andersen at gmail.com (Jesper Louis Andersen) Date: Mon Feb 22 07:13:17 2010 Subject: [Haskell-cafe] Some great results on fused code with the LLVM backend In-Reply-To: <20100222015725.GA1870@whirlpool.galois.com> References: <20100222015725.GA1870@whirlpool.galois.com> Message-ID: <56a0a2841002220442r79c01d86h1afe3d374ff270b6@mail.gmail.com> On Mon, Feb 22, 2010 at 2:57 AM, Don Stewart wrote: > I tried out some of the vector and uvector fusion benchmarks with the > new LLVM backend and got some great results for the tight loops generated through fusion. This is excellent news! > The LLVM backend looks very promising -- considering we've not even > begun to explore the optimization pipeline at the level. There is a complete cake at: http://llvm.org/docs/Passes.html (yes, I dabbled in LLVM for some time) Some of the analysis passes gives us a nice hook into the toolchain when you want to see what is going on at the lowest level. Some of the transformations will, perhaps, yield some speedups. -- J. From marlowsd at gmail.com Mon Feb 22 09:10:55 2010 From: marlowsd at gmail.com (Simon Marlow) Date: Mon Feb 22 08:41:49 2010 Subject: [Haskell-cafe] Re: Scarry parallel garbage collection behavior (6.12.1, Mac OSX) In-Reply-To: <42C6FD61-DDAA-49E1-A798-24A06D02BFE5@gmail.com> References: <42C6FD61-DDAA-49E1-A798-24A06D02BFE5@gmail.com> Message-ID: <4B82906F.1020003@gmail.com> On 19/02/2010 21:26, Pavel Perikov wrote: > This is a long post, sorry. The bottom line: specifying +RTS -Nn where n> number of cores slows the program compiled with 6.12.1 by orders of magnitude under Mac OSX. Turning off parallel garbage collections with -qg > resolves the problem. Independent verification is appreciated. The parallel GC currently requires all cores to synchronise, so if you're trying to use more cores than you actually have, you can expect the cost of that synchronisation to be high. Having said that, the cost is higher than we would like mainly due to the use of spinlocks for synchronisation - spinlocks turned out to be the fastest way to synchronise when all the threads are running, but are quite bad when some threads have been descheduled (as would be the case if you are using more threads than you have cores). So in 6.12.2 there will be some changes that reduce the overhead quite significantly, see http://hackage.haskell.org/trac/ghc/ticket/3758 and http://ghcmutterings.wordpress.com/2010/01/25/yielding-more-improvements-in-parallel-performance/ Cheers, Simon From marlowsd at gmail.com Mon Feb 22 09:17:48 2010 From: marlowsd at gmail.com (Simon Marlow) Date: Mon Feb 22 08:48:31 2010 Subject: [Haskell-cafe] Re: Threading and FFI In-Reply-To: <1266659529.5427.25.camel@picard> References: <27611528.post@talk.nabble.com> <1266659529.5427.25.camel@picard> Message-ID: <4B82920C.2070806@gmail.com> On 20/02/2010 09:52, Maciej Piechotka wrote: > Sorry I start spin-off of thread but all over the haskell code is idiom: > > throwErrorIfMinus1_ $ someCode args > > However this code is dependent on errno, which is thread dependent. Is > GHC making sure that errno set from C call is propagated back into > correct thread? Yes, it is. > Are there any requirements regarding safeness/unsafeness of such > propagation No there aren't. Cheers, Simon From apfelmus at quantentunnel.de Mon Feb 22 11:53:17 2010 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Mon Feb 22 11:24:02 2010 Subject: [Haskell-cafe] Re: Heterogeneous Data Structures - Nested Pairs and functional references In-Reply-To: References: <4B7AFC98.9080103@web.de> <4B7D8BD8.7050804@web.de> Message-ID: Alexander Solla wrote: > Yup, that's a type error. I mean to fold the View (in this case a > ConcatView) into a monoid. I think I meant > > foldMap renderXHtml (ConcatViews l r) Hm, that would require a type renderXHtml :: Monoid t => View t -> Html >> Your intention reminds me of the use of type variables to get >> functor-like behavior for free, like in >> >> data RGB' a = RGB a a a -- auxiliary type constructor >> type RGB = RGB' Int -- what we're interested in >> >> but I don't quite see what you're doing with the free monad here, >> Alexander? > > As you noticed, I am seeking that functorial behavior in order to gain > some genericity. bind and return do encode some logic about the nature > of monadic adjunction, which I am relying on theoretically. I could > have used a Functor instance just as easily, but I would have lost my > "intention" of defining co-equalizers implicitly. > (http://en.wikipedia.org/wiki/Beck%27s_monadicity_theorem) I don't know, the new ReturnView constructor which gives rise to the monad does allow us to represent "views with variables". But to me, this doesn't seem to add much genericity. Regards, Heinrich Apfelmus -- http://apfelmus.nfshost.com From jfredett at gmail.com Mon Feb 22 12:42:02 2010 From: jfredett at gmail.com (jfredett@gmail.com) Date: Mon Feb 22 12:12:40 2010 Subject: [Haskell-cafe] Haskell Weekly News: Issue 150 - February 22, 2010 Message-ID: <4b82c1ea.9f15f10a.7c2d.647e@mx.google.com> --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20100222 Issue 150 - February 22, 2010 --------------------------------------------------------------------------- Welcome to issue 150 of HWN, a newsletter covering developments in the [1]Haskell community. From the very pits of Harddrive failure I return... The Haskell Weekly News Reborn! Last week, on friday, my HWN machine suffered what can only be appropriately named a unbelievably poorly timed hard drive failure, hence the lack of an HWN. I trumphently return this week with a megaedition. Tons and tons of awesome stuff happened in the last two weeks. So I won't make you wait any longer, haskellers, your Haskell Weekly News! Announcements vty-ui 0.3. Jonathan Daugherty [2]announced a new version of vty-ui, featuring a richer rendering engine, generalized text transformations, and a more functional style. darcs 2.4 release candidate 2. Reinier Lamers [3]announced a new release candidate for darcs 2.4. iteratee-parsec 0.0.1. Maciej Piechotka [4]announced the release of iteratee-parsec, a library whih provides support for parsec parsers in an Iteratee monad. concurrent-extra-0.1. Roel van Dijk [5]announced the release of concurrent-extra, which provides a few new synchronization primitives. wyvern, a Dragon Go Server 'client'. wagnerdm [6]announced wyvern, a Dragon Go Server 'client', which plays moves for you on the [7]Dragon Go Server. atom-1.0.0. Tom Hawkins [8]announced a new major release of the atom library. Call for Copy: Monad.Reader Issue 16. Brent Yorgey [9]announced the call for copy for Monad.Reader issue 16. hmatrix 0.8.3. Alberto Ruiz [10]announced a new version of hmatrix. First Atlanta Function Programming Users Group Meeting. David Vollbracht [11]announced the first Atlanta FP Group meetup. TFP 2010 - Call for Papers and Participation. Simon Marlow [12]announced a call for papers and particpation in TFP 2010, the 11th Symposium on Trends in Functional Programming. CMCS 2010: Call for Short Submissions & Call for Participation. Alexandra Silva [13]announced a call for short submissions and participation in the 10th International Workshop on Coalgebraic Methods in Computer Science. WGP 2010 Call for Papers. Bruno Oliveira [14]announced a call for papers for Workshop on Generic Programming. ICE 2010: First call for papers. Alexandra Silva [15]announced the first call for papers for ICE2010, the 3rd Interation and Concurrency Experience workshop. Call for Papers: Haskell Symposium 2010. Jeremy.Gibbons [16]announced a call for papers for the 2010 Haskell Symposium. Dungeons of Wor - a largish FRP example and a fun game, all in one! Patai Gergely [17]announced Dungeons of Wor, a Game written in Haskell using the Elerea library and Functional Reactive Techniques. Discussion The Related monad and constant values in type classes. Jonas Almstroem Duregard [18]talked about a common pattern which occurs when associating data with a type (as opposed to a value). Heterogeneous Data Structures - Nested Pairs and functional references. Guenther Schmidt [19]asked about different ways to implement heterogeonous datastructures. Blog noise [20]Haskell news from the [21]blogosphere. Blog posts from people new to the Haskell community are marked with >>>, be sure to welcome them! * Michael Snoyman: [22]Four HTTP Request Body Interfaces (repost). * Brent Yorgey: [23]Math.Combinatorics.Multiset. * Darcs: [24]darcs weekly news #55. * Galois, Inc: [25]Tech Talk: Modern Benchmarking in Haskell. * Ketil Malde: [26]Tools for pyrosequencing analysis. * Arch Haskell News: [27]Arch Haskell News: February 2010. * Don Stewart (dons): [28]Migrating from uvector to vector. * GHC / OpenSPARC Project: [29]Memory Barriers and GHC 6.12.1. * Darcs: [30]darcs weekly news #54. * Gergely Patai: [31]Behind the dungeons. * David Amos: [32]How to find a strong generating set. Quotes of the Week * fasta: And by cool, I mean 'that is not supposed to happen'. * uncyclopedia: Calculations which are undefined are denoted by the _|_ symbol, pronounced Bottom, which the documentation explains as the compiler giving you the finger. * Draconx|Laptop: mathematics is the art of finding different ways to write "therefore". * medfly: Cale, #haskell wants to know all your personal preferences so we can all copy you * Cale: Gentoo is a massive waste of electricity. * hobophobe: So, I can only conclude that Haskell is a memetic virus, and monads are the eggs it lays out in innocent programming forums to entice others to become infected. * benmachine: unsafeCoerce is just a generalisation of id * jmcarthur: what good is a state monad if your state is basically 'i have no idea what the hell my state is'? About the Haskell Weekly News New editions are posted to [33]the Haskell mailing list as well as to [34]the Haskell Sequence and [35]Planet Haskell. [36]RSS is also available, and headlines appear on [37]haskell.org. To help create new editions of this newsletter, please see the information on [38]how to contribute. Send stories to jfredett . at . gmail . dot . com. The darcs repository is available at darcs get [39]http://patch-tag.com/r/jfredett/HWN2/pullrepo HWN2 . References 1. http://haskell.org/ 2. http://article.gmane.org/gmane.comp.lang.haskell.cafe/70589 3. http://article.gmane.org/gmane.comp.lang.haskell.cafe/70563 4. http://article.gmane.org/gmane.comp.lang.haskell.cafe/70533 5. http://article.gmane.org/gmane.comp.lang.haskell.cafe/70485 6. http://article.gmane.org/gmane.comp.lang.haskell.cafe/70344 7. http://www.dragongoserver.net/ 8. http://article.gmane.org/gmane.comp.lang.haskell.cafe/70328 9. http://article.gmane.org/gmane.comp.lang.haskell.cafe/70314 10. http://article.gmane.org/gmane.comp.lang.haskell.cafe/70290 11. http://article.gmane.org/gmane.comp.lang.haskell.general/17802 12. http://article.gmane.org/gmane.comp.lang.haskell.general/17799 13. http://article.gmane.org/gmane.comp.lang.haskell.general/17791 14. http://article.gmane.org/gmane.comp.lang.haskell.general/17783 15. http://article.gmane.org/gmane.comp.lang.haskell.general/17779 16. http://article.gmane.org/gmane.comp.lang.haskell.general/17778 17. http://article.gmane.org/gmane.comp.lang.haskell.cafe/70188 18. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/70492 19. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/70450 20. http://planet.haskell.org/ 21. http://haskell.org/haskellwiki/Blog_articles 22. http://snoyberg.wordpress.com/2010/02/21/four-http-request-body-interfaces-repost/ 23. http://byorgey.wordpress.com/2010/02/20/math-combinatorics-multiset/ 24. http://blog.darcs.net/2010/02/darcs-weekly-news-55.html 25. http://www.galois.com/blog/2010/02/19/tech-talk-modern-benchmarking-in-haskell/ 26. http://blog.malde.org/index.php/2010/02/19/tools-for-pyrosequencing-analysis/ 27. http://archhaskell.wordpress.com/2010/02/19/arch-haskell-news-february-2010/ 28. http://donsbot.wordpress.com/2010/02/15/migrating-from-uvector-to-vector/ 29. http://ghcsparc.blogspot.com/2010/02/memory-barriers-and-ghc-6121.html 30. http://blog.darcs.net/2010/02/darcs-weekly-news-54.html 31. http://just-bottom.blogspot.com/2010/02/behind-dungeons.html 32. http://haskellformaths.blogspot.com/2010/02/how-to-find-strong-generating-set.html 33. http://www.haskell.org/mailman/listinfo/haskell 34. http://sequence.complete.org/ 35. http://planet.haskell.org/ 36. http://sequence.complete.org/node/feed 37. http://haskell.org/ 38. http://haskell.org/haskellwiki/HWN 39. http://patch-tag.com/r/jfredett/HWN2/pullrepo%20HWN2 From jejansse at gmail.com Mon Feb 22 12:54:02 2010 From: jejansse at gmail.com (Jeroen Janssen) Date: Mon Feb 22 12:24:47 2010 Subject: [Haskell-cafe] Re: [Haskell] Functional Programming User Group Ghent In-Reply-To: <3c6288ab1002220137q393dc3e5w10e20a9d0aa62069@mail.gmail.com> References: <8B6A33CA-B550-4B44-96D8-C8CE9B6959C6@gmail.com> <40a414c21002212359y2e263991kd141ff5e816c4518@mail.gmail.com> <201002220934.26144.jejansse@gmail.com> <3c6288ab1002220137q393dc3e5w10e20a9d0aa62069@mail.gmail.com> Message-ID: <71E7F21B-940F-4624-BF5A-7D869530E059@gmail.com> On 22-feb-2010, at 10:37, Sean Leather wrote: > I think the Dutch Haskell Users Group [1] has met with great success by establishing English as the lingua franca from the beginning. My impressions are that we attract numerous foreign visitors (including university staff and students) and that we have not discouraged very many native Dutch speakers. Of course, being a foreigner who also has trouble with the local language, I admit being somewhat biased in this matter. > Thanks for the input! Like I said, we're not really planning it as a Dutch-only group, thus maybe really proposing English as the lingua franca (unless no non-native speakers are not there) isn't such a bad idea. Regards, Jeroen. From lemming at henning-thielemann.de Mon Feb 22 13:28:46 2010 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon Feb 22 12:59:20 2010 Subject: [Haskell-cafe] Pointfree composition for higher arity In-Reply-To: <4B7C0CDA.7000101@kent.ac.uk> References: <3c6288ab1002170731m1661c479r936f3e5b5ff8d89d@mail.gmail.com> <4B7C0CDA.7000101@kent.ac.uk> Message-ID: On Wed, 17 Feb 2010, Neil Brown wrote: > I very often write this too (wanting function composition, but with a > two-argument function on the right hand side). The trick I picked up from > somewhere is to do: > > fun = (runFun .) . someFun someDefault > > I'm not too keen on that, as it seems clumsy. I often end up writing the > operator that you describe, but have never settled on a consistent name > (since the obvious one to me, (..), is taken). Maybe helpful: http://www.haskell.org/haskellwiki/Composing_functions_with_multiple_values From vandijk.roel at gmail.com Mon Feb 22 13:33:17 2010 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Mon Feb 22 13:03:50 2010 Subject: [Haskell-cafe] ANN: concurrent-extra-0.2 Message-ID: Hello, We would like to announce an update of concurrent-extra [1]. Bug fixes: - A bug in RLock.acquire (thanks to Felipe Lessa). New features: - Broadcast: Wake multiple threads by broadcasting a value. This is a generalisation of Event. - Thread: Threads extended with the ability to wait for their termination. - delay: Arbitrarily long thread delays. - timeout: Wait arbitrarily long for an IO computation to finish. The lightweight thread wrapper was inspired by the threadmanager package [2]. The main advantage of our implementation is that we don't maintain an internal mapping from ThreadId to ThreadStatus. Instead we rely on the forked thread to broadcast its status to interested listeners. This should result in better performance (no lookup required). Every exported symbol is now documented. Regards, Roel & Bas van Dijk [1] http://hackage.haskell.org/package/concurrent-extra-0.2 [2] http://hackage.haskell.org/package/threadmanager-0.1.3 From bos at serpentine.com Mon Feb 22 13:44:32 2010 From: bos at serpentine.com (Bryan O'Sullivan) Date: Mon Feb 22 13:15:02 2010 Subject: [Haskell-cafe] Parsing of bytestrings with non-String errors? In-Reply-To: <4B8128C5.6030105@therning.org> References: <4B8128C5.6030105@therning.org> Message-ID: On Sun, Feb 21, 2010 at 4:36 AM, Magnus Therning wrote: > I've looked at polyparse and attoparsec and they seem to have in common > that > the error always is a String. My current ideas for a project would be a > lot > easier if I could just return some other type, something that I can pattern > match on. It would be easy enough to add this, but you'd end up with a slightly convoluted API. Because of the presence of fail in all monadic APIs, you'd have to support only-a-string as a failure result in some form, so your failure type would have to be something like Either String a. There's no support for this in attoparsec simply because I haven't needed it. I suspect the same is true of other libraries, nothing deeper. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100222/a3691937/attachment.html From lemming at henning-thielemann.de Mon Feb 22 13:53:06 2010 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon Feb 22 13:23:45 2010 Subject: [Haskell-cafe] A small oversight In-Reply-To: References: <4B7FBDC2.8090606@btinternet.com> Message-ID: On Sun, 21 Feb 2010, Leon Smith wrote: > On Sat, Feb 20, 2010 at 5:47 AM, Andrew Coppin > wrote: > >> ?sortOn :: (Ord y) => (x -> y) -> [x] -> [x] >> ?sortOn foo = sortBy (compare `on` foo) > > > Incidentally, this function is provided as Data.List.Ordered.sortOn' > in the data-ordlist package... Or Key.sort in utility-ht which caches the keys to be sorted. Useful if the function is not just a record selector. http://hackage.haskell.org/packages/archive/utility-ht/0.0.5.1/doc/html/Data-List-Key.html#v%3Asort From v.dijk.bas at gmail.com Mon Feb 22 14:13:17 2010 From: v.dijk.bas at gmail.com (Bas van Dijk) Date: Mon Feb 22 13:44:10 2010 Subject: [Haskell-cafe] ANN: concurrent-extra-0.2 In-Reply-To: References: Message-ID: 2010/2/22 Roel van Dijk : > Hello, > > We would like to announce an update of concurrent-extra [1]. > > Bug fixes: > ?- A bug in RLock.acquire (thanks to Felipe Lessa). > > New features: > > ?- Broadcast: Wake multiple threads by broadcasting a value. This > ? is a generalisation of Event. > ?- Thread: Threads extended with the ability to wait for their > ? termination. > ?- delay: Arbitrarily long thread delays. > ?- timeout: Wait arbitrarily long for an IO computation to finish. > > The lightweight thread wrapper was inspired by the threadmanager > package [2]. The main advantage of our implementation is that we > don't maintain an internal mapping from ThreadId to > ThreadStatus. Instead we rely on the forked thread to broadcast > its status to interested listeners. This should result in better > performance (no lookup required). > > Every exported symbol is now documented. > > > Regards, > Roel & Bas van Dijk > > [1] http://hackage.haskell.org/package/concurrent-extra-0.2 > [2] http://hackage.haskell.org/package/threadmanager-0.1.3 > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > We just realized we missed an important opportunity in Control.Concurrent.Thread: When we fork the IO computation... http://hackage.haskell.org/packages/archive/concurrent-extra/0.2/doc/html/src/Control-Concurrent-Thread.html#fork ...we catch its potential exception and notify our listeners by wrapping the exception into Just and broadcasting it. However when the computation terminates normally without throwing an exception we notify our listeners by broadcasting Nothing, ignoring its return value (>>). This is unfortunate because we can easily broadcast the return value by choosing an 'Either SomeException a' instead of 'Maybe SomeException'. We have released a new version 0.3 that changes this: http://hackage.haskell.org/package/concurrent-extra-0.3 darcs get http://code.haskell.org/concurrent-extra regards, Roel and Bas van Dijk From perikov at gmail.com Mon Feb 22 15:23:24 2010 From: perikov at gmail.com (Pavel Perikov) Date: Mon Feb 22 14:54:02 2010 Subject: [Haskell-cafe] Re: Scarry parallel garbage collection behavior (6.12.1, Mac OSX) In-Reply-To: <4B82906F.1020003@gmail.com> References: <42C6FD61-DDAA-49E1-A798-24A06D02BFE5@gmail.com> <4B82906F.1020003@gmail.com> Message-ID: <75891E3F-3505-45DC-A561-78C038E45225@gmail.com> Thanks, Simon. I know I should try to find the existing ticket before posting :) P. On 22.02.2010, at 17:10, Simon Marlow wrote: > On 19/02/2010 21:26, Pavel Perikov wrote: > >> This is a long post, sorry. The bottom line: specifying +RTS -Nn where n> number of cores slows the program compiled with 6.12.1 by orders of magnitude under Mac OSX. Turning off parallel garbage collections with -qg >> resolves the problem. Independent verification is appreciated. > > The parallel GC currently requires all cores to synchronise, so if you're trying to use more cores than you actually have, you can expect the cost of that synchronisation to be high. Having said that, the cost is higher than we would like mainly due to the use of spinlocks for synchronisation - spinlocks turned out to be the fastest way to synchronise when all the threads are running, but are quite bad when some threads have been descheduled (as would be the case if you are using more threads than you have cores). So in 6.12.2 there will be some changes that reduce the overhead quite significantly, see > > http://hackage.haskell.org/trac/ghc/ticket/3758 > > and > > http://ghcmutterings.wordpress.com/2010/01/25/yielding-more-improvements-in-parallel-performance/ > > Cheers, > Simon From magnus at therning.org Mon Feb 22 17:38:59 2010 From: magnus at therning.org (Magnus Therning) Date: Mon Feb 22 17:09:40 2010 Subject: [Haskell-cafe] Parsing of bytestrings with non-String errors? In-Reply-To: References: <4B8128C5.6030105@therning.org> Message-ID: <4B830783.2090104@therning.org> On 22/02/10 18:44, Bryan O'Sullivan wrote: > On Sun, Feb 21, 2010 at 4:36 AM, Magnus Therning > wrote: > > I've looked at polyparse and attoparsec and they seem to have in common > that the error always is a String. My current ideas for a project would > be a lot easier if I could just return some other type, something that I > can pattern match on. > > > It would be easy enough to add this, but you'd end up with a slightly > convoluted API. Because of the presence of fail in all monadic APIs, you'd > have to support only-a-string as a failure result in some form, so your > failure type would have to be something like Either String a. My thoughts went more like a parser type like data Parser e a = ... Possibly with the addition that 'e' implements a class that goes something like class ParserError e where baseError :: e addError :: e -> e -> e (At first I thought that maybe Monoid would do, but both a identity and associativity feels awkward in this case. :-) With 'String' implemented something like instance ParserError String where baseError = "Parser error, expected:\n" addError = (++) Then I believe 'Parser String' would be equivalent to the existing attoparsec parser (as found in the 0.7 series). I still haven't convinced myself that this will work though. Also, I had a look at attoparsec on bitbucket, and there are some major changes between 0.7 and 0.8. I realised I'll have to spend a lot more time understanding the code than I initially hoped. Right now that is unlikely to happen any time soon :( > There's no support for this in attoparsec simply because I haven't > needed it. I suspect the same is true of other libraries, nothing deeper. Yeah, that's what I thought. In a current project I just have a need to differentiate between errors in different parts of the parser. And handling those errors would just be simple if I could use pattern matching rather than inspect strings. /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100222/d65eecbd/signature.bin From bos at serpentine.com Mon Feb 22 19:39:59 2010 From: bos at serpentine.com (Bryan O'Sullivan) Date: Mon Feb 22 19:10:30 2010 Subject: [Haskell-cafe] Parsing of bytestrings with non-String errors? In-Reply-To: <4B830783.2090104@therning.org> References: <4B8128C5.6030105@therning.org> <4B830783.2090104@therning.org> Message-ID: On Mon, Feb 22, 2010 at 2:38 PM, Magnus Therning wrote: > My thoughts went more like a parser type like > > data Parser e a = ... > Yes, I knew that's where you were going :-) The trouble is, you'd still have to deal with fail :: Monad m => String -> m a which would require your failure type to somehow accept a string. Plumbing that in would be a little more awkward than your initial exporations suggest :-\ You have two problems. The first is how to construct a value of your failure type that accepts a String parameter so that you can support users of "fail". The second is that you might need to pass extra information to construct your failure value when na?ve code uses fail or mzero, otherwise you will only get useful error values out quite infrequently. > I still haven't convinced myself that this will work though. Also, I had a > look at attoparsec on bitbucket, and there are some major changes between > 0.7 > and 0.8. Even though those changes represent a major modification to the internals of attoparsec, they shouldn't really affect what you want to do, or anything interesting about how to do it. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100222/f78eee1c/attachment.html From paul.brauner at loria.fr Mon Feb 22 20:08:12 2010 From: paul.brauner at loria.fr (Paul Brauner) Date: Mon Feb 22 19:38:47 2010 Subject: [Haskell-cafe] "datakind" declaration In-Reply-To: References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <75cc17ac1002180924r6d8eb5f4r3a7ddebd9825c69f@mail.gmail.com> <4B7D8D23.3020402@t-online.de> <201002182031.03105.daniel.is.fischer@web.de> <4B7DEE0B.7050309@t-online.de> <681D5A1F-0BAC-4ECA-8A1D-2D5C1DB00F5E@cs.otago.ac.nz> <4B80345A.6090204@t-online.de> Message-ID: <20100223010812.GE17714@inria.fr> Hello, I remember seeing something like > typedata T = A | B somewhere, where A and B are type constructors, but I can't find it in the ghc doc. Have I been dreaming or is it some hidden feature ? Paul From pumpkingod at gmail.com Mon Feb 22 20:13:27 2010 From: pumpkingod at gmail.com (Daniel Peebles) Date: Mon Feb 22 19:43:56 2010 Subject: [Haskell-cafe] "datakind" declaration In-Reply-To: <20100223010812.GE17714@inria.fr> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <75cc17ac1002180924r6d8eb5f4r3a7ddebd9825c69f@mail.gmail.com> <4B7D8D23.3020402@t-online.de> <201002182031.03105.daniel.is.fischer@web.de> <4B7DEE0B.7050309@t-online.de> <681D5A1F-0BAC-4ECA-8A1D-2D5C1DB00F5E@cs.otago.ac.nz> <4B80345A.6090204@t-online.de> <20100223010812.GE17714@inria.fr> Message-ID: It's not quite what you're asking for, but a very similar idea is the SHE preprocessor: http://personal.cis.strath.ac.uk/~conor/pub/she/ Dan On Mon, Feb 22, 2010 at 8:08 PM, Paul Brauner wrote: > Hello, > > I remember seeing something like > > > typedata T = A | B > > somewhere, where A and B are type constructors, but I can't find it in > the ghc doc. Have I been dreaming or is it some hidden feature ? > > Paul > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100222/03c205cc/attachment.html From g9ks157k at acme.softbase.org Tue Feb 23 04:01:28 2010 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Tue Feb 23 03:31:59 2010 Subject: [Haskell-cafe] grapefruit on windows or osX In-Reply-To: <20100221135745.75469f813b58c2e0e98e8a30424d5d59.60f1960477.wbe@email05.secureserver.net> References: <20100221135745.75469f813b58c2e0e98e8a30424d5d59.60f1960477.wbe@email05.secureserver.net> Message-ID: <201002231001.28907.g9ks157k@acme.softbase.org> Am Sonntag, 21. Februar 2010 21:57:45 schrieb gladstein@gladstein.com: > I'm unable to get grapefruit going on osx or windows because (I think) I > can't get the underlying GTK installed. Hi, thank you for giving Grapefruit a try. Yes, you are most likely right that Gtk2Hs is the stumbling block. Grapefruit itself doesn?t do anything OS-specific, and since it works on Linux, it should also work on OS X. I strongly suggest that you try out the current development version of Grapefruit instead of the version on Hackage, since the latter is lacking a bunch of features. If you have any Grapefruit-related questions, please ask here or on the Grapefruit mailing list. Best wishes, Wolfgang From amit.deshwar at gmail.com Tue Feb 23 04:15:48 2010 From: amit.deshwar at gmail.com (Amit Deshwar) Date: Tue Feb 23 03:46:18 2010 Subject: [Haskell-cafe] Alex Lexer: Trying to get rid of "Alex" Message-ID: <4b6ff42c1002230115m3bc0dcf6wcd11d739e8283b56@mail.gmail.com> Hi Haskell-cafe My problem: I'm trying to obtain the current position of the lexer once it reaches the end of the file (line and row number). I'm trying to do this in a function: getEndPosition = do (a,b,c) <- alexGetInput return a Unfortunately, the type of a is 'Alex AlexPosn' instead of just 'AlexPosn' How do I strip the Alex so I'm left with just a AlexPosn object? Thanks, Amit Deshwar University of Calgary -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100223/6986b95f/attachment.html From florbitous at gmail.com Tue Feb 23 04:58:55 2010 From: florbitous at gmail.com (Bernie Pope) Date: Tue Feb 23 04:29:25 2010 Subject: [Haskell-cafe] Alex Lexer: Trying to get rid of "Alex" In-Reply-To: <4b6ff42c1002230115m3bc0dcf6wcd11d739e8283b56@mail.gmail.com> References: <4b6ff42c1002230115m3bc0dcf6wcd11d739e8283b56@mail.gmail.com> Message-ID: <4d8ad03a1002230158s41dd9fa7nd0c893d289307367@mail.gmail.com> On 23 February 2010 20:15, Amit Deshwar wrote: > Hi Haskell-cafe > My problem: ?I'm trying to obtain the current position of the lexer once it > reaches the end of the file (line and row number). > I'm trying to do this in a function: > getEndPosition = do > ??(a,b,c) <- alexGetInput > ??return a > > Unfortunately, the type of a is 'Alex AlexPosn' instead of just 'AlexPosn' > How do I strip the Alex so I'm left with just a AlexPosn object? Hi Amit, Are you sure about the type of a? It looks like you are using the "monad" wrapper, described here: http://www.haskell.org/alex/doc/html/wrappers.html If that is true, then: alexGetInput :: Alex AlexInput and type AlexInput = (AlexPosn, Char, String) >From that we can infer from your code: getEndPosition :: Alex AlexPosn and thus: a :: AlexPosn If you want to manipulate the value bound to a, you can simply apply a function to it in the body of getEndPosition, and return the result of that application (still inside the Alex type). Or you can use the function: runAlex :: String -> Alex a -> Either String a Cheers, Bernie. From magnus at therning.org Tue Feb 23 06:04:04 2010 From: magnus at therning.org (Magnus Therning) Date: Tue Feb 23 05:34:35 2010 Subject: [Haskell-cafe] Parsing of bytestrings with non-String errors? In-Reply-To: References: <4B8128C5.6030105@therning.org> <4B830783.2090104@therning.org> Message-ID: On Tue, Feb 23, 2010 at 00:39, Bryan O'Sullivan wrote: > On Mon, Feb 22, 2010 at 2:38 PM, Magnus Therning > wrote: >> >> My thoughts went more like a parser type like >> >> ? ?data Parser e a = ... > > Yes, I knew that's where you were going :-) > The trouble is, you'd still have to deal with > fail :: Monad m => String -> m a > which would require your failure type to somehow accept a string. Plumbing > that in would be a little more awkward than your initial exporations suggest > :-\ > You have two problems. The first is how to construct a value of your failure > type that accepts a String parameter so that you can support users of > "fail". The second is that you might need to pass extra information to > construct your failure value when na?ve code uses fail or mzero, otherwise > you will only get useful error values out quite infrequently. Yes, I suspected there'd be something I had missed. I guess it'd would require 'Parser e a' to have a 'fail' that's similar to the one in 'Maybe'. Users would then be forced to use '' to get useful error info out. Would that be an unworkable situation? >> I still haven't convinced myself that this will work though. ?Also, I had >> a >> look at attoparsec on bitbucket, and there are some major changes between >> 0.7 >> and 0.8. > > Even though those changes represent a major modification to the internals of > attoparsec, they shouldn't really affect what you want to do, or anything > interesting about how to do it. Ah, that's good. I think I'll have to postpone any work on this for now though, and instead implement a 'String -> MyErrorType' function for, hopefully, temporary use. I've already been sidetracked twice before ;-) /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From RafaelGCPP.Linux at gmail.com Tue Feb 23 06:30:18 2010 From: RafaelGCPP.Linux at gmail.com (Rafael Gustavo da Cunha Pereira Pinto) Date: Tue Feb 23 06:00:48 2010 Subject: [Haskell-cafe] Function to detect duplicates Message-ID: <351ff25e1002230330n7913ba28h40b641096a777acc@mail.gmail.com> Hi folks, While solving a puzzle, I was posed the problem of finding if there was no duplicates on a list. First I used: noneRepeated=null.(filter (>1)).(map length).group.sort But this seemed very unneficient, so I thought that I could detect the duplicates while sorting, and devised this: import Control.Monad import Data.Maybe noneRepeated=isNothing . (foldl merge (Just [])) . (map sort) . pairs pairs []=[] pairs [x]=[[x]] pairs (x:y:xs)=[x,y]:pairs xs sort []=Just [] sort [x]=Just [x] sort [x,y] | x>y=Just [y,x] | y>x=Just [x,y] | x==y=Nothing merge::(Eq a, Ord a) => Maybe [a]->Maybe [a]->Maybe[a] merge _ Nothing = Nothing merge Nothing _ = Nothing merge (Just []) (Just xs)=Just xs merge (Just xs) (Just [])=Just xs merge (Just (x:xs)) (Just (y:ys)) | x==y = Nothing | x>y = (Just y) +? (merge (Just (x:xs)) (Just ys)) | x References: <351ff25e1002230330n7913ba28h40b641096a777acc@mail.gmail.com> Message-ID: <3690ee141002230357x2a156858g36f13fc847053830@mail.gmail.com> Hi Rafael, I assume you will perform this operation on some very large lists, or performance would not be an issue. Have you tested if your optimized version is better than your initial one? You should compare your implementation against something like this: import qualified Data.Set as Set noneRepeated :: (Ord a) => [a] -> Bool noneRepeated = accum Set.empty where accum _ [] = True accum s (x:xs) | Set.member x s = False | otherwise = accum (Set.insert x s) xs Also there is some discussion about the nub function that relates to this topic, e.g. http://buffered.io/2008/07/28/a-better-nub/. /Jonas On 23 February 2010 12:30, Rafael Gustavo da Cunha Pereira Pinto wrote: > > Hi folks, > > While solving a puzzle, I was posed the problem of finding if there was no > duplicates on a list. > > First I used: > > noneRepeated=null.(filter (>1)).(map length).group.sort > > > But this seemed very unneficient, so I thought that I could detect the > duplicates while sorting, and devised this: > > import Control.Monad > import Data.Maybe > > noneRepeated=isNothing . (foldl merge (Just [])) . (map sort) . pairs > > pairs []=[] > pairs [x]=[[x]] > pairs (x:y:xs)=[x,y]:pairs xs > > sort []=Just [] > sort [x]=Just [x] > sort [x,y] | x>y=Just [y,x] > ?????????? | y>x=Just [x,y] > ?????????? | x==y=Nothing > > merge::(Eq a, Ord a) => Maybe [a]->Maybe [a]->Maybe[a] > merge _ Nothing = Nothing > merge Nothing _ = Nothing > merge (Just []) (Just xs)=Just xs > merge (Just xs) (Just [])=Just xs > merge (Just (x:xs)) (Just (y:ys)) | x==y = Nothing > ????????????????????????????????? | x>y? = (Just y) +? (merge (Just (x:xs)) > (Just ys)) > ????????????????????????????????? | x (Just (y:ys))) > > (+?) = liftM2 (:) > > > > My version of the merge sort returns Nothing whenever it finds two equal > entries, aborting all subsequent comparisons. > > I have a few questions for the friendly people at this cafe: > > 1) Is there any improvement I can make? > 2) Can it be parallelized (par, pseq)? > > > Best regards, > > Rafael > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From shahn at cs.tu-berlin.de Tue Feb 23 07:01:26 2010 From: shahn at cs.tu-berlin.de (=?utf-8?q?S=C3=B6nke_Hahn?=) Date: Tue Feb 23 06:31:58 2010 Subject: [Haskell-cafe] Profiling OpenGL applications Message-ID: <201002231301.27576.shahn@cs.tu-berlin.de> On Sunday, Andrew Coppin asked: > Is Thread Scope any use for profiling single-threaded programs? I used threadscope to look at eventlogs from a program that uses OpenGL to render multiple frames per second (compiled without "-threaded"). That means, there is CPU activity regularly (multiple times per second), and this can be observed via threadscope and i found it somewhat useful. There are some problems, though: 1. I can't definitely tell, which time span corresponds to CPU activity for the calculations for one frame. Is it possible to generate threadscope bookmarks from within the profiled program? (Or other events that can be shown in threadscope?) 2. The GPU activity cannot be observed. This is not a problem specific to Haskell, though. Is it even possible (with end user hardware) to get something similar to threadscope, not for CPU, but GPU activity? Any other ideas, that might help gathering information, about what's going on on the CPU(s) and the GPU? Many thanks, S?nke From es at ertes.de Tue Feb 23 07:03:45 2010 From: es at ertes.de (Ertugrul Soeylemez) Date: Tue Feb 23 06:34:25 2010 Subject: [Haskell-cafe] Re: Function to detect duplicates References: <351ff25e1002230330n7913ba28h40b641096a777acc@mail.gmail.com> Message-ID: <20100223130345.647b67e1@tritium.streitmacht.eu> Rafael Gustavo da Cunha Pereira Pinto wrote: > While solving a puzzle, I was posed the problem of finding if there > was no duplicates on a list. > > First I used: > > noneRepeated=null.(filter (>1)).(map length).group.sort > > But this seemed very unneficient, so I thought that I could detect the > duplicates while sorting, and devised this: > > import Control.Monad > import Data.Maybe > > noneRepeated=isNothing . (foldl merge (Just [])) . (map sort) . pairs import Data.List noneRepeated xs = xs == nub xs Greets Ertugrul -- nightmare = unsafePerformIO (getWrongWife >>= sex) http://blog.ertes.de/ From daniel.is.fischer at web.de Tue Feb 23 07:28:03 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Feb 23 07:00:31 2010 Subject: [Haskell-cafe] Re: Function to detect duplicates In-Reply-To: <20100223130345.647b67e1@tritium.streitmacht.eu> References: <351ff25e1002230330n7913ba28h40b641096a777acc@mail.gmail.com> <20100223130345.647b67e1@tritium.streitmacht.eu> Message-ID: <201002231328.03614.daniel.is.fischer@web.de> Am Dienstag 23 Februar 2010 13:03:45 schrieb Ertugrul Soeylemez: > Rafael Gustavo da Cunha Pereira Pinto wrote: > > While solving a puzzle, I was posed the problem of finding if there > > was no duplicates on a list. > > > > First I used: > > > > noneRepeated=null.(filter (>1)).(map length).group.sort > > > > But this seemed very unneficient, so I thought that I could detect the > > duplicates while sorting, and devised this: > > > > import Control.Monad > > import Data.Maybe > > > > noneRepeated=isNothing . (foldl merge (Just [])) . (map sort) . pairs > > import Data.List > > noneRepeated xs = xs == nub xs Talk about inefficiency :) import Data.Set (Set) import qualified Data.Set as Set noneRepeated = go 0 Set.empty where go ct st (x:xs) | Set.size st < ct = False | otherwise = go (ct+1) (Set.insert x st) xs go ct st [] = ct == Set.size st > > > Greets > Ertugrul From jonas.duregard at gmail.com Tue Feb 23 07:31:03 2010 From: jonas.duregard at gmail.com (=?ISO-8859-1?Q?Jonas_Almstr=F6m_Dureg=E5rd?=) Date: Tue Feb 23 07:01:32 2010 Subject: [Haskell-cafe] Re: Function to detect duplicates In-Reply-To: <20100223130345.647b67e1@tritium.streitmacht.eu> References: <351ff25e1002230330n7913ba28h40b641096a777acc@mail.gmail.com> <20100223130345.647b67e1@tritium.streitmacht.eu> Message-ID: <3690ee141002230431r7ef74868u1f70166797fa1fac@mail.gmail.com> Ertugrul: while your solution is minimalistic, Rafael deemed his ~n*log n implementation too inefficient. Thus your ~n^3 implementation is hardly an improvement... /Jonas On 23 February 2010 13:03, Ertugrul Soeylemez wrote: > Rafael Gustavo da Cunha Pereira Pinto wrote: > >> While solving a puzzle, I was posed the problem of finding if there >> was no duplicates on a list. >> >> First I used: >> >> noneRepeated=null.(filter (>1)).(map length).group.sort >> >> But this seemed very unneficient, so I thought that I could detect the >> duplicates while sorting, and devised this: >> >> import Control.Monad >> import Data.Maybe >> >> noneRepeated=isNothing . (foldl merge (Just [])) . (map sort) . pairs > > import Data.List > > noneRepeated xs = xs == nub xs > > > Greets > Ertugrul > > > -- > nightmare = unsafePerformIO (getWrongWife >>= sex) > http://blog.ertes.de/ > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ketil at malde.org Tue Feb 23 07:42:53 2010 From: ketil at malde.org (Ketil Malde) Date: Tue Feb 23 07:13:37 2010 Subject: [Haskell-cafe] Function to detect duplicates In-Reply-To: <351ff25e1002230330n7913ba28h40b641096a777acc@mail.gmail.com> (Rafael Gustavo da Cunha Pereira Pinto's message of "Tue, 23 Feb 2010 08:30:18 -0300") References: <351ff25e1002230330n7913ba28h40b641096a777acc@mail.gmail.com> Message-ID: <878wak3yya.fsf@malde.org> Rafael Gustavo da Cunha Pereira Pinto writes: > First I used: > > noneRepeated=null.(filter (>1)).(map length).group.sort > But this seemed very unneficient, so I thought that I could detect the > duplicates while sorting, and devised this: [...] > 1) Is there any improvement I can make? Well - it's a bit long, don't you think? Long enough that from a cursory glance, I'd say it's in the "no obvious errors" category. How about (inspired by quicksort, as you no doubt can tell): noneRepeated [] = True noneRepeated (x:xs) = noneRepeated lt && singleton eq && noneRepeated gt where lt = filter (x) xs eq = x:filter (==x) xs singleton [_] = True singleton _ = False > 2) Can it be parallelized (par, pseq)? You could force each of the sublists in parallel, but you might lose some laziness properties, so I'd carefully benchmark it. -k -- If I haven't seen further, it is by standing in the footprints of giants From es at ertes.de Tue Feb 23 07:59:49 2010 From: es at ertes.de (Ertugrul Soeylemez) Date: Tue Feb 23 07:30:30 2010 Subject: [Haskell-cafe] Re: Function to detect duplicates References: <351ff25e1002230330n7913ba28h40b641096a777acc@mail.gmail.com> <20100223130345.647b67e1@tritium.streitmacht.eu> <3690ee141002230431r7ef74868u1f70166797fa1fac@mail.gmail.com> Message-ID: <20100223135949.313f8a53@tritium.streitmacht.eu> Jonas Almstr?m Dureg?rd wrote: > Ertugrul: while your solution is minimalistic, Rafael deemed his > ~n*log n implementation too inefficient. Thus your ~n^3 implementation > is hardly an improvement... My variant has an advantage, though. It is completely lazy, so it will take a shortcut, as soon as a duplicate is found. Depending on his application, this may be useful or not. I think the nub-based solution is the best one in general, but it's the base library implementation of nub, which is unfortunate. In fact, with a better nub implementation, this becomes an O(n * log n) time algorithm, too, but with the additional laziness advantage. The article you linked to contains such an implementation, I think. Greets Ertugrul -- nightmare = unsafePerformIO (getWrongWife >>= sex) http://blog.ertes.de/ From daniel.is.fischer at web.de Tue Feb 23 08:09:32 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Feb 23 07:41:58 2010 Subject: [Haskell-cafe] Re: Function to detect duplicates In-Reply-To: <20100223135949.313f8a53@tritium.streitmacht.eu> References: <351ff25e1002230330n7913ba28h40b641096a777acc@mail.gmail.com> <3690ee141002230431r7ef74868u1f70166797fa1fac@mail.gmail.com> <20100223135949.313f8a53@tritium.streitmacht.eu> Message-ID: <201002231409.33033.daniel.is.fischer@web.de> Am Dienstag 23 Februar 2010 13:59:49 schrieb Ertugrul Soeylemez: > Jonas Almstr?m Dureg?rd wrote: > > Ertugrul: while your solution is minimalistic, Rafael deemed his > > ~n*log n implementation too inefficient. Thus your ~n^3 implementation > > is hardly an improvement... Not quite as bad, nub is O(n^2). > > My variant has an advantage, though. It is completely lazy, so it will > take a shortcut, as soon as a duplicate is found. Depending on his > application, this may be useful or not. > > I think the nub-based solution is the best one in general, but it's the > base library implementation of nub, which is unfortunate. In fact, with > a better nub implementation, this becomes an O(n * log n) time How can you nub in O(n*log n)? Remember, you only have Eq for nub. > algorithm, too, but with the additional laziness advantage. The article > you linked to contains such an implementation, I think. > > > Greets > Ertugrul From haskell at gimbo.org.uk Tue Feb 23 08:44:50 2010 From: haskell at gimbo.org.uk (Andy Gimblett) Date: Tue Feb 23 08:15:28 2010 Subject: [Haskell-cafe] Proper round-trip HughesPJ/Parsec for Doubles? Message-ID: <1CA520E4-F8FA-4237-916C-98CEB93AC4F9@gimbo.org.uk> Hi all, Short version: How can I pretty print and parse values of type Double such that those operations are each other's inverse? Long version: I'm writing and QuickCheck-testing a parser using the approach set out here: http://lstephen.wordpress.com/2007/07/29/parsec-parser-testing-with-quickcheck/ That is, each syntactic category gets a pretty-printer and a parser and an Arbitrary instance, and QuickCheck checks that (parse . prettyPrint) == id, basically. Somewhat unsurprisingly, this sometimes fails for floating point values (I'm using Doubles). Now, I know that floats are in some sense imprecise, and comparing for equality is fraught with peril, but it seems that if x==x then it ought to be at least _possible_ to arrange matters such that (parse . prettyPrint x) == x as well. At worst, pretty-printing the underlying binary representation!? So my feeling is that my parser could be improved. At the moment I'm working around it by defining a type class which checks for equality within some margin of error, and using that instead of Eq - but it's messier than I'd like, so I wondered if there was something obvious I'm missing. As hpaste.org seems to be down, I'll attach a code example here instead. Thanks! -Andy -- Andy Gimblett http://gimbo.org.uk/ -------------- next part -------------- A non-text attachment was scrubbed... Name: TestParse.hs Type: application/octet-stream Size: 1527 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100223/76987856/TestParse.obj -------------- next part -------------- From jonas.duregard at gmail.com Tue Feb 23 08:54:36 2010 From: jonas.duregard at gmail.com (=?ISO-8859-1?Q?Jonas_Almstr=F6m_Dureg=E5rd?=) Date: Tue Feb 23 08:25:15 2010 Subject: [Haskell-cafe] Re: Function to detect duplicates In-Reply-To: <201002231409.33033.daniel.is.fischer@web.de> References: <351ff25e1002230330n7913ba28h40b641096a777acc@mail.gmail.com> <3690ee141002230431r7ef74868u1f70166797fa1fac@mail.gmail.com> <20100223135949.313f8a53@tritium.streitmacht.eu> <201002231409.33033.daniel.is.fischer@web.de> Message-ID: <3690ee141002230554h4434ec1aye130e9b3bb73e88f@mail.gmail.com> >>noneRepeated xs = xs == nub xs > Not quite as bad, nub is O(n^2) You are correct of course. Still, it will probably be a bit less inefficient if the length of the lists are compared (as opposed to the elements): noneRepeated xs = length xs == length (nub xs) On 23 February 2010 14:09, Daniel Fischer wrote: > Am Dienstag 23 Februar 2010 13:59:49 schrieb Ertugrul Soeylemez: >> Jonas Almstr?m Dureg?rd wrote: >> > Ertugrul: while your solution is minimalistic, Rafael deemed his >> > ~n*log n implementation too inefficient. Thus your ~n^3 implementation >> > is hardly an improvement... > > Not quite as bad, nub is O(n^2). > >> >> My variant has an advantage, though. ?It is completely lazy, so it will >> take a shortcut, as soon as a duplicate is found. ?Depending on his >> application, this may be useful or not. >> >> I think the nub-based solution is the best one in general, but it's the >> base library implementation of nub, which is unfortunate. ?In fact, with >> a better nub implementation, this becomes an O(n * log n) time > > How can you nub in O(n*log n)? Remember, you only have Eq for nub. > >> algorithm, too, but with the additional laziness advantage. ?The article >> you linked to contains such an implementation, I think. >> >> >> Greets >> Ertugrul > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From daniel.is.fischer at web.de Tue Feb 23 09:08:56 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Feb 23 08:41:25 2010 Subject: [Haskell-cafe] Re: Function to detect duplicates In-Reply-To: <3690ee141002230554h4434ec1aye130e9b3bb73e88f@mail.gmail.com> References: <351ff25e1002230330n7913ba28h40b641096a777acc@mail.gmail.com> <201002231409.33033.daniel.is.fischer@web.de> <3690ee141002230554h4434ec1aye130e9b3bb73e88f@mail.gmail.com> Message-ID: <201002231508.57515.daniel.is.fischer@web.de> Am Dienstag 23 Februar 2010 14:54:36 schrieb Jonas Almstr?m Dureg?rd: > You are correct of course. Still, it will probably be a bit less > inefficient if the length of the lists are compared (as opposed to the > elements): > > noneRepeated xs = length xs == length (nub xs) Only if no repeated elements appear early. For xs = 1 : [1 .. 10^7], xs == nub xs will return False without noticeable delay, length xs == length (nub xs) will take VERY long. From daniel.is.fischer at web.de Tue Feb 23 09:27:27 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Feb 23 08:59:53 2010 Subject: [Haskell-cafe] Proper round-trip HughesPJ/Parsec for Doubles? In-Reply-To: <1CA520E4-F8FA-4237-916C-98CEB93AC4F9@gimbo.org.uk> References: <1CA520E4-F8FA-4237-916C-98CEB93AC4F9@gimbo.org.uk> Message-ID: <201002231527.28102.daniel.is.fischer@web.de> Am Dienstag 23 Februar 2010 14:44:50 schrieb Andy Gimblett: > Hi all, > > Short version: How can I pretty print and parse values of type Double > such that those operations are each other's inverse? > > Long version: I'm writing and QuickCheck-testing a parser using the > approach set out here: > > http://lstephen.wordpress.com/2007/07/29/parsec-parser-testing-with-quic >kcheck/ > > That is, each syntactic category gets a pretty-printer and a parser > and an Arbitrary instance, and QuickCheck checks that (parse . > prettyPrint) == id, basically. Somewhat unsurprisingly, this > sometimes fails for floating point values (I'm using Doubles). > > Now, I know that floats are in some sense imprecise, and comparing for > equality is fraught with peril, but it seems that if x==x then it > ought to be at least _possible_ to arrange matters such that (parse . > prettyPrint x) == x as well. At worst, pretty-printing the underlying > binary representation!? So my feeling is that my parser could be > improved. Parse it as a Rational, then convert with fromRational. I don't know whether that will always have parse . prettyPrint == id, but it'll be much closer. The naturalOrFloat default implementation uses fraction = do{ char '.' ; digits <- many1 digit "fraction" ; return (foldr op 0.0 digits) } "fraction" where op d f = (f + fromIntegral (digitToInt d))/10.0 and division by 10 isn't exact with a binary representation. > > At the moment I'm working around it by defining a type class which > checks for equality within some margin of error, and using that > instead of Eq - but it's messier than I'd like, so I wondered if there > was something obvious I'm missing. > > As hpaste.org seems to be down, I'll attach a code example here instead. > > Thanks! > > -Andy > > -- > Andy Gimblett > http://gimbo.org.uk/ From Christian.Maeder at dfki.de Tue Feb 23 10:13:22 2010 From: Christian.Maeder at dfki.de (Christian Maeder) Date: Tue Feb 23 09:43:52 2010 Subject: [Haskell-cafe] Re: Proper round-trip HughesPJ/Parsec for Doubles? In-Reply-To: <1CA520E4-F8FA-4237-916C-98CEB93AC4F9@gimbo.org.uk> References: <1CA520E4-F8FA-4237-916C-98CEB93AC4F9@gimbo.org.uk> Message-ID: <4B83F092.20606@dfki.de> Andy Gimblett schrieb: > Hi all, > > Short version: How can I pretty print and parse values of type Double > such that those operations are each other's inverse? Maybe you have more luck with show and read (without Parsec.Token). Your example: x = 9.91165677454629 fails because the computation performed by the parser 9.0 + 0.91165677454629 yields 9.911656774546291 Cheers Christian > Long version: I'm writing and QuickCheck-testing a parser using the > approach set out here: > > http://lstephen.wordpress.com/2007/07/29/parsec-parser-testing-with-quickcheck/ > > > That is, each syntactic category gets a pretty-printer and a parser and > an Arbitrary instance, and QuickCheck checks that (parse . prettyPrint) > == id, basically. Somewhat unsurprisingly, this sometimes fails for > floating point values (I'm using Doubles). > > Now, I know that floats are in some sense imprecise, and comparing for > equality is fraught with peril, but it seems that if x==x then it ought > to be at least _possible_ to arrange matters such that (parse . > prettyPrint x) == x as well. At worst, pretty-printing the underlying > binary representation!? So my feeling is that my parser could be improved. > > At the moment I'm working around it by defining a type class which > checks for equality within some margin of error, and using that instead > of Eq - but it's messier than I'd like, so I wondered if there was > something obvious I'm missing. > > As hpaste.org seems to be down, I'll attach a code example here instead. > > Thanks! > > -Andy > > -- > Andy Gimblett > http://gimbo.org.uk/ > > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From haskell at gimbo.org.uk Tue Feb 23 11:08:29 2010 From: haskell at gimbo.org.uk (Andy Gimblett) Date: Tue Feb 23 10:39:06 2010 Subject: [Haskell-cafe] Re: Proper round-trip HughesPJ/Parsec for Doubles? In-Reply-To: <4B83F092.20606@dfki.de> References: <1CA520E4-F8FA-4237-916C-98CEB93AC4F9@gimbo.org.uk> <4B83F092.20606@dfki.de> Message-ID: >> Short version: How can I pretty print and parse values of type Double >> such that those operations are each other's inverse? > > Maybe you have more luck with show and read (without Parsec.Token). > > Your example: > x = 9.91165677454629 > > fails because the computation performed by the parser > 9.0 + 0.91165677454629 yields 9.911656774546291 That seems to do the trick! Below, for the record, the code I've come up with (I threw away the Either Integer Double part so it's a bit simpler, also). I'm sure it can be improved, but this is passing all tests reliably, it seems. Many thanks, Christian and Daniel, for your help! Best, -Andy parseDouble :: Parser Double parseDouble = try $ do (symbol toks) "-" n <- floater return $ negate n <|> floater where toks = makeTokenParser emptyDef -- This could definitely be improved, but it's working. :-) floater :: Parser Double floater = do w <- many1 digit char '.' f <- many1 digit e <- optionMaybe $ do char 'e' -- Optional exponent part n <- option "" (char '-' >> return "-") -- Optional negation in exponent m <- many1 digit return $ n ++ m case e of Nothing -> return $ read $ w ++ "." ++ f Just e' -> return $ read $ w ++ "." ++ f ++ "e" ++ e' -- Andy Gimblett http://gimbo.org.uk/ From maciej.podgurski at googlemail.com Tue Feb 23 13:51:51 2010 From: maciej.podgurski at googlemail.com (Maciej Podgurski) Date: Tue Feb 23 13:22:32 2010 Subject: [Haskell-cafe] Problems linking hsql-mysql Message-ID: <4B8423C7.5040302@googlemail.com> Hi, I have problems linking a simple test program that imports Database.HSQL.MySQL via ghc --make Test.hs. The error only occurs when importing this module of hsql-mysql-1.7.1. I pasted the building output here: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=22911 (actually it was even longer but hpaste only takes 30k). When I do ghc -e main Test.hs or starting it from GHCi, everything works fine and no errors occur. So I guess all needed .lib files are there but GHC can't find them when linking (adding the flag -L"path to mysql/lib/opt" doesn't help). Anyone an idea? Best wishes, Maciej From lennart at augustsson.net Tue Feb 23 15:08:32 2010 From: lennart at augustsson.net (Lennart Augustsson) Date: Tue Feb 23 14:39:01 2010 Subject: [Haskell-cafe] Proper round-trip HughesPJ/Parsec for Doubles? In-Reply-To: <1CA520E4-F8FA-4237-916C-98CEB93AC4F9@gimbo.org.uk> References: <1CA520E4-F8FA-4237-916C-98CEB93AC4F9@gimbo.org.uk> Message-ID: If you use read (reads) and show for the actual conversion it will round trip. It appears to be non-trivial since most languages and libraries get it wrong. :) -- Lennart On Tue, Feb 23, 2010 at 1:44 PM, Andy Gimblett wrote: > Hi all, > > Short version: How can I pretty print and parse values of type Double such > that those operations are each other's inverse? > > Long version: I'm writing and QuickCheck-testing a parser using the approach > set out here: > > http://lstephen.wordpress.com/2007/07/29/parsec-parser-testing-with-quickcheck/ > > That is, each syntactic category gets a pretty-printer and a parser and an > Arbitrary instance, and QuickCheck checks that (parse . prettyPrint) == id, > basically. ?Somewhat unsurprisingly, this sometimes fails for floating point > values (I'm using Doubles). > > Now, I know that floats are in some sense imprecise, and comparing for > equality is fraught with peril, but it seems that if x==x then it ought to > be at least _possible_ to arrange matters such that (parse . prettyPrint x) > == x as well. ?At worst, pretty-printing the underlying binary > representation!? ?So my feeling is that my parser could be improved. > > At the moment I'm working around it by defining a type class which checks > for equality within some margin of error, and using that instead of Eq - but > it's messier than I'd like, so I wondered if there was something obvious I'm > missing. > > As hpaste.org seems to be down, I'll attach a code example here instead. > > Thanks! > > -Andy > > -- > Andy Gimblett > http://gimbo.org.uk/ > > > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From haskell at gimbo.org.uk Tue Feb 23 16:55:41 2010 From: haskell at gimbo.org.uk (Andy Gimblett) Date: Tue Feb 23 16:26:16 2010 Subject: [Haskell-cafe] Re: Proper round-trip HughesPJ/Parsec for Doubles? In-Reply-To: References: <1CA520E4-F8FA-4237-916C-98CEB93AC4F9@gimbo.org.uk> <4B83F092.20606@dfki.de> Message-ID: <91CFF9A8-8549-45D1-83D8-A9CE167BE536@gimbo.org.uk> For the record, here's the final improved version: float' :: TokenParser st -> GenParser Char st Double float' t = do n <- liftCtoS '-' w <- many1 digit char '.' f <- many1 digit e <- option "" $ do char 'e' n' <- liftCtoS '-' m <- many1 digit return $ concat ["e", n', m] whiteSpace t return $ read $ concat [n, w, ".", f, e] where liftCtoS a = option "" (char a >> return [a]) Thanks for all the help, again. -Andy -- Andy Gimblett http://gimbo.org.uk/ From joerg.rudnick at t-online.de Tue Feb 23 19:07:09 2010 From: joerg.rudnick at t-online.de (Nick Rudnick) Date: Tue Feb 23 18:37:47 2010 Subject: [Haskell-cafe] Problems linking hsql-mysql In-Reply-To: <4B8423C7.5040302@googlemail.com> References: <4B8423C7.5040302@googlemail.com> Message-ID: <4B846DAD.9040506@t-online.de> Hi Maciej, I will try to reproduce the error -- could you send me your both *.cabal files (for hsql & hsql-mysql), if you have changed anything, and your system configuration. Is this extremely urgent? I ask this, as these days exactly the end phase of the projects of about 100 beginner Haskell students, which I am the one to look after. So I am in a little of slow motion regarding other things... ;-) But in case you are in emergency, please let me know... At first sight, I would say it looks like a configuration problem... ;-) Cheers, Nick Maciej Podgurski wrote: > Hi, > > I have problems linking a simple test program that imports > Database.HSQL.MySQL via ghc --make Test.hs. The error only occurs when > importing this module of hsql-mysql-1.7.1. I pasted the building > output here: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=22911 > (actually it was even longer but hpaste only takes 30k). > > When I do ghc -e main Test.hs or starting it from GHCi, everything > works fine and no errors occur. So I guess all needed .lib files are > there but GHC can't find them when linking (adding the flag -L"path to > mysql/lib/opt" doesn't help). Anyone an idea? > > > Best wishes, > > Maciej > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From allbery at ece.cmu.edu Tue Feb 23 23:10:59 2010 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue Feb 23 22:41:43 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: References: <1266394750-sup-7721@oz.taruti.net> <1266508065-sup-8211@oz.taruti.net> <20100221175030.7D7F493C40@mail.avvanta.com> <77FAF8ED-CE5C-44F6-9219-B60688CB39A4@n-heptane.com> <20100222003924.6E28893C2E@mail.avvanta.com> Message-ID: <4DC8E5B2-134D-4016-9A6F-081EC8450037@ece.cmu.edu> Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100223/c19d8921/PGP.bin From donn at avvanta.com Tue Feb 23 23:47:41 2010 From: donn at avvanta.com (Donn Cave) Date: Tue Feb 23 23:18:09 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? References: <1266394750-sup-7721@oz.taruti.net> <1266508065-sup-8211@oz.taruti.net> <20100221175030.7D7F493C40@mail.avvanta.com> <77FAF8ED-CE5C-44F6-9219-B60688CB39A4@n-heptane.com> <20100222003924.6E28893C2E@mail.avvanta.com> <4DC8E5B2-134D-4016-9A6F-081EC8450037@ece.cmu.edu> Message-ID: <20100224044741.D11AF276C4A@mail.avvanta.com> Quoth "Brandon S. Allbery KF8NH" , > On Feb 21, 2010, at 20:17 , Jeremy Shaw wrote: >> The PS3 does do something though. If we were doing a write *and* >> read select on the socket, the read select would wakeup. So, it is >> trying to notify us that something has happened, but we are not >> seeing it because we are only looking at the write select(). > > Earlier the OP claimed this would happen within a few minutes if he > seeked in a movie. If it's that reproducible, it should be easy to > capture a tcpdump and attach it to an email (or pastebin it), allowing > us to determine what really happens. > > Also, Donn, you are incorrect about invalidating premises; we know the > connection is going away, we can infer it's not going away normally, > that's why there have been comments about it sending a FIN and > dropping the connection entirely (bypassing the shutdown handshake), > or sending an RST, etc. That's what I'm saying - it clearly is not a full close, i.e., going away normally per protocol. With luck maybe the packets will show that something does happen at a wire protocol level, and there will be a way to recognize the event at the `user land' level and plug that into the event loop. My prediction is that on the contrary, the transition between functional and defunct will not be not announced in any way by the peer, but that's just guessing. It would be a lot less interesting. Donn From allbery at ece.cmu.edu Tue Feb 23 23:54:06 2010 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue Feb 23 23:24:37 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: <20100224044741.D11AF276C4A@mail.avvanta.com> References: <1266394750-sup-7721@oz.taruti.net> <1266508065-sup-8211@oz.taruti.net> <20100221175030.7D7F493C40@mail.avvanta.com> <77FAF8ED-CE5C-44F6-9219-B60688CB39A4@n-heptane.com> <20100222003924.6E28893C2E@mail.avvanta.com> <4DC8E5B2-134D-4016-9A6F-081EC8450037@ece.cmu.edu> <20100224044741.D11AF276C4A@mail.avvanta.com> Message-ID: <51FB9832-7486-4ED9-ADC8-E2D759382CB1@ece.cmu.edu> On Feb 23, 2010, at 23:47 , Donn Cave wrote: > My prediction is that on the contrary, the transition between > functional > and defunct will not be not announced in any way by the peer, but > that's > just guessing. It would be a lot less interesting. But that's not the issue. The *kernel* is clearly detecting it; the problem is it's only being reported for the *read* end of the socket, whereas sendfile() (correctly) only cares about, and therefore only registers interest in, the *write* end. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100223/f3eaa519/PGP.bin From allbery at ece.cmu.edu Tue Feb 23 23:56:50 2010 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue Feb 23 23:27:18 2010 Subject: [Haskell-cafe] Optimizing hash array mapped tries In-Reply-To: <1266821677-sup-1773@ezyang> References: <1266821677-sup-1773@ezyang> Message-ID: <26A88501-21DC-4B51-BCF1-C40D0FB68179@ece.cmu.edu> On Feb 22, 2010, at 02:15 , Edward Z. Yang wrote: > * i-Full-update essentially copies a 32-size vector, with a change to > one element. I think I am getting brutally punished for this, in > terms of both memory usage as well as runtime. What I'm curious is > whether or not this is intrinsic to the algorithm, or if it's > something special that GHC is doing. IIRC this is intrinsic to the way GHC modifies and garbage-collects array modifications. There's been discussion on -cafe about it. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100223/61a362e8/PGP.bin From allbery at ece.cmu.edu Wed Feb 24 00:02:12 2010 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue Feb 23 23:32:41 2010 Subject: [Haskell-cafe] GHC RTS question In-Reply-To: <20100222083656.GA14436@flit> References: <88bdc6651002210745p6629e363se0a5c70e039dd2e6@mail.gmail.com> <201002211713.26123.daniel.is.fischer@web.de> <88bdc6651002210920o7bae3b56u13eadf18600b1f7c@mail.gmail.com> <201002211925.31945.daniel.is.fischer@web.de> <88bdc6651002211058n6af64adewb04ef8918f06cb7f@mail.gmail.com> <81addec71002211115v657ad55bk35e3d6b430d6e2af@mail.gmail.com> <20100222083656.GA14436@flit> Message-ID: On Feb 22, 2010, at 03:36 , Roman Cheplyaka wrote: > * Anthony Cowley [2010-02-21 14:15:00-0500] >> #! /usr/bin/env bash >> ./prog --RTS $* > > ./prog --RTS "$@" > > Otherwise it will work wrong if arguments contain quoted field > separators (e.g. spaces). #! /bin/sh ./prog --RTS ${1+"$@"} The longer specification above should work with whatever /bin/sh is around, whether it's Solaris /sbin/sh, FreeBSD's sh, general Linux bash, Debian/Ubuntu dash, etc. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100223/ea36e41d/PGP.bin From allbery at ece.cmu.edu Wed Feb 24 00:08:41 2010 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue Feb 23 23:39:11 2010 Subject: [Haskell-cafe] Linux ghci vs Windows ghci In-Reply-To: <4f56deb71002210327q1407ba35s12cae0b137def8c0@mail.gmail.com> References: <4f56deb71002210322w3c35889ev2a9e689584f23d6d@mail.gmail.com> <4f56deb71002210327q1407ba35s12cae0b137def8c0@mail.gmail.com> Message-ID: Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100223/2e376314/PGP.bin From roma at ro-che.info Wed Feb 24 02:18:57 2010 From: roma at ro-che.info (Roman Cheplyaka) Date: Wed Feb 24 01:49:47 2010 Subject: [Haskell-cafe] [offtopic] UNIX Shell (was: GHC RTS question) In-Reply-To: References: <88bdc6651002210745p6629e363se0a5c70e039dd2e6@mail.gmail.com> <201002211713.26123.daniel.is.fischer@web.de> <88bdc6651002210920o7bae3b56u13eadf18600b1f7c@mail.gmail.com> <201002211925.31945.daniel.is.fischer@web.de> <88bdc6651002211058n6af64adewb04ef8918f06cb7f@mail.gmail.com> <81addec71002211115v657ad55bk35e3d6b430d6e2af@mail.gmail.com> <20100222083656.GA14436@flit> Message-ID: <20100224071857.GA22654@flit> * Brandon S. Allbery KF8NH [2010-02-24 00:02:12-0500] > On Feb 22, 2010, at 03:36 , Roman Cheplyaka wrote: > >* Anthony Cowley [2010-02-21 14:15:00-0500] > >>#! /usr/bin/env bash > >>./prog --RTS $* > > > > ./prog --RTS "$@" > > > >Otherwise it will work wrong if arguments contain quoted field > >separators (e.g. spaces). > > > #! /bin/sh > ./prog --RTS ${1+"$@"} > > The longer specification above should work with whatever /bin/sh is > around, whether it's Solaris /sbin/sh, FreeBSD's sh, general Linux > bash, Debian/Ubuntu dash, etc. Are you referring to some Solaris shell bug? Under POSIX these constructs seem to be equivalent. "If there are no positional parameters, the expansion of '@' shall generate zero fields, even when '@' is double-quoted." -- Roman I. Cheplyaka :: http://ro-che.info/ "Don't let school get in the way of your education." - Mark Twain From artyom.kazak at gmail.com Wed Feb 24 03:23:07 2010 From: artyom.kazak at gmail.com (Artyom Kazak) Date: Wed Feb 24 02:53:34 2010 Subject: [Haskell-cafe] GHC RTS question In-Reply-To: References: <88bdc6651002210745p6629e363se0a5c70e039dd2e6@mail.gmail.com> <201002211713.26123.daniel.is.fischer@web.de> <88bdc6651002210920o7bae3b56u13eadf18600b1f7c@mail.gmail.com> <201002211925.31945.daniel.is.fischer@web.de> <88bdc6651002211058n6af64adewb04ef8918f06cb7f@mail.gmail.com> <81addec71002211115v657ad55bk35e3d6b430d6e2af@mail.gmail.com> <20100222083656.GA14436@flit> Message-ID: <88bdc6651002240023q2ea41dd2h46021c0563bdbe7d@mail.gmail.com> 2010/2/24 Brandon S. Allbery KF8NH : > On Feb 22, 2010, at 03:36 , Roman Cheplyaka wrote: >> >> * Anthony Cowley [2010-02-21 14:15:00-0500] >>> >>> #! /usr/bin/env bash >>> ./prog --RTS $* >> >> ?./prog --RTS "$@" >> >> Otherwise it will work wrong if arguments contain quoted field >> separators (e.g. spaces). > > > ?#! /bin/sh > ?./prog --RTS ${1+"$@"} > > The longer specification above should work with whatever /bin/sh is around, > whether it's Solaris /sbin/sh, FreeBSD's sh, general Linux bash, > Debian/Ubuntu dash, etc. > And with Windows, of course :) Haskell is cross-platform, isn't it? From magnus at therning.org Wed Feb 24 04:11:54 2010 From: magnus at therning.org (Magnus Therning) Date: Wed Feb 24 03:42:21 2010 Subject: [Haskell-cafe] [offtopic] UNIX Shell (was: GHC RTS question) In-Reply-To: <20100224071857.GA22654@flit> References: <88bdc6651002210745p6629e363se0a5c70e039dd2e6@mail.gmail.com> <201002211713.26123.daniel.is.fischer@web.de> <88bdc6651002210920o7bae3b56u13eadf18600b1f7c@mail.gmail.com> <201002211925.31945.daniel.is.fischer@web.de> <88bdc6651002211058n6af64adewb04ef8918f06cb7f@mail.gmail.com> <81addec71002211115v657ad55bk35e3d6b430d6e2af@mail.gmail.com> <20100222083656.GA14436@flit> <20100224071857.GA22654@flit> Message-ID: On Wed, Feb 24, 2010 at 07:18, Roman Cheplyaka wrote: > * Brandon S. Allbery KF8NH [2010-02-24 00:02:12-0500] >> On Feb 22, 2010, at 03:36 , Roman Cheplyaka wrote: >> >* Anthony Cowley [2010-02-21 14:15:00-0500] >> >>#! /usr/bin/env bash >> >>./prog --RTS $* >> > >> > ./prog --RTS "$@" >> > >> >Otherwise it will work wrong if arguments contain quoted field >> >separators (e.g. spaces). >> >> >> ? #! /bin/sh >> ? ./prog --RTS ${1+"$@"} >> >> The longer specification above should work with whatever /bin/sh is >> around, whether it's Solaris /sbin/sh, FreeBSD's sh, general Linux >> bash, Debian/Ubuntu dash, etc. > > Are you referring to some Solaris shell bug? > > Under POSIX these constructs seem to be equivalent. > "If there are no positional parameters, the expansion of '@' shall > generate zero fields, even when '@' is double-quoted." I believe he's referring to the following bit (taken from bash's man page): * Expands to the positional parameters, starting from one. When the expansion occurs within double quotes, it expands to a single word with the value of each parameter separated by the first character of the IFS special variable. That is, "$*" is equivalent to "$1c$2c...", where c is the first character of the value of the IFS variable. If IFS is unset, the parameters are separated by spaces. If IFS is null, the parameters are joined without intervening separators. @ Expands to the positional parameters, starting from one. When the expansion occurs within double quotes, each parameter expands to a separate word. That is, "$@" is equivalent to "$1" "$2" ... If the double-quoted expansion occurs within a word, the expansion of the first parameter is joined with the beginning part of the original word, and the expansion of the last parameter is joined with the last part of the original word. When there are no positional parameters, "$@" and $@ expand to nothing (i.e., they are removed). /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From magnus at therning.org Wed Feb 24 04:17:47 2010 From: magnus at therning.org (Magnus Therning) Date: Wed Feb 24 03:48:13 2010 Subject: [Haskell-cafe] Testing and module export lists Message-ID: How do people who like unit testing / property testing deal with export lists? I often find that I do want an export list to reduce clutter in the finished code, but for testing I'd like to expose everything in a module. Is there a nice way to deal with this (using the C pre-processor would not qualify as "nice" ;-)? Maybe there's a switch that causes GHC to simply ignore the export list of a module and export everything? /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From bulat.ziganshin at gmail.com Wed Feb 24 04:25:27 2010 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Feb 24 03:57:19 2010 Subject: [Haskell-cafe] Linux ghci vs Windows ghci In-Reply-To: References: <4f56deb71002210322w3c35889ev2a9e689584f23d6d@mail.gmail.com> <4f56deb71002210327q1407ba35s12cae0b137def8c0@mail.gmail.com> Message-ID: <543620757.20100224122527@gmail.com> Hello Brandon, Wednesday, February 24, 2010, 8:08:41 AM, you wrote: >> I feel that ghci code executing speed in guest os is 1.5~2x faster >> than host os > My guess is that GHC (and the GHC RTS) on win32 is using a POSIX > emulation layer supplied by mingw32 for all system calls, introducing > extra overhead. 1. yes, mingw is using POSIX emulation layer for file operations, but i don't believe that it provides any serious overhead - even for i/o 2. this example was purely computational, no OS calls involved -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From aruiz at um.es Wed Feb 24 05:07:08 2010 From: aruiz at um.es (Alberto Ruiz) Date: Wed Feb 24 04:37:42 2010 Subject: [Haskell-cafe] Linear programming in Haskell In-Reply-To: <20100218093323.2f1b0003.mle+hs@mega-nerd.com> References: <20100216195420.GA26057@kira.casa> <20100216203725.GA30360@kira.casa> <4B7BAAFE.3080303@um.es> <20100218093323.2f1b0003.mle+hs@mega-nerd.com> Message-ID: <4B84FA4C.8040903@um.es> I have uploaded to hackage an interface to the simplex algorithm based on GLPK. It is a very early version, it will probably have lots of problems. In the future I would like to add support for integer variables (MIP). Any suggestion is welcome. This is an example taken from "glpk-utils": http://code.haskell.org/hmatrix/packages/glpk/examples/simplex3.hs Documentation: http://perception.inf.um.es/~aruiz/hmatrix-glpk/ Installation: $ sudo apt-get install libglpk-dev $ cabal update $ cabal install hmatrix-glpk If hmatrix is not installed we also need $ sudo apt-get install libgsl0-dev liblapack-dev I hope it is useful, Alberto Erik de Castro Lopo wrote: > Alberto Ruiz wrote: > >> I think that GSL does not include linear programming solvers, but in the >> GSL home page there is a reference to the GLPK package: >> >> http://www.gnu.org/software/glpk/glpk.html >> >> I have not used it, but it would be very nice to have a simple Haskell >> interface to GLPK (or other similar library) in hmatrix or as a separate >> package. I will take a look at this. > > I used GLPK many years ago and I found it excellent. > > Erik From roma at ro-che.info Wed Feb 24 05:16:48 2010 From: roma at ro-che.info (Roman Cheplyaka) Date: Wed Feb 24 04:47:53 2010 Subject: [Haskell-cafe] GHC RTS question In-Reply-To: <88bdc6651002240023q2ea41dd2h46021c0563bdbe7d@mail.gmail.com> References: <88bdc6651002210745p6629e363se0a5c70e039dd2e6@mail.gmail.com> <201002211713.26123.daniel.is.fischer@web.de> <88bdc6651002210920o7bae3b56u13eadf18600b1f7c@mail.gmail.com> <201002211925.31945.daniel.is.fischer@web.de> <88bdc6651002211058n6af64adewb04ef8918f06cb7f@mail.gmail.com> <81addec71002211115v657ad55bk35e3d6b430d6e2af@mail.gmail.com> <20100222083656.GA14436@flit> <88bdc6651002240023q2ea41dd2h46021c0563bdbe7d@mail.gmail.com> Message-ID: <20100224101648.GA30011@flit> * Artyom Kazak [2010-02-24 10:23:07+0200] > 2010/2/24 Brandon S. Allbery KF8NH : > > On Feb 22, 2010, at 03:36 , Roman Cheplyaka wrote: > >> > >> * Anthony Cowley [2010-02-21 14:15:00-0500] > >>> > >>> #! /usr/bin/env bash > >>> ./prog --RTS $* > >> > >> ?./prog --RTS "$@" > >> > >> Otherwise it will work wrong if arguments contain quoted field > >> separators (e.g. spaces). > > > > > > ?#! /bin/sh > > ?./prog --RTS ${1+"$@"} > > > > The longer specification above should work with whatever /bin/sh is around, > > whether it's Solaris /sbin/sh, FreeBSD's sh, general Linux bash, > > Debian/Ubuntu dash, etc. > > > > And with Windows, of course :) Haskell is cross-platform, isn't it? Haskell is a language, it does not have any notion of platform. It has several implementations, which may or may not be cross-platform. (OP asked specifically about ghc, which supports a number of platforms, including Windows.) Here we talk not about ghc itself, but about POSIX shell interpreter, which is available on every POSIX-compliant operating system. Windows (out of the box) lacks implementation of POSIX shell. -- Roman I. Cheplyaka :: http://ro-che.info/ "Don't let school get in the way of your education." - Mark Twain From roma at ro-che.info Wed Feb 24 05:19:11 2010 From: roma at ro-che.info (Roman Cheplyaka) Date: Wed Feb 24 04:50:34 2010 Subject: [Haskell-cafe] [offtopic] UNIX Shell (was: GHC RTS question) In-Reply-To: References: <88bdc6651002210745p6629e363se0a5c70e039dd2e6@mail.gmail.com> <201002211713.26123.daniel.is.fischer@web.de> <88bdc6651002210920o7bae3b56u13eadf18600b1f7c@mail.gmail.com> <201002211925.31945.daniel.is.fischer@web.de> <88bdc6651002211058n6af64adewb04ef8918f06cb7f@mail.gmail.com> <81addec71002211115v657ad55bk35e3d6b430d6e2af@mail.gmail.com> <20100222083656.GA14436@flit> <20100224071857.GA22654@flit> Message-ID: <20100224101911.GB30011@flit> * Magnus Therning [2010-02-24 09:11:54+0000] > On Wed, Feb 24, 2010 at 07:18, Roman Cheplyaka wrote: > > * Brandon S. Allbery KF8NH [2010-02-24 00:02:12-0500] > >> On Feb 22, 2010, at 03:36 , Roman Cheplyaka wrote: > >> >* Anthony Cowley [2010-02-21 14:15:00-0500] > >> >>#! /usr/bin/env bash > >> >>./prog --RTS $* > >> > > >> > ./prog --RTS "$@" > >> > > >> >Otherwise it will work wrong if arguments contain quoted field > >> >separators (e.g. spaces). > >> > >> > >> ? #! /bin/sh > >> ? ./prog --RTS ${1+"$@"} > >> > >> The longer specification above should work with whatever /bin/sh is > >> around, whether it's Solaris /sbin/sh, FreeBSD's sh, general Linux > >> bash, Debian/Ubuntu dash, etc. > > > > Are you referring to some Solaris shell bug? > > > > Under POSIX these constructs seem to be equivalent. > > "If there are no positional parameters, the expansion of '@' shall > > generate zero fields, even when '@' is double-quoted." > > I believe he's referring to the following bit (taken from bash's man page): > > @ Expands to the positional parameters, starting from one. When the expansion > occurs within double quotes, each parameter expands to a separate word. That > is, "$@" is equivalent to "$1" "$2" ... If the double-quoted expansion > occurs within a word, the expansion of the first parameter is joined with > the beginning part of the original word, and the expansion of the last > parameter is joined with the last part of the original word. When there are > no positional parameters, "$@" and $@ expand to nothing (i.e., they are > removed). Well, this agrees with POSIX. So still I don't see the difference between "$@" and ${1+"$@"}. -- Roman I. Cheplyaka :: http://ro-che.info/ "Don't let school get in the way of your education." - Mark Twain From magnus at therning.org Wed Feb 24 06:01:38 2010 From: magnus at therning.org (Magnus Therning) Date: Wed Feb 24 05:32:05 2010 Subject: [Haskell-cafe] Testing and module export lists In-Reply-To: References: Message-ID: On Wed, Feb 24, 2010 at 10:41, Arnaud Bailly wrote: > Maybe you just want to test what's in your export list which > represents the public interface of your code. And if you cannot write > a test that exercise private implementation through the public > interface, then maybe there is a design problem... Possibly! The specific case I have is a module for parsing a small language. The module exports a single function, a function that takes a string and returns a tree. Of course the parser is built using parser combinators. I'd like to test each combinator I've built, but I don't want to export them all. The only way I see of achieving this is to split each module in two, one public and one internal, where the public one just re-exports the relevant pieces of the internal one. That's workable, but hardly aesthetically pleasing ;-) /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From jwlato at gmail.com Wed Feb 24 06:21:50 2010 From: jwlato at gmail.com (John Lato) Date: Wed Feb 24 05:52:17 2010 Subject: [Haskell-cafe] Re: Testing and module export lists Message-ID: <9979e72e1002240321w4a55848bt49d7cb2bf5723a42@mail.gmail.com> > From: Magnus Therning > > How do people who like unit testing / property testing deal with export lists? > > I often find that I do want an export list to reduce clutter in the > finished code, but for testing I'd like to expose everything in a > module. ?Is there a nice way to deal with this (using the C > pre-processor would not qualify as "nice" ;-)? > Maybe there's a switch that causes GHC to simply ignore the export > list of a module and export everything? That would be a nice feature to deal with this problem. The best solution I have is to separate functions that don't belong in the public interface into separate modules that aren't exposed (they're listed in the other-modules section of the .cabal file). I then add the test executable to the .cabal file, so when it's built it can access the hidden modules (or I run the test from ghci). Of course this only works if it makes sense to structure the code this way. Cheers, John From haskell at gimbo.org.uk Wed Feb 24 07:54:51 2010 From: haskell at gimbo.org.uk (Andy Gimblett) Date: Wed Feb 24 07:25:25 2010 Subject: [Haskell-cafe] Building/installing OS X application bundles for GUIs - cabal-macosx In-Reply-To: <20100111164645.GB11640@brighton.ac.uk> References: <9CA71752-36FB-4E29-8BBA-A935BF4E82A5@gimbo.org.uk> <20100111164645.GB11640@brighton.ac.uk> Message-ID: <923DF44D-DD21-4C82-9A74-6C0417E6DA43@gimbo.org.uk> Hi all, Last week I quietly released v0.1.0 of cabal-macosx, providing support for building OSX application bundles (e.g. and in particular for GUIs created using wxHaskell and gtk2hs - hence all the cross-posting): http://hackage.haskell.org/package/cabal-macosx I'm now soliciting input on how to handle the install stage, leading (I hope) to a loudly-announcable release soon. :-) The current package provides a post-build hook which creates an application bundle at dist/build/foo.app (for example). It seems to work well. See the source repository for examples. However, running "runghc Setup install" copies the bare executable at dist/build/foo/foo (rather than the foo.app bundle) to the install location, which is no good. So I need to put in some install infrastructure to copy the .app, not the bare executable, to the right place. That raises the question: what is the right place? It seems to me that the defaults are not the right defaults for this case. --global should probably go to /Applications, and --user should perhaps go to ~/ Applications (though I'm less sure about that). Of course, end-users can explicitly set this on a per-install basis, but it seems that for bundles we'd want to override the default. Thus I'm currently asking: * What do people think about the default installation question? * Can anyone advise me on the right way to handle this (installing the .app, and overriding the default locations) with Cabal? I'm hoping I can just tweak part of the LocalBuildInfo and let the default machinery then handle the work, but at present it's not clear to me how to do that, and rather than spend ages trying to figure it out, perhaps someone who knows can help me out? I'm hoping I'm not going to have to completely override the install machinery - that would feel somewhat self-defeating. Many thanks, -Andy -- Andy Gimblett http://gimbo.org.uk/ From Christian.Maeder at dfki.de Wed Feb 24 08:24:07 2010 From: Christian.Maeder at dfki.de (Christian Maeder) Date: Wed Feb 24 07:54:34 2010 Subject: [Haskell-cafe] Re: Proper round-trip HughesPJ/Parsec for Doubles? In-Reply-To: <91CFF9A8-8549-45D1-83D8-A9CE167BE536@gimbo.org.uk> References: <1CA520E4-F8FA-4237-916C-98CEB93AC4F9@gimbo.org.uk> <4B83F092.20606@dfki.de> <91CFF9A8-8549-45D1-83D8-A9CE167BE536@gimbo.org.uk> Message-ID: <4B852877.9000006@dfki.de> Andy Gimblett schrieb: > For the record, here's the final improved version: Hi Andy, I hope you don't mind if I make some style comments to your "final" version. 1. break the line after "do" (to avoid a layout change when change name or arguments of float' or rename the variable "e") 2. The "t :: TokenParser st" is only used for the white spaces. This should be done separately (use "lexeme" from the TokenParser if you really need to). Just using "spaces" is also an alternative. 3. "liftCtoS" is only applied to '-', so an "optSign" would suffice. optSign = option "" $ fmap (: []) (char '-') (read also allows a capital 'E' and a '+' before the exponent, but no initial '+' sign. The decimal point is optional. Also "NaN" and "Infinity" can be read, both possibly preceded by a '-' sign followed by spaces. But you may restrict yourself to the possible outputs of show, which would include "NaN" and "Infinity", though.) It may make sense to use something like readMaybe (which is missing in the Prelude) instead of "read" to allow the parser to fail more nicely. Btw I observed the following problem with read (that readMaybe would also not solve). http://hackage.haskell.org/trac/ghc/ticket/3897 Cheers Christian > > float' :: TokenParser st -> GenParser Char st Double > float' t = do n <- liftCtoS '-' > w <- many1 digit > char '.' > f <- many1 digit > e <- option "" $ do char 'e' > n' <- liftCtoS '-' > m <- many1 digit > return $ concat ["e", n', m] > whiteSpace t > return $ read $ concat [n, w, ".", f, e] > where liftCtoS a = option "" (char a >> return [a]) > > Thanks for all the help, again. > > -Andy > > -- > Andy Gimblett > http://gimbo.org.uk/ From es at ertes.de Wed Feb 24 08:25:20 2010 From: es at ertes.de (Ertugrul Soeylemez) Date: Wed Feb 24 07:56:01 2010 Subject: [Haskell-cafe] Re: Function to detect duplicates References: <351ff25e1002230330n7913ba28h40b641096a777acc@mail.gmail.com> <3690ee141002230431r7ef74868u1f70166797fa1fac@mail.gmail.com> <20100223135949.313f8a53@tritium.streitmacht.eu> <201002231409.33033.daniel.is.fischer@web.de> <3690ee141002230554h4434ec1aye130e9b3bb73e88f@mail.gmail.com> Message-ID: <20100224142520.42df50f4@tritium.streitmacht.eu> Jonas Almstr?m Dureg?rd wrote: > >>noneRepeated xs = xs == nub xs > > > Not quite as bad, nub is O(n^2) > > You are correct of course. Still, it will probably be a bit less > inefficient if the length of the lists are compared (as opposed to the > elements): > > noneRepeated xs = length xs == length (nub xs) > > [...] > > > How can you nub in O(n*log n)? Remember, you only have Eq for nub. Again note that the big advantage of my method is laziness. The comparison will end on the first duplicate found. Using the following nub implementation the overall time complexity should be O(n * log n), but may be space-intensive, because it uses O(n) space. Also note that it has a different context (the type needs to be Ord instead of Eq): import qualified Data.Set as S import Data.List myNub :: Ord a => [a] -> [a] myNub = concat . snd . mapAccumL nubMap S.empty where nubMap s x | S.member x s = (s, []) | otherwise = (S.insert x s, [x]) Greets Ertugrul -- nightmare = unsafePerformIO (getWrongWife >>= sex) http://blog.ertes.de/ From fabian.roth at gmail.com Wed Feb 24 08:53:32 2010 From: fabian.roth at gmail.com (Fabian Roth) Date: Wed Feb 24 08:23:58 2010 Subject: [Haskell-cafe] Lazy IO with recursive reads? Message-ID: <78fc98011002240553l37fb4dc0h837ae29186e21c37@mail.gmail.com> Hi all, I am trying to read structured data from a socket and return a lazy list of records. However, the socket reading operation seems to be strict and never returns (until stack overflow). Here's some simplified code to reproduce the problem: -------------------- import Control.Monad main = do messages <- readLazy mapM_ (\x -> putStr $ show x ++ "\n") $ messages return () where readLazy :: IO [String] readLazy = do c <- fancyIORead liftM2 (++) (return c) readLazy fancyIORead :: IO [String] fancyIORead = return ["aa","bb"] -------------------- In my implementation fancyIORead reads blocks from the socket and returns a list of records. But it seems readLazy doesn't ever return. What could be the problem here? Also, if anyone has a better solution to write this thing, pls let me know. Thanks! Fabian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100224/dcba7ae1/attachment.html From haskell at benmachine.co.uk Wed Feb 24 09:22:39 2010 From: haskell at benmachine.co.uk (Ben Millwood) Date: Wed Feb 24 08:53:05 2010 Subject: [Haskell-cafe] Re: Proper round-trip HughesPJ/Parsec for Doubles? In-Reply-To: <4B852877.9000006@dfki.de> References: <1CA520E4-F8FA-4237-916C-98CEB93AC4F9@gimbo.org.uk> <4B83F092.20606@dfki.de> <91CFF9A8-8549-45D1-83D8-A9CE167BE536@gimbo.org.uk> <4B852877.9000006@dfki.de> Message-ID: On Wed, Feb 24, 2010 at 1:24 PM, Christian Maeder wrote: > 1. break the line after "do" > (to avoid a layout change when change name or arguments of float' or > rename the variable "e") You can also break it immediately before do, which I think is sometimes more clear. From johann.hoechtl at gmail.com Wed Feb 24 10:11:49 2010 From: johann.hoechtl at gmail.com (=?ISO-8859-1?Q?Johann_H=F6chtl?=) Date: Wed Feb 24 09:42:15 2010 Subject: [Haskell-cafe] Re: Some great results on fused code with the LLVM backend In-Reply-To: <20100222015725.GA1870@whirlpool.galois.com> References: <20100222015725.GA1870@whirlpool.galois.com> Message-ID: <7dceb1a7-f413-4ee7-94e2-a19ec9200229@q21g2000yqm.googlegroups.com> On Feb 22, 2:57?am, Don Stewart wrote: > TheLLVMbackend looks very promising -- considering we've not even > begun to explore the optimization pipeline at the level. > The mere numbers on this tiny snipets look definitely promising. I also read through http://hackage.haskell.org/trac/ghc/wiki/LlvmBackend but I wonder what componentes of the LLVM infrastructure will eventually make it into GHC. Will this eg mean * interoperability between LLVM assemblies for free * plugable garbage collectors * GHC/LLVM bytecode with JIT-option? > -- Don Johann > _______________________________________________ > Haskell-Cafe mailing list > Haskell-C...@haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe From eric.kow at gmail.com Wed Feb 24 10:12:27 2010 From: eric.kow at gmail.com (Eric Kow) Date: Wed Feb 24 09:42:56 2010 Subject: [Haskell-cafe] Re: [wxhaskell-users] Building/installing OS X application bundles for GUIs - cabal-macosx In-Reply-To: <923DF44D-DD21-4C82-9A74-6C0417E6DA43@gimbo.org.uk> References: <9CA71752-36FB-4E29-8BBA-A935BF4E82A5@gimbo.org.uk> <20100111164645.GB11640@brighton.ac.uk> <923DF44D-DD21-4C82-9A74-6C0417E6DA43@gimbo.org.uk> Message-ID: <20100224151224.GM12264@brighton.ac.uk> On Wed, Feb 24, 2010 at 12:54:51 +0000, Andy Gimblett wrote: > That raises the question: what is the right place? It seems to me > that the defaults are not the right defaults for this case. --global > should probably go to /Applications, and --user should perhaps go to ~/ > Applications (though I'm less sure about that). Of course, end-users > can explicitly set this on a per-install basis, but it seems that for > bundles we'd want to override the default. Just to give some background to this: I won't claim this is the right place, but the GenI setup script (distant/fond ancestor of cabal-macosx) copies the app bundle to wherever Cabal normally wants to put binaries, and then dumps out a shell script for people who still want a command line interface to their GUI app. So you get ~/.cabal/bin/geni.app # application bundle ~/.cabal/bin/geni # shell script that calls geni.app/Contents/MacOS/geni Again, not sure if that's the right thing to do, but it works for setups where you still expect cabal install GenI to work the same way as, say cabal install darcs, would. -- Eric Kow PGP Key ID: 08AC04F9 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: Digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100224/0b06396d/attachment.bin From haskell at benmachine.co.uk Wed Feb 24 10:27:16 2010 From: haskell at benmachine.co.uk (Ben Millwood) Date: Wed Feb 24 09:57:43 2010 Subject: [Haskell-cafe] Lazy IO with recursive reads? In-Reply-To: <78fc98011002240553l37fb4dc0h837ae29186e21c37@mail.gmail.com> References: <78fc98011002240553l37fb4dc0h837ae29186e21c37@mail.gmail.com> Message-ID: On Wed, Feb 24, 2010 at 1:53 PM, Fabian Roth wrote: > Hi all, > I am trying to read structured data from a socket and return a lazy list of > records. However, the socket reading operation seems to be strict and never > returns (until stack overflow). > This is expected behaviour. Normal sequencing of IO actions is done in such a way as to preserve their order, which is obviously pretty important if you want to ask for a response to your message after you've sent it, rather than before. Lazy IO operations violate that order and as a result are pretty scary and usually to be avoided. In general, laziness only works well with pure functions where the order doesn't matter because there are no observable side-effects. There are ways of making IO lazy, but there are pretty much invariably other ways of doing the same thing which result in fewer headaches later on. I am hoping that other people more educated than I am will be able to tell you about Iteratees and so forth. From maciej.podgurski at googlemail.com Wed Feb 24 10:30:16 2010 From: maciej.podgurski at googlemail.com (Maciej Podgurski) Date: Wed Feb 24 10:00:45 2010 Subject: [Haskell-cafe] Problems linking hsql-mysql In-Reply-To: <4B846DAD.9040506@t-online.de> References: <4B8423C7.5040302@googlemail.com> <4B846DAD.9040506@t-online.de> Message-ID: <4B854608.9010507@googlemail.com> Hi, no, it's absolutely not urgent. I'm just in early stage with building a Happstack webpage and testing via GHCi works fine. The problem occurs on a Windows XP machine with hsql-1.7.1, hsql-mysql-1.7.1, GHC-6.10.4 and MySQL Server 5.1. Last year I posted an instruction on how I got hsql-mysql running (see http://www.mail-archive.com/haskell-cafe@haskell.org/msg61265.html), the changes for the new GHC version where exactly the same. To replicate the error, just do an import Database.HSQL.MySQL and build the file via ghc --make. As far as I remember this worked with GHC-6.8.3, but I'm not quite sure. Let me know if you need additional informationen. Thanks for help, Maciej Am 24.02.2010 01:07 schrieb Nick Rudnick: > Hi Maciej, > > I will try to reproduce the error -- could you send me your both > *.cabal files (for hsql & hsql-mysql), if you have changed anything, > and your system configuration. > > Is this extremely urgent? I ask this, as these days exactly the end > phase of the projects of about 100 beginner Haskell students, which I > am the one to look after. So I am in a little of slow motion regarding > other things... ;-) > > But in case you are in emergency, please let me know... At first > sight, I would say it looks like a configuration problem... ;-) > > Cheers, > > Nick > > Maciej Podgurski wrote: >> Hi, >> >> I have problems linking a simple test program that imports >> Database.HSQL.MySQL via ghc --make Test.hs. The error only occurs >> when importing this module of hsql-mysql-1.7.1. I pasted the building >> output here: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=22911 >> (actually it was even longer but hpaste only takes 30k). >> >> When I do ghc -e main Test.hs or starting it from GHCi, everything >> works fine and no errors occur. So I guess all needed .lib files are >> there but GHC can't find them when linking (adding the flag -L"path >> to mysql/lib/opt" doesn't help). Anyone an idea? >> >> >> Best wishes, >> >> Maciej >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> From stephen.tetley at gmail.com Wed Feb 24 10:38:17 2010 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Wed Feb 24 10:08:43 2010 Subject: [Haskell-cafe] Lazy IO with recursive reads? In-Reply-To: <78fc98011002240553l37fb4dc0h837ae29186e21c37@mail.gmail.com> References: <78fc98011002240553l37fb4dc0h837ae29186e21c37@mail.gmail.com> Message-ID: <5fdc56d71002240738n18e358b1y8c38d622ad436329@mail.gmail.com> Hi Fabian You need to yield with unsafeInterleaveIO to allow some of the list to be be consumed. Something like this (which never terminates of course, but do produce output): import System.IO.Unsafe import Control.Monad main = do messages <- readLazy mapM_ (\x -> putStr $ show x ++ "\n") $ messages return () where readLazy :: IO [String] readLazy = unsafeInterleaveIO $ do { c <- fancyIORead ; liftM2 (++) (return c) readLazy } fancyIORead :: IO [String] fancyIORead = return ["aa","bb"] From daniel.is.fischer at web.de Wed Feb 24 10:59:25 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Feb 24 10:31:50 2010 Subject: [Haskell-cafe] Re: Function to detect duplicates In-Reply-To: <20100224142520.42df50f4@tritium.streitmacht.eu> References: <351ff25e1002230330n7913ba28h40b641096a777acc@mail.gmail.com> <3690ee141002230554h4434ec1aye130e9b3bb73e88f@mail.gmail.com> <20100224142520.42df50f4@tritium.streitmacht.eu> Message-ID: <201002241659.26719.daniel.is.fischer@web.de> Am Mittwoch 24 Februar 2010 14:25:20 schrieb Ertugrul Soeylemez: > Jonas Almstr?m Dureg?rd wrote: > > >>noneRepeated xs = xs == nub xs > > > > > > Not quite as bad, nub is O(n^2) > > > > You are correct of course. Still, it will probably be a bit less > > inefficient if the length of the lists are compared (as opposed to the > > elements): > > > > noneRepeated xs = length xs == length (nub xs) > > > > [...] > > > > > How can you nub in O(n*log n)? Remember, you only have Eq for nub. > > Again note that the big advantage of my method is laziness. The > comparison will end on the first duplicate found. Yes, and the suggestions Jonas and I posted had the same property :) > Using the following nub implementation the overall time complexity should > be O(n * log n), but may be space-intensive, because it uses O(n) space. Data.List.nub also uses O(n) space (but has a smaller constant factor). > Also note that it has a different context (the type needs to be Ord > instead of Eq): Yeah, that's the catch, it has a more restricted type. If you have only Eq, I don't think you can do better than O(n^2). That's why I was irritated by > > I think the nub-based solution is the best one in general, but it's > > the base library implementation of nub, which is unfortunate. ?In > > fact, with a better nub implementation, this becomes an O(n * log n) > > time , for the type of nub, the library implementation is rather good (perhaps it can still be improved, but not much, I think). > > import qualified Data.Set as S > import Data.List > > myNub :: Ord a => [a] -> [a] > myNub = concat . snd . mapAccumL nubMap S.empty > where nubMap s x > > | S.member x s = (s, []) > | otherwise = (S.insert x s, [x]) I prefer {-# LANGUAGE BangPatterns #-} {-# OPTIONS_GHC -O2 #-} module OrdNub (ordNub, ordNubRare) where import qualified Data.Set as Set ordNub :: Ord a => [a] -> [a] ordNub = go Set.empty where go !st (x:xs) | x `Set.member` st = go st xs | otherwise = x : go (Set.insert x st) xs go _ [] = [] , it's faster. If you know that duplicates are rare, ordNubRare :: Ord a => [a] -> [a] ordNubRare = go 0 Set.empty where go sz st (x:xs) | sz1 == sz = go sz st xs | otherwise = x : go sz1 st1 xs where st1 = Set.insert x st !sz1 = Set.size st1 go _ _ [] = [] is even faster because it omits the lookups (but it sucks when there are many duplicates, of course). > > Greets > Ertugrul Cheers, Daniel From donn at avvanta.com Wed Feb 24 11:08:02 2010 From: donn at avvanta.com (Donn Cave) Date: Wed Feb 24 10:38:28 2010 Subject: [Haskell-cafe] [offtopic] UNIX Shell (was: GHC RTS question) References: <88bdc6651002210745p6629e363se0a5c70e039dd2e6@mail.gmail.com> <201002211713.26123.daniel.is.fischer@web.de> <88bdc6651002210920o7bae3b56u13eadf18600b1f7c@mail.gmail.com> <201002211925.31945.daniel.is.fischer@web.de> <88bdc6651002211058n6af64adewb04ef8918f06cb7f@mail.gmail.com> <81addec71002211115v657ad55bk35e3d6b430d6e2af@mail.gmail.com> <20100222083656.GA14436@flit> <20100224071857.GA22654@flit> <20100224101911.GB30011@flit> Message-ID: <20100224160802.DA03A276C43@mail.avvanta.com> Quoth Roman Cheplyaka , ... > Well, this agrees with POSIX. So still I don't see the difference > between "$@" and ${1+"$@"}. Whatever the standards etc. may say, I believe "$@" is reliably the same as ${1+"$@"}, for old Bourne shells and new. Donn From spam at scientician.net Wed Feb 24 12:25:34 2010 From: spam at scientician.net (Bardur Arantsson) Date: Wed Feb 24 11:56:49 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: <4DC8E5B2-134D-4016-9A6F-081EC8450037@ece.cmu.edu> References: <1266394750-sup-7721@oz.taruti.net> <1266508065-sup-8211@oz.taruti.net> <20100221175030.7D7F493C40@mail.avvanta.com> <77FAF8ED-CE5C-44F6-9219-B60688CB39A4@n-heptane.com> <20100222003924.6E28893C2E@mail.avvanta.com> <4DC8E5B2-134D-4016-9A6F-081EC8450037@ece.cmu.edu> Message-ID: On 2010-02-24 05:10, Brandon S. Allbery KF8NH wrote: > On Feb 21, 2010, at 20:17 , Jeremy Shaw wrote: >> The PS3 does do something though. If we were doing a write *and* read >> select on the socket, the read select would wakeup. So, it is trying >> to notify us that something has happened, but we are not seeing it >> because we are only looking at the write select(). > > Earlier the OP claimed this would happen within a few minutes if he > seeked in a movie. If it's that reproducible, it should be easy to > capture a tcpdump and attach it to an email (or pastebin it), allowing > us to determine what really happens. It's a huge amount of data since it's streaming ~900Kb/s (or thereabouts). I don't think it's really practical to look through all that to try to figure out exactly when the problem occurs. Anyone know of any programs which can highlight 'anomalous' tcp traffic in tcpdumps? Still, I'd be happy to try a capture and upload it somewhere if anyone cares too have a look at it. It'll have to wait for the weekend, though. Cheers, From allbery at ece.cmu.edu Wed Feb 24 12:43:32 2010 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Wed Feb 24 12:14:08 2010 Subject: [Haskell-cafe] Re: [offtopic] UNIX Shell (was: GHC RTS question) In-Reply-To: <20100224071857.GA22654@flit> References: <88bdc6651002210745p6629e363se0a5c70e039dd2e6@mail.gmail.com> <201002211713.26123.daniel.is.fischer@web.de> <88bdc6651002210920o7bae3b56u13eadf18600b1f7c@mail.gmail.com> <201002211925.31945.daniel.is.fischer@web.de> <88bdc6651002211058n6af64adewb04ef8918f06cb7f@mail.gmail.com> <81addec71002211115v657ad55bk35e3d6b430d6e2af@mail.gmail.com> <20100222083656.GA14436@flit> <20100224071857.GA22654@flit> Message-ID: <41AC0ADD-80F9-4143-A8F7-44ED8EE223D3@ece.cmu.edu> On Feb 24, 2010, at 02:18 , Roman Cheplyaka wrote: >> #! /bin/sh >> ./prog --RTS ${1+"$@"} >> >> The longer specification above should work with whatever /bin/sh is >> around, whether it's Solaris /sbin/sh, FreeBSD's sh, general Linux >> bash, Debian/Ubuntu dash, etc. > > Are you referring to some Solaris shell bug? > > Under POSIX these constructs seem to be equivalent. > "If there are no positional parameters, the expansion of '@' shall > generate zero fields, even when '@' is double-quoted." s/Solaris/most commercial Unixes/ because making /bin/sh POSIX would break too many things (unlike Linux/*BSD, they have to consider backward compatibility; a concept that Linux in particular seems not to comprehend). -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100224/f6db931f/PGP.bin From allbery at ece.cmu.edu Wed Feb 24 12:47:01 2010 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Wed Feb 24 12:17:28 2010 Subject: [Haskell-cafe] [offtopic] UNIX Shell (was: GHC RTS question) In-Reply-To: <20100224101911.GB30011@flit> References: <88bdc6651002210745p6629e363se0a5c70e039dd2e6@mail.gmail.com> <201002211713.26123.daniel.is.fischer@web.de> <88bdc6651002210920o7bae3b56u13eadf18600b1f7c@mail.gmail.com> <201002211925.31945.daniel.is.fischer@web.de> <88bdc6651002211058n6af64adewb04ef8918f06cb7f@mail.gmail.com> <81addec71002211115v657ad55bk35e3d6b430d6e2af@mail.gmail.com> <20100222083656.GA14436@flit> <20100224071857.GA22654@flit> <20100224101911.GB30011@flit> Message-ID: <99658E75-BC0B-4079-A958-4129D13C10A8@ece.cmu.edu> On Feb 24, 2010, at 05:19 , Roman Cheplyaka wrote: > Well, this agrees with POSIX. So still I don't see the difference > between "$@" and ${1+"$@"}. The difference is that Unix /bin/sh predates POSIX, and on systems that usefully support a notion of backward compatibility (nostly commercial, because (1) they have installed user bases that predate POSIX and (2) they actually think it's worthwhile to support said user bases) /bin/sh uses the traditional behavior that "$@" expands to "" if there are no arguments. (This is "stupid" but consistent, another concept that seems to have been thrown to the wolves.) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100224/852dcecb/PGP.bin From apfelmus at quantentunnel.de Wed Feb 24 13:15:35 2010 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Wed Feb 24 12:46:25 2010 Subject: [Haskell-cafe] Re: Heterogeneous Data Structures - Nested Pairs and functional references In-Reply-To: <4B7AFC98.9080103@web.de> References: <4B7AFC98.9080103@web.de> Message-ID: G?nther Schmidt wrote: > I've been thinking a lot lately about heterogeneous and extensible data > structures for which HList certainly offers a solution. > > While HList is implemented through type-level programming I wonder if I > can achieve similar results through value-level programming alone. > > This is where I was thinking of functional references. > > I wonder if or rather how one could do this: > > Let's say there was some clever monad ... > > someMonad = do > h1 <- add "twenty" > h2 <- add False > h3 <- add 16 > ..... > modify h2 True > > and get a ("twenty",(True, 16)) back. And while *in* the monad some > accessors available. > > Now come to think of it I think I actually read about this somewhere so > I doubt this is truly my idea. > > Anybody got some thoughts on this? Dropping the part involving modification, I think you want to write something like this val "twenty" `pair` (val False `pair` left) where left is a "magic function" that returns the previous entry of the pair, so that the whole expression yields ("twenty", (False, False)) The difficult part is to keep track of the types. But fortunately, there is a neat trick by Oliver Danvy which does exactly that, see also Oliver Danvy. Functional unparsing. http://www.brics.dk/RS/98/12/BRICS-RS-98-12.pdf Namely, let's assume we are already given a "magic" type constructor |- (so magic that it's not even legal Haskell syntax) with the property that A |- B somehow denotes an expression of type B with free variables of type A . In other words, the result of type B is somehow allowed to depend on values of type A . Given this type, we can now assign types to our functions: pair :: (a |- b) -> ((a,b) |- c) -> (a |- (b,c)) left :: (a,b) |- b val :: x -> (a |- x) In other words, everything may depend on additional free variables of some type a . But of course, A |- B is just the same as A -> B , which readily suggest the implementation pair f g = \a -> let b = f a in (b, g (a,b)) left = \(a,b) -> b val x = \a -> x For instance, we get example :: a -> (String, (Bool, Bool)) example = val "twenty" `pair` (val True `pair` left) and example undefined = ("twenty",(True,True)) While the functionality is a bit limited, I'm confident that this approach can be extended considerably. Whether the result is useful is another question, of course. Regards, Heinrich Apfelmus -- http://apfelmus.nfshost.com From ekmett at gmail.com Wed Feb 24 13:28:56 2010 From: ekmett at gmail.com (Edward Kmett) Date: Wed Feb 24 12:59:21 2010 Subject: [Haskell-cafe] Re: Some great results on fused code with the LLVM backend In-Reply-To: <7dceb1a7-f413-4ee7-94e2-a19ec9200229@q21g2000yqm.googlegroups.com> References: <20100222015725.GA1870@whirlpool.galois.com> <7dceb1a7-f413-4ee7-94e2-a19ec9200229@q21g2000yqm.googlegroups.com> Message-ID: <7fb8f82f1002241028m27ad0e3dh82d29b45a69e589e@mail.gmail.com> On Wed, Feb 24, 2010 at 10:11 AM, Johann H?chtl wrote: > > Will this eg mean > > * interoperability between LLVM assemblies for free > * plugable garbage collectors > Keep in mind the LLVM GHC backend still uses the separate Haskell stack and uses a custom calling convention, so LLVM's garbage collection support isn't used at all, it is still a rather strange duck as far as the rest of the LLVM ecosystem is concerned. > * GHC/LLVM bytecode with JIT-option? > There is little preventing this one. -Edward Kmett -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100224/6868d551/attachment.html From alistair at abayley.org Wed Feb 24 13:40:12 2010 From: alistair at abayley.org (Alistair Bayley) Date: Wed Feb 24 13:10:37 2010 Subject: [Haskell-cafe] gtk2hs and ghc-6.10.4 on Windows (Vista) Message-ID: <79d7c4981002241040j141334dcwf49d179461f8d1c8@mail.gmail.com> On 16 February 2010 17:57, Neil Mitchell wrote: > Hi Serguey, > > A GHC 6.10.4 version of Gtk2hs: > > http://www.mail-archive.com/gtk2hs-devel@lists.sourceforge.net/msg00340.html > > I used to recommend Gtk2hs over wxHaskell for GUI development as there > was always a version that worked on Windows with the latest GHC > release. I think I might have to switch back to recommending C# for > GUI development... Is there a trick to getting this installed? I have run the installer in a Vista machine, both as user and admin, and the installation is mostly successful, except that the packages are not registered with ghc-6.10.4. Also, the first step of the install complains that "GHC does not appear to be installed correctly, try reinstalling GHC version 6.10.4. Setup found what appears to be a non-working installation of GHC in ..." What test does it apply to determine if GHC is working or not? It can run the gtk-demo, so it's not all bad, but I can't build anything that uses it (like Yi). Alistair From allbery at ece.cmu.edu Wed Feb 24 13:46:57 2010 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Wed Feb 24 13:17:35 2010 Subject: [Haskell-cafe] Lazy IO with recursive reads? In-Reply-To: <78fc98011002240553l37fb4dc0h837ae29186e21c37@mail.gmail.com> References: <78fc98011002240553l37fb4dc0h837ae29186e21c37@mail.gmail.com> Message-ID: <9B515E15-6A09-4729-9599-E02245A7AE2E@ece.cmu.edu> Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100224/a127dbab/PGP.bin From ezyang at MIT.EDU Wed Feb 24 14:32:59 2010 From: ezyang at MIT.EDU (Edward Z. Yang) Date: Wed Feb 24 14:03:30 2010 Subject: [Haskell-cafe] Optimizing hash array mapped tries In-Reply-To: <1266821677-sup-1773@ezyang> References: <1266821677-sup-1773@ezyang> Message-ID: <1267039139-sup-660@ezyang> Hey guys, an update! It turns out, Clojure is using mutation under the hood during its initial data structure generation to make populating the hash-map blazingly fast. When I force it to use the purely functional interface, the performance is much closer to Haskell's. Haskell Clojure 128K 0.56s 0.33s 256K 1.20s 0.84s 512K 2.62s 2.80s There's a large amount of variance in the Java samples, as HotSpot kicks in; they appear to start off with identical performance and then the Clojure implementation steadily performs better as the JVM optimizes away. I'd be really curious about techniques that permit mutation during the construction of functional datastructures; this seems like a cool way to get fast performance w/o giving up any of the benefits of immutability. Unfortunately, my (admittedly short) experiments in this domain ran up against the difficulty that vector didn't let me unsafely freeze its mutable version. :-) Cheers, Edward From allbery at ece.cmu.edu Wed Feb 24 14:50:02 2010 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Wed Feb 24 14:20:40 2010 Subject: [Haskell-cafe] Re: sendfile leaking descriptors on Linux? In-Reply-To: References: <1266394750-sup-7721@oz.taruti.net> <1266508065-sup-8211@oz.taruti.net> <20100221175030.7D7F493C40@mail.avvanta.com> <77FAF8ED-CE5C-44F6-9219-B60688CB39A4@n-heptane.com> <20100222003924.6E28893C2E@mail.avvanta.com> <4DC8E5B2-134D-4016-9A6F-081EC8450037@ece.cmu.edu> Message-ID: <90F48773-BA8B-49C2-8FAB-9F281219762C@ece.cmu.edu> On Feb 24, 2010, at 12:25 , Bardur Arantsson wrote: > It's a huge amount of data since it's streaming ~900Kb/s (or > thereabouts). I don't think it's really practical to look through > all that to try to figure out exactly when the problem occurs. Given what we're looking for, I think you can ignore normal packets: tcpdump 'host ps3 and tcp[tcpflags] & 0x27 != 0' (substitute the hostname of your PS3; you may need to escape the ! depending on your shell) This (flags = SYN, FIN, RST; URG thrown in for the heck of it) should omit all data packets from the capture. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100224/601b3b1e/PGP.bin From bulat.ziganshin at gmail.com Wed Feb 24 14:48:53 2010 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Feb 24 14:27:01 2010 Subject: [Haskell-cafe] Optimizing hash array mapped tries In-Reply-To: <1267039139-sup-660@ezyang> References: <1266821677-sup-1773@ezyang> <1267039139-sup-660@ezyang> Message-ID: <1288354344.20100224224853@gmail.com> Hello Edward, Wednesday, February 24, 2010, 10:32:59 PM, you wrote: > I'd be really curious about techniques that permit mutation during > the construction of functional datastructures; this seems like a cool > way to get fast performance w/o giving up any of the benefits of > immutability. Unfortunately, my (admittedly short) experiments in > this domain ran up against the difficulty that vector didn't let me > unsafely freeze its mutable version. :-) actually, this technique is already used in haskell. look into array library sources, search for freeze -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From icfp.publicity at googlemail.com Wed Feb 24 15:11:18 2010 From: icfp.publicity at googlemail.com (Wouter Swierstra) Date: Wed Feb 24 14:41:46 2010 Subject: [Haskell-cafe] ICFP 2010: Second call for papers Message-ID: <53ff55481002241211s1c058277r14f6c3635010e6fb@mail.gmail.com> ===================================================================== Second Call for Papers ICFP 2010: International Conference on Functional Programming Baltimore, Maryland, 27 -- 29 September 2010 http://www.icfpconference.org/icfp2010 ===================================================================== Important Dates (at 14:00 UTC) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Submission: 2 April 2010 Author response: 24 -- 25 May 2010 Notification: 7 June 2010 Final papers due: 12 July 2010 Scope ~~~~~ ICFP 2010 seeks original papers on the art and science of functional programming. Submissions are invited on all topics from principles to practice, from foundations to features, from abstraction to application. The scope includes all languages that encourage functional programming, including both purely applicative and imperative languages, as well as languages with objects or concurrency. Particular topics of interest include * Language Design: type systems; concurrency and distribution; modules; components and composition; metaprogramming; relations to object-oriented or logic programming; interoperability * Implementation: abstract machines; compilation; compile-time and run-time optimization; memory management; multi-threading; exploiting parallel hardware; interfaces to foreign functions, services, components or low-level machine resources * Software-Development Techniques: algorithms and data structures; design patterns; specification; verification; validation; proof assistants; debugging; testing; tracing; profiling * Foundations: formal semantics; lambda calculus; rewriting; type theory; monads; continuations; control; state; effects * Transformation and Analysis: abstract interpretation; partial evaluation; program transformation; program calculation; program proof * Applications and Domain-Specific Languages: symbolic computing; formal-methods tools; artificial intelligence; systems programming; distributed-systems and web programming; hardware design; databases; XML processing; scientific and numerical computing; graphical user interfaces; multimedia programming; scripting; system administration; security; education * Functional Pearls: elegant, instructive, and fun essays on functional programming The conference also solicits Experience Reports, which are short papers that provide evidence that functional programming really works or describe obstacles that have kept it from working in a particular application. Abbreviated instructions for authors ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ By 2 April 2010, 14:00 UTC, submit an abstract of at most 300 words and a full paper of at most 12 pages (6 pages for an Experience Report), including bibliography and figures. The deadline will be strictly enforced and papers exceeding the page limits will be summarily rejected. Authors have the option to attach supplementary material to a submission, on the understanding that reviewers may choose not to look at it. A submission will be evaluated according to its relevance, correctness, significance, originality, and clarity. It should explain its contributions in both general and technical terms, clearly identifying what has been accomplished, explaining why it is significant, and comparing it with previous work. The technical content should be accessible to a broad audience. Functional Pearls and Experience Reports are separate categories of papers that need not report original research results and must be marked as such at the time of submission. Detailed guidelines on both categories are on the conference web site. Each submission must adhere to SIGPLAN's republication policy, as explained on the web at http://www.acm.org/sigplan/republicationpolicy.htm. Proceedings will be published by ACM Press. Authors of accepted submissions are expected to transfer the copyright to the ACM. Presentations will be videotaped and released online if the presenter consents by signing an additional permission form at the time of the presentation. Formatting: Submissions must be in PDF format printable in black and white on US Letter sized paper and interpretable by Ghostscript. If this requirement is a hardship, make contact with the program chair at least one week before the deadline. Papers must adhere to the standard ACM conference format: two columns, nine-point font on a ten-point baseline, with columns 20pc (3.33in) wide and 54pc (9in) tall, with a column gutter of 2pc (0.33in). A suitable document template for LATEX is available from SIGPLAN at http://www.acm.org/sigs/sigplan/authorInformation.htm. Submission: Submissions will be accepted electronically at a URL to be named later. Improved versions of a paper may be submitted at any point before the submission deadline using the same web interface. Author response: Authors will have a 48-hour period, starting at 14:00 UTC on 24 May 2010, to read and respond to reviews. Special Journal Issue: There will be a special issue of the Journal of Functional Programming with papers from ICFP 2010. The program committee will invite the authors of select accepted papers to submit a journal version to this issue. Organization ~~~~~~~~~~~~ Conference Chair Paul Hudak, Yale University Program Chair Stephanie Weirich, University of Pennsylvania Program Committee: Umut Acar, Max Planck Institute for Software Systems Zena Ariola, University of Oregon James Cheney, University of Edinburgh Peter Dybjer, Chalmers University of Technology Robert Bruce Findler, Northwestern University Andy Gill, Kansas University Fritz Henglein, University of Copenhagen Michael Hicks, University of Maryland, College Park Patricia Johann, University of Strathclyde Andres L?h, Utrecht University Simon L. Peyton Jones, Microsoft Research Didier R?my, INRIA Paris-Rocquencourt John Reppy, University of Chicago Manuel Serrano, INRIA Sophia-Antipolis Matthieu Sozeau, Harvard University From gwern0 at gmail.com Wed Feb 24 15:25:04 2010 From: gwern0 at gmail.com (Gwern Branwen) Date: Wed Feb 24 14:55:31 2010 Subject: [Haskell-cafe] Function to detect duplicates In-Reply-To: <3690ee141002230357x2a156858g36f13fc847053830@mail.gmail.com> References: <351ff25e1002230330n7913ba28h40b641096a777acc@mail.gmail.com> <3690ee141002230357x2a156858g36f13fc847053830@mail.gmail.com> Message-ID: 2010/2/23 Jonas Almstr?m Dureg?rd : > Hi Rafael, > > I assume you will perform this operation on some very large lists, or > performance would not be an issue. Have you tested if your optimized > version is better than your initial one? > > You should compare your implementation against something like this: > > import qualified Data.Set as Set > noneRepeated :: (Ord a) => [a] -> Bool > noneRepeated = accum Set.empty where > ?accum _ [] = True > ?accum s (x:xs) > ? ?| Set.member x s = False > ? ?| otherwise ? ? ?= accum (Set.insert x s) xs > > Also there is some discussion about the nub function that relates to > this topic, e.g. http://buffered.io/2008/07/28/a-better-nub/. > > /Jonas Or better yet, http://www.haskell.org/pipermail/libraries/2008-October/010778.html Much more thorough and practical w/r/t to actually getting faster nubs in the libraries. -- gwern From Christian.Maeder at dfki.de Wed Feb 24 15:36:38 2010 From: Christian.Maeder at dfki.de (Christian Maeder) Date: Wed Feb 24 15:07:04 2010 Subject: [Haskell-cafe] Re: Proper round-trip HughesPJ/Parsec for Doubles? In-Reply-To: References: <1CA520E4-F8FA-4237-916C-98CEB93AC4F9@gimbo.org.uk> <4B83F092.20606@dfki.de> <91CFF9A8-8549-45D1-83D8-A9CE167BE536@gimbo.org.uk> <4B852877.9000006@dfki.de> Message-ID: <4B858DD6.2000504@dfki.de> Ben Millwood schrieb: > On Wed, Feb 24, 2010 at 1:24 PM, Christian Maeder > wrote: >> 1. break the line after "do" >> (to avoid a layout change when change name or arguments of float' or >> rename the variable "e") > > You can also break it immediately before do, which I think is > sometimes more clear. If not an extra space is added following "do" this leads to an "odd" indentation of at least one line. C. From andrewcoppin at btinternet.com Wed Feb 24 15:47:56 2010 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Wed Feb 24 15:18:17 2010 Subject: [Haskell-cafe] OpenSUSE 11.2 Message-ID: <4B85907C.1080108@btinternet.com> OK, I imagined to install OpenSUSE 11.2. However, I can't find a way to make it install either GHC or the Haskell Platform. A quick Google search turns up a folder on download.opensuse.org which is stuffed full of Haskell stuff, yet no ammount of prodding YaST will convince it that it's possible to install anything remotely Haskell-related. (Now I remember why I don't use Linux much...) Does anybody know how to install this stuff on OpenSUSE? Alternatively, does anybody know of an alternative Linux distribution where this kind of thing is likely to work better? (I think I've got a Debian ISO somewhere - but IME everything on Debian is always 8 years old.) From ehamberg at gmail.com Wed Feb 24 15:57:56 2010 From: ehamberg at gmail.com (Erlend Hamberg) Date: Wed Feb 24 15:27:41 2010 Subject: [Haskell-cafe] OpenSUSE 11.2 In-Reply-To: <4B85907C.1080108@btinternet.com> References: <4B85907C.1080108@btinternet.com> Message-ID: <201002242158.02834.ehamberg@gmail.com> On Wednesday 24. February 2010 21.47.56 Andrew Coppin wrote: > no ammount of prodding YaST will convince it that > it's possible to install anything remotely Haskell-related if you open the software manager and go to configuration ? repositories, you should be able to add new software sources. i use the following repository: Server name: download.opensuse.org Directory: /repositories/devel:/languages:/haskell/openSUSE_11.2/ This repository contains GHC 6.12, alex, happy, etc. -- Erlend Hamberg ?Everything will be ok in the end. If its not ok, its not the end.? GPG/PGP: 0xAD3BCF19 45C3 E2E7 86CA ADB7 8DAD 51E7 3A1A F085 AD3B CF19 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part. Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100224/3ebbd2d5/attachment.bin From ezyang at MIT.EDU Wed Feb 24 16:01:25 2010 From: ezyang at MIT.EDU (Edward Z. Yang) Date: Wed Feb 24 15:31:50 2010 Subject: [Haskell-cafe] Optimizing hash array mapped tries In-Reply-To: <1288354344.20100224224853@gmail.com> References: <1266821677-sup-1773@ezyang> <1267039139-sup-660@ezyang> <1288354344.20100224224853@gmail.com> Message-ID: <1267045131-sup-1331@ezyang> Excerpts from Bulat Ziganshin's message of Wed Feb 24 14:48:53 -0500 2010: > > I'd be really curious about techniques that permit mutation during > > the construction of functional datastructures; this seems like a cool > > way to get fast performance w/o giving up any of the benefits of > > immutability. Unfortunately, my (admittedly short) experiments in > > this domain ran up against the difficulty that vector didn't let me > > unsafely freeze its mutable version. :-) > > actually, this technique is already used in haskell. look into array > library sources, search for freeze Yup, I'm aware of this. In fact, vector has thaw/freeze functions for itself, although it doesn't export them. I'd rather not have to reimplement vector just to get this unsafe mutation capability tough (and since the mutable array GC problem is not fixed for the version of GHC I'm on, I'd likely see no benefit either). What I thought was pretty neat about the Clojure approach was how easy they made it for you to jump into mutation-land and back out again: just a (transient) call and you're off to the races. As far as I can tell, you have to painstakingly write the specific operation you'd like to do via mutation out using all sorts of unsafe calls. Cheers, Edward From dons at galois.com Wed Feb 24 16:13:18 2010 From: dons at galois.com (Don Stewart) Date: Wed Feb 24 15:43:45 2010 Subject: [Haskell-cafe] Optimizing hash array mapped tries In-Reply-To: <1267039139-sup-660@ezyang> References: <1266821677-sup-1773@ezyang> <1267039139-sup-660@ezyang> Message-ID: <20100224211318.GG19176@whirlpool.galois.com> ezyang: > Hey guys, an update! > > It turns out, Clojure is using mutation under the hood during its > initial data structure generation to make populating the hash-map > blazingly fast. When I force it to use the purely functional > interface, the performance is much closer to Haskell's. > > Haskell Clojure > 128K 0.56s 0.33s > 256K 1.20s 0.84s > 512K 2.62s 2.80s > > There's a large amount of variance in the Java samples, as HotSpot > kicks in; they appear to start off with identical performance and > then the Clojure implementation steadily performs better as the JVM > optimizes away. > > I'd be really curious about techniques that permit mutation during > the construction of functional datastructures; this seems like a cool > way to get fast performance w/o giving up any of the benefits of > immutability. Unfortunately, my (admittedly short) experiments in > this domain ran up against the difficulty that vector didn't let me > unsafely freeze its mutable version. :-) Almost all the vector library generators fill a vector destructively, before doing an unsafeFreeze. Here's an example of filling a buffer with randoms, random g n = do v <- GM.new n fill v 0 G.unsafeFreeze v where fill v i | i < n = do x <- R.random g GM.unsafeWrite v i x fill v (i+1) | otherwise = return () From dons at galois.com Wed Feb 24 16:13:38 2010 From: dons at galois.com (Don Stewart) Date: Wed Feb 24 15:44:06 2010 Subject: [Haskell-cafe] Optimizing hash array mapped tries In-Reply-To: <1267045131-sup-1331@ezyang> References: <1266821677-sup-1773@ezyang> <1267039139-sup-660@ezyang> <1288354344.20100224224853@gmail.com> <1267045131-sup-1331@ezyang> Message-ID: <20100224211338.GH19176@whirlpool.galois.com> ezyang: > Excerpts from Bulat Ziganshin's message of Wed Feb 24 14:48:53 -0500 2010: > > > I'd be really curious about techniques that permit mutation during > > > the construction of functional datastructures; this seems like a cool > > > way to get fast performance w/o giving up any of the benefits of > > > immutability. Unfortunately, my (admittedly short) experiments in > > > this domain ran up against the difficulty that vector didn't let me > > > unsafely freeze its mutable version. :-) > > > > actually, this technique is already used in haskell. look into array > > library sources, search for freeze > > Yup, I'm aware of this. In fact, vector has thaw/freeze functions for > itself, although it doesn't export them. I'd rather not have to reimplement > vector just to get this unsafe mutation capability tough (and since the > mutable array GC problem is not fixed for the version of GHC I'm on, I'd likely > see no benefit either). These are exported from vector, though. From daniel.is.fischer at web.de Wed Feb 24 16:13:00 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Feb 24 15:45:21 2010 Subject: [Haskell-cafe] Function to detect duplicates In-Reply-To: References: <351ff25e1002230330n7913ba28h40b641096a777acc@mail.gmail.com> <3690ee141002230357x2a156858g36f13fc847053830@mail.gmail.com> Message-ID: <201002242213.00601.daniel.is.fischer@web.de> Am Mittwoch 24 Februar 2010 21:25:04 schrieb Gwern Branwen: > 2010/2/23 Jonas Almstr?m Dureg?rd : > > Hi Rafael, > > > > I assume you will perform this operation on some very large lists, or > > performance would not be an issue. Have you tested if your optimized > > version is better than your initial one? > > > > You should compare your implementation against something like this: > > > > import qualified Data.Set as Set > > noneRepeated :: (Ord a) => [a] -> Bool > > noneRepeated = accum Set.empty where > > ?accum _ [] = True > > ?accum s (x:xs) > > ? ?| Set.member x s = False > > ? ?| otherwise ? ? ?= accum (Set.insert x s) xs > > > > Also there is some discussion about the nub function that relates to > > this topic, e.g. http://buffered.io/2008/07/28/a-better-nub/. > > > > /Jonas > > Or better yet, > http://www.haskell.org/pipermail/libraries/2008-October/010778.html Much > more thorough and practical w/r/t to actually getting faster nubs in the > libraries. Umm, using the nubOrd' code to nub a 1 million long list of pseudo random numbers takes (here) about 2.5 times the time and twice space as the Set- based ordNub. It does slightly better for 100,000 elements, but still takes more than twice the time (and 1.6 x the space). In my book, that's a compelling reason to go with the set-based implementation - unless we're talking about code to include directly in Data.List, but then I'd still _use_ the set-based one. From fabian.roth at gmail.com Wed Feb 24 16:17:13 2010 From: fabian.roth at gmail.com (Fabian Roth) Date: Wed Feb 24 15:47:39 2010 Subject: [Haskell-cafe] Lazy IO with recursive reads? In-Reply-To: <5fdc56d71002240738n18e358b1y8c38d622ad436329@mail.gmail.com> References: <78fc98011002240553l37fb4dc0h837ae29186e21c37@mail.gmail.com> <5fdc56d71002240738n18e358b1y8c38d622ad436329@mail.gmail.com> Message-ID: <78fc98011002241317v1ae75c74kd226b285e8eabdad@mail.gmail.com> Hi Stephen Thank you very much, this indeed does the trick! Using UnsafeIO, however, leaves a creepy unsafe feeling... I don't fully understand though why it is unsafe. Doesn't hGetContents do the exact same thing (i.e. reading from IO returning a lazy string) but does not require UnsafeIO. Fabian On Wed, Feb 24, 2010 at 4:38 PM, Stephen Tetley wrote: > Hi Fabian > > You need to yield with unsafeInterleaveIO to allow some of the list to > be be consumed. > > Something like this (which never terminates of course, but do produce > output): > > > import System.IO.Unsafe > import Control.Monad > > main = do messages <- readLazy > mapM_ (\x -> putStr $ show x ++ "\n") $ messages > return () > where > readLazy :: IO [String] > readLazy = unsafeInterleaveIO $ do > { c <- fancyIORead > ; liftM2 (++) (return c) readLazy > } > fancyIORead :: IO [String] > fancyIORead = return ["aa","bb"] > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100224/5d3fbd5a/attachment.html From ezyang at MIT.EDU Wed Feb 24 16:19:43 2010 From: ezyang at MIT.EDU (Edward Z. Yang) Date: Wed Feb 24 15:50:08 2010 Subject: [Haskell-cafe] Optimizing hash array mapped tries In-Reply-To: <20100224211338.GH19176@whirlpool.galois.com> References: <1266821677-sup-1773@ezyang> <1267039139-sup-660@ezyang> <1288354344.20100224224853@gmail.com> <1267045131-sup-1331@ezyang> <20100224211338.GH19176@whirlpool.galois.com> Message-ID: <1267046356-sup-3004@ezyang> Excerpts from Don Stewart's message of Wed Feb 24 16:13:38 -0500 2010: > These are exported from vector, though. Aha! I was looking in Data.Vector for them; they're actually in Data.Vector.Generic. Awesome. Cheers, Edward From stephen.tetley at gmail.com Wed Feb 24 16:41:14 2010 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Wed Feb 24 16:11:40 2010 Subject: [Haskell-cafe] Lazy IO with recursive reads? In-Reply-To: <78fc98011002241317v1ae75c74kd226b285e8eabdad@mail.gmail.com> References: <78fc98011002240553l37fb4dc0h837ae29186e21c37@mail.gmail.com> <5fdc56d71002240738n18e358b1y8c38d622ad436329@mail.gmail.com> <78fc98011002241317v1ae75c74kd226b285e8eabdad@mail.gmail.com> Message-ID: <5fdc56d71002241341p35f5d7a0web29832792e775ea@mail.gmail.com> Hi Fabian >From the source viewable in the Haddock docs supplied with GHC - hGetContents calls lazyRead: hGetContents :: Handle -> IO String hGetContents handle = wantReadableHandle "hGetContents" handle $ \handle_ -> do xs <- lazyRead handle return (handle_{ haType=SemiClosedHandle}, xs ) - lazyRead : lazyRead :: Handle -> IO String lazyRead handle = unsafeInterleaveIO $ <> hGetContents is using unsafeInterleaveIO already so you don't have to. Best wishes Stephen From v.dijk.bas at gmail.com Wed Feb 24 17:08:29 2010 From: v.dijk.bas at gmail.com (Bas van Dijk) Date: Wed Feb 24 16:39:13 2010 Subject: [Haskell-cafe] ANN: concurrent-extra-0.2 In-Reply-To: References: Message-ID: Hello, I discovered a bug in our: Control.Concurrent.Thread In the documentation of 'forkIO' we specify that the forked thread inherits the blocked state of its parent. However our implementation did not ensure this. The newly released concurrent-extra-0.3.1 fixes this. This release also adds the following function: -- |Like 'wait' but will rethrow the exception that was thrown in target thread. unsafeWait ? ThreadId ? ? IO ? unsafeWait tid = wait tid >>= either (\(SomeException e) ? throwIO e) return Documentation: http://hackage.haskell.org/package/concurrent-extra-0.3.1 To install this latest release do: cabal update cabal install concurrent-extra Or get the development sources using: darcs get http://code.haskell.org/concurrent-extra regards, Bas From andrewcoppin at btinternet.com Wed Feb 24 17:17:46 2010 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Wed Feb 24 16:48:03 2010 Subject: [Haskell-cafe] OpenSUSE 11.2 In-Reply-To: <201002242158.02834.ehamberg@gmail.com> References: <4B85907C.1080108@btinternet.com> <201002242158.02834.ehamberg@gmail.com> Message-ID: <4B85A58A.2050905@btinternet.com> Erlend Hamberg wrote: > if you open the software manager and go to configuration ? repositories, you > should be able to add new software sources. i use the following repository: > > Server name: download.opensuse.org > Directory: /repositories/devel:/languages:/haskell/openSUSE_11.2/ > > This repository contains GHC 6.12, alex, happy, etc. > OK, I'll try that tomorrow and see where I get... Thanks, Andrew. From caseyh at istar.ca Wed Feb 24 17:32:37 2010 From: caseyh at istar.ca (Casey Hawthorne) Date: Wed Feb 24 17:03:13 2010 Subject: [Haskell-cafe] Function to detect duplicates In-Reply-To: <351ff25e1002230330n7913ba28h40b641096a777acc@mail.gmail.com> References: <351ff25e1002230330n7913ba28h40b641096a777acc@mail.gmail.com> Message-ID: <33abo5tf1eskdoqot10ekr0fj2p2j8op7b@4ax.com> On Tue, 23 Feb 2010 08:30:18 -0300, you wrote: >Hi folks, > >While solving a puzzle, I was posed the problem of finding if there was no >duplicates on a list. Must it be a list data structure(DS) or list ADT? Mergesort can be parallelized. > >Best regards, > >Rafael -- Regards, Casey From daniel.is.fischer at web.de Wed Feb 24 17:34:33 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Feb 24 17:06:54 2010 Subject: [Haskell-cafe] OpenSUSE 11.2 In-Reply-To: <4B85A58A.2050905@btinternet.com> References: <4B85907C.1080108@btinternet.com> <201002242158.02834.ehamberg@gmail.com> <4B85A58A.2050905@btinternet.com> Message-ID: <201002242334.33952.daniel.is.fischer@web.de> Am Mittwoch 24 Februar 2010 23:17:46 schrieb Andrew Coppin: > Erlend Hamberg wrote: > > if you open the software manager and go to configuration ? > > repositories, you should be able to add new software sources. i use > > the following repository: > > > > Server name: download.opensuse.org > > Directory: /repositories/devel:/languages:/haskell/openSUSE_11.2/ > > > > This repository contains GHC 6.12, alex, happy, etc. > > OK, I'll try that tomorrow and see where I get... Or, go to http://software.opensuse.org/search/ , type ghc [alex, happy, ...] in the search box, click the search button and 1-click-install. > > Thanks, > Andrew. > From caseyh at istar.ca Wed Feb 24 17:43:00 2010 From: caseyh at istar.ca (Casey Hawthorne) Date: Wed Feb 24 17:13:41 2010 Subject: [Haskell-cafe] Function to detect duplicates In-Reply-To: <351ff25e1002230330n7913ba28h40b641096a777acc@mail.gmail.com> References: <351ff25e1002230330n7913ba28h40b641096a777acc@mail.gmail.com> Message-ID: On Tue, 23 Feb 2010 08:30:18 -0300, you wrote: >Hi folks, > >While solving a puzzle, I was posed the problem of finding if there was no >duplicates on a list. Must it be a list data structure(DS) or list ADT? Mergesort can be parallelized. > >Best regards, > >Rafael If space is at a premium you might want to look at a Bloom Filter. http://en.wikipedia.org/wiki/Bloom_filter The Bloom filter, conceived by Burton Howard Bloom in 1970,[1] is a space-efficient probabilistic data structure that is used to test whether an element is a member of a set. False positives are possible, but false negatives are not. Elements can be added to the set, but not removed (though this can be addressed with a counting filter). The more elements that are added to the set, the larger the probability of false positives. The book "Real World Haskell" has an implementation. -- Regards, Casey From allbery at ece.cmu.edu Wed Feb 24 17:52:58 2010 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Wed Feb 24 17:23:35 2010 Subject: [Haskell-cafe] Lazy IO with recursive reads? In-Reply-To: <78fc98011002241317v1ae75c74kd226b285e8eabdad@mail.gmail.com> References: <78fc98011002240553l37fb4dc0h837ae29186e21c37@mail.gmail.com> <5fdc56d71002240738n18e358b1y8c38d622ad436329@mail.gmail.com> <78fc98011002241317v1ae75c74kd226b285e8eabdad@mail.gmail.com> Message-ID: <589FE07F-27B3-490B-95B1-410D551A7B0A@ece.cmu.edu> Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100224/56bcca9f/PGP.bin From ivan.miljenovic at gmail.com Wed Feb 24 18:10:50 2010 From: ivan.miljenovic at gmail.com (Ivan Miljenovic) Date: Wed Feb 24 17:41:16 2010 Subject: [Haskell-cafe] Testing and module export lists In-Reply-To: References: Message-ID: On 24 February 2010 20:17, Magnus Therning wrote: > I often find that I do want an export list to reduce clutter in the > finished code, but for testing I'd like to expose everything in a > module. ?Is there a nice way to deal with this (using the C > pre-processor would not qualify as "nice" ;-)? > Maybe there's a switch that causes GHC to simply ignore the export > list of a module and export everything? If you start a function name with an underscore, it is "implicitly exported" by GHC (I can't find the actual documentation page at the moment however). Whilst it may not appear in the export list, you are still able to call it from outside the module. This will, however, result in "ugly" function names as well as possibly still have those items appear in the haddock documentation... -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com Joan Crawford - "I, Joan Crawford, I believe in the dollar. Everything I earn, I spend." - http://www.brainyquote.com/quotes/authors/j/joan_crawford.html From qdunkan at gmail.com Wed Feb 24 18:21:38 2010 From: qdunkan at gmail.com (Evan Laforge) Date: Wed Feb 24 17:52:03 2010 Subject: [Haskell-cafe] Testing and module export lists In-Reply-To: References: Message-ID: <2518b95d1002241521y7e3c981et252d42fdd24c6d5a@mail.gmail.com> On Wed, Feb 24, 2010 at 3:10 PM, Ivan Miljenovic wrote: > On 24 February 2010 20:17, Magnus Therning wrote: >> I often find that I do want an export list to reduce clutter in the >> finished code, but for testing I'd like to expose everything in a >> module. ?Is there a nice way to deal with this (using the C >> pre-processor would not qualify as "nice" ;-)? >> Maybe there's a switch that causes GHC to simply ignore the export >> list of a module and export everything? > > If you start a function name with an underscore, it is "implicitly > exported" by GHC (I can't find the actual documentation page at the > moment however). ?Whilst it may not appear in the export list, you are > still able to call it from outside the module. > > This will, however, result in "ugly" function names as well as > possibly still have those items appear in the haddock documentation... Wow, I'd never heard of that feature. I currently export everything because under development it's too much hassle to maintain export lists. However when modules stabilize I think export lists are a good idea because then GHC can warn about unused functions and and hopefully eliminate internal bindings if they are all inlined. However, testing individual functions is much easier to understand and leads to shorter and less brittle tests, with clearer failures. So when the time comes I'll probably use #ifdef. That way I can run presumably ghci with -DTESTING as well and bypass the other annoying thing about export lists, which is that you have to get ghci to byte compile to see the internal symbols. It's not that much work to add #ifdef to each export list especially compared to the work of writing it in the first place, but it would still be nicer if there were a compiler flag that did this explicitly. The underscore thing seems sub-optimal to me because it doesn't help you with unused functions or dead code elimination. From ivan.miljenovic at gmail.com Wed Feb 24 18:36:41 2010 From: ivan.miljenovic at gmail.com (Ivan Miljenovic) Date: Wed Feb 24 18:07:05 2010 Subject: [Haskell-cafe] Testing and module export lists In-Reply-To: <2518b95d1002241521y7e3c981et252d42fdd24c6d5a@mail.gmail.com> References: <2518b95d1002241521y7e3c981et252d42fdd24c6d5a@mail.gmail.com> Message-ID: On 25 February 2010 10:21, Evan Laforge wrote: > On Wed, Feb 24, 2010 at 3:10 PM, Ivan Miljenovic > wrote: >> If you start a function name with an underscore, it is "implicitly >> exported" by GHC (I can't find the actual documentation page at the >> moment however). ?Whilst it may not appear in the export list, you are >> still able to call it from outside the module. > > Wow, I'd never heard of that feature. Neither had I, until Curt Sampson asked me to support it in SourceGraph. Anyway, I've tracked down the documentation page: http://www.haskell.org/ghc/docs/latest/html/users_guide/options-sanity.html . It's not listed explicitly anywhere; different items have different documentation regarding it throughout the page. -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com Samuel Goldwyn - "I don't think anyone should write their autobiography until after they're dead." - http://www.brainyquote.com/quotes/authors/s/samuel_goldwyn.html From dons at galois.com Wed Feb 24 19:24:58 2010 From: dons at galois.com (Don Stewart) Date: Wed Feb 24 18:55:25 2010 Subject: [Haskell-cafe] Testing and module export lists In-Reply-To: References: Message-ID: <20100225002458.GU19176@whirlpool.galois.com> ivan.miljenovic: > On 24 February 2010 20:17, Magnus Therning wrote: > > I often find that I do want an export list to reduce clutter in the > > finished code, but for testing I'd like to expose everything in a > > module. ?Is there a nice way to deal with this (using the C > > pre-processor would not qualify as "nice" ;-)? > > Maybe there's a switch that causes GHC to simply ignore the export > > list of a module and export everything? > > If you start a function name with an underscore, it is "implicitly > exported" by GHC (I can't find the actual documentation page at the > moment however). Whilst it may not appear in the export list, you are > still able to call it from outside the module. Seriously?? Doesn't that break the module system? So this should work? Z.hs module Z () where _secret = "10" M.hs import Z main = print _secret $ runhaskell M.hs M.hs:3:14: Not in scope: `_secret' From felipe.lessa at gmail.com Wed Feb 24 20:22:23 2010 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Wed Feb 24 19:52:52 2010 Subject: [Haskell-cafe] Re: Some great results on fused code with the LLVM backend In-Reply-To: <7fb8f82f1002241028m27ad0e3dh82d29b45a69e589e@mail.gmail.com> References: <20100222015725.GA1870@whirlpool.galois.com> <7dceb1a7-f413-4ee7-94e2-a19ec9200229@q21g2000yqm.googlegroups.com> <7fb8f82f1002241028m27ad0e3dh82d29b45a69e589e@mail.gmail.com> Message-ID: <20100225012223.GC8261@kira.casa> On Wed, Feb 24, 2010 at 01:28:56PM -0500, Edward Kmett wrote: > > * GHC/LLVM bytecode with JIT-option? > > There is little preventing this one. Oh, what a great idea! C code being inlined into Haskell functions! :D If clang were used to compile the C code into LLVM IR, and everything were linked by LLVM, bang!, the link-time optimizer would take care of inlining cheap functions into Haskell code that uses them. Cheers, =) -- Felipe. From ivan.miljenovic at gmail.com Wed Feb 24 20:51:30 2010 From: ivan.miljenovic at gmail.com (Ivan Miljenovic) Date: Wed Feb 24 20:21:54 2010 Subject: [Haskell-cafe] Testing and module export lists In-Reply-To: <20100225002458.GU19176@whirlpool.galois.com> References: <20100225002458.GU19176@whirlpool.galois.com> Message-ID: On 25 February 2010 11:24, Don Stewart wrote: > Seriously?? Doesn't that break the module system? Maybe I misunderstood it; all I know is that Curt Sampson says he uses this kind of stuff for testing purposes by not having to export functions. See the -fwarn-unused-binds section at http://www.haskell.org/ghc/docs/latest/html/users_guide/options-sanity.html . -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com Charles de Gaulle - "The better I get to know men, the more I find myself loving dogs." - http://www.brainyquote.com/quotes/authors/c/charles_de_gaulle.html From ok at cs.otago.ac.nz Wed Feb 24 21:02:51 2010 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Wed Feb 24 20:33:20 2010 Subject: [Haskell-cafe] Re: Testing and module export lists In-Reply-To: <9979e72e1002240321w4a55848bt49d7cb2bf5723a42@mail.gmail.com> References: <9979e72e1002240321w4a55848bt49d7cb2bf5723a42@mail.gmail.com> Message-ID: <886F9404-8F8B-40D5-8FA1-CE352990F39D@cs.otago.ac.nz> For what it's worth, Erlang addresses this issue with an -export_all directive, which can be passed as a compiler option. From anotheraddress at gmx.de Wed Feb 24 21:58:04 2010 From: anotheraddress at gmx.de (Daniel =?iso-8859-1?q?Sch=FCssler?=) Date: Wed Feb 24 21:28:34 2010 Subject: [Haskell-cafe] Linear programming in Haskell In-Reply-To: <4B84FA4C.8040903@um.es> References: <20100218093323.2f1b0003.mle+hs@mega-nerd.com> <4B84FA4C.8040903@um.es> Message-ID: <201002250358.05031.anotheraddress@gmx.de> Hello Alberto, Thank you! I don't have a problem calling for LP at hand right now, but some time ago I was looking for such a package. Now I know where to look next time :) Greetings, Daniel On Wednesday 24 February 2010 11:07:08 Alberto Ruiz wrote: > I have uploaded to hackage an interface to the simplex algorithm based > on GLPK. It is a very early version, it will probably have lots of > problems. In the future I would like to add support for integer > variables (MIP). Any suggestion is welcome. From gladstein at gladstein.com Wed Feb 24 22:11:38 2010 From: gladstein at gladstein.com (gladstein@gladstein.com) Date: Wed Feb 24 21:42:04 2010 Subject: [Haskell-cafe] RE: gtk2hs and ghc-6.10.4 on Windows (Vista) Message-ID: <20100224201138.75469f813b58c2e0e98e8a30424d5d59.0126761a39.wbe@email05.secureserver.net> In correspondance with Alistair Bayley I learned that there is in fact a gtk2hs installer for 6.10.4. One can find it by Googling "gtk2hs 6.10.4" (which I did not think to do). The URL is in http://www.mail-archive.com/gtk2hs-devel@lists.sourceforge.net/msg00340.html The installer doesn't work if the Haskell Platform is installed in the default location, which has spaces in the pathname. Reinstalling Haskell in, say, c:\HaskellPlatform makes it all work. From nomeata at debian.org Thu Feb 25 04:15:08 2010 From: nomeata at debian.org (Joachim Breitner) Date: Thu Feb 25 03:45:37 2010 Subject: [Haskell-cafe] Re: Bug#570284: O: washngo In-Reply-To: <20100217213545.14516.84928.reportbug@katherina.lan.complete.org> References: <20100217213545.14516.84928.reportbug@katherina.lan.complete.org> Message-ID: <1267089308.2511.8.camel@localhost> Hi, Am Mittwoch, den 17.02.2010, 15:35 -0600 schrieb John Goerzen: > I no longer use WASH, nor do I have time to maintain it anymore. > Orphaning it, and CCing debian-haskell in case someone there has > interest in it. we have two option: Taking it over by the Haskell Group, or dropping it from Debian. Therefore my question: Is anyone using Wash? Is it still useful, three years after the last change and with HAppS around? Greetings, Joachim -- Joachim "nomeata" Breitner Debian Developer nomeata@debian.org | ICQ# 74513189 | GPG-Keyid: 4743206C JID: nomeata@joachim-breitner.de | http://people.debian.org/~nomeata -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: Dies ist ein digital signierter Nachrichtenteil Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100225/c829f041/attachment.bin From marco-oweber at gmx.de Thu Feb 25 04:27:49 2010 From: marco-oweber at gmx.de (Marc Weber) Date: Thu Feb 25 03:58:14 2010 Subject: [Haskell-cafe] Re: Bug#570284: O: washngo In-Reply-To: <1267089308.2511.8.camel@localhost> References: <20100217213545.14516.84928.reportbug@katherina.lan.complete.org> <1267089308.2511.8.camel@localhost> Message-ID: <1267089795-sup-6214@nixos> Excerpts from Joachim Breitner's message of Thu Feb 25 10:15:08 +0100 2010: > Hi, > > Am Mittwoch, den 17.02.2010, 15:35 -0600 schrieb John Goerzen: > > I no longer use WASH, nor do I have time to maintain it anymore. > > Orphaning it, and CCing debian-haskell in case someone there has > > interest in it. > > we have two option: Taking it over by the Haskell Group, or dropping it > from Debian. Therefore my question: > > Is anyone using Wash? Is it still useful, three years after the last > change and with HAppS around? It's a nice piece of code. I'm not using it either. But its ideas should not be forgotten. What exactly is the problem with supporting it? It's not using many extensions so compiling it should not make any trouble, does it? Maybe someone (I?) should write a .cabal file and add it to hackage. Then everyone who is interested in it can install it using cabal-install. I never want to miss having read some of its code. Marc Weber From nomeata at debian.org Thu Feb 25 04:31:48 2010 From: nomeata at debian.org (Joachim Breitner) Date: Thu Feb 25 04:02:13 2010 Subject: [Haskell-cafe] Re: Bug#570284: O: washngo In-Reply-To: <1267089795-sup-6214@nixos> References: <20100217213545.14516.84928.reportbug@katherina.lan.complete.org> <1267089308.2511.8.camel@localhost> <1267089795-sup-6214@nixos> Message-ID: <1267090308.2511.11.camel@localhost> Hi, Am Donnerstag, den 25.02.2010, 10:27 +0100 schrieb Marc Weber: > It's a nice piece of code. I'm not using it either. But its ideas should > not be forgotten. What exactly is the problem with supporting it? > > It's not using many extensions so compiling it should not make any > trouble, does it? > > Maybe someone (I?) should write a .cabal file and add it to hackage. > > Then everyone who is interested in it can install it using > cabal-install. > > I never want to miss having read some of its code. It?s not even cabalized yet? That would cause even extra work... But if it is cabalized and builds without issues, then supporting it is not much effort (although it?s not Debian?s task to be a code library, people can go to hackage for that). Greetings, Joachim -- Joachim "nomeata" Breitner Debian Developer nomeata@debian.org | ICQ# 74513189 | GPG-Keyid: 4743206C JID: nomeata@joachim-breitner.de | http://people.debian.org/~nomeata -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: Dies ist ein digital signierter Nachrichtenteil Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100225/7f33f92f/attachment.bin From haskell at gimbo.org.uk Thu Feb 25 07:15:07 2010 From: haskell at gimbo.org.uk (Andy Gimblett) Date: Thu Feb 25 06:45:44 2010 Subject: [Haskell-cafe] Re: Proper round-trip HughesPJ/Parsec for Doubles? In-Reply-To: <4B852877.9000006@dfki.de> References: <1CA520E4-F8FA-4237-916C-98CEB93AC4F9@gimbo.org.uk> <4B83F092.20606@dfki.de> <91CFF9A8-8549-45D1-83D8-A9CE167BE536@gimbo.org.uk> <4B852877.9000006@dfki.de> Message-ID: <15912BE2-5FE5-4694-97F2-791CAA8A2B84@gimbo.org.uk> Hi Christian, On 24 Feb 2010, at 13:24, Christian Maeder wrote: > I hope you don't mind if I make some style comments to your "final" > version. Not at all - thanks! > 1. break the line after "do" > (to avoid a layout change when change name or arguments of float' or > rename the variable "e") I'm not convinced by this; perhaps while editing the code it's useful, but those changes don't happen very often, and when they do, any half- decent editor ought to be able to handle making the change consistently. I do sometimes drop the do to the next line, but usually in order to keep things within 80 columns. I think this is somewhat a matter of personal taste though. More on this at the end... > 2. The "t :: TokenParser st" is only used for the white spaces. > This should be done separately (use "lexeme" from the TokenParser if > you > really need to). Just using "spaces" is also an alternative. OK - but what I'm trying to do here is create something I can use as a drop-in replacement for float from Text.ParserCombinators.Parsec.Token - in which case it shouldn't be done separately, I think? > 3. "liftCtoS" is only applied to '-', so an "optSign" would suffice. > optSign = option "" $ fmap (: []) (char '-') Agreed - although I resurrect it later as maybeChar (see below), matching against a choice of characters (to handle +/-) or returning "" if empty. > (read also allows a capital 'E' and a '+' before the exponent, but no > initial '+' sign. OK: didn't catch this because show doesn't (it seems) ever write them like that. Thanks. > The decimal point is optional. Same comment. :-) Fixed below, although I remove this optionality for my application (for now) because (I think) I want to be explicit about int vs float... > Also "NaN" and "Infinity" can be read, both possibly preceded by a > '-' sign followed by > spaces. But you may restrict yourself to the possible outputs of show, > which would include "NaN" and "Infinity", though.) OK. Indeed, it seems an initial '-' can be followed by spaces for other cases, e.g. "- 2e4", so have implemented that more general form. Adding the NaN and Infinity cases gives us another level of indent, and pushes us close enough to 80 columns that I've dropped the outermost do to the next line. > It may make sense to use something like readMaybe (which is missing in > the Prelude) instead of "read" to allow the parser to fail more > nicely. It seems to be kicking up reasonable errors as it is, e.g.: *Main> parse aFloat "" "2e-h" Left (line 1, column 4): unexpected "h" expecting digit I haven't seen any uncaught exceptions propagating, if that's what you're worried about...? > Btw I observed the following problem with read (that readMaybe would > also not solve). http://hackage.haskell.org/trac/ghc/ticket/3897 Ah, well that's out of scope for me, I fear. :-) So here's what I have now: float' :: TokenParser st -> GenParser Char st Double float' t = do n <- maybeChar "-" spaces fs <- choice [symbol t "NaN", symbol t "Infinity", do whole <- many1 digit frac <- option "" $ do char '.' ds <- many1 digit return $ '.' : ds ex <- option "" $ do choice [char 'e', char 'E'] s <- maybeChar "+-" ds <- many1 digit return $ concat ["e", s, ds] return $ concat [whole, frac, ex] ] whiteSpace t return $ read $ n ++ fs where maybeChar :: String -> GenParser Char st String maybeChar as = option "" (choice (map char as) >>= \a -> return [a]) >> You can also break it immediately before do, which I think is >> sometimes more clear. > > If not an extra space is added following "do" this leads to an "odd" > indentation of at least one line. I'm curious: which line in the above is indented oddly? Oh, wait: you don't mean odd as in "strange", do you? You mean odd as in "not even"? So, e.g. the "spaces" line starts at column 5? What's wrong with that? Cheers! -Andy -- Andy Gimblett http://gimbo.org.uk/ From marco-oweber at gmx.de Thu Feb 25 07:27:31 2010 From: marco-oweber at gmx.de (Marc Weber) Date: Thu Feb 25 06:57:57 2010 Subject: [Haskell-cafe] Re: Bug#570284: O: washngo In-Reply-To: <1267090308.2511.11.camel@localhost> References: <20100217213545.14516.84928.reportbug@katherina.lan.complete.org> <1267089308.2511.8.camel@localhost> <1267089795-sup-6214@nixos> <1267090308.2511.11.camel@localhost> Message-ID: <1267100721-sup-2537@nixos> Hi, It compiles even with ghc HEAD with very minimal cabal adjustments. I will upload it to hackage soon. Whether it is a debian package or not isn't that important (IMHO). Marc Weber From nccb2 at kent.ac.uk Thu Feb 25 07:41:00 2010 From: nccb2 at kent.ac.uk (Neil Brown) Date: Thu Feb 25 07:13:16 2010 Subject: [Haskell-cafe] Re: Proper round-trip HughesPJ/Parsec for Doubles? In-Reply-To: <15912BE2-5FE5-4694-97F2-791CAA8A2B84@gimbo.org.uk> References: <1CA520E4-F8FA-4237-916C-98CEB93AC4F9@gimbo.org.uk> <4B83F092.20606@dfki.de> <91CFF9A8-8549-45D1-83D8-A9CE167BE536@gimbo.org.uk> <4B852877.9000006@dfki.de> <15912BE2-5FE5-4694-97F2-791CAA8A2B84@gimbo.org.uk> Message-ID: <4B866FDC.7020906@kent.ac.uk> Andy Gimblett wrote: > >> 1. break the line after "do" >> (to avoid a layout change when change name or arguments of float' or >> rename the variable "e") > > I'm not convinced by this; perhaps while editing the code it's useful, > but those changes don't happen very often, and when they do, any > half-decent editor ought to be able to handle making the change > consistently. I do sometimes drop the do to the next line, but > usually in order to keep things within 80 columns. I think this is > somewhat a matter of personal taste though. More on this at the end... > I think the implication is that the layout change you mention will cause a version control commit to look like the whole function changed, whereas if you didn't have to alter the indent, it would be clear that the only lines that changed are the one introducing the extra parameter, and any subsequent lines that need to be changed to use the parameter. BTW, to add another option, I like this style: float' t = do ... Thanks, Neil. From vandijk.roel at gmail.com Thu Feb 25 08:00:52 2010 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Thu Feb 25 07:31:15 2010 Subject: [Haskell-cafe] Testing and module export lists In-Reply-To: References: Message-ID: What I usually do in such a case is create a separate internal module. The internal module exports everything. Then create a module which defines the public interface. This module simple reexports symbols from the internal module. Now you can create a Test module which has full access to all internal symbols. module Internal where a = 1 b = 2 secret = 42 module Public ( a, b ) where import Internal ( a, b ) module Test where import Internal ( secret ) test = assert $ isUltimateAnswer secret On Wed, Feb 24, 2010 at 10:17 AM, Magnus Therning wrote: > How do people who like unit testing / property testing deal with export lists? > > I often find that I do want an export list to reduce clutter in the > finished code, but for testing I'd like to expose everything in a > module. ?Is there a nice way to deal with this (using the C > pre-processor would not qualify as "nice" ;-)? > Maybe there's a switch that causes GHC to simply ignore the export > list of a module and export everything? > > /M From gue.schmidt at web.de Thu Feb 25 08:43:31 2010 From: gue.schmidt at web.de (=?ISO-8859-15?Q?G=FCnther_Schmidt?=) Date: Thu Feb 25 08:14:10 2010 Subject: [Haskell-cafe] Haskell and XML, need some tips from practioners Message-ID: <4B867E83.6020303@web.de> Hi everyone, I had to transform a 136 page word document into an XML-Document so that it can be imported into an application. The word document contained records in nested tables. Anyway through a very, very tedious process of xslt-transformations I finally have the XML document I need. But now I need to amend the attributes of some elements with looked up values from the outside, the lookup-key is a particular attribute value of the nodes. This I cannot do through xslt processing as the information needed is not within the xml document. I was thus going to use Haskell instead of an XSLT-processor for this final step. My question to those with experience of the Haskell-XML tools: which one should I use? G?nther From Alistair.Bayley at invesco.com Thu Feb 25 09:01:03 2010 From: Alistair.Bayley at invesco.com (Bayley, Alistair) Date: Thu Feb 25 08:31:26 2010 Subject: [Haskell-cafe] Haskell and XML, need some tips from practioners In-Reply-To: <4B867E83.6020303@web.de> References: <4B867E83.6020303@web.de> Message-ID: <125EACD0CAE4D24ABDB4D148C4593DA911026788@GBLONXMB02.corp.amvescap.net> > From: haskell-cafe-bounces@haskell.org > [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of G?nther Schmidt > > Anyway through a very, very tedious process of xslt-transformations I > finally have the XML document I need. > > But now I need to amend the attributes of some elements with > looked up > values from the outside, the lookup-key is a particular > attribute value > of the nodes. This I cannot do through xslt processing as the > information needed is not within the xml document. Not the answer you were looking for, but... Is the lookup table in another XML document? If so then you might well be able to use the document() function, if your xslt processor supports it e.g. That said, if you can, use Haskell to do all the transformations i.e. avoid xslt altogether. I despise xslt. Alistair ***************************************************************** Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. ***************************************************************** From colin at colina.demon.co.uk Thu Feb 25 09:04:41 2010 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Thu Feb 25 08:35:05 2010 Subject: [Haskell-cafe] Haskell and XML, need some tips from practioners In-Reply-To: <4B867E83.6020303@web.de> (=?utf-8?Q?=22G=C3=BCnther?= Schmidt"'s message of "Thu, 25 Feb 2010 14:43:31 +0100") References: <4B867E83.6020303@web.de> Message-ID: >>>>> "G?nther" == G?nther Schmidt writes: G?nther> But now I need to amend the attributes of some elements G?nther> with looked up values from the outside, the lookup-key is a G?nther> particular attribute value of the nodes. This I cannot do G?nther> through xslt processing as the information needed is not G?nther> within the xml document. You probably can. Via implementing some custom URI resolver, or an extension function, or such like. Depending upon the xslt implementation. Not that I'm discouraging you from doing it in Haskell instead. -- Colin Adams Preston Lancashire From gue.schmidt at web.de Thu Feb 25 09:37:59 2010 From: gue.schmidt at web.de (=?ISO-8859-1?Q?G=FCnther_Schmidt?=) Date: Thu Feb 25 09:08:42 2010 Subject: [Haskell-cafe] Re: Haskell and XML, need some tips from practioners In-Reply-To: <125EACD0CAE4D24ABDB4D148C4593DA911026788@GBLONXMB02.corp.amvescap.net> References: <4B867E83.6020303@web.de> <125EACD0CAE4D24ABDB4D148C4593DA911026788@GBLONXMB02.corp.amvescap.net> Message-ID: <4B868B47.90606@web.de> Dear Alistair, after working intensely with XSLT again (with a break for several years), I wholeheartedly concur. You guys are right though, through the document function it would be possible. So any particular tool-set you could recommend? G?nther Am 25.02.10 15:01, schrieb Bayley, Alistair: >> From: haskell-cafe-bounces@haskell.org >> [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of G?nther Schmidt >> >> Anyway through a very, very tedious process of xslt-transformations I >> finally have the XML document I need. >> >> But now I need to amend the attributes of some elements with >> looked up >> values from the outside, the lookup-key is a particular >> attribute value >> of the nodes. This I cannot do through xslt processing as the >> information needed is not within the xml document. > > > Not the answer you were looking for, but... > > Is the lookup table in another XML document? If so then you might well be able to use the document() function, if your xslt processor supports it e.g. > > > > That said, if you can, use Haskell to do all the transformations i.e. avoid xslt altogether. I despise xslt. > > Alistair > ***************************************************************** > Confidentiality Note: The information contained in this message, > and any attachments, may contain confidential and/or privileged > material. It is intended solely for the person(s) or entity to > which it is addressed. Any review, retransmission, dissemination, > or taking of any action in reliance upon this information by > persons or entities other than the intended recipient(s) is > prohibited. If you received this in error, please contact the > sender and delete the material from any computer. > ***************************************************************** From Alistair.Bayley at invesco.com Thu Feb 25 09:44:25 2010 From: Alistair.Bayley at invesco.com (Bayley, Alistair) Date: Thu Feb 25 09:14:47 2010 Subject: [Haskell-cafe] Re: Haskell and XML, need some tips from practioners In-Reply-To: <4B868B47.90606@web.de> References: <4B867E83.6020303@web.de><125EACD0CAE4D24ABDB4D148C4593DA911026788@GBLONXMB02.corp.amvescap.net> <4B868B47.90606@web.de> Message-ID: <125EACD0CAE4D24ABDB4D148C4593DA91102678A@GBLONXMB02.corp.amvescap.net> > From: haskell-cafe-bounces@haskell.org > [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of G?nther Schmidt > > You guys are right though, through the document function it would be > possible. > > So any particular tool-set you could recommend? On Windows, the Microsoft xslt processor supports document(), I believe. Other than that, I have no recommendations. Alistair ***************************************************************** Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. ***************************************************************** From gue.schmidt at web.de Thu Feb 25 10:03:48 2010 From: gue.schmidt at web.de (=?ISO-8859-15?Q?G=FCnther_Schmidt?=) Date: Thu Feb 25 09:34:25 2010 Subject: [Haskell-cafe] Multiple Interpretations for a monad? Message-ID: <4B869154.3020104@web.de> Hi everyone, in my attempts to remove boilerplate and thus to do more "abstraction" I come across a number of interesting things and suggestions. Especially blog posts from Dan Piponi and also Heinrich Apfelmus. I think what they both are saying is that you can construct / implement some sort of 2 layered monad which can then have more than one interpretation. In the responses to one of my posts on DSLs Dan Piponi also points out that he considers monads also to be DSLs. It didn't click with me when he said it, but reading more of his blog posts made me remember that. Now I know this is probably something obvious to most haskellers, but to me it's not. Did I understand this correctly so far? G?nther From gue.schmidt at web.de Thu Feb 25 10:05:48 2010 From: gue.schmidt at web.de (=?ISO-8859-1?Q?G=FCnther_Schmidt?=) Date: Thu Feb 25 09:36:11 2010 Subject: [Haskell-cafe] Re: Haskell and XML, need some tips from practioners In-Reply-To: <125EACD0CAE4D24ABDB4D148C4593DA91102678A@GBLONXMB02.corp.amvescap.net> References: <4B867E83.6020303@web.de><125EACD0CAE4D24ABDB4D148C4593DA911026788@GBLONXMB02.corp.amvescap.net> <4B868B47.90606@web.de> <125EACD0CAE4D24ABDB4D148C4593DA91102678A@GBLONXMB02.corp.amvescap.net> Message-ID: <4B8691CC.7070109@web.de> Hi Alistair, sorry, misunderstanding. I meant which *Haskell* - XML-tools. G?nther Am 25.02.10 15:44, schrieb Bayley, Alistair: >> From: haskell-cafe-bounces@haskell.org >> [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of G?nther Schmidt >> >> You guys are right though, through the document function it would be >> possible. >> >> So any particular tool-set you could recommend? >> > On Windows, the Microsoft xslt processor supports document(), I believe. Other than that, I have no recommendations. > > Alistair > ***************************************************************** > Confidentiality Note: The information contained in this message, > and any attachments, may contain confidential and/or privileged > material. It is intended solely for the person(s) or entity to > which it is addressed. Any review, retransmission, dissemination, > or taking of any action in reliance upon this information by > persons or entities other than the intended recipient(s) is > prohibited. If you received this in error, please contact the > sender and delete the material from any computer. > ***************************************************************** > > From schlepptop at henning-thielemann.de Thu Feb 25 10:14:11 2010 From: schlepptop at henning-thielemann.de (Henning Thielemann) Date: Thu Feb 25 09:42:41 2010 Subject: [Haskell-cafe] Re: Some great results on fused code with the LLVM backend In-Reply-To: <20100225012223.GC8261@kira.casa> References: <20100222015725.GA1870@whirlpool.galois.com> <7dceb1a7-f413-4ee7-94e2-a19ec9200229@q21g2000yqm.googlegroups.com> <7fb8f82f1002241028m27ad0e3dh82d29b45a69e589e@mail.gmail.com> <20100225012223.GC8261@kira.casa> Message-ID: <4B8693C3.4000301@henning-thielemann.de> Felipe Lessa schrieb: > On Wed, Feb 24, 2010 at 01:28:56PM -0500, Edward Kmett wrote: >>> * GHC/LLVM bytecode with JIT-option? >> There is little preventing this one. > > Oh, what a great idea! C code being inlined into Haskell > functions! :D How about LLVM inline assembly code? You can already do this using the 'llvm' package. From leimy2k at gmail.com Thu Feb 25 10:50:14 2010 From: leimy2k at gmail.com (David Leimbach) Date: Thu Feb 25 10:20:38 2010 Subject: [Haskell-cafe] Multiple Interpretations for a monad? In-Reply-To: <4B869154.3020104@web.de> References: <4B869154.3020104@web.de> Message-ID: <3e1162e61002250750n90f269am450cb9d7f18e5b37@mail.gmail.com> Monads aren't necessarily EDSLs by themselves but are often shipped with functions that provide what would make them an EDSL. Take the State monad, it has at least a get and a put function to work with the state in the monad. That get and put are commands that function only within the domain of the State monad, and therefore could be thought of as an embedded language that is used to work with the state encapsulated in the State Monad computation. The way I like to think of it, a Monad provides an environment or a context within which it is very convenient to express an EDSL, and that this style of coding should be encouraged! :-) Dave 2010/2/25 G?nther Schmidt > Hi everyone, > > in my attempts to remove boilerplate and thus to do more "abstraction" I > come across a number of interesting things and suggestions. > > Especially blog posts from Dan Piponi and also Heinrich Apfelmus. I think > what they both are saying is that you can construct / implement some sort of > 2 layered monad which can then have more than one interpretation. > > In the responses to one of my posts on DSLs Dan Piponi also points out that > he considers monads also to be DSLs. It didn't click with me when he said > it, but reading more of his blog posts made me remember that. > > Now I know this is probably something obvious to most haskellers, but to me > it's not. > > Did I understand this correctly so far? > > G?nther > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100225/3901c367/attachment.html From greg at gregorycollins.net Thu Feb 25 11:17:13 2010 From: greg at gregorycollins.net (Gregory Collins) Date: Thu Feb 25 10:47:34 2010 Subject: [Haskell-cafe] Haskell and XML, need some tips from practioners In-Reply-To: <4B867E83.6020303@web.de> (=?utf-8?Q?=22G=C3=BCnther?= Schmidt"'s message of "Thu, 25 Feb 2010 14:43:31 +0100") References: <4B867E83.6020303@web.de> Message-ID: <873a0pguie.fsf@gregorycollins.net> G?nther Schmidt writes: > My question to those with experience of the Haskell-XML tools: which > one should I use? You'll need to evaluate which one fits your needs best; in my mind the contenders are: ------------------------------------------------------------------------------ xml: http://hackage.haskell.org/package/xml Small, simple, comprehensible DOM interface with some simple search + cursor functions, uses String internally. If performance is not a concern this one is the "nicest" in my opinion. ------------------------------------------------------------------------------ hexpat: http://hackage.haskell.org/package/hexpat A binding to the expat C library; super-fast as a result, most of the useful functions from xml have been ported over here. Has support for SAX parsing. This is the one I usually use when I don't need things like DTD validation or XPath support (i.e. 100% of the time). Not much in the way of docs (haddock only) but it's small enough to be comprehensible. ------------------------------------------------------------------------------ HXT: http://hackage.haskell.org/package/hxt Dauntingly enormous, oodles of features, you need to grok arrows. Uses String internally. The documentation is pretty iffy -- individual modules are haddocked pretty well but there are a zillion of them and a table of contents is sorely needed. Website docs/manuals are of the "read this wiki page, this paper, and my master's thesis" variety, but the wiki page is actually pretty good. This is the one I use when I need a feature hexpat doesn't have, but normally I avoid it if I can because arrows cause me to "grind the gears". ------------------------------------------------------------------------------ HaXml: http://hackage.haskell.org/package/HaXml Lots of modules and features here, uses String internally, has the same "table of contents" issue as HXT, manual seems to consist of an ICFP paper from 1999, Haddock is a little terse/spotty. Hope this helps, G -- Gregory Collins From colin at colina.demon.co.uk Thu Feb 25 11:18:12 2010 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Thu Feb 25 10:48:36 2010 Subject: [Haskell-cafe] Re: Haskell and XML, need some tips from practioners In-Reply-To: <4B868B47.90606@web.de> (=?utf-8?Q?=22G=C3=BCnther?= Schmidt"'s message of "Thu, 25 Feb 2010 15:37:59 +0100") References: <4B867E83.6020303@web.de> <125EACD0CAE4D24ABDB4D148C4593DA911026788@GBLONXMB02.corp.amvescap.net> <4B868B47.90606@web.de> Message-ID: >>>>> "G?nther" == G?nther Schmidt writes: G?nther> Dear Alistair, after working intensely with XSLT again G?nther> (with a break for several years), I wholeheartedly concur. G?nther> You guys are right though, through the document function it G?nther> would be possible. G?nther> So any particular tool-set you could recommend? Saxon is by far the best, if you're happy with a java program. (I can hardly recommend my own. Not through modesty, of which I am not over-endowed, but because I refuse to support it since the W3C abolished the concept of XML as self-describing data.) -- Colin Adams Preston Lancashire From gue.schmidt at web.de Thu Feb 25 11:25:17 2010 From: gue.schmidt at web.de (=?UTF-8?B?R8O8bnRoZXIgU2NobWlkdA==?=) Date: Thu Feb 25 10:55:40 2010 Subject: [Haskell-cafe] Haskell and XML, need some tips from practioners In-Reply-To: <873a0pguie.fsf@gregorycollins.net> References: <4B867E83.6020303@web.de> <873a0pguie.fsf@gregorycollins.net> Message-ID: <4B86A46D.7080400@web.de> Hello Gregory, we have pretty much come to the same conclusion :) G?nther Am 25.02.10 17:17, schrieb Gregory Collins: > G?nther Schmidt writes: > > >> My question to those with experience of the Haskell-XML tools: which >> one should I use? >> > You'll need to evaluate which one fits your needs best; in my mind the > contenders are: > > ------------------------------------------------------------------------------ > xml: http://hackage.haskell.org/package/xml > > Small, simple, comprehensible DOM interface with some simple > search + cursor functions, uses String internally. If performance is not > a concern this one is the "nicest" in my opinion. > > ------------------------------------------------------------------------------ > hexpat: http://hackage.haskell.org/package/hexpat > > A binding to the expat C library; super-fast as a result, most of the > useful functions from xml have been ported over here. Has support for > SAX parsing. This is the one I usually use when I don't need things like > DTD validation or XPath support (i.e. 100% of the time). Not much in the > way of docs (haddock only) but it's small enough to be comprehensible. > > ------------------------------------------------------------------------------ > HXT: http://hackage.haskell.org/package/hxt > > Dauntingly enormous, oodles of features, you need to grok arrows. Uses > String internally. The documentation is pretty iffy -- individual > modules are haddocked pretty well but there are a zillion of them and a > table of contents is sorely needed. Website docs/manuals are of the > "read this wiki page, this paper, and my master's thesis" variety, but > the wiki page is actually pretty good. This is the one I use when I need > a feature hexpat doesn't have, but normally I avoid it if I can because > arrows cause me to "grind the gears". > > ------------------------------------------------------------------------------ > HaXml: http://hackage.haskell.org/package/HaXml > > Lots of modules and features here, uses String internally, has the same > "table of contents" issue as HXT, manual seems to consist of an ICFP > paper from 1999, Haddock is a little terse/spotty. > > Hope this helps, > > G > From byorgey at seas.upenn.edu Thu Feb 25 12:10:09 2010 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Thu Feb 25 11:40:31 2010 Subject: [Haskell-cafe] "datakind" declaration In-Reply-To: <20100223010812.GE17714@inria.fr> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <75cc17ac1002180924r6d8eb5f4r3a7ddebd9825c69f@mail.gmail.com> <4B7D8D23.3020402@t-online.de> <201002182031.03105.daniel.is.fischer@web.de> <4B7DEE0B.7050309@t-online.de> <681D5A1F-0BAC-4ECA-8A1D-2D5C1DB00F5E@cs.otago.ac.nz> <4B80345A.6090204@t-online.de> <20100223010812.GE17714@inria.fr> Message-ID: <20100225171009.GA2119@seas.upenn.edu> On Tue, Feb 23, 2010 at 02:08:12AM +0100, Paul Brauner wrote: > Hello, > > I remember seeing something like > > > typedata T = A | B > > somewhere, where A and B are type constructors, but I can't find it in > the ghc doc. Have I been dreaming or is it some hidden feature ? No, this doesn't* exist. -Brent * yet! From es at ertes.de Thu Feb 25 12:32:10 2010 From: es at ertes.de (Ertugrul Soeylemez) Date: Thu Feb 25 12:02:43 2010 Subject: [Haskell-cafe] Re: Function to detect duplicates References: <351ff25e1002230330n7913ba28h40b641096a777acc@mail.gmail.com> <3690ee141002230554h4434ec1aye130e9b3bb73e88f@mail.gmail.com> <20100224142520.42df50f4@tritium.streitmacht.eu> <201002241659.26719.daniel.is.fischer@web.de> Message-ID: <20100225183210.0a93e602@tritium.streitmacht.eu> Daniel Fischer wrote: > Am Mittwoch 24 Februar 2010 14:25:20 schrieb Ertugrul Soeylemez: > > > Again note that the big advantage of my method is laziness. The > > comparison will end on the first duplicate found. > > Yes, and the suggestions Jonas and I posted had the same property :) Indeed. My suggestion was a response to the sort-based method proposed first. =) Greets Ertugrul -- nightmare = unsafePerformIO (getWrongWife >>= sex) http://blog.ertes.de/ From ajs at 2piix.com Thu Feb 25 13:14:14 2010 From: ajs at 2piix.com (Alexander Solla) Date: Thu Feb 25 12:44:43 2010 Subject: [Haskell-cafe] Re: Heterogeneous Data Structures - Nested Pairs and functional references In-Reply-To: References: <4B7AFC98.9080103@web.de> Message-ID: <710EFA9E-78E8-4885-8A23-9E6AC8688AE8@2piix.com> On Feb 24, 2010, at 10:15 AM, Heinrich Apfelmus wrote: > Namely, let's assume we are already given a "magic" type > constructor |- > (so magic that it's not even legal Haskell syntax) with the property > that > > A |- B > > somehow denotes an expression of type B with free variables of > type A > . In other words, the result of type B is somehow allowed to > depend on > values of type A . In the context of this post, when I say "functor", I don't mean a Functor instance. I mean the mathematical object which maps between categories. As you noted, functions satisfy your "magic". A function from a type A to B is a functor from A to B from a different point of view. (One is "in" some kind of algebra in A and B, and the other is in the category of small categories). But you lose something important by using functions. Consider the parallel type specification of (my) Views with types, guided by your example code: concat_views :: a -> v -> v -> (a, (v, v)) -- v's are meant to be the result of calling a *_view function. nest_views :: a -> v -> v -> v -> (a, (v, v, v)) page_view :: a -> v -> v -> v -> v -> (a, [v]) text_view :: String -> v -> (String, v) As you can see from the types, these are functions that take values and "wrap them up". These functions trivially induce functors of the form View a :: v -> (a, [v]) (let's call them lists for the purposes of "form" since there can be any number of v's). What are we gaining? What are we losing? My Functor-based implementation had a uniform interface to all the View's innards, which we have lost. And if we want to turn these functions into an algebra, we need to define a fair amount of plumbing. If you take the time to do that, you'll see that the implementation encodes a traversal for each of result types. An fmap equivalent for this implementation. In short, before you can do anything with your construct, you will need to normalize the return result. You can do that by reifying them: > data View view = EmptyView | TextView String | ConcatViews (View view) (View view) | ... or by doing algebra on things of the form (a, [v]). Notice, also, that the View view data constructors are (basically) functions of the form [View] -> (a, [View]) or a -> (a, [View]) for some a. (The tricky bit is the "some a" part. Consider why EmptyView and (TextView String) is a (View view) no matter what type view is). The parallel for EmptyView is: > empty_view :: a -> v -> (a, v) > empty_view a v = (a, ()) --? I guess that works. Dummy arguments for empty things. Ikky. My example code had some problems, but I really think it's a superior solution for the problem of making reusable renderable fragments. Indeed, this post described how I refactored your approach into mine, when I wrote my View code in the first place. Then again, I also got tired of wrestling with Data.Foldable and moved on to using a plain initial algebra and Uniplate. From nomeata at debian.org Thu Feb 25 13:58:13 2010 From: nomeata at debian.org (Joachim Breitner) Date: Thu Feb 25 13:28:39 2010 Subject: [Haskell-cafe] hmake and hat Message-ID: <1267124293.2511.73.camel@localhost> Hi, I made hmake compile on Debian again, but it seems it?s not working yet properly. This also affects hat, as it uses hmake to compile. I guess we could just drop hmake and hat, but this is Debian, and we try to avoid dropping stuff that made it into a stable release. Is anyone interested in figuring out whats wrong with hmake and how to make hat compile again? Also, to haskell-cafe, are there any hat users out there? Greetings, Joachim -- Joachim "nomeata" Breitner Debian Developer nomeata@debian.org | ICQ# 74513189 | GPG-Keyid: 4743206C JID: nomeata@joachim-breitner.de | http://people.debian.org/~nomeata -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: Dies ist ein digital signierter Nachrichtenteil Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100225/10539be8/attachment.bin From thomas at 0xc29.net Thu Feb 25 14:01:34 2010 From: thomas at 0xc29.net (Thomas Girod) Date: Thu Feb 25 13:41:46 2010 Subject: [Haskell-cafe] hdbc-mysql fails to compile Message-ID: <20100225190134.GA30023@fairlight.lan> Hi there. Looks like hdbc-mysql cannot compile against GHC-6.12 -- confirmed by the hackage build logs. [1] anyone know a way to dodge the problem ? cheers, Tom [1] http://hackage.haskell.org/packages/archive/HDBC-mysql/0.6/logs/failure/ghc-6.12 From daniel.is.fischer at web.de Thu Feb 25 14:59:13 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Feb 25 14:31:32 2010 Subject: [Haskell-cafe] hdbc-mysql fails to compile In-Reply-To: <20100225190134.GA30023@fairlight.lan> References: <20100225190134.GA30023@fairlight.lan> Message-ID: <201002252059.13883.daniel.is.fischer@web.de> Am Donnerstag 25 Februar 2010 20:01:34 schrieb Thomas Girod: > Hi there. Looks like hdbc-mysql cannot compile against GHC-6.12 -- > confirmed by the hackage build logs. [1] Change in the Cabal API. > > anyone know a way to dodge the problem ? Rewrite Setup.[l]hs to work with the new API or pester the maintainer to do it. > > cheers, > > Tom From thomas at 0xc29.net Thu Feb 25 14:51:49 2010 From: thomas at 0xc29.net (Thomas Girod) Date: Thu Feb 25 14:32:03 2010 Subject: [Haskell-cafe] hdbc-mysql fails to compile In-Reply-To: <20100225190134.GA30023@fairlight.lan> References: <20100225190134.GA30023@fairlight.lan> Message-ID: <20100225195149.GA30084@fairlight.lan> replying to myself. there is only one line to fix in Setup.lhs (mysqlConfigProg, _) <- requireProgram verbosity mysqlConfigProgram AnyVersion (withPrograms lbi) becomes : (mysqlConfigProg, _) <- requireProgram verbosity mysqlConfigProgram (withPrograms lbi) obviously the new cabal version makes a difference between "requireProgram" and "requireProgramVersion" On Thu, Feb 25, 2010 at 08:01:34PM +0100, Thomas Girod wrote: > Hi there. Looks like hdbc-mysql cannot compile against GHC-6.12 -- > confirmed by the hackage build logs. [1] > > anyone know a way to dodge the problem ? > > cheers, > > Tom > > [1] > http://hackage.haskell.org/packages/archive/HDBC-mysql/0.6/logs/failure/ghc-6.12 > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From haskell at benmachine.co.uk Thu Feb 25 15:10:53 2010 From: haskell at benmachine.co.uk (Ben Millwood) Date: Thu Feb 25 14:41:20 2010 Subject: [Haskell-cafe] "datakind" declaration In-Reply-To: <20100223010812.GE17714@inria.fr> References: <40922FA2-46AE-41AE-AB54-56B091C856E2@chariot.net.au> <75cc17ac1002180924r6d8eb5f4r3a7ddebd9825c69f@mail.gmail.com> <4B7D8D23.3020402@t-online.de> <201002182031.03105.daniel.is.fischer@web.de> <4B7DEE0B.7050309@t-online.de> <681D5A1F-0BAC-4ECA-8A1D-2D5C1DB00F5E@cs.otago.ac.nz> <4B80345A.6090204@t-online.de> <20100223010812.GE17714@inria.fr> Message-ID: On Tue, Feb 23, 2010 at 1:08 AM, Paul Brauner wrote: > Hello, > > I remember seeing something like > >> typedata T = A | B > > somewhere, where A and B are type constructors, but I can't find it in > the ghc doc. Have I been dreaming or is it some hidden feature ? > > Paul > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > This is similar to what you are thinking of: http://hackage.haskell.org/trac/ghc/wiki/KindSystem ...but it's not implemented (yet). From leather at cs.uu.nl Thu Feb 25 17:43:00 2010 From: leather at cs.uu.nl (Sean Leather) Date: Thu Feb 25 17:13:43 2010 Subject: [Haskell-cafe] Interested in the Dutch HUG Day (24 April 2010)? Message-ID: <3c6288ab1002251443n35866dabued14d8839a81d7aa@mail.gmail.com> In honor of the first anniversary of the Dutch Haskell Users Group (formed at Hac5 in Utrecht), we are planning a mini symposium to bring together Haskell and functional programming enthusiasts in the Netherlands and surrounding area. *The Dutch HUG Day will be held on Saturday, 24 April.* Please mark that date in your calendar. The remaining details are being worked out. In order to help us with this process, we have created a short survey. If you are even remotely considering attending, please take a moment to fill out a form with your name and the activities that interest you. * http://spreadsheets.google.com/viewform?formkey=dGVuVTdnZEl0ZDE3MEVweUtRdmlnZGc6MA Note that this does not commit you to anything. We will only use this information to help plan the event (e.g. determine the number of seats at the location and the types of activities). For more information about the Dutch HUG, visit the wiki page and sign up for the mailing list. * http://www.haskell.org/haskellwiki/Dutch_HUG * http://groups.google.com/group/dutch-hug Thanks for your time! Sincerely, The Dutch HUG Day planning team -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100225/dc8e95eb/attachment.html From schlepptop at henning-thielemann.de Thu Feb 25 18:12:15 2010 From: schlepptop at henning-thielemann.de (Henning Thielemann) Date: Thu Feb 25 17:44:37 2010 Subject: [Haskell-cafe] Testing and module export lists In-Reply-To: References: Message-ID: <4B8703CF.8080801@henning-thielemann.de> Magnus Therning schrieb: > On Wed, Feb 24, 2010 at 10:41, Arnaud Bailly wrote: > >> Maybe you just want to test what's in your export list which >> represents the public interface of your code. And if you cannot write >> a test that exercise private implementation through the public >> interface, then maybe there is a design problem... >> > > Possibly! > > The specific case I have is a module for parsing a small language. > The module exports a single function, a function that takes a string > and returns a tree. Of course the parser is built using parser > combinators. I'd like to test each combinator I've built, but I don't > want to export them all. The only way I see of achieving this is to > split each module in two, one public and one internal, where the > public one just re-exports the relevant pieces of the internal one. > That's workable, but hardly aesthetically pleasing ;-) > It can be tedious to manage two variants of each module, but I often had to go this way anyway in order to avoid cyclic dependencies or because some modules need internals of other modules of the same package. From wasserman.louis at gmail.com Thu Feb 25 18:33:14 2010 From: wasserman.louis at gmail.com (Louis Wasserman) Date: Thu Feb 25 18:03:56 2010 Subject: [Haskell-cafe] Linear programming in Haskell In-Reply-To: <4B84FA4C.8040903@um.es> References: <20100216195420.GA26057@kira.casa> <20100216203725.GA30360@kira.casa> <4B7BAAFE.3080303@um.es> <20100218093323.2f1b0003.mle+hs@mega-nerd.com> <4B84FA4C.8040903@um.es> Message-ID: Yo, Man, I'd never used FFI before, but it's really not as scary as I'd feared. I've implemented a more comprehensive interface to GLPK's simplex solver and -- rather importantly, for my own needs -- its MIP solver. This doesn't depend on hmatrix, and in fact, it doesn't require any matrix or vector manipulation at all -- linear functions are specified as a straight-up Data.Map from an arbitrary variable type to their coefficients. The library is now available as glpk-hs on hackage. Example: import Data.LinearProgram.LPMonad import Data.LinearProgram import Data.LinearProgram.GLPK objFun :: LinFunc String Int objFun = linCombination [(10, "x1"), (6, "x2"), (4, "x3")] lp :: LP String Int lp = execLPM $ do setDirection Max setObjective objFun leqTo (varSum ["x1", "x2", "x3"]) 100 leqTo (10 *^ var "x1" ^+^ 4 *& "x2" ^+^ 5 *^ var "x3") 600 -- c *^ var v, c *& v, and linCombination [(c, v)] are all equivalent. -- ^+^ is the addition operation on linear functions. leqTo (linCombination [(2, "x1"), (2, "x2"), (6, "x3")]) 300 varGeq "x1" 0 varBds "x2" 0 50 varGeq "x3" 0 setVarKind "x1" IntVar setVarKind "x2" ContVar main = print =<< glpSolveVars mipDefaults lp This requires GLPK to be installed, like below. Louis Wasserman wasserman.louis@gmail.com http://profiles.google.com/wasserman.louis On Wed, Feb 24, 2010 at 4:07 AM, Alberto Ruiz wrote: > I have uploaded to hackage an interface to the simplex algorithm based on > GLPK. It is a very early version, it will probably have lots of problems. In > the future I would like to add support for integer variables (MIP). Any > suggestion is welcome. > > This is an example taken from "glpk-utils": > > http://code.haskell.org/hmatrix/packages/glpk/examples/simplex3.hs > > Documentation: http://perception.inf.um.es/~aruiz/hmatrix-glpk/ > > Installation: > > $ sudo apt-get install libglpk-dev > $ cabal update > $ cabal install hmatrix-glpk > > If hmatrix is not installed we also need > > $ sudo apt-get install libgsl0-dev liblapack-dev > > I hope it is useful, > Alberto > > > > Erik de Castro Lopo wrote: > >> Alberto Ruiz wrote: >> >> I think that GSL does not include linear programming solvers, but in the >>> GSL home page there is a reference to the GLPK package: >>> >>> http://www.gnu.org/software/glpk/glpk.html >>> >>> I have not used it, but it would be very nice to have a simple Haskell >>> interface to GLPK (or other similar library) in hmatrix or as a separate >>> package. I will take a look at this. >>> >> >> I used GLPK many years ago and I found it excellent. >> >> Erik >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100225/c1274c91/attachment.html From anotheraddress at gmx.de Thu Feb 25 18:47:47 2010 From: anotheraddress at gmx.de (Daniel =?iso-8859-15?q?Sch=FCssler?=) Date: Thu Feb 25 18:18:21 2010 Subject: [Haskell-cafe] Linear programming in Haskell In-Reply-To: <7be1feae1002180226t44681856m82c971a0d128d19@mail.gmail.com> References: <7be1feae1002180226t44681856m82c971a0d128d19@mail.gmail.com> Message-ID: <201002260047.47678.anotheraddress@gmx.de> On Thursday 18 February 2010 11:26:02 Ozgur Akgun wrote: > I've no idea about the GLPK system. > > But, isn't it the case that you can transform any linear inequality into a > linear equality and a slack (or excess) variable? Well yes, but the slack variables are constrained to be nonnegative, which isn't essentially different from having arbitrary inequalities (but it's convenient). The problem doesn't reduce to solving a system of linear equalities (as an illustration of how it's more tricky than linear equalities, the question of whether the problem is in P was settled quite recently, in 1972. ("Recently" when compared to classical linear algebra :))). Greetings, Daniel From RafaelGCPP.Linux at gmail.com Thu Feb 25 18:57:48 2010 From: RafaelGCPP.Linux at gmail.com (Rafael Gustavo da Cunha Pereira Pinto) Date: Thu Feb 25 18:28:09 2010 Subject: [Haskell-cafe] Re: Function to detect duplicates In-Reply-To: <20100225183210.0a93e602@tritium.streitmacht.eu> References: <351ff25e1002230330n7913ba28h40b641096a777acc@mail.gmail.com> <3690ee141002230554h4434ec1aye130e9b3bb73e88f@mail.gmail.com> <20100224142520.42df50f4@tritium.streitmacht.eu> <201002241659.26719.daniel.is.fischer@web.de> <20100225183210.0a93e602@tritium.streitmacht.eu> Message-ID: <351ff25e1002251557i1ad678bam8fa4d685e3dabfb6@mail.gmail.com> Just to clarify the issue, I will propose the puzzle: There is a single 10 digit number that: 1) uses all ten digits [0..9], with no repetitions 2) the number formed by the first digit (right to left, most significant) is divisible by one 3) the number formed by the first 2 digits (again right to left) is divisible by two 4) the number formed by the first 3 digits is divisible by three and so on, until: 11) the number formed by the first 10 digits (all!) is by 10 Actually this can be solved by a little logic, but I wanted to give a try on brute force search using haskell. I am not looking very large lists, but I was expecting a handful of small lists. My algorithm follow these steps: 1) start with an list of empty list ([[]]), call it ds 2) I cons each member of [0..9] to ds 3) filter using: a) noneRepeated b) (listToNum d) `mod` l == 0, where l is the length of each sublist d (not computed, it is an accumulator that is incremented each time I cons) 4) repeat steps 2-3 until l==10 So, I represent each possible number as a reversed list of its digits... It ran REALLY fast (sub-second). So, bragging about Haskell with a Smalltalk-lover friend, by showing him how clean was the code and how easy was to profile, I figured out that I spent 99% on noneRepeated. After changing to the merge sort version, I have 30% on noneRepeated, 30% on listToNum and 30% on putStrLn. Pretty good! Besides, I could brag a little more about Hakell to that specific friend!! ;-) Best regards to you all!! Rafael PS: Here is the original search code, with the bad noneRepeated and still using length import Data.List digits=[0..9] noneRepeated::[Integer]->Bool noneRepeated=null.(filter (>1)).(map length).group.sort listToNum::[Integer]->Integer listToNum = (foldl (\a x->10*a+x) 0).reverse check::[Integer]->Bool check ds= and [noneRepeated ds, (listToNum ds) `mod` l==0] where l=fromIntegral $ length ds nextlevel::[[Integer]]->[[Integer]] nextlevel dss=filter (check) [d:ds | ds<-dss,d<-digits] main=do dss<-runlevel 10 0 [[]] print $ map (listToNum) dss runlevel 0 b dds=return dds runlevel a b dds=do let dds'=nextlevel dds putStrLn $ "Level "++(show (b+1))++": "++(show $ length dds')++" matches" print $ map (listToNum) dds' runlevel (a-1) (b+1) dds' -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100225/db2e72c8/attachment-0001.html From daniel.is.fischer at web.de Thu Feb 25 20:30:35 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Feb 25 20:02:54 2010 Subject: [Haskell-cafe] Re: Function to detect duplicates In-Reply-To: <351ff25e1002251557i1ad678bam8fa4d685e3dabfb6@mail.gmail.com> References: <351ff25e1002230330n7913ba28h40b641096a777acc@mail.gmail.com> <20100225183210.0a93e602@tritium.streitmacht.eu> <351ff25e1002251557i1ad678bam8fa4d685e3dabfb6@mail.gmail.com> Message-ID: <201002260230.36306.daniel.is.fischer@web.de> Am Freitag 26 Februar 2010 00:57:48 schrieb Rafael Gustavo da Cunha Pereira Pinto: > Just to clarify the issue, I will propose the puzzle: > > There is a single 10 digit number that: > > 1) uses all ten digits [0..9], with no repetitions > 2) the number formed by the first digit (right to left, most > significant) is divisible by one > 3) the number formed by the first 2 digits (again right to left) is > divisible by two > 4) the number formed by the first 3 digits is divisible by three > and so on, until: > 11) the number formed by the first 10 digits (all!) is by 10 > > Actually this can be solved by a little logic, but I wanted to give a > try on brute force search using haskell. Okay, so I won't talk about choosing a better algorithm :) > > I am not looking very large lists, but I was expecting a handful of > small lists. And these are so short that actually noneRepeated xs = xs == nub xs is *faster* than sorting and grouping. > > My algorithm follow these steps: > > 1) start with an list of empty list ([[]]), call it ds > 2) I cons each member of [0..9] to ds > 3) filter using: > a) noneRepeated > b) (listToNum d) `mod` l == 0, where l is the length of each Reverse the tests, \l d -> (listToNum d) `mod` l == 0 is cheap in comparison to noneRepeated, even with noneRepeated xs = xs == nub xs. > sublist d (not computed, it is an accumulator that is incremented each > time I cons) 4) repeat steps 2-3 until l==10 > > > So, I represent each possible number as a reversed list of its digits... > It ran REALLY fast (sub-second). > > So, bragging about Haskell with a Smalltalk-lover friend, by showing him > how clean was the code and how easy was to profile, I figured out that I > spent 99% on noneRepeated. That doesn't run long enough to get a reliable profile, even if you reduce the tick-time to 1ms. > > After changing to the merge sort version, I have 30% on noneRepeated, > 30% on listToNum and 30% on putStrLn. Pretty good! > > Besides, I could brag a little more about Hakell to that specific > friend!! ;-) > > > Best regards to you all!! > > Rafael > > > PS: Here is the original search code, with the bad noneRepeated and > still using length > > > > import Data.List > > digits=[0..9] > > noneRepeated::[Integer]->Bool > noneRepeated=null.(filter (>1)).(map length).group.sort > > listToNum::[Integer]->Integer > listToNum = (foldl (\a x->10*a+x) 0).reverse Doesn't really matter, but try to acquire the habit of using foldl' rather than foldl (unless you need foldl for its additional laziness). You'll run into fewer laziness leaks that way. > > check::[Integer]->Bool > check ds= and [noneRepeated ds, (listToNum ds) `mod` l==0] > where l=fromIntegral $ length ds Use (&&) if you have only two tests. > > nextlevel::[[Integer]]->[[Integer]] > nextlevel dss=filter (check) [d:ds | ds<-dss,d<-digits] Why not move the checks into the generation, nextlevel dss = filter ((== 0) . (`mod` l) . listToNum) [d:ds | ds <- dss, d <- digits, d `notElem` ds] where l = 1 + length (head dss) or nextlevel dss = let l = 1 + length (head dss) in [d:ds | ds <- dss, let n = 10*listToNum ds , d <- digits, d `notElem` ds, (n+d) `mod` l == 0] ? At least the d `notElem` ds seems very natural here (and it's more efficient, too). > > main=do > dss<-runlevel 10 0 [[]] > print $ map (listToNum) dss > > runlevel 0 b dds=return dds > runlevel a b dds=do > let dds'=nextlevel dds > putStrLn $ "Level "++(show (b+1))++": "++(show $ length dds')++" > matches" > print $ map (listToNum) dds' > runlevel (a-1) (b+1) dds' From joerg.rudnick at t-online.de Thu Feb 25 20:54:57 2010 From: joerg.rudnick at t-online.de (Nick Rudnick) Date: Thu Feb 25 20:25:26 2010 Subject: [Haskell-cafe] hdbc-mysql fails to compile In-Reply-To: <20100225195149.GA30084@fairlight.lan> References: <20100225190134.GA30023@fairlight.lan> <20100225195149.GA30084@fairlight.lan> Message-ID: <4B8729F1.5070804@t-online.de> Hi Thomas, up to 3/3/2010 I am looking after nearly 100 Haskell newbies in their project end phase -- but Marc Weber promised to kick my ass in time so I look after the hsql-XXX repos. Anyway, I just uploaded 1.8.1, since it seems to work. Cheers, Nick Thomas Girod wrote: > replying to myself. there is only one line to fix in Setup.lhs > > > (mysqlConfigProg, _) <- requireProgram verbosity > mysqlConfigProgram AnyVersion (withPrograms lbi) > > > becomes : > > > (mysqlConfigProg, _) <- requireProgram verbosity > mysqlConfigProgram (withPrograms lbi) > > > obviously the new cabal version makes a difference between > "requireProgram" and "requireProgramVersion" > > > On Thu, Feb 25, 2010 at 08:01:34PM +0100, Thomas Girod wrote: > >> Hi there. Looks like hdbc-mysql cannot compile against GHC-6.12 -- >> confirmed by the hackage build logs. [1] >> >> anyone know a way to dodge the problem ? >> >> cheers, >> >> Tom >> >> [1] >> http://hackage.haskell.org/packages/archive/HDBC-mysql/0.6/logs/failure/ghc-6.12 >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100225/c180a61c/attachment.html From ryani.spam at gmail.com Thu Feb 25 21:42:10 2010 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Feb 25 21:12:30 2010 Subject: [Haskell-cafe] Multiple Interpretations for a monad? In-Reply-To: <3e1162e61002250750n90f269am450cb9d7f18e5b37@mail.gmail.com> References: <4B869154.3020104@web.de> <3e1162e61002250750n90f269am450cb9d7f18e5b37@mail.gmail.com> Message-ID: <2f9b2d31002251842h2c7e9d34h7720daa187489c0f@mail.gmail.com> To take this a step further, there is the DSL: get :: m S put :: S -> m () and the concrete implementation m = State S Of course, there are other monads which implement this DSL as well: m = StateT S IO m = Prompt StatePrompt with data StatePrompt a where Get :: StatePrompt S Put :: S -> StatePrompt () The "Prompt" solution(1) encodes your program (object of type Prompt StatePrompt a) into a way such that it can be used with *any* interpreter, whether it is the (s -> (a,s)) of State, or lifted into part of some larger DSL, or whatever. For example, to lift into StateT S IO: interpretPrompt :: Prompt StatePrompt a -> StateT S IO a interpretPrompt = runPromptM f where f :: StatePrompt a -> StateT S IO a f Get = get f (Put x) = put x So, I think a better way to describe it is that a DSL could be implemented by many monads, and some monads let you interpret the DSL into another monad. Even StateT is this way, in a sense; you interpret it with runStateT: runStateT myProgram initialState :: IO (S, a) Now you have another program in a different monad (IO) which you need to interpret somehow. -- ryan (1) http://hackage.haskell.org/package/MonadPrompt 2010/2/25 David Leimbach : > Monads aren't necessarily EDSLs by themselves but are often shipped with > functions that provide what would make them an EDSL. ?Take the State monad, > it has at least a get and a put function to work with the state in the > monad. ?That get and put are commands that function only within the domain > of the State monad, and therefore could be thought of as an embedded > language that is used to work with the state encapsulated in the State Monad > computation. > The way I like to think of it, a Monad provides an environment or a context > within which it is very convenient to express an EDSL, and that this style > of coding should be encouraged! ?:-) > Dave > 2010/2/25 G?nther Schmidt >> >> Hi everyone, >> >> in my attempts to remove boilerplate and thus to do more "abstraction" I >> come across a number of interesting things and suggestions. >> >> Especially blog posts from Dan Piponi and also Heinrich Apfelmus. I think >> what they both are saying is that you can construct / implement some sort of >> 2 layered monad which can then have more than one interpretation. >> >> In the responses to one of my posts on DSLs Dan Piponi also points out >> that he considers monads also to be DSLs. It didn't click with me when he >> said it, but reading more of his blog posts made me remember that. >> >> Now I know this is probably something obvious to most haskellers, but to >> me it's not. >> >> Did I understand this correctly so far? >> >> G?nther >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From leimy2k at gmail.com Thu Feb 25 22:23:48 2010 From: leimy2k at gmail.com (David Leimbach) Date: Thu Feb 25 21:54:09 2010 Subject: [Haskell-cafe] haddock installation weirdness? Message-ID: <3e1162e61002251923g37b0edffic8f6dec5c90d67f8@mail.gmail.com> I'm on Mac OS X Snow Leopard, and can't get haddock installed due to the following error: Resolving dependencies... Configuring haddock-2.6.0... Warning: This package indirectly depends on multiple versions of the same package. This is highly likely to cause a compile failure. package haddock-2.6.0 requires Cabal-1.8.0.2 package ghc-6.12.1 requires Cabal-1.8.0.2 package bin-package-db-0.0.0.0 requires Cabal-1.8.0.2 Preprocessing library haddock-2.6.0... Preprocessing executables for haddock-2.6.0... unused terminals: 1 Building haddock-2.6.0... : cannot satisfy -package-id ghc-6.12.1-b691a185e99c62533666d9a28a9e1988: ghc-6.12.1-b691a185e99c62533666d9a28a9e1988 is unusable due to missing or recursive dependencies: Cabal-1.8.0.2-a08510b9460f1b65f9dee06ed53f0650 bin-package-db-0.0.0.0-0c559ebe951f9972c4e6dfe5ebd4ce6a (use -v for more information) cabal: Error: some packages failed to install: haddock-2.6.0 failed during the building phase. The exception was: ExitFailure 1 When I do a "ghc-pkg list | grep Cabal" I get the following: ghc-pkg list | grep Cabal Cabal-1.8.0.2 Cabal-1.8.0.2 I'm wondering if this means I have a copy in my .cabal, and another from GHC,and if that could be causing a problem? I'm trying to work on the Haddock docs for the NineP package I uploaded the other day, and would rather not have to finish uploading before previewing the result :-) Dave -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100225/4328ea14/attachment.html From leimy2k at gmail.com Thu Feb 25 22:31:51 2010 From: leimy2k at gmail.com (David Leimbach) Date: Thu Feb 25 22:02:11 2010 Subject: [Haskell-cafe] Re: haddock installation weirdness? In-Reply-To: <3e1162e61002251923g37b0edffic8f6dec5c90d67f8@mail.gmail.com> References: <3e1162e61002251923g37b0edffic8f6dec5c90d67f8@mail.gmail.com> Message-ID: <3e1162e61002251931y36ae9138i990fe6c55b2b925d@mail.gmail.com> This might be heavy handed but I think I just got over this by clobbering my .ghc directory and redoing cabal install haddock Dave On Thu, Feb 25, 2010 at 7:23 PM, David Leimbach wrote: > I'm on Mac OS X Snow Leopard, and can't get haddock installed due to the > following error: > > Resolving dependencies... > Configuring haddock-2.6.0... > Warning: This package indirectly depends on multiple versions of the same > package. This is highly likely to cause a compile failure. > package haddock-2.6.0 requires Cabal-1.8.0.2 > package ghc-6.12.1 requires Cabal-1.8.0.2 > package bin-package-db-0.0.0.0 requires Cabal-1.8.0.2 > Preprocessing library haddock-2.6.0... > Preprocessing executables for haddock-2.6.0... > unused terminals: 1 > Building haddock-2.6.0... > : cannot satisfy -package-id > ghc-6.12.1-b691a185e99c62533666d9a28a9e1988: > ghc-6.12.1-b691a185e99c62533666d9a28a9e1988 is unusable due to missing > or recursive dependencies: > Cabal-1.8.0.2-a08510b9460f1b65f9dee06ed53f0650 > bin-package-db-0.0.0.0-0c559ebe951f9972c4e6dfe5ebd4ce6a > (use -v for more information) > cabal: Error: some packages failed to install: > haddock-2.6.0 failed during the building phase. The exception was: > ExitFailure 1 > > > When I do a "ghc-pkg list | grep Cabal" I get the following: > > ghc-pkg list | grep Cabal > Cabal-1.8.0.2 > Cabal-1.8.0.2 > > I'm wondering if this means I have a copy in my .cabal, and another from > GHC,and if that could be causing a problem? > > I'm trying to work on the Haddock docs for the NineP package I uploaded the > other day, and would rather not have to finish uploading before previewing > the result :-) > > Dave > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100225/71e6acec/attachment.html From jason.dusek at gmail.com Thu Feb 25 23:48:16 2010 From: jason.dusek at gmail.com (Jason Dusek) Date: Thu Feb 25 23:18:41 2010 Subject: [Haskell-cafe] hmake and hat In-Reply-To: <1267124293.2511.73.camel@localhost> References: <1267124293.2511.73.camel@localhost> Message-ID: <42784f261002252048s247a28c0t6ec715d5ec6c5397@mail.gmail.com> Can you provide a link to something describing the error? -- Jason Dusek From bos at serpentine.com Fri Feb 26 00:13:56 2010 From: bos at serpentine.com (Bryan O'Sullivan) Date: Thu Feb 25 23:44:27 2010 Subject: [Haskell-cafe] vector to uvector and back again In-Reply-To: <201002120844.07078.dan.doel@gmail.com> References: <4B72F3F6.3050506@k-hornz.de> <201002120728.17965.dan.doel@gmail.com> <201002120844.07078.dan.doel@gmail.com> Message-ID: Dan, do you think you might be releasing your port of uvector-algorithms to vector any time soon? I've ported mwc-random to use vector, and I'd like to move statistics (which needs uvector-algorithms) and criterion (ditto) too. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100225/f5896fca/attachment.html From dan.doel at gmail.com Fri Feb 26 01:29:33 2010 From: dan.doel at gmail.com (Dan Doel) Date: Fri Feb 26 00:59:59 2010 Subject: [Haskell-cafe] vector to uvector and back again In-Reply-To: References: <4B72F3F6.3050506@k-hornz.de> <201002120844.07078.dan.doel@gmail.com> Message-ID: <201002260129.33909.dan.doel@gmail.com> On Friday 26 February 2010 12:13:56 am Bryan O'Sullivan wrote: > Dan, do you think you might be releasing your port of uvector-algorithms to > vector any time soon? I've ported mwc-random to use vector, and I'd like to > move statistics (which needs uvector-algorithms) and criterion (ditto) too. I don't want to hold anything up, so I've released the port to vector. It's available on hackage as vector-algorithms 0.3: http://hackage.haskell.org/package/vector-algorithms It's mostly a straight port, so not much new to learn. - There's no ".Array" in the module names anymore. - The Schwartzian transform combinators are gone from Data.Vector.Algorithms.Combinators, because I haven't decided on the best way to handle those yet (the existing implementation won't work on all vectors in the MVector class). Hope that isn't a problem. - There's also a new module D.V.A.Search, which so far implements a couple variations on binary search. It was something I was starting before the switch to vector, so it isn't complete yet. There are some moderate performance regressions on some of the algorithms, but nothing major. Also, the optimizer in 6.12 seems to get very confused when working with IO as the PrimMonad in question, resulting in significantly worse performance. So, I'd recommend sticking with ST, or at least making sure the algorithms are called in ST, with stToIO. HEAD is better on both these fronts, so things should get better in the future. Let me know if there are any issues.* -- Dan * P.S. I just noticed I left the .cabal recommending -O2 and -fvia-c -optc-O3. That's obviously not current since the .cabal is set to compile with -Odph and with the NCG. I'll amend that in a later version. :) From ketil at malde.org Fri Feb 26 02:52:31 2010 From: ketil at malde.org (Ketil Malde) Date: Fri Feb 26 02:23:09 2010 Subject: [Haskell-cafe] Haskell and XML, need some tips from practioners In-Reply-To: <873a0pguie.fsf@gregorycollins.net> (Gregory Collins's message of "Thu, 25 Feb 2010 11:17:13 -0500") References: <4B867E83.6020303@web.de> <873a0pguie.fsf@gregorycollins.net> Message-ID: <87aauwph6o.fsf@malde.org> Gregory Collins writes: > xml: http://hackage.haskell.org/package/xml > hexpat: http://hackage.haskell.org/package/hexpat > HXT: http://hackage.haskell.org/package/hxt > HaXml: http://hackage.haskell.org/package/HaXml After experimenting with a couple of the above, I ended up using tagsoup, which is relatively fast and (very) simple - but useful for just extracting data without validation or any "real" XML stuff. In my case, the files were fairly large, which didn't go down well with the more proper XML parsers I tried. (This may have changed in later times, of course.) -k -- If I haven't seen further, it is by standing in the footprints of giants From tphyahoo at gmail.com Fri Feb 26 04:28:40 2010 From: tphyahoo at gmail.com (Thomas Hartman) Date: Fri Feb 26 03:59:00 2010 Subject: [Haskell-cafe] sendfile leaking descriptors on Linux? In-Reply-To: References: Message-ID: <910ddf451002260128j5e22c3c8jd1625d945612feb5@mail.gmail.com> I believe this might be causing problems for me with patch-tag. me: Like mightybyte, I run my app in a shell loop that will just restart it after a crash. But every once in a while it won't restart because of the busy socket and I need to do a manual restart, killing multiple processes (usually 2). the error I get is: bind: resource busy (Address already in use) This sounds like what is being discussed. I have some questions. > the server will eventually run out of file descriptors How can I tell if I am running out of file descriptors? > If I use the portable build of the sendfile package, everything works fine for hours and hours of this happening. What is the portable build and how do I use it? Do you eventually have troubles here as well? What is the reason to use the linux native build then? speed / more connections per second? thanks for your help! 2010/2/4 Bardur Arantsson : > Hi all, > > I've been using the sendfile package off Hackage, but it seems to be leaking > file descriptors when using the Linux-native build. > > What's happening in my specific case is the following: > > ? 1) client requests a range of a file > ? 2) server starts sending the range > ? 3) client disconnects before receiving the whole file > > This happens over and over with the client requesting different ranges of > the file (so the client does make progress). > > If I use the portable build of the sendfile package, everything works fine > for hours and hours of this happening. > > If I use the Linux-native build of the sendfile package, the server > will eventually run out of file descriptors. According to "lsof" the files > that are being kept open are the data files being sent in 2) above. > > This is on GHC 6.10.x (Ubuntu). > > Is anyone else seeing this? Anyone got any idea what's going on? > > Cheers, > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From aruiz at um.es Fri Feb 26 04:32:02 2010 From: aruiz at um.es (Alberto Ruiz) Date: Fri Feb 26 04:02:32 2010 Subject: [Haskell-cafe] Linear programming in Haskell In-Reply-To: References: <20100216195420.GA26057@kira.casa> <20100216203725.GA30360@kira.casa> <4B7BAAFE.3080303@um.es> <20100218093323.2f1b0003.mle+hs@mega-nerd.com> <4B84FA4C.8040903@um.es> Message-ID: <4B879512.8020302@um.es> Louis Wasserman wrote: > Yo, > > Man, I'd never used FFI before, but it's really not as scary as I'd feared. The FFI is fantastic. We can even use C higher order functions with normal Haskell function arguments... :) > I've implemented a more comprehensive interface to GLPK's simplex solver > and -- rather importantly, for my own needs -- its MIP solver. This > doesn't depend on hmatrix, and in fact, it doesn't require any matrix or > vector manipulation at all -- linear functions are specified as a > straight-up Data.Map from an arbitrary variable type to their coefficients. I like your interface, it is very complete and user friendly. (I used hmatrix because of (my own) laziness, to take advantage of some utilities, but of course it is not really required.) Thanks for your work! Alberto > The library is now available as glpk-hs on hackage. > > Example: > > import Data.LinearProgram.LPMonad > import Data.LinearProgram > import Data.LinearProgram.GLPK > > objFun :: LinFunc String Int > objFun = linCombination [(10, "x1"), (6, "x2"), (4, "x3")] > > lp :: LP String Int > lp = execLPM $ do setDirection Max > setObjective objFun > leqTo (varSum ["x1", "x2", "x3"]) 100 > leqTo (10 *^ var "x1" ^+^ 4 *& "x2" ^+^ 5 *^ var "x3") 600 > -- c *^ var v, c *& v, and linCombination [(c, v)] are all equivalent. > -- ^+^ is the addition operation on linear functions. > leqTo (linCombination [(2, "x1"), (2, "x2"), (6, "x3")]) 300 > varGeq "x1" 0 > varBds "x2" 0 50 > varGeq "x3" 0 > setVarKind "x1" IntVar > setVarKind "x2" ContVar > > main = print =<< glpSolveVars mipDefaults lp > > This requires GLPK to be installed, like below. > > Louis Wasserman > wasserman.louis@gmail.com > http://profiles.google.com/wasserman.louis > > > On Wed, Feb 24, 2010 at 4:07 AM, Alberto Ruiz > wrote: > > I have uploaded to hackage an interface to the simplex algorithm > based on GLPK. It is a very early version, it will probably have > lots of problems. In the future I would like to add support for > integer variables (MIP). Any suggestion is welcome. > > This is an example taken from "glpk-utils": > > http://code.haskell.org/hmatrix/packages/glpk/examples/simplex3.hs > > Documentation: http://perception.inf.um.es/~aruiz/hmatrix-glpk/ > > > Installation: > > $ sudo apt-get install libglpk-dev > $ cabal update > $ cabal install hmatrix-glpk > > If hmatrix is not installed we also need > > $ sudo apt-get install libgsl0-dev liblapack-dev > > I hope it is useful, > Alberto > > > > Erik de Castro Lopo wrote: > > Alberto Ruiz wrote: > > I think that GSL does not include linear programming > solvers, but in the GSL home page there is a reference to > the GLPK package: > > http://www.gnu.org/software/glpk/glpk.html > > I have not used it, but it would be very nice to have a > simple Haskell interface to GLPK (or other similar library) > in hmatrix or as a separate package. I will take a look at this. > > > I used GLPK many years ago and I found it excellent. > > Erik > > > From nomeata at debian.org Fri Feb 26 04:48:51 2010 From: nomeata at debian.org (Joachim Breitner) Date: Fri Feb 26 04:19:15 2010 Subject: [Haskell-cafe] hmake and hat In-Reply-To: <42784f261002252048s247a28c0t6ec715d5ec6c5397@mail.gmail.com> References: <1267124293.2511.73.camel@localhost> <42784f261002252048s247a28c0t6ec715d5ec6c5397@mail.gmail.com> Message-ID: <1267177731.2623.3.camel@localhost> Skipped content of type multipart/mixed-------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: Dies ist ein digital signierter Nachrichtenteil Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100226/a73f979b/attachment.bin From allbery at ece.cmu.edu Fri Feb 26 06:26:54 2010 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Fri Feb 26 05:57:37 2010 Subject: [Haskell-cafe] sendfile leaking descriptors on Linux? In-Reply-To: <910ddf451002260128j5e22c3c8jd1625d945612feb5@mail.gmail.com> References: <910ddf451002260128j5e22c3c8jd1625d945612feb5@mail.gmail.com> Message-ID: <83B57F02-0BA2-4641-AB36-775E5A25054E@ece.cmu.edu> On Feb 26, 2010, at 04:28 , Thomas Hartman wrote: > me: Like mightybyte, I run my app in a shell loop that will just > restart it after a crash. But every once in a while it won't restart > because of the busy socket and I need to do a manual restart, killing > multiple processes (usually 2). > > the error I get is: > > bind: resource busy (Address already in use) This is on application restart? It's not out of file descriptors, it's just the system keeping the socket around (netstat will show it in TIME_WAIT, or possibly in a shutdown negotiation state such as LAST_ACK, FIN_WAIT, etc. TCP lacks *reliable* socket shutdown negotiation). You want to configure the socket with SO_REUSEADDR before trying to bind it (setSocketOption socket ReuseAddr 1). As to the portable version of sendfile, it's because not all systems offer a sendfile() system call. Linux and *BSD do, and can use the native implementation; the portable version emulates sendfile() when it doesn't exist, at the price of additional CPU usage/system load (sendfile() having been created specifically to reduce system load in the common case for web servers). -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100226/cf51dd88/PGP.bin From gerard.michels at ou.nl Fri Feb 26 06:52:36 2010 From: gerard.michels at ou.nl (gmi) Date: Fri Feb 26 06:22:56 2010 Subject: [Haskell-cafe] problem loading package unix-2.3.2.0 while installing hackages on OpenSuse Message-ID: <27717114.post@talk.nabble.com> I have OpenSuse 11.2 running on VMWare and I have recently installed ghc 6.10.4 from the RPM from OpenSuse. Now I want to install cabal. I have downloaded the required packages from hackage and I try to run: runhaskell Setup configure on any of these packages. With option -v I can see an error while linking unix-2.3.2.0. I am no expert on OpenSuse yet. Does anyone know what's happening here? linux-nrvh:/home/gmi/Download/cabal/zlib-0.5.2.0 # runhaskell -f /usr/bin/ghc -v Setup configure --with-compiler=ghc-6.10.4 ... Loading package filepath-1.1.0.2 ... linking ... done. Loading package unix-2.3.2.0 ... Setup: : can't load .so/.DLL for: dl (libdl.so: cannot open shared object file: No such file or directory) -- View this message in context: http://old.nabble.com/problem-loading-package-unix-2.3.2.0-while-installing-hackages-on-OpenSuse-tp27717114p27717114.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From Christian.Maeder at dfki.de Fri Feb 26 07:18:28 2010 From: Christian.Maeder at dfki.de (Christian Maeder) Date: Fri Feb 26 06:48:47 2010 Subject: [Haskell-cafe] Re: Proper round-trip HughesPJ/Parsec for Doubles? In-Reply-To: <15912BE2-5FE5-4694-97F2-791CAA8A2B84@gimbo.org.uk> References: <1CA520E4-F8FA-4237-916C-98CEB93AC4F9@gimbo.org.uk> <4B83F092.20606@dfki.de> <91CFF9A8-8549-45D1-83D8-A9CE167BE536@gimbo.org.uk> <4B852877.9000006@dfki.de> <15912BE2-5FE5-4694-97F2-791CAA8A2B84@gimbo.org.uk> Message-ID: <4B87BC14.9010808@dfki.de> Andy Gimblett schrieb: > Hi Christian, [...] >> It may make sense to use something like readMaybe (which is missing in >> the Prelude) instead of "read" to allow the parser to fail more nicely. > > It seems to be kicking up reasonable errors as it is, e.g.: > > *Main> parse aFloat "" "2e-h" > Left (line 1, column 4): > unexpected "h" > expecting digit yes, this is fine, because you reject "-h", but suppose it was passed to read (due to a programming error). > I haven't seen any uncaught exceptions propagating, if that's what > you're worried about...? Yes, "read" will always work for you. But you could use a parser *almost* as simple as many1 $ oneOf "NaInfity+-.eE0123456789" and ask "readMaybe" if the parsed String can be read as Double. > So here's what I have now: > > float' :: TokenParser st -> GenParser Char st Double > float' t = > do n <- maybeChar "-" > spaces > fs <- choice [symbol t "NaN", > symbol t "Infinity", > do whole <- many1 digit > frac <- option "" $ do char '.' > ds <- many1 digit > return $ '.' : ds > ex <- option "" $ do choice [char 'e', char 'E'] > s <- maybeChar "+-" > ds <- many1 digit > return $ concat ["e", s, ds] > return $ concat [whole, frac, ex] > ] > whiteSpace t > return $ read $ n ++ fs > where maybeChar :: String -> GenParser Char st String > maybeChar as = option "" (choice (map char as) >>= \a -> return > [a]) I would omit handling of spaces (that's a separate lexing step). It's enough to be able to parse those numbers, that are possible results of "show" (for round-trip). "symbol t" could be replaced by "(try . string)" in order to get rid of the TokenParser (that I don't like). Spaces following an initial minus sign are quite unusual and rather indicate that the sign does not belong to number, but that the sign is a separate operation. >>> You can also break it immediately before do, which I think is >>> sometimes more clear. >> >> If not an extra space is added following "do" this leads to an "odd" >> indentation of at least one line. > > I'm curious: which line in the above is indented oddly? Oh, wait: you > don't mean odd as in "strange", do you? You mean odd as in "not even"? > So, e.g. the "spaces" line starts at column 5? What's wrong with that? Right, again a matter of taste. Cheers Christian P.S. below is my parser for tptp numbers (as comparison). It rejects leading zeros, but allows an initial + sign. "fmap read real" would work if the input does not start with + (or is NaN or Infinity). -- | does not allow leading zeros natural :: Parser String natural = string "0" <|> many1 digit decimal :: Parser String decimal = do s <- option "" $ string "+" <|> string "-" ds <- natural return $ s ++ ds real :: Parser String real = do d <- decimal f <- option "" $ do p <- char '.' n <- many1 digit return $ p : n e <- option "" $ do x <- char 'e' <|> char 'E' g <- decimal return $ x : g return $ d ++ f ++ e From tittoassini at gmail.com Fri Feb 26 07:35:57 2010 From: tittoassini at gmail.com (Pasqualino "Titto" Assini) Date: Fri Feb 26 07:06:21 2010 Subject: [Haskell-cafe] do we need types? Message-ID: <2d34474e1002260435v50469206u12ff76a930f04aa0@mail.gmail.com> Hi, just a silly question (or maybe more than one): In Haskell we have data types (Integer,[a],...) as well as type classes (Num, Ord...). But, if we have type classes do we still need types? Why shouldn't the objects that we process be defined only by their 'interfaces' (assuming that a type class is a kind of interface)? Maybe the real question is: are type classes a more primitive concept than data types? And if so, in a language that had only type classes what would a data declaration like the following map to: data List a = Cons a (List a) | Nil And what about pattern matching? Would that still be possible, and what form would it take? And finally, would having only type classes make the type system any simpler? Thanks, titto From daniel.is.fischer at web.de Fri Feb 26 07:39:41 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Fri Feb 26 07:11:58 2010 Subject: [Haskell-cafe] problem loading package unix-2.3.2.0 while installing hackages on OpenSuse In-Reply-To: <27717114.post@talk.nabble.com> References: <27717114.post@talk.nabble.com> Message-ID: <201002261339.41881.daniel.is.fischer@web.de> Am Freitag 26 Februar 2010 12:52:36 schrieb gmi: > I have OpenSuse 11.2 running on VMWare and I have recently installed ghc > 6.10.4 from the RPM from OpenSuse. Now I want to install cabal. I have > downloaded the required packages from hackage and I try to run: In principle, just unpacking the cabal-install package and running bootstrap.sh is far far easier. > runhaskell Setup configure on any of these packages. With option -v I > can see an error while linking unix-2.3.2.0. I am no expert on OpenSuse > yet. Does anyone know what's happening here? > > > linux-nrvh:/home/gmi/Download/cabal/zlib-0.5.2.0 # runhaskell -f > /usr/bin/ghc -v Setup configure --with-compiler=ghc-6.10.4 > ... > Loading package filepath-1.1.0.2 ... linking ... done. > Loading package unix-2.3.2.0 ... Setup: : can't load > .so/.DLL for: dl (libdl.so: cannot open shared object file: No such file > or directory) You seem to not have libdl.so, which is needed by the unix package. Can you confirm this by running $ locate libdl (or $ ls /usr/lib | grep libdl $ ls /lib | grep libdl if you don't have [the rights to run] locate)? If that doesn't show something like /lib/libdl-2.9.so /lib/libdl.so.2 /usr/lib/libdl.a /usr/lib/libdl.so , you'll have to install glibc-devel, which provides /usr/lib/libdl.a and /usr/lib/libdl.so (the others are provided by glibc, but I can't imagine that you haven't that installed). And while you're in YaST, installing software, grab almost every *-devel package you see, unless you're sufficiently sure that you will not need that one - installing one more devel-package a week becomes annoying pretty soon. From tom at lokhorst.eu Fri Feb 26 08:03:48 2010 From: tom at lokhorst.eu (Tom Lokhorst) Date: Fri Feb 26 07:34:32 2010 Subject: [Haskell-cafe] do we need types? In-Reply-To: <2d34474e1002260435v50469206u12ff76a930f04aa0@mail.gmail.com> References: <2d34474e1002260435v50469206u12ff76a930f04aa0@mail.gmail.com> Message-ID: <317ca7671002260503q2b2ec9d7i519f2a28b90b9f57@mail.gmail.com> Together with Sebastiaan Visser, I've been working on a library called AwesomePrelude [1]. This is a library where we try to reimplement the Prelude by replacing all concrete data types with type classes. This way you can have multiple implementations of a "data type". This is our current implementation of a list: > class ListC j where > nil :: j [a] > cons :: j a -> j [a] -> j [a] > list :: j r -> (j a -> j [a] -> j r) -> j [a] -> j r The two constructors (Nil, Cons) have been replaced by two equivalent methods (nil, cons), and the concept of pattern matching for this data type has been replaced by a single method (list). A couple of weeks ago, we presented [2] the current version of the library. Where we have JavaScript instances for the different type classes. E.g: > xs ++ ys Represents a JavaScript AST that concatenates two JavaScript lists. > And finally, would having only type classes make the type system any simpler? In our library, the types definitely don't get simpler, but thats probably because it also still deals with concrete JavaScript data types. - Tom Lokhorst [1]: http://github.com/tomlokhorst/AwesomePrelude [2]: http://tom.lokhorst.eu/2010/02/awesomeprelude-presentation-video On Fri, Feb 26, 2010 at 1:35 PM, Pasqualino "Titto" Assini wrote: > Hi, just a silly question (or maybe more than one): > > > In Haskell we have data types (Integer,[a],...) as well as type > classes (Num, Ord...). > > But, if we have type classes do we still need types? > > > Why shouldn't the objects that we process be defined only by their > 'interfaces' (assuming that a type class is a kind of interface)? > > > Maybe the real question is: are type classes a more primitive concept > than data types? > > And if so, in a language that had only type classes what would a data > declaration like the following map to: > > data List a = Cons a (List a) | Nil > > And what about pattern matching? Would that still be possible, and > what form would it take? > > > And finally, would having only type classes make the type system any simpler? > > > Thanks, > > ? ? ? ? ? ? ? ? ? ? ? ? titto > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From waldmann at imn.htwk-leipzig.de Fri Feb 26 08:07:07 2010 From: waldmann at imn.htwk-leipzig.de (Johannes Waldmann) Date: Fri Feb 26 07:37:41 2010 Subject: [Haskell-cafe] Re: do we need types? References: <2d34474e1002260435v50469206u12ff76a930f04aa0@mail.gmail.com> Message-ID: A type is, well, a type. A type class is a relation between types. The confusion probably comes from OO programming where (interfaces) describe unary relations (= one parameter type classes). (begin rant) I wouldn't easily give up algebraic data types just because OO programmers don't seem know about them - so the re-invent them and call it "composite" pattern... From miguelimo38 at yandex.ru Fri Feb 26 08:23:52 2010 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Fri Feb 26 07:54:39 2010 Subject: [Haskell-cafe] do we need types? In-Reply-To: <2d34474e1002260435v50469206u12ff76a930f04aa0@mail.gmail.com> References: <2d34474e1002260435v50469206u12ff76a930f04aa0@mail.gmail.com> Message-ID: <4B87CB68.70808@yandex.ru> I'd say we don't really need subclasses. I mean, what's the difference: class Eq a where (==) :: a -> a -> Bool instance Eq a => Eq (Maybe a) where Nothing == Nothing = True Just x == Just y = x == y _ == _ = False sort :: Eq a => [a] -> [a] or data Eq a = Eq {eq :: a -> a -> Bool} eqMaybe :: Eq a -> Eq (Maybe a) eqMaybe e = Eq {eq = eqM} where eqM Nothing Nothing = True eqM (Just x) (Just y) = eq e x y eqM _ _ = False sort :: Eq a -> [a] -> [a] Replacing classes with types, we only lose one thing: the compiler won't deduce the right instances for us. I'll trade it for the ability to abstract over them. After all, we CAN deduce the right instances by hand, it's just a finite amount of work (not very big, in my experience). Pasqualino "Titto" Assini wrote: > Hi, just a silly question (or maybe more than one): > > > In Haskell we have data types (Integer,[a],...) as well as type > classes (Num, Ord...). > > But, if we have type classes do we still need types? > > > Why shouldn't the objects that we process be defined only by their > 'interfaces' (assuming that a type class is a kind of interface)? > > > Maybe the real question is: are type classes a more primitive concept > than data types? > > And if so, in a language that had only type classes what would a data > declaration like the following map to: > > data List a = Cons a (List a) | Nil > > And what about pattern matching? Would that still be possible, and > what form would it take? > > > And finally, would having only type classes make the type system any simpler? > > > Thanks, > > titto > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From miguelimo38 at yandex.ru Fri Feb 26 08:25:03 2010 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Fri Feb 26 07:55:54 2010 Subject: [Haskell-cafe] do we need types? In-Reply-To: <4B87CB68.70808@yandex.ru> References: <2d34474e1002260435v50469206u12ff76a930f04aa0@mail.gmail.com> <4B87CB68.70808@yandex.ru> Message-ID: <4B87CBAF.40908@yandex.ru> s/subclasses/classes/ Sorry for the confusion. Miguel Mitrofanov wrote: > I'd say we don't really need subclasses. I mean, what's the difference: > > class Eq a where (==) :: a -> a -> Bool > instance Eq a => Eq (Maybe a) where > Nothing == Nothing = True > Just x == Just y = x == y > _ == _ = False > sort :: Eq a => [a] -> [a] > > or > > data Eq a = Eq {eq :: a -> a -> Bool} > eqMaybe :: Eq a -> Eq (Maybe a) > eqMaybe e = Eq {eq = eqM} where > eqM Nothing Nothing = True > eqM (Just x) (Just y) = eq e x y > eqM _ _ = False > sort :: Eq a -> [a] -> [a] > > Replacing classes with types, we only lose one thing: the compiler won't > deduce the right instances for us. I'll trade it for the ability to > abstract over them. After all, we CAN deduce the right > instances by hand, it's just a finite amount of work (not very big, in > my experience). > > Pasqualino "Titto" Assini wrote: >> Hi, just a silly question (or maybe more than one): >> >> >> In Haskell we have data types (Integer,[a],...) as well as type >> classes (Num, Ord...). >> >> But, if we have type classes do we still need types? >> >> >> Why shouldn't the objects that we process be defined only by their >> 'interfaces' (assuming that a type class is a kind of interface)? >> >> >> Maybe the real question is: are type classes a more primitive concept >> than data types? >> >> And if so, in a language that had only type classes what would a data >> declaration like the following map to: >> >> data List a = Cons a (List a) | Nil >> >> And what about pattern matching? Would that still be possible, and >> what form would it take? >> >> >> And finally, would having only type classes make the type system any >> simpler? >> >> >> Thanks, >> >> titto >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From gerard.michels at ou.nl Fri Feb 26 08:27:33 2010 From: gerard.michels at ou.nl (gmi) Date: Fri Feb 26 07:57:53 2010 Subject: [Haskell-cafe] problem loading package unix-2.3.2.0 while installing hackages on OpenSuse In-Reply-To: <27717114.post@talk.nabble.com> References: <27717114.post@talk.nabble.com> Message-ID: <27718263.post@talk.nabble.com> Thanks a lot. It was all about installing *-devel things. -- View this message in context: http://old.nabble.com/problem-loading-package-unix-2.3.2.0-while-installing-hackages-on-OpenSuse-tp27717114p27718263.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From mauricio.antunes at gmail.com Fri Feb 26 09:19:14 2010 From: mauricio.antunes at gmail.com (=?ISO-8859-1?Q?Maur=ED=ADcio_CA?=) Date: Fri Feb 26 08:49:53 2010 Subject: [Haskell-cafe] Re: do we need types? In-Reply-To: References: <2d34474e1002260435v50469206u12ff76a930f04aa0@mail.gmail.com> Message-ID: > A type class is a relation between types. Yes, but not officially, just de facto: http://hackage.haskell.org/trac/haskell-prime/ticket/90 Best, Maur?cio From daniel.is.fischer at web.de Fri Feb 26 09:31:14 2010 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Fri Feb 26 09:03:30 2010 Subject: GUI (was: Re: [Haskell-cafe] DLL on Windows) In-Reply-To: <1266405430.30462.1360422343@webmail.messagingengine.com> References: <600376291002160633m638099cy846dd3770a3190cf@mail.gmail.com> <4c44d90b1002161755n405fb1dck9343a05ca85b69aa@mail.gmail.com> <1266405430.30462.1360422343@webmail.messagingengine.com> Message-ID: <201002261531.14758.daniel.is.fischer@web.de> Am Mittwoch 17 Februar 2010 12:17:10 schrieb Jeremy O'Donoghue: > You're probably correct about the dependencies. I have never tried to > compile wxHaskell against GHC 6.12.1 > > I'm waiting for Haskell Platform to be released to make the required > changes since (working primarily on Windows) I just don't have time to > create a complete GHC 6.12 installation with most of the HP libraries > (some of which are a pain to get working on Windows). > > wxHaskell will support GHC 6.12.x within a couple of days of release of > a suitable Haskell Platform. > > Regards > Jeremy Beating a dead horse, but today I decided to see whether I could install wxHaskell, all it took was a few edits in some .cabal files and one in wxcore's Setup to make it all build with 6.12.1. Still, it's annoying because you have to unpack everything, edit and cabal install in the unpacked directories. Now since I did that, I could upload new verxions of wxdirect, wxcore and wx to hackage, so others could do a simple cabal install wx. But I would only do that if I get a go-ahead from somebody authorised (since Jeremy uploaded the previous versions, he'd be qualified, I think). Or I could send the edits to Jeremy and let him do the uploading, whatever is preferred. > > On Tue, 16 Feb 2010 17:55 -0800, "Thomas DuBuisson" > > wrote: > > On Tue, Feb 16, 2010 at 3:48 PM, Henk-Jan