From bertram.felgenhauer at googlemail.com Sun Jun 1 00:29:02 2008 From: bertram.felgenhauer at googlemail.com (Bertram Felgenhauer) Date: Sun Jun 1 00:21:54 2008 Subject: [Haskell-cafe] type-level integers using type families In-Reply-To: <48416FA4.7040402@gmail.com> References: <483E1FCF.9000101@gmail.com> <66615E96-5F85-4DAD-A280-1CEBF356B682@cse.unsw.edu.au> <483FEFB0.3060904@di.unipi.it> <48416FA4.7040402@gmail.com> Message-ID: <20080601042902.GA4221@zombie.inf.tu-dresden.de> Peter Gavin wrote: > Roberto Zunino wrote: >> Maybe he wants, given >> cond :: Cond x y z => x -> y -> z >> tt :: True >> true_exp :: a >> false_exp :: <<>> >> that >> cond tt true_exp false_exp :: a >> That is the type of false_exp is "lazily inferred", so that type errors >> do not make inference fail if they show up in an unneeded place. > > Yes, that's exactly what I want, but for type families (not MPTC). I think > it could be done if the type arguments were matched one at a time, across > all visible instances. What do you think of the following idea? Using naive type level natural numbers, > data Zero > newtype Succ a = Succ a Booleans, > data True > data False comparison, > type family (:<:) x y > type instance (Zero :<: Succ a) = True > type instance (Zero :<: Zero ) = False > type instance (Succ a :<: Zero ) = False > type instance (Succ a :<: Succ b) = a :<: b difference, > type family Minus x y > type instance Minus a Zero = a > type instance Minus (Succ a) (Succ b) = Minus a b and a higher order type level conditional, > type family Cond2 x :: (* -> * -> *) -> (* -> * -> *) -> * -> * -> * > type First2 (x :: * -> * -> *) (y :: * -> * -> *) = x > type Second2 (x :: * -> * -> *) (y :: * -> * -> *) = y > type instance Cond2 True = First2 > type instance Cond2 False = Second2 we can define division as follows: > type family Div x y > type DivZero x y = Zero > type DivStep x y = Succ (Div (Minus0 x y) y) > type instance Div x y = Cond2 (x :<: y) DivZero DivStep x y It's not exactly what you asked for, but I believe it gets the effect that you wanted. Enjoy, Bertram From thomas.dubuisson at gmail.com Sun Jun 1 02:11:22 2008 From: thomas.dubuisson at gmail.com (Thomas M. DuBuisson) Date: Sun Jun 1 01:59:44 2008 Subject: [Haskell-cafe] [ANN] Bindings to Xen Control (xenctrl.h) Message-ID: <1212300682.2448.14.camel@Clunker> All, I'm just getting started with hsXenCtrl [1] as both a fun way to play with Xen and become proficient with Haskell FFI. Once I get my community.haskell.org account squared away I'll likely setup a public darcs repo (and a homepage somewhere). As for modules: I intend to expand on the trival FFI bindings in System.Xen.CBindings and there'll be a higher level interface in System.Xen (functions will standardize on returning Either or throwing exceptions, hiding the xc_handle open/close, etc). Typical Disclaimers: The _only_ thing I've actually done with this, just tonight, is pause / unpause domains. API is subject to change! Only my exact build of Xen is sure to work, and no promise even then. TomMD [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hsXenCtrl From dons at galois.com Sun Jun 1 02:31:40 2008 From: dons at galois.com (Don Stewart) Date: Sun Jun 1 02:24:41 2008 Subject: [Haskell-cafe] [ANN] Bindings to Xen Control (xenctrl.h) In-Reply-To: <1212300682.2448.14.camel@Clunker> References: <1212300682.2448.14.camel@Clunker> Message-ID: <20080601063140.GA1200@scytale.galois.com> thomas.dubuisson: > All, > I'm just getting started with hsXenCtrl [1] as both a fun way to play > with Xen and become proficient with Haskell FFI. Once I get my > community.haskell.org account squared away I'll likely setup a public > darcs repo (and a homepage somewhere). > > As for modules: I intend to expand on the trival FFI bindings in > System.Xen.CBindings and there'll be a higher level interface in > System.Xen (functions will standardize on returning Either or throwing > exceptions, hiding the xc_handle open/close, etc). > > Typical Disclaimers: > The _only_ thing I've actually done with this, just tonight, is pause / > unpause domains. API is subject to change! Only my exact build of Xen > is sure to work, and no promise even then. > > TomMD > > [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hsXenCtrl Good stuff. Perhaps the synopsis should include a link or description of the typical use cases/ thinks we might achieve? -- Don From apfelmus at quantentunnel.de Sun Jun 1 03:37:39 2008 From: apfelmus at quantentunnel.de (apfelmus) Date: Sun Jun 1 03:30:40 2008 Subject: [Haskell-cafe] Re: appending an element to a list In-Reply-To: <48414C2B.9010606@daimi.au.dk> References: <483EE208.2010601@inf.fu-berlin.de> <483EF36B.5040100@daimi.au.dk> <48404039.6030605@cisco.com> <48405717.20206@daimi.au.dk> <87r6bja609.fsf@hbox.dyndns.org> <3c4d5adf0805302159o23113ad2sb24754e02789bb06@mail.gmail.com> <48414C2B.9010606@daimi.au.dk> Message-ID: Tillmann Rendel wrote: > Abhay Parvate wrote: >> I think I would like to make another note: when we talk about the complexity >> of a function, we are talking about the time taken to completely evaluate >> the result. Otherwise any expression in haskell will be O(1), since it >> just creates a thunk. > > I don't like this notion of complexity, since it seems not very suited > for the analysis of composite expression in Haskell. > > Is this intuitive view generalizable to arbitrary datatypes (instead of > lists) and formalized somewhere? See also the thread section beginning with http://thread.gmane.org/gmane.comp.lang.haskell.cafe/34398/focus=34435 Regards, apfelmus From vigalchin at gmail.com Sun Jun 1 04:00:27 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Sun Jun 1 03:53:13 2008 Subject: [Haskell-cafe] modelling C in Haskell .. In-Reply-To: References: <5ae4f2ba0805292346y217d799du8a3e097a1e004e7a@mail.gmail.com> <5ae4f2ba0805300029s69b1a1fdn73e07fe17b458b10@mail.gmail.com> Message-ID: <5ae4f2ba0806010100j3788d29bj4aa0f5f4e3a8c5a8@mail.gmail.com> my knowledge of point-free is from category theory. in what sense is Haskell point-free handle namespace pollution? Kind regards, Vasili On Fri, May 30, 2008 at 3:23 AM, Jonathan Cast wrote: > On 30 May 2008, at 12:29 AM, Galchin, Vasili wrote: > > compactness in writing and also namespace pollution .. ;^) >> > > I know what the advantages of C's notation are. But getting the best > notation out of Haskell generally doesn't happen by trying to make your code > look like C. > > So the general answer to questions of the form `C can do x; can Haskell' is > `No'. Don't do it like in C. It won't be idiomatic, it won't be elegant, > and neither of us will like the results. Understand the features of Haskell > that make your program compact, point-free (how Haskell handles namespace > pollution), and elegant and use those. This will require a different > factoring of your program vs. C. Sorry, but that's life. > > jcc > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080601/72642831/attachment.htm From aruiz at um.es Sun Jun 1 06:20:03 2008 From: aruiz at um.es (Alberto Ruiz) Date: Sun Jun 1 06:12:51 2008 Subject: [Haskell-cafe] Re: hmatrix In-Reply-To: References: Message-ID: <484277D3.9020604@um.es> Anatoly Yakovenko wrote: > What is the most efficient way to update a position in a matrix or a > vector? I came up with this: > > updateVector :: Vector Double -> Int -> Double -> Vector Double > updateVector vec pos val = vec `add` v2 > where > v2 = fromList $ (replicate (pos) 0.0) ++ ((val - (vec @> > pos)):(replicate ((dim vec)- pos - 1) 0.0)) > > but this seems pretty inefficient to me. > > thanks, > Anatoly > It is probably more efficient to use subVector and join (implemented by copyArray): updateVector' v pos val | pos == 0 = join [b,c] | pos == dim v -1 = join [a,b] | otherwise = join [a,b,c] where a = subVector 0 pos v b = fromList [val] c = subVector (pos+1) (dim v -pos-1) v > updateVector' (fromList [1,2,3,4,5]) 2 57 5 |> [1.0,2.0,57.0,4.0,5.0] (The three cases are required because empty vectors are not currently allowed.) Something similar can be done for matrices using flatten and reshape. Although vectors and matrices in this library are immutable and intended to be manipulated as a whole by higher level functions, this kind of update functions may often be useful. I will include them soon. Alberto From bertram.felgenhauer at googlemail.com Sun Jun 1 14:44:46 2008 From: bertram.felgenhauer at googlemail.com (Bertram Felgenhauer) Date: Sun Jun 1 14:37:38 2008 Subject: [Haskell-cafe] [ANNOUNCE] git-darcs-import 0.1 Message-ID: <20080601184446.GA27750@zombie.inf.tu-dresden.de> Hi, I'm pleased to announce yet another tool for importing darcs repositories to git. Unlike darcs2git [1] and darcs-to-git [2], it's written in Haskell, on top of the darcs2 source code. The result is a much faster program - it can convert the complete ghc 6.9 branch (without libraries) in less than 15 minutes on my slightly dated machine (Athlon XP 2500+), which is quite fast [3]. Incremental updates work, too. The program is still rough around the edges, and there's some cosmetical work to do, especially with respect to converting author names. The program should recover from most errors, as long as nobody else modifies the destination repository. Nevertheless, it seems quite useable already. I hope somebody finds this useful. You can grab the source at http://int-e.home.tlink.de/haskell/git-darcs-import-0.1.tar.bz2 Look at the README for further information. Credits go to: David Roundy and all contributors for darcs2. The code base is surprisingly pleasant to work with. And of course, Linus Torvalds, Junio Hamano and all other git contributors. Enjoy, Bertram [1] http://repo.or.cz/w/darcs2git.git?a=shortlog [2] http://git.sanityinc.com/?p=darcs-to-git.git [3] http://nominolo.blogspot.com/2008/05/thing-that-should-not-be-or-how-to.html From aeyakovenko at gmail.com Sun Jun 1 14:45:09 2008 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Sun Jun 1 14:37:55 2008 Subject: [Haskell-cafe] Re: hmatrix In-Reply-To: <484277D3.9020604@um.es> References: <484277D3.9020604@um.es> Message-ID: do you have any plans to provide an interface for inplace updates? On Sun, Jun 1, 2008 at 3:20 AM, Alberto Ruiz wrote: > Anatoly Yakovenko wrote: >> >> What is the most efficient way to update a position in a matrix or a >> vector? I came up with this: >> >> updateVector :: Vector Double -> Int -> Double -> Vector Double >> updateVector vec pos val = vec `add` v2 >> where >> v2 = fromList $ (replicate (pos) 0.0) ++ ((val - (vec @> >> pos)):(replicate ((dim vec)- pos - 1) 0.0)) >> >> but this seems pretty inefficient to me. >> >> thanks, >> Anatoly >> > > It is probably more efficient to use subVector and join (implemented by > copyArray): > > updateVector' v pos val > | pos == 0 = join [b,c] > | pos == dim v -1 = join [a,b] > | otherwise = join [a,b,c] > where a = subVector 0 pos v > b = fromList [val] > c = subVector (pos+1) (dim v -pos-1) v > >> updateVector' (fromList [1,2,3,4,5]) 2 57 > 5 |> [1.0,2.0,57.0,4.0,5.0] > > (The three cases are required because empty vectors are not currently > allowed.) > > Something similar can be done for matrices using flatten and reshape. > > Although vectors and matrices in this library are immutable and intended to > be manipulated as a whole by higher level functions, this kind of update > functions may often be useful. I will include them soon. > > Alberto > From pieter at laeremans.org Sun Jun 1 18:18:36 2008 From: pieter at laeremans.org (Pieter Laeremans) Date: Sun Jun 1 18:11:20 2008 Subject: [Haskell-cafe] Ghc / cgi static linking Message-ID: Hello, I'm researching the use of Haskell to replace some perl scripts (in a web app). The app is deployed with a webhosting provider. CGI scripts can be executed => I can use Haskell. I've tried some hello world cgi scripts, compiled them on the same linux the hosting company uses and deployed them. It worked! But I would like to implement a search feature for the website. For Java/php/perl there 's lucene. For haskell there 's holumbus. Unfortunately, sqlite is a requirement for holumbus. It is not installed at the server of the hosting company. Is it possible to staticly link the sqlite3 library using ghc ? And are there other lucene like libs available like holumbus for haskell ? thanks in advance, Pieter -- Pieter Laeremans From dons at galois.com Sun Jun 1 18:26:00 2008 From: dons at galois.com (Don Stewart) Date: Sun Jun 1 18:18:48 2008 Subject: [Haskell-cafe] Ghc / cgi static linking In-Reply-To: References: Message-ID: <20080601222600.GE4759@scytale.galois.com> pieter: > Hello, > > I'm researching the use of Haskell to replace some perl scripts (in a web app). > The app is deployed with a webhosting provider. > > CGI scripts can be executed => I can use Haskell. I've tried some > hello world cgi scripts, compiled them on the same linux > the hosting company uses and deployed them. It worked! > > But I would like to implement a search feature for the website. For > Java/php/perl there 's lucene. > For haskell there 's holumbus. Unfortunately, sqlite is a requirement > for holumbus. It is not installed at the server of the > hosting company. > > Is it possible to staticly link the sqlite3 library using ghc ? Yes, it is entirely possible to statically link entire CGI apps. For example, this simple program, import Database.SQLite main = print "hey, test this" when compiled as $ ghc A.hs --make is dynamically linked against: $ ldd A A: Start End Type Open Ref GrpRef Name 0000000000000000 0000000000000000 exe 1 0 0 A 0000000041a85000 0000000041ee5000 rlib 0 1 0 /usr/local/lib/libsqlite3.so.9.0 0000000049b04000 0000000049f1d000 rlib 0 1 0 /usr/lib/libm.so.2.3 0000000042213000 000000004264f000 rlib 0 1 0 /usr/local/lib/libgmp.so.7.0 0000000047d0e000 00000000481e0000 rlib 0 1 0 /usr/lib/libc.so.42.0 0000000047900000 0000000047900000 rtld 0 1 0 /usr/libexec/ld.so Now, we can just pass some linker flags through to statically link this lot, $ ghc A.hs --make -optl-static -no-recomp $ ldd A ldd: A: not a dynamic executable $ file A A: ELF 64-bit LSB executable, AMD64, version 1, for OpenBSD, statically linked, not stripped I've added this information to the web programming FAQ, haskell.org/haskellwiki/Practical_web_programming_in_Haskell#Deploying_statically_linked_applications Note it also works for fastcgi, which when combined with Haskell's lightweight threads, makes a good option for performance-oriented web apps. -- Don From peteg42 at gmail.com Sun Jun 1 21:27:56 2008 From: peteg42 at gmail.com (Peter Gammie) Date: Sun Jun 1 21:21:09 2008 Subject: [Haskell-cafe] Ghc / cgi static linking In-Reply-To: <20080601222600.GE4759@scytale.galois.com> References: <20080601222600.GE4759@scytale.galois.com> Message-ID: <12F6690C-C370-4C25-B080-ADC3975318EC@gmail.com> On 02/06/2008, at 5:26 AM, Don Stewart wrote: > pieter: > Yes, it is entirely possible to statically link entire CGI apps. You might want to watch out for a bug in GHC 6.8.2 that means GHC's "- static" flag doesn't work. (At least for me, at least on Debian: the "- lpthread" flag is passed before the "-lrt" one, and symbols are left unresolved as a result.) Apparently the near-to-release 6.8.3 will fix this issue. Presumably dons is using a more recent GHC than 6.8.2, or other (BSD?) platforms are not affected. Note also you may have to tweak sundry .cabal files to add "extra- libraries" fields. As an example, I added this to HSQL's PostgreSQL backend to get it to statically link: extra-libraries: pq, crypt, pthread (If anyone cares you need to build PostgreSQL without kerberos as that doesn't seem to statically link any more.) cheers peter -- http://peteg.org/ From dons at galois.com Sun Jun 1 21:31:00 2008 From: dons at galois.com (Don Stewart) Date: Sun Jun 1 21:23:45 2008 Subject: [Haskell-cafe] Ghc / cgi static linking In-Reply-To: <12F6690C-C370-4C25-B080-ADC3975318EC@gmail.com> References: <20080601222600.GE4759@scytale.galois.com> <12F6690C-C370-4C25-B080-ADC3975318EC@gmail.com> Message-ID: <20080602013100.GJ4759@scytale.galois.com> peteg42: > On 02/06/2008, at 5:26 AM, Don Stewart wrote: > > >pieter: > >Yes, it is entirely possible to statically link entire CGI apps. > > You might want to watch out for a bug in GHC 6.8.2 that means GHC's "- > static" flag doesn't work. (At least for me, at least on Debian: the "- > lpthread" flag is passed before the "-lrt" one, and symbols are left > unresolved as a result.) Apparently the near-to-release 6.8.3 will fix > this issue. > > Presumably dons is using a more recent GHC than 6.8.2, or other (BSD?) > platforms are not affected. Yeah, that's the case. > Note also you may have to tweak sundry .cabal files to add "extra- > libraries" fields. As an example, I added this to HSQL's PostgreSQL > backend to get it to statically link: > > extra-libraries: pq, crypt, pthread > > (If anyone cares you need to build PostgreSQL without kerberos as that > doesn't seem to statically link any more.) > Hey Pete, Can you add these caveats to the wiki page? haskell.org/haskellwiki/Practical_web_programming_in_Haskell#Deploying_statically_linked_applications From donn at avvanta.com Sun Jun 1 22:08:38 2008 From: donn at avvanta.com (Donn Cave) Date: Sun Jun 1 22:00:44 2008 Subject: [Haskell-cafe] haskell compiler on NetBSD amd64 In-Reply-To: <20080510093512.GA27361@matstaff04.nuigalway.ie> References: <20080509222119.cfe30daa.donn@avvanta.com> <20080510093512.GA27361@matstaff04.nuigalway.ie> Message-ID: <20080601190838.61e222e3.donn@avvanta.com> On Sat, 10 May 2008 10:35:12 +0100 Emil Skoeldberg wrote: > On Fri, May 09, 2008 at 10:21:19PM -0700, Donn Cave wrote: > > So here I am with 64 bit Athlon hardware, running amd64 > > NetBSD (a.k.a. x86_64), reasonably motivated to compile > > Haskell. > > So, we are in the same boat then! OK, for you and me and probably no one else in the world, I have built 6.8.2, and for a short time I have it on-line - at my ISP's site, http://www.avvanta.com/~donn/ ... append file name, which is ghc-6.8.2-netbsd-amd64.tar.bz2 Size is ca. 54 Mb. When you want to use this to build future ghc releases, you'll probably have to modify libbfd.so to get GNU ar to index one or two of the larger libraries. I believe the release itself will work fine without this mod - ld uses the same library, but I think only ar has the problem. That cost me a lot of time. The other thing that cost me some time was the gmp dist in ghc-6.6.1, which didn't fully configure for the platform. The rest was reasonably straightforward. I built 6.6.1 .hc files on OpenBSD. -- Donn Cave From dons at galois.com Sun Jun 1 22:34:10 2008 From: dons at galois.com (Don Stewart) Date: Sun Jun 1 22:27:22 2008 Subject: [Haskell-cafe] haskell compiler on NetBSD amd64 In-Reply-To: <20080601190838.61e222e3.donn@avvanta.com> References: <20080509222119.cfe30daa.donn@avvanta.com> <20080510093512.GA27361@matstaff04.nuigalway.ie> <20080601190838.61e222e3.donn@avvanta.com> Message-ID: <20080602023410.GK4759@scytale.galois.com> donn: > On Sat, 10 May 2008 10:35:12 +0100 > Emil Skoeldberg wrote: > > > On Fri, May 09, 2008 at 10:21:19PM -0700, Donn Cave wrote: > > > So here I am with 64 bit Athlon hardware, running amd64 > > > NetBSD (a.k.a. x86_64), reasonably motivated to compile > > > Haskell. > > > > So, we are in the same boat then! > > OK, for you and me and probably no one else in the world, I have > built 6.8.2, and for a short time I have it on-line - at my ISP's > site, http://www.avvanta.com/~donn/ ... append file name, which > is ghc-6.8.2-netbsd-amd64.tar.bz2 Size is ca. 54 Mb. > > When you want to use this to build future ghc releases, you'll > probably have to modify libbfd.so to get GNU ar to index one > or two of the larger libraries. I believe the release itself > will work fine without this mod - ld uses the same library, but > I think only ar has the problem. > > That cost me a lot of time. The other thing that cost me some > time was the gmp dist in ghc-6.6.1, which didn't fully configure > for the platform. The rest was reasonably straightforward. > I built 6.6.1 .hc files on OpenBSD. Great work, let's get it up on the download page, http://haskell.org/ghc/download_ghc_682.html -- Don From donn at avvanta.com Sun Jun 1 23:50:12 2008 From: donn at avvanta.com (Donn Cave) Date: Sun Jun 1 23:42:18 2008 Subject: [Haskell-cafe] haskell compiler on NetBSD amd64 In-Reply-To: <20080602023410.GK4759@scytale.galois.com> References: <20080509222119.cfe30daa.donn@avvanta.com> <20080510093512.GA27361@matstaff04.nuigalway.ie> <20080601190838.61e222e3.donn@avvanta.com> <20080602023410.GK4759@scytale.galois.com> Message-ID: <20080601205012.6973f74a.donn@avvanta.com> On Sun, 1 Jun 2008 19:34:10 -0700 Don Stewart wrote: > Great work, let's get it up on the download page, > > http://haskell.org/ghc/download_ghc_682.html > Suits me, but now that I've had a chance to compile a little more Haskell with it, I think I might like to fix up a couple things. I'm not promising to make ghci work, though that would be nice, but mainly I'm talking about linker warnings attached to a couple of "compatibility" functions that got linked in when the more POSIX compliant versions would have been found if e.g. stdlib.h had been included. opendir(), unsetenv(), etc. So if that's agreeable, don't take the file I put on-line, I'll build up another one. thanks -- Donn Cave From thomas.dubuisson at gmail.com Mon Jun 2 00:19:24 2008 From: thomas.dubuisson at gmail.com (Thomas M. DuBuisson) Date: Mon Jun 2 00:07:35 2008 Subject: [Haskell-cafe] [ANN] Bindings to Xen Control (xenctrl.h) In-Reply-To: <20080601063140.GA1200@scytale.galois.com> References: <1212300682.2448.14.camel@Clunker> <20080601063140.GA1200@scytale.galois.com> Message-ID: <1212380364.2448.39.camel@Clunker> Don, I'll throw future work ideas in the next releases cabal. The most obvious doors opened are Haskell rewrites of the current Xen infrastructure (virt-install, xm, xend). Slightly more interesting tasks could be (warning: random thoughts): 1) HAPPS server that can manage Xen domains (without requiring python libs or System.cmd) 2) Network or BSD socket based remote management programs in Haskell. haxr or session-types might be of use here. 3) With the functions that can alter the CPUs availability, more complex rules or sharing arrangements could be implemented. Same concept applies to other resources such as PCI and memory allocation. Seeing as Xen doesn't over-commit memory, a guest VM program that detects low/high memory situations and reports to the host for policy controlled balloning (adjustment of VM allocated memory) would be kind of fun... but probably complete overkill for any user of Xen. Right now I think the bindings are enough for an 'xm' replacement but nothing more. I've over doubled the number of functions bound just now. There will probably be regular releases for the next few weeks as I find time. Thomas On Sat, 2008-05-31 at 23:31 -0700, Don Stewart wrote: > thomas.dubuisson: > > All, > > I'm just getting started with hsXenCtrl [1] as both a fun way to play > > with Xen and become proficient with Haskell FFI. Once I get my > > community.haskell.org account squared away I'll likely setup a public > > darcs repo (and a homepage somewhere). > > > > As for modules: I intend to expand on the trival FFI bindings in > > System.Xen.CBindings and there'll be a higher level interface in > > System.Xen (functions will standardize on returning Either or throwing > > exceptions, hiding the xc_handle open/close, etc). > > > > Typical Disclaimers: > > The _only_ thing I've actually done with this, just tonight, is pause / > > unpause domains. API is subject to change! Only my exact build of Xen > > is sure to work, and no promise even then. > > > > TomMD > > > > [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hsXenCtrl > > Good stuff. Perhaps the synopsis should include a link or description of > the typical use cases/ thinks we might achieve? > > -- Don From abhay.parvate at gmail.com Mon Jun 2 01:04:07 2008 From: abhay.parvate at gmail.com (Abhay Parvate) Date: Mon Jun 2 00:56:51 2008 Subject: [Haskell-cafe] Re: appending an element to a list In-Reply-To: References: <483EE208.2010601@inf.fu-berlin.de> <483EF36B.5040100@daimi.au.dk> <48404039.6030605@cisco.com> <48405717.20206@daimi.au.dk> <87r6bja609.fsf@hbox.dyndns.org> <3c4d5adf0805302159o23113ad2sb24754e02789bb06@mail.gmail.com> <48414C2B.9010606@daimi.au.dk> Message-ID: <3c4d5adf0806012204p25133bdaxbc22955b70f094ff@mail.gmail.com> I somehow thought it would be easy to talk about complexity of calculating individual elements in an infinite list should be sufficient, but that seems to be involved, and my over-generalization doesn't seem to work. Thanks for the link; particularly it has reference to Wadler's papers exactly on this problem. Abhay On Sun, Jun 1, 2008 at 1:07 PM, apfelmus wrote: > Tillmann Rendel wrote: > >> Abhay Parvate wrote: >> >>> I think I would like to make another note: when we talk about the >>> complexity >>> of a function, we are talking about the time taken to completely evaluate >>> the result. Otherwise any expression in haskell will be O(1), since it >>> just creates a thunk. >>> >> >> I don't like this notion of complexity, since it seems not very suited for >> the analysis of composite expression in Haskell. >> >> Is this intuitive view generalizable to arbitrary datatypes (instead of >> lists) and formalized somewhere? >> > > See also the thread section beginning with > > http://thread.gmane.org/gmane.comp.lang.haskell.cafe/34398/focus=34435 > > > > Regards, > apfelmus > > > _______________________________________________ > 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/20080602/ad4530cb/attachment.htm From vigalchin at gmail.com Mon Jun 2 01:07:11 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Mon Jun 2 00:59:54 2008 Subject: [Haskell-cafe] ghc 6.8.2 issue Message-ID: <5ae4f2ba0806012207i2797be95kf773d0cf75d6b39@mail.gmail.com> Hello, I have been developing new code for the "unix" package. I have run into what I think are ghc 6.8.2 anomalies but couldn't see a pattern. Possibly now I do. I have been using the 32-bit x86 ghc binary that I downloaded from http://www.haskell.org and running on Ubuntu Linux. I am pretty I can repeat now. Everything is ok until I do "sudo runhaskell Setup.hs install" which installs a new "unix" package that I just built. Of course the "intall" installs into /usr/local/lib/unix-2.3.0.0/ghc-6.8.2. The "install" seems to destroy some ghc compiler state under /usr/local ... This is of course just a theory. However, once I re-install ghc et. al. from the binary download then things are ok again. I have tried the ghc re-install at least 4 times. Hope I am not misleading anybody .. just trying to help! Kind regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080602/088b1dc1/attachment.htm From yann at kierun.org Mon Jun 2 03:48:21 2008 From: yann at kierun.org (Yann Golanski) Date: Mon Jun 2 03:41:08 2008 Subject: [Haskell-cafe] Re: Images and GUIs in Haskell In-Reply-To: <20080601040910.545853dc@solaris> References: <62728db30805311530x6c28431fwf2615a18fac343cb@mail.gmail.com> <20080601014052.5658743f@solaris> <62728db30805311800s472cc708rf50bd77a70c65eb3@mail.gmail.com> <20080601040910.545853dc@solaris> Message-ID: <20080602074821.GC1271@kierun.org> Quoth Achim Schneider on Sun, Jun 01, 2008 at 04:09:10 +0200 > I would go for GL(U(T)), as it's as good for 2d primitives as SDL will > ever be, has excellent cross-platform support and allows you to go 3d > if you want to. There's also some very decent event handling. You can use R as well. http://www.r-project.org/ -- yann@kierun.org -= H+ =- www.kierun.org PGP: 009D 7287 C4A7 FD4F 1680 06E4 F751 7006 9DE2 6318 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080602/a80df81a/attachment.bin From jules at jellybean.co.uk Mon Jun 2 05:10:16 2008 From: jules at jellybean.co.uk (Jules Bean) Date: Mon Jun 2 05:02:59 2008 Subject: [Haskell-cafe] GHCi panic In-Reply-To: <48406AC1.4090003@btinternet.com> References: <48406AC1.4090003@btinternet.com> Message-ID: <4843B8F8.9070309@jellybean.co.uk> Andrew Coppin wrote: > I don't suppose this will surprise anybody greatly, but... > > Apparently if you write a Haskell module that is 400 KB in size and > defines a single CAF consisting of a 45,000-element [String], GHCi > panics when attempting to load it interpretted, and hits a stack > overflow attempting to load it compiled. qv http://hackage.haskell.org/trac/ghc/ticket/2002 From aruiz at um.es Mon Jun 2 05:37:14 2008 From: aruiz at um.es (Alberto Ruiz) Date: Mon Jun 2 05:29:57 2008 Subject: [Haskell-cafe] Re: hmatrix In-Reply-To: References: <484277D3.9020604@um.es> Message-ID: <4843BF4A.2080800@um.es> Anatoly Yakovenko wrote: > do you have any plans to provide an interface for inplace updates? Yes, I will try to write a simple version of Data.Array.ST... > On Sun, Jun 1, 2008 at 3:20 AM, Alberto Ruiz wrote: >> Anatoly Yakovenko wrote: >>> What is the most efficient way to update a position in a matrix or a >>> vector? I came up with this: >>> >>> updateVector :: Vector Double -> Int -> Double -> Vector Double >>> updateVector vec pos val = vec `add` v2 >>> where >>> v2 = fromList $ (replicate (pos) 0.0) ++ ((val - (vec @> >>> pos)):(replicate ((dim vec)- pos - 1) 0.0)) >>> >>> but this seems pretty inefficient to me. >>> >>> thanks, >>> Anatoly >>> >> It is probably more efficient to use subVector and join (implemented by >> copyArray): >> >> updateVector' v pos val >> | pos == 0 = join [b,c] >> | pos == dim v -1 = join [a,b] >> | otherwise = join [a,b,c] >> where a = subVector 0 pos v >> b = fromList [val] >> c = subVector (pos+1) (dim v -pos-1) v >> >>> updateVector' (fromList [1,2,3,4,5]) 2 57 >> 5 |> [1.0,2.0,57.0,4.0,5.0] >> >> (The three cases are required because empty vectors are not currently >> allowed.) >> >> Something similar can be done for matrices using flatten and reshape. >> >> Although vectors and matrices in this library are immutable and intended to >> be manipulated as a whole by higher level functions, this kind of update >> functions may often be useful. I will include them soon. >> >> Alberto >> > From duncan.coutts at worc.ox.ac.uk Mon Jun 2 06:38:20 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Mon Jun 2 06:28:00 2008 Subject: [Haskell-cafe] ghc 6.8.2 issue In-Reply-To: <5ae4f2ba0806012207i2797be95kf773d0cf75d6b39@mail.gmail.com> References: <5ae4f2ba0806012207i2797be95kf773d0cf75d6b39@mail.gmail.com> Message-ID: <1212403100.15010.133.camel@localhost> On Mon, 2008-06-02 at 00:07 -0500, Galchin, Vasili wrote: > Hello, > > I have been developing new code for the "unix" package. I have > run into what I think are ghc 6.8.2 anomalies but couldn't see a > pattern. Possibly now I do. I have been using the 32-bit x86 ghc > binary that I downloaded from http://www.haskell.org and running on > Ubuntu Linux. I am pretty I can repeat now. Everything is ok until I > do "sudo runhaskell Setup.hs install" which installs a new "unix" > package that I just built. Of course the "intall" installs > into /usr/local/lib/unix-2.3.0.0/ghc-6.8.2. The "install" seems to > destroy some ghc compiler state under /usr/local ... That sounds right. You're replacing the unix-2.3.0.0 library that comes with ghc-6.8.2 with your own version. It is highly unlikely to be ABI compatible with the one you are replacing and so all the other packages that already depends on the existing unix-2.3.0.0 library end up broken. You'd expect this kind of breakage to be exposed as link errors and segfaults. I suggest you do not replace any of the libraries that come with ghc. To be more precise, it is perfectly ok to *add new versions* but it is not ok to *replace existing versions* without rebuilding all the other libs that depend on it. Make sense? So if you really want to make changes to the unix lib, make sure you change the version number too. I also suggest not installing the packages as root, just install them locally. That way you can guarantee you never mess up your ghc install. You would be able to revert to a clean ghc install just by removing your ~/.ghc/$arch/ghc-6.8.2/package.conf file which will unregister *all* locally registered packages. To unregister individual packages use ghc-pkg --user unregister $pkgname Duncan From nominolo at googlemail.com Mon Jun 2 06:42:15 2008 From: nominolo at googlemail.com (Thomas Schilling) Date: Mon Jun 2 06:35:12 2008 Subject: [Haskell-cafe] [ANNOUNCE] git-darcs-import 0.1 In-Reply-To: <20080601184446.GA27750@zombie.inf.tu-dresden.de> References: <20080601184446.GA27750@zombie.inf.tu-dresden.de> Message-ID: <8D4BA8BD-D3A2-4B56-B18E-FD6EA7A81D45@googlemail.com> On 1 jun 2008, at 20.44, Bertram Felgenhauer wrote: > Hi, > > I'm pleased to announce yet another tool for importing darcs > repositories > to git. Unlike darcs2git [1] and darcs-to-git [2], it's written in > Haskell, on top of the darcs2 source code. The result is a much faster > program - it can convert the complete ghc 6.9 branch (without > libraries) > in less than 15 minutes on my slightly dated machine (Athlon XP 2500 > +), > which is quite fast [3]. Incremental updates work, too. > Nice! Do you happen to also have a darcs (or Git) repository somewhere? / Thomas -- Monkey killing monkey killing monkey over pieces of the ground. Silly monkeys give them thumbs they forge a blade And where there's one they're bound to divide it Right in two -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 194 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080602/084b0ebd/PGP.bin From bertram.felgenhauer at googlemail.com Mon Jun 2 08:05:03 2008 From: bertram.felgenhauer at googlemail.com (Bertram Felgenhauer) Date: Mon Jun 2 07:57:51 2008 Subject: [Haskell-cafe] [ANNOUNCE] git-darcs-import 0.1 In-Reply-To: <8D4BA8BD-D3A2-4B56-B18E-FD6EA7A81D45@googlemail.com> References: <20080601184446.GA27750@zombie.inf.tu-dresden.de> <8D4BA8BD-D3A2-4B56-B18E-FD6EA7A81D45@googlemail.com> Message-ID: <20080602120503.GB4258@zombie.inf.tu-dresden.de> Thomas Schilling wrote: > > On 1 jun 2008, at 20.44, Bertram Felgenhauer wrote: [git-darcs-import] > > Nice! Do you happen to also have a darcs (or Git) repository somewhere? I've uploaded my (git) repo to repo.or.cz, see http://repo.or.cz/w/git-darcs-import.git Patches are welcome. enjoy, Bertram From devriese at cs.tcd.ie Mon Jun 2 09:05:11 2008 From: devriese at cs.tcd.ie (Edsko de Vries) Date: Mon Jun 2 08:57:56 2008 Subject: [Haskell-cafe] hs-plugins compile error Message-ID: <20080602130511.GA24905@netsoc.tcd.ie> Hi, I'm getting the compilation error that is actually logged on Hackage: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/plugins Below is a small diff file that resolves these problems; I don't know what the proper protocol is for submitting these diffs but it may be useful to someone. - E diff -ur plugins-1.2-orig/src/System/Plugins/Env.hs plugins-1.2/src/System/Plugins/Env.hs --- plugins-1.2-orig/src/System/Plugins/Env.hs 2008-06-02 14:57:59.000000000 +0100 +++ plugins-1.2/src/System/Plugins/Env.hs 2008-06-02 15:00:25.000000000 +0100 @@ -73,7 +73,7 @@ import Control.Concurrent.MVar ( MVar(), newMVar, withMVar ) -import Distribution.Package +import Distribution.Package hiding (packageName) import Text.ParserCombinators.ReadP import qualified Data.Map as M diff -ur plugins-1.2-orig/src/System/Plugins/PackageAPI.hs plugins-1.2/src/System/Plugins/PackageAPI.hs --- plugins-1.2-orig/src/System/Plugins/PackageAPI.hs 2008-06-02 14:57:59.000000000 +0100 +++ plugins-1.2/src/System/Plugins/PackageAPI.hs 2008-06-02 14:59:49.000000000 +0100 @@ -40,7 +40,7 @@ #if CABAL == 1 || __GLASGOW_HASKELL__ >= 604 import Distribution.InstalledPackageInfo -import Distribution.Package +import Distribution.Package hiding (depends, packageName) #else import System.Plugins.Package #endif diff -ur plugins-1.2-orig/src/System/Plugins/ParsePkgConfCabal.hs plugins-1.2/src/System/Plugins/ParsePkgConfCabal.hs --- plugins-1.2-orig/src/System/Plugins/ParsePkgConfCabal.hs 2008-06-02 14:57:59.000000000 +0100 +++ plugins-1.2/src/System/Plugins/ParsePkgConfCabal.hs 2008-06-02 14:58:56.000000000 +0100 @@ -6,7 +6,7 @@ ) where import Distribution.InstalledPackageInfo -import Distribution.Package +import Distribution.Package hiding (depends) import Distribution.Version import Data.Char ( isSpace, isAlpha, isAlphaNum, isUpper, isDigit ) From richardg at richardg.name Mon Jun 2 09:39:39 2008 From: richardg at richardg.name (Richard Giraud) Date: Mon Jun 2 09:32:24 2008 Subject: [Haskell-cafe] Mutually Recursive Modules Message-ID: <4843F81B.7060808@richardg.name> Hello I'm using GHC 6.8.2 with mutally recursive modules. I'm familiar with how to do simple cases in GHC ({-# SOURCE #-} and .hs-boot files) but I can't figure out how to get it to work for a particular set of modules. Is it known (i.e., proven) that GHC 6.8.2 can compile any set of mutually recursive modules without refactoring? Are there known limitations? Thanks, Richard G. From isaacdupree at charter.net Mon Jun 2 09:55:25 2008 From: isaacdupree at charter.net (Isaac Dupree) Date: Mon Jun 2 09:48:05 2008 Subject: [Haskell-cafe] Mutually Recursive Modules In-Reply-To: <4843F81B.7060808@richardg.name> References: <4843F81B.7060808@richardg.name> Message-ID: <4843FBCD.8000001@charter.net> Richard Giraud wrote: > Hello > > I'm using GHC 6.8.2 with mutally recursive modules. I'm familiar with > how to do simple cases in GHC ({-# SOURCE #-} and .hs-boot files) but I > can't figure out how to get it to work for a particular set of modules. > > Is it known (i.e., proven) that GHC 6.8.2 can compile any set of > mutually recursive modules without refactoring? Are there known > limitations? With the old (6.2 and before) .hi-boot scheme where there was no abstraction in boot-files, it could probably do anything that it could do. But I'm not convinced with .hs-boot... it can resolve one level of cycle, and I don't know how to *prove* that it *can't* do any given thing, but I strongly suspect there are things it can't do. Luckily, it is very often the case that your code will be better off anyway if refactored to have less module recursion. (though not always.) -Isaac From g9ks157k at acme.softbase.org Mon Jun 2 10:08:38 2008 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Mon Jun 2 10:01:32 2008 Subject: [Haskell-cafe] Re: Damnit, we need a CPAN. In-Reply-To: <20080530220930.6dff9dfa@solaris> References: <20080529173830.3aae4434@solaris> <200805301834.16537.g9ks157k@acme.softbase.org> <20080530220930.6dff9dfa@solaris> Message-ID: <200806021608.39009.g9ks157k@acme.softbase.org> Am Freitag, 30. Mai 2008 22:09 schrieb Achim Schneider: > [?] > I'm generally very interested in declarative GUI programming, but not > nearly enough acquainted with the whole topic to judge one project's > approach over the other. I just followed standard scientific evaluation > technique to select the projects to consider: The ones with the most and > most recent activity win. > > So far, my impression is that documentation is severely lacking, but > then I'm too busy watching Babylon 5 right now and did not get more > than half an hour or so looking at grapefruit. Okay, I think we?ll improve API documentation and then make a release, despite Grapefruit not being production quality yet. I hope, you?ll find it useful. :-) Best wishes, Wolfgang From aditya_siram at hotmail.com Mon Jun 2 10:37:11 2008 From: aditya_siram at hotmail.com (Aditya Siram) Date: Mon Jun 2 10:29:57 2008 Subject: [Haskell-cafe] What is the maturity of Haskell Web Frameworks Message-ID: I am building a web-app that, in broad strokes, allows a leader to assign tasks to team members and allows team members to accept/reject/pick tasks that they want to do. I really like Haskell and I would like to use it to implement the solution. Are frameworks like Happs ready? Not so much in terms of documentation, but in functionality and stability. -Deech _________________________________________________________________ Give to a good cause with every e-mail. Join the i?m Initiative from Microsoft. http://im.live.com/Messenger/IM/Join/Default.aspx?souce=EML_WL_ GoodCause From isaacdupree at charter.net Mon Jun 2 10:45:31 2008 From: isaacdupree at charter.net (Isaac Dupree) Date: Mon Jun 2 10:38:12 2008 Subject: [Haskell-cafe] Default definitions for associated type synonyms In-Reply-To: <52f14b210805300710k366731d6w340231d6eef3ef19@mail.gmail.com> References: <52f14b210805300710k366731d6w340231d6eef3ef19@mail.gmail.com> Message-ID: <4844078B.1010201@charter.net> Dreixel wrote: > Hello, > > Does anyone know if it is possible to specify a default definition for an > associated type synonym? When I tried: > > class A a where >> type B a = a >> > > GHC (version 6.9.20080309) told me: "Type declaration in a class must be a > kind signature or synonym default". However, when I look at the parser I see > no way to specify such synonym default. Is this possible? I'm curious... so, cc'ing glasgow-haskell-users mailinglist because the question is more likely to be noticed by relevant people there. > Thanks, > Z? Pedro From stefan at cs.uu.nl Mon Jun 2 10:50:00 2008 From: stefan at cs.uu.nl (Stefan Holdermans) Date: Mon Jun 2 10:42:48 2008 Subject: [Haskell-cafe] Default definitions for associated type synonyms In-Reply-To: <4844078B.1010201@charter.net> References: <52f14b210805300710k366731d6w340231d6eef3ef19@mail.gmail.com> <4844078B.1010201@charter.net> Message-ID: <9AAEC7D1-A1C3-4124-B2B0-E1F9F3E4675D@cs.uu.nl> Isaac, >> Does anyone know if it is possible to specify a default definition >> for an >> associated type synonym? According to http://hackage.haskell.org/trac/ghc/wiki/TypeFunctionsStatus defaults for associated types is still a TODO. Cheers, Stefan From daniel at dbpatterson.com Mon Jun 2 10:57:04 2008 From: daniel at dbpatterson.com (Daniel Patterson) Date: Mon Jun 2 10:47:10 2008 Subject: [Haskell-cafe] What is the maturity of Haskell Web Frameworks In-Reply-To: References: Message-ID: <20080602105704.1e4dc5ed@patagonia.local> You definitely could use HAppS for that, but considering that it sounds like a pretty small/lightweight app, you might want to check out hvac ( http://fmapfixreturn.wordpress.com/2008/03/23/ ), which is a newer (but still surprisingly full-featured) web framework. It is pretty lightweight, and might be easier to get working for your purposes. Daniel On Mon, 2 Jun 2008 09:37:11 -0500 Aditya Siram wrote: > > I am building a web-app that, in broad strokes, allows a leader to assign > tasks to team members and allows team members to accept/reject/pick tasks > that they want to do. > > I really like Haskell and I would like to use it to implement the solution. > Are frameworks like Happs ready? Not so much in terms of documentation, but > in functionality and stability. > > -Deech > _________________________________________________________________ > Give to a good cause with every e-mail. Join the i?m Initiative from > Microsoft. http://im.live.com/Messenger/IM/Join/Default.aspx?souce=EML_WL_ > GoodCause_______________________________________________ Haskell-Cafe mailing > list Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From marco-oweber at gmx.de Mon Jun 2 11:16:36 2008 From: marco-oweber at gmx.de (Marc Weber) Date: Mon Jun 2 11:09:20 2008 Subject: [Haskell-cafe] What is the maturity of Haskell Web Frameworks In-Reply-To: References: Message-ID: <20080602151636.GA20757@gmx.de> On Mon, Jun 02, 2008 at 09:37:11AM -0500, Aditya Siram wrote: > > I am building a web-app that, in broad strokes, allows a leader to assign tasks to team members and allows team members to accept/reject/pick tasks that they want to do. > > I really like Haskell and I would like to use it to implement the solution. Are frameworks like Happs ready? Not so much in terms of documentation, but in functionality and stability. Me too, but in this case if it's only about assigning tasks you should consider using existing solutions such as flysrpay or mantis http://www.mantisbt.org/ Maybe they fit your needs ? mit freundlichem Gruss Marc Weber From nominolo at googlemail.com Mon Jun 2 12:13:33 2008 From: nominolo at googlemail.com (Thomas Schilling) Date: Mon Jun 2 12:06:27 2008 Subject: [Haskell-cafe] Damnit, we need a CPAN. In-Reply-To: <20080529161307.GA17931@scytale.galois.com> References: <20080529173830.3aae4434@solaris> <404396ef0805290847w41cb7635ud6f655a9c096f28e@mail.gmail.com> <20080529110555.3d08fcb6@Eridanus.javasnob.homelinux.net> <20080529161307.GA17931@scytale.galois.com> Message-ID: On 29 maj 2008, at 18.13, Don Stewart wrote: >> Hackage and Cabal are nice, but a command line tool for automatically >> searching Hackage and installing Hackage packages (like the cpan >> program, or easy_install) would be nice. Unless I haven't done my >> homework and this tool exists... >> > > This tool exists. It is called 'cabal-install'. To try out one of > today's new packages: > > $ cabal update > $ cabal install category-extras > Another nice feature: Say you want to hack on the darcs version of a project, but you need to install the dependencies. If the project is Cabalised you can build and install the darcs version as well as all dependencies by calling 'cabal install' with no arguments inside the project directory. $ darcs get $ cd $ cabal install / Thomas -- Push the envelope. Watch it bend. -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 194 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080602/17c7ae5a/PGP.bin From tphyahoo at gmail.com Mon Jun 2 12:42:08 2008 From: tphyahoo at gmail.com (Thomas Hartman) Date: Mon Jun 2 12:34:51 2008 Subject: [Haskell-cafe] cabal install fail for happs-hsp-template Message-ID: <910ddf450806020942n4bc2fac8kc454aeda446b77ee@mail.gmail.com> Can cabal install be made to work for this package? ***** thartman@thartman-laptop:~>sudo cabal install happs-hsp-template [sudo] password for thartman: cabal: internal error: could not construct a valid install plan. The proposed (invalid) plan contained the following problems: Package Cabal is required by several packages, but they require inconsistent versions: package ghc-6.8.2 requires Cabal-1.2.3.0 package plugins-1.2 requires Cabal-1.5.2 thartman@thartman-laptop:~>cabal --version cabal-install version 0.4.7 using version 1.3.11 of the Cabal library thartman@thartman-laptop:~>ghc --version The Glorious Glasgow Haskell Compilation System, version 6.8.2 thartman@thartman-laptop:~>ghc-pkg list | grep -i ghc /usr/local/lib/ghc-6.8.2/package.conf: (ghc-6.8.2), haskell-src-1.0.1.1, haskell98-1.0.1.0, hpc-0.5.0.0, From tphyahoo at gmail.com Mon Jun 2 12:59:24 2008 From: tphyahoo at gmail.com (Thomas Hartman) Date: Mon Jun 2 12:52:06 2008 Subject: [Haskell-cafe] Re: cabal install fail for happs-hsp-template In-Reply-To: <910ddf450806020942n4bc2fac8kc454aeda446b77ee@mail.gmail.com> References: <910ddf450806020942n4bc2fac8kc454aeda446b77ee@mail.gmail.com> Message-ID: <910ddf450806020959i368abde0ud1080acc23734a0b@mail.gmail.com> I just noticed this is also reported as a 6.8 build failure on hackage itself. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/happs-hsp-template 2008/6/2 Thomas Hartman : > Can cabal install be made to work for this package? > ***** > thartman@thartman-laptop:~>sudo cabal install happs-hsp-template > [sudo] password for thartman: > cabal: internal error: could not construct a valid install plan. > The proposed (invalid) plan contained the following problems: > Package Cabal is required by several packages, but they require > inconsistent versions: > package ghc-6.8.2 requires Cabal-1.2.3.0 > package plugins-1.2 requires Cabal-1.5.2 > > > thartman@thartman-laptop:~>cabal --version > cabal-install version 0.4.7 > using version 1.3.11 of the Cabal library > thartman@thartman-laptop:~>ghc --version > The Glorious Glasgow Haskell Compilation System, version 6.8.2 > thartman@thartman-laptop:~>ghc-pkg list | grep -i ghc > /usr/local/lib/ghc-6.8.2/package.conf: > (ghc-6.8.2), haskell-src-1.0.1.1, haskell98-1.0.1.0, hpc-0.5.0.0, > From aeyakovenko at gmail.com Mon Jun 2 13:06:40 2008 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Mon Jun 2 12:59:21 2008 Subject: [Haskell-cafe] Re: hmatrix In-Reply-To: <4843BF4A.2080800@um.es> References: <484277D3.9020604@um.es> <4843BF4A.2080800@um.es> Message-ID: >> do you have any plans to provide an interface for inplace updates? > > Yes, I will try to write a simple version of Data.Array.ST... > I can try to help you, although I still dont quite grok monads. Wouldn't it be more efficient to use StorableArray, so you can cast from and to C? I am not sure how vectors and matrixes are represented in C, but I imagine it should be possible to manipulate them without resorting to copying between haskell and C. From dons at galois.com Mon Jun 2 13:21:31 2008 From: dons at galois.com (Don Stewart) Date: Mon Jun 2 13:14:14 2008 Subject: [Haskell-cafe] What is the maturity of Haskell Web Frameworks In-Reply-To: References: Message-ID: <20080602172131.GA7534@scytale.galois.com> aditya_siram: > > I am building a web-app that, in broad strokes, allows a leader to > assign tasks to team members and allows team members to > accept/reject/pick tasks that they want to do. > > I really like Haskell and I would like to use it to implement the > solution. Are frameworks like Happs ready? Not so much in terms of > documentation, but in functionality and stability. HAppS is nice (see hpaste.org for example, which is nice and simple, and has been running for over a year). Another nice option in Haskell is using something like HStringTemplate or the xhtml combinators with fastcgi hooked into GHC's concurrency mechanisms. You can find *many* more things here, http://hackage.haskell.org/packages/archive/pkg-list.html#cat:Network http://hackage.haskell.org/packages/archive/pkg-list.html#cat:Web From bulat.ziganshin at gmail.com Mon Jun 2 13:21:34 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Jun 2 13:16:45 2008 Subject: [Haskell-cafe] Re: hmatrix In-Reply-To: References: <484277D3.9020604@um.es> <4843BF4A.2080800@um.es> Message-ID: <814976210.20080602212134@gmail.com> Hello Anatoly, >> Yes, I will try to write a simple version of Data.Array.ST... > Wouldn't it be more efficient to use StorableArray, so you can cast there is some difference between them - MutableByteArray# (used for STUArray) is movable Haskell object which is subject to GC while StorableArray has a fixed address and allocated through C malloc(). this makes MBA more appropriate for small arrays while SA should be used for large ones because GC makes memory usage of program 3 times larger -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From dons at galois.com Mon Jun 2 13:24:01 2008 From: dons at galois.com (Don Stewart) Date: Mon Jun 2 13:16:50 2008 Subject: [Haskell-cafe] hs-plugins compile error In-Reply-To: <20080602130511.GA24905@netsoc.tcd.ie> References: <20080602130511.GA24905@netsoc.tcd.ie> Message-ID: <20080602172401.GB7534@scytale.galois.com> Thanks, if possible, could you construct this as a patch against the darcs branch, which lives here: http://code.haskell.org/~dons/code/hs-plugins Cheers, Don devriese: > Hi, > > I'm getting the compilation error that is actually logged on Hackage: > > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/plugins > > Below is a small diff file that resolves these problems; I don't know > what the proper protocol is for submitting these diffs but it may be > useful to someone. > > - E > > diff -ur plugins-1.2-orig/src/System/Plugins/Env.hs plugins-1.2/src/System/Plugins/Env.hs > --- plugins-1.2-orig/src/System/Plugins/Env.hs 2008-06-02 14:57:59.000000000 +0100 > +++ plugins-1.2/src/System/Plugins/Env.hs 2008-06-02 15:00:25.000000000 +0100 > @@ -73,7 +73,7 @@ > > import Control.Concurrent.MVar ( MVar(), newMVar, withMVar ) > > -import Distribution.Package > +import Distribution.Package hiding (packageName) > import Text.ParserCombinators.ReadP > > import qualified Data.Map as M > diff -ur plugins-1.2-orig/src/System/Plugins/PackageAPI.hs plugins-1.2/src/System/Plugins/PackageAPI.hs > --- plugins-1.2-orig/src/System/Plugins/PackageAPI.hs 2008-06-02 14:57:59.000000000 +0100 > +++ plugins-1.2/src/System/Plugins/PackageAPI.hs 2008-06-02 14:59:49.000000000 +0100 > @@ -40,7 +40,7 @@ > > #if CABAL == 1 || __GLASGOW_HASKELL__ >= 604 > import Distribution.InstalledPackageInfo > -import Distribution.Package > +import Distribution.Package hiding (depends, packageName) > #else > import System.Plugins.Package > #endif > diff -ur plugins-1.2-orig/src/System/Plugins/ParsePkgConfCabal.hs plugins-1.2/src/System/Plugins/ParsePkgConfCabal.hs > --- plugins-1.2-orig/src/System/Plugins/ParsePkgConfCabal.hs 2008-06-02 14:57:59.000000000 +0100 > +++ plugins-1.2/src/System/Plugins/ParsePkgConfCabal.hs 2008-06-02 14:58:56.000000000 +0100 > @@ -6,7 +6,7 @@ > ) where > > import Distribution.InstalledPackageInfo > -import Distribution.Package > +import Distribution.Package hiding (depends) > import Distribution.Version > > import Data.Char ( isSpace, isAlpha, isAlphaNum, isUpper, isDigit ) > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From ben.franksen at online.de Mon Jun 2 14:40:14 2008 From: ben.franksen at online.de (Ben Franksen) Date: Mon Jun 2 14:33:09 2008 Subject: [Haskell-cafe] Re: modelling C in Haskell .. References: <5ae4f2ba0805292346y217d799du8a3e097a1e004e7a@mail.gmail.com> <5ae4f2ba0805300029s69b1a1fdn73e07fe17b458b10@mail.gmail.com> <5ae4f2ba0806010100j3788d29bj4aa0f5f4e3a8c5a8@mail.gmail.com> Message-ID: Galchin, Vasili wrote: > my knowledge of point-free is from category theory. in what sense is > Haskell point-free handle namespace pollution? In the sense that you can write e.g. f = g . h instead of f x = g (h x) thereby avoiding the need to give a name the argument to f. Cheers Ben BTW, A: No. Q: Should I include quotations after my reply? From ben.franksen at online.de Mon Jun 2 14:53:30 2008 From: ben.franksen at online.de (Ben Franksen) Date: Mon Jun 2 14:46:22 2008 Subject: [Haskell-cafe] Re: modelling C in Haskell .. References: <5ae4f2ba0805292346y217d799du8a3e097a1e004e7a@mail.gmail.com> Message-ID: Galchin, Vasili wrote: > > typedef struct blah > { > int val1; > > union { > > int val2; > > struct { > > int val3; > > int val4; > } > } > } C_type; > > question: in Haskell, can I embed definition of the "union" inside of the > C typedef, i.e. recursion definition? Or must I have a separate definition > for the "union" which I "instantiate" inside the Haskell "typedef", i.e. > Haskell "data"? No. Each definition of a data type must occur at the top-level. Also, Haskell has only a very weak record system, a deficit that is generally agreed to be one of Haskell's greatest weaknesses. Like jcc, I'd also be interested what concrete problem prompted your question. While I have often found it annoying that in Haskell e.g. record labels are global in scope, I have never encountered a situation where I wanted to have lexically nested data type declarations. Cheers Ben From keith at oreilly.com Mon Jun 2 14:56:46 2008 From: keith at oreilly.com (Keith Fahlgren) Date: Mon Jun 2 14:49:29 2008 Subject: [Haskell-cafe] What is the maturity of Haskell Web Frameworks In-Reply-To: <20080602172131.GA7534@scytale.galois.com> References: <20080602172131.GA7534@scytale.galois.com> Message-ID: <4844426E.7010101@oreilly.com> On 6/2/08 10:21 AM, Don Stewart wrote: > aditya_siram: >> I am building a web-app that, in broad strokes, allows a leader to >> assign tasks to team members and allows team members to >> accept/reject/pick tasks that they want to do. >> >> I really like Haskell and I would like to use it to implement the >> solution. Are frameworks like Happs ready? Not so much in terms of >> documentation, but in functionality and stability. > > HAppS is nice (see hpaste.org for example, which is nice and simple, and > has been running for over a year). > > Another nice option in Haskell is using something like HStringTemplate > or the xhtml combinators with fastcgi hooked into GHC's concurrency > mechanisms. If you're interested in the background of rolling your own web stuff, I like Paul Brown's description of building perpubplat here: http://mult.ifario.us/t/blog HTH, Keith From devriese at cs.tcd.ie Mon Jun 2 15:23:32 2008 From: devriese at cs.tcd.ie (Edsko de Vries) Date: Mon Jun 2 15:16:15 2008 Subject: [Haskell-cafe] hs-plugins compile error In-Reply-To: <20080602172401.GB7534@scytale.galois.com> References: <20080602130511.GA24905@netsoc.tcd.ie> <20080602172401.GB7534@scytale.galois.com> Message-ID: <20080602192332.GB24905@netsoc.tcd.ie> Hi Don, Is this the kind of thing you mean (I'm not really a darcs user; this is the patch created by darcs record): [Hide some names to remove ambiguity errors Edsko de Vries **20080602202001] { hunk ./src/System/Plugins/Env.hs 76 -import Distribution.Package +import Distribution.Package hiding (packageName) hunk ./src/System/Plugins/PackageAPI.hs 43 -import Distribution.Package +import Distribution.Package hiding (depends, packageName) hunk ./src/System/Plugins/ParsePkgConfCabal.hs 9 -import Distribution.Package +import Distribution.Package hiding (depends) } Edsko From ekmett at gmail.com Mon Jun 2 15:25:28 2008 From: ekmett at gmail.com (Edward Kmett) Date: Mon Jun 2 15:18:12 2008 Subject: [Haskell-cafe] Re: [ANN] bloomfilter 1.0 - Fast immutable and mutable Bloom filters In-Reply-To: <4841CFB2.1020203@cs.pdx.edu> References: <48408014.30401@serpentine.com> <20080531005127.4b330ff7@solaris> <20080531202904.45054b49@solaris> <4841CFB2.1020203@cs.pdx.edu> Message-ID: <7fb8f82f0806021225l7bccc5det817cd572b1f0ca14@mail.gmail.com> On Sat, May 31, 2008 at 6:22 PM, Jim Snow wrote: > In practice, one might use something like 32 hash tables. This yields a > false positive rate of 1/(2^32). Their most obvious application is to store > the dictionary for a spell checker in a space-efficient way, though I have a > friend who wrote a paper on using them for router caches. One minor technicality is that you don't actually use k separate hash tables. You use k separate hash functions, and hash using different functions into the same physical table with a goal of having approximately half of the bits in the table set when all of your data is hashed. From jstrait at moonloop.net Mon Jun 2 15:48:12 2008 From: jstrait at moonloop.net (Jon Strait) Date: Mon Jun 2 15:51:46 2008 Subject: [Haskell-cafe] Vancouver Haskell users meeting Message-ID: <48444E7C.7050602@moonloop.net> An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080602/205dcae6/attachment-0001.htm From kr.angelov at gmail.com Mon Jun 2 16:35:22 2008 From: kr.angelov at gmail.com (Krasimir Angelov) Date: Mon Jun 2 16:28:04 2008 Subject: [Haskell-cafe] Implementing ParseChart with Data.Map Message-ID: Hi, I have to write ParseChart implementation with Data.Map/Set. The chart is type like this: type Chart k v = Map k (Set v) now I need operation like: insert :: k -> v -> Chart k v -> Maybe (Chart k v) where the result is (Just _) if the (k,v) is actually added to the chart or Nothing if it was already there and nothing have to be done. The straight forward implementation is: case Map.lookup k chart of Nothing -> Just (Map.insert k (Set.singleton v) chart) Just set | Set.member v set -> Nothing | otherwise -> Just (Map.insert k (Set.insert v set) chart) The problem with this is that both the Map and the Set are traversed twice. The first time from lookup/member and the second time from insert. Does someone have an idea how to do this with the current libraries? There are the Map.updateLookupWithKey and the Map.alter functions: updateLookupWithKey :: Ord k => (k -> a -> Maybe a) -> k -> Map k a -> (Maybe a,Map k a) alter :: Ord k => (Maybe a -> Maybe a) -> k -> Map k a -> Map k a which are the closest that I need. The problem is that the first doesn't allow the client function to be called if there isn't matching key in the map and the second is doesn't allow to return value from the client function. What I really need is an alterLook?p function: alterLook?p :: Ord k => (Maybe a -> (b,Maybe a)) -> k -> Map k a -> (b,Map k a) The chart manipulation is in the tight loop of my application so I need fast code. Any other ideas? Regards, Krasimir From jstrait at moonloop.net Mon Jun 2 16:45:26 2008 From: jstrait at moonloop.net (Jon Strait) Date: Mon Jun 2 16:48:58 2008 Subject: [Haskell-cafe] Vancouver Haskell users meeting Message-ID: <48445BE6.4090108@moonloop.net> Anyone else here from Vancouver (Canada)? I thought it would be great to have a little informal get-together at a local cafe and share how we're currently using Haskell, or really anything (problems, comparisons, useful software tools, etc.) in relation to Haskell. I'm scheduling a meeting for this Thursday, June 5th. for 7PM at Waazubee Cafe - http://www.waazubee.com/content/directions.php (at Commercial Dr. and 1st Ave.) They have wireless internet access. I'll get a table near the back, bring my laptop, and will have a copy of Hudak's SOE book (the front cover is impossible to miss) out on the table. If anyone wants to meet, but this Thursday is not a good day for you, let me know what days are better and we'll move the meeting. If anyone is sure that they will come this Thursday, you might let me know, so I can have an idea about the resistance in changing the day, if needed. Thanks, Jon From dons at galois.com Mon Jun 2 17:09:21 2008 From: dons at galois.com (Don Stewart) Date: Mon Jun 2 17:02:06 2008 Subject: [Haskell-cafe] Vancouver Haskell users meeting In-Reply-To: <48445BE6.4090108@moonloop.net> References: <48445BE6.4090108@moonloop.net> Message-ID: <20080602210921.GC7820@scytale.galois.com> jstrait: > Anyone else here from Vancouver (Canada)? I thought it would be great > to have a little informal get-together at a local cafe and share how > we're currently using Haskell, or really anything (problems, > comparisons, useful software tools, etc.) in relation to Haskell. > > I'm scheduling a meeting for this Thursday, June 5th. for 7PM at > Waazubee Cafe - > http://www.waazubee.com/content/directions.php (at Commercial Dr. and > 1st Ave.) > > They have wireless internet access. I'll get a table near the back, > bring my laptop, and will have a copy of Hudak's SOE book (the front > cover is impossible to miss) out on the table. > > If anyone wants to meet, but this Thursday is not a good day for you, > let me know what days are better and we'll move the meeting. If anyone > is sure that they will come this Thursday, you might let me know, so I > can have an idea about the resistance in changing the day, if needed. Great! I've added these details to the events listing on http://haskell.org From ndmitchell at gmail.com Mon Jun 2 18:07:55 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Mon Jun 2 18:00:46 2008 Subject: [Haskell-cafe] Implementing ParseChart with Data.Map In-Reply-To: References: Message-ID: <404396ef0806021507r312db11ak8eefb6e4087afccf@mail.gmail.com> Hi Krasimir, > insert :: k -> v -> Chart k v -> Maybe (Chart k v) > > where the result is (Just _) if the (k,v) is actually added to the > chart or Nothing if it was already there and nothing have to be done. insertLookupWithKey :: Ord k => (k -> a -> a -> a) -> k -> a -> Map k a -> (Maybe a, Map k a) This should provide the information you need, without the double traversal of the data structure. Thanks Neil From tphyahoo at gmail.com Mon Jun 2 18:15:50 2008 From: tphyahoo at gmail.com (Thomas Hartman) Date: Mon Jun 2 18:08:31 2008 Subject: [Haskell-cafe] hs-plugins compile error In-Reply-To: <20080602192332.GB24905@netsoc.tcd.ie> References: <20080602130511.GA24905@netsoc.tcd.ie> <20080602172401.GB7534@scytale.galois.com> <20080602192332.GB24905@netsoc.tcd.ie> Message-ID: <910ddf450806021515x4864ec26obeb735f2a53ea9fe@mail.gmail.com> after darcs record, darcs send -o file.patch and then send file.patch via email to the maintainer. 2008/6/2 Edsko de Vries : > Hi Don, > > Is this the kind of thing you mean (I'm not really a darcs user; this is > the patch created by darcs record): > > [Hide some names to remove ambiguity errors > Edsko de Vries **20080602202001] { > hunk ./src/System/Plugins/Env.hs 76 > -import Distribution.Package > +import Distribution.Package hiding (packageName) > hunk ./src/System/Plugins/PackageAPI.hs 43 > -import Distribution.Package > +import Distribution.Package hiding (depends, packageName) > hunk ./src/System/Plugins/ParsePkgConfCabal.hs 9 > -import Distribution.Package > +import Distribution.Package hiding (depends) > } > > Edsko > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From duncan.coutts at worc.ox.ac.uk Mon Jun 2 18:28:29 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Mon Jun 2 18:17:52 2008 Subject: [Haskell-cafe] Implementing ParseChart with Data.Map In-Reply-To: References: Message-ID: <1212445709.15010.144.camel@localhost> On Mon, 2008-06-02 at 22:35 +0200, Krasimir Angelov wrote: > The problem with this is that both the Map and the Set are traversed > twice. The first time from lookup/member and the second time from > insert. Does someone have an idea how to do this with the current > libraries? > The chart manipulation is in the tight loop of my application so I > need fast code. Any other ideas? I'm not sure if it helps your application but we had a discussion on #haskell the other day about Data.Map and were talking about a general insert/modify/delete operator like: modify :: k -> Map k e -> (e, Maybe e -> Map k e) so it's a lookup that returns the element at k and also a continuation that lets you rebuild a new map with an altered element. I guess that doesn't account for the element not existing. There's probably a generalisation that does. Duncan From duncan.coutts at worc.ox.ac.uk Mon Jun 2 18:32:21 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Mon Jun 2 18:21:41 2008 Subject: [Haskell-cafe] cabal install fail for happs-hsp-template In-Reply-To: <910ddf450806020942n4bc2fac8kc454aeda446b77ee@mail.gmail.com> References: <910ddf450806020942n4bc2fac8kc454aeda446b77ee@mail.gmail.com> Message-ID: <1212445941.15010.148.camel@localhost> On Mon, 2008-06-02 at 09:42 -0700, Thomas Hartman wrote: > Can cabal install be made to work for this package? > ***** > thartman@thartman-laptop:~>sudo cabal install happs-hsp-template > [sudo] password for thartman: > cabal: internal error: could not construct a valid install plan. > The proposed (invalid) plan contained the following problems: > Package Cabal is required by several packages, but they require > inconsistent versions: > package ghc-6.8.2 requires Cabal-1.2.3.0 > package plugins-1.2 requires Cabal-1.5.2 The package deps are not actually inconsistent, the problem is that the current cabal-install dependency resolution algorithm is completely naive and comes up with an invalid install plan. I'll let people know when the new dep resolver for cabal-install is ready (hopefully just a few days now). It should address this issue. Duncan From kr.angelov at gmail.com Mon Jun 2 18:33:24 2008 From: kr.angelov at gmail.com (Krasimir Angelov) Date: Mon Jun 2 18:26:04 2008 Subject: [Haskell-cafe] Implementing ParseChart with Data.Map In-Reply-To: <404396ef0806021507r312db11ak8eefb6e4087afccf@mail.gmail.com> References: <404396ef0806021507r312db11ak8eefb6e4087afccf@mail.gmail.com> Message-ID: Not completely! This is a possible implementation: case insertLookupWithKey (\_ -> Set.union) k (Set.singleton v) chart of (Nothing, chart) -> Just chart (Just set, chart) | Set.member v set -> Nothing | otherwise -> Just chart but notice that the set is still traversed twice. On Tue, Jun 3, 2008 at 12:07 AM, Neil Mitchell wrote: > Hi Krasimir, > >> insert :: k -> v -> Chart k v -> Maybe (Chart k v) >> >> where the result is (Just _) if the (k,v) is actually added to the >> chart or Nothing if it was already there and nothing have to be done. > > insertLookupWithKey :: Ord k => (k -> a -> a -> a) -> k -> a -> Map k > a -> (Maybe a, Map k a) > > This should provide the information you need, without the double > traversal of the data structure. > > Thanks > > Neil > From ndmitchell at gmail.com Mon Jun 2 18:41:30 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Mon Jun 2 18:34:11 2008 Subject: [Haskell-cafe] Implementing ParseChart with Data.Map In-Reply-To: References: <404396ef0806021507r312db11ak8eefb6e4087afccf@mail.gmail.com> Message-ID: <404396ef0806021541v6d62f6ffgb198714f105100ff@mail.gmail.com> Hi > case insertLookupWithKey (\_ -> Set.union) k (Set.singleton v) chart of > (Nothing, chart) -> Just chart > (Just set, chart) | Set.member v set -> Nothing > | otherwise -> Just chart > > but notice that the set is still traversed twice. Yes, I missed that bit. I don't see any way of reducing that, other than using an unsafePerformIO and IORef to track the combining function - which is probably a really bad idea. Thanks Neil From ryani.spam at gmail.com Mon Jun 2 18:52:29 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Mon Jun 2 18:45:09 2008 Subject: [Haskell-cafe] [Newbie question] -- Looping stdin until condition is met In-Reply-To: <1212192870.15596.1255975237@webmail.messagingengine.com> References: <20080531002837.0F09A3C8001@banane.furius.ca> <1212192870.15596.1255975237@webmail.messagingengine.com> Message-ID: <2f9b2d30806021552x36e5bcabw2727b04abfa9525f@mail.gmail.com> On 5/30/08, Martin Blais wrote: > Dear Philip, could you point your virtual finger towards a > reference/paper/book/any-bleeping-thing that would help this simple > beginner understand why it doesn't work in this case? I'm trying to > picture why a "read" function that terminates the program would be > useful anywhere. In fact, any library function other than something like > UNIX's "exit" or "kill" which terminates my program is not really > welcome in any of my computer programs, but then again, I haven't yet > been illuminated by the genie of pure functional languages. A reference > would be awesome. As others have pointed out, the reason why it doesn't work is due to lazy evaluation; the exception is "hidden" in a pure value and isn't triggered until some other bit of code causes the pure value to be evaluated. You can force the exception to be generated in your catch block by using "seq" (or "$!", which is implemented using "seq"). This forces the evaluation to happen at that point, although there are a lot of gotchas involved; for Int it works fine, though. Your question, then, requires asking "why would you want to hide an exception in a pure value"? The answer to that is quite interesting, but here's a simpler example that might enlighten you: head :: [a] -> a head (x:_) = x head _ = error "head: empty list" Just as you are required to prove before calling "head" that you aren't passing an empty list, for your program to be total, you should prove before calling "read" that the string parses properly. If you can't provide that proof (because, in this case, the string is provided by the user), you should be using another function for parsing. Don suggested "reads" to implement "maybeRead", which seems like a great idea to me. -- ryan From ndmitchell at gmail.com Mon Jun 2 19:07:32 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Mon Jun 2 19:00:13 2008 Subject: [Haskell-cafe] [Newbie question] -- Looping stdin until condition is met In-Reply-To: <20080530235828.GI25572@scytale.galois.com> References: <20080531002837.0F09A3C8001@banane.furius.ca> <20080530235828.GI25572@scytale.galois.com> Message-ID: <404396ef0806021607x4b679180i8c3ec5255f2fe8e5@mail.gmail.com> Hi > The best thing to do is bypass read and use 'reads' to define your > own safe read. > > maybeRead :: Read a => String -> Maybe a > maybeRead s = case reads s of > [(x, "")] -> Just x > _ -> Nothing Or just use the Safe package: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/safe http://hackage.haskell.org/packages/archive/safe/0.2/doc/html/Safe.html#v%3AreadMay Thanks Neil From vigalchin at gmail.com Tue Jun 3 00:11:54 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Tue Jun 3 00:04:39 2008 Subject: [Haskell-cafe] ghc 6.8.2 issue In-Reply-To: <1212403100.15010.133.camel@localhost> References: <5ae4f2ba0806012207i2797be95kf773d0cf75d6b39@mail.gmail.com> <1212403100.15010.133.camel@localhost> Message-ID: <5ae4f2ba0806022111l33fecf27xfbd6ee5f7dabf35f@mail.gmail.com> Hi Duncan, Not sure I agree the behavior is ok. E.g. here is a build of mmap: vigalchin@ubuntu:~/FTP/Haskell/bytestring-mmap-0.2.0$ runhaskell Setup.lhs clean cleaning... vigalchin@ubuntu:~/FTP/Haskell/bytestring-mmap-0.2.0$ runhaskell Setup.lhs configure Configuring bytestring-mmap-0.2.0... vigalchin@ubuntu:~/FTP/Haskell/bytestring-mmap-0.2.0$ runhaskell Setup.lhs build Preprocessing library bytestring-mmap-0.2.0... Building bytestring-mmap-0.2.0... [1 of 3] Compiling System.IO.Posix.MMap.Internal ( System/IO/Posix/MMap/Internal.hs, dist/build/System/IO/Posix/MMap/Internal.o ) [2 of 3] Compiling System.IO.Posix.MMap.Lazy ( System/IO/Posix/MMap/Lazy.hs, dist/build/System/IO/Posix/MMap/Lazy.o ) [3 of 3] Compiling System.IO.Posix.MMap ( System/IO/Posix/MMap.hs, dist/build/System/IO/Posix/MMap.o ) /usr/bin/ar: creating dist/build/libHSbytestring-mmap-0.2.0.a at this point rebuild and install the "unix" package ... vigalchin@ubuntu:~/FTP/Haskell/bytestring-mmap-0.2.0$ runhaskell Setup.lhs clean cleaning... vigalchin@ubuntu:~/FTP/Haskell/bytestring-mmap-0.2.0$ runhaskell Setup.lhs configure Configuring bytestring-mmap-0.2.0... vigalchin@ubuntu:~/FTP/Haskell/bytestring-mmap-0.2.0$ runhaskell Setup.lhs build Setup.lhs: error reading dist/setup-config; run "setup configure" command? "dist/setup-config" is not being populated at the end. In your response below, are you saying that teh segfaults occur because ghc itself relies on the "unix" package? Thanks, Vasili On Mon, Jun 2, 2008 at 5:38 AM, Duncan Coutts wrote: > > On Mon, 2008-06-02 at 00:07 -0500, Galchin, Vasili wrote: > > Hello, > > > > I have been developing new code for the "unix" package. I have > > run into what I think are ghc 6.8.2 anomalies but couldn't see a > > pattern. Possibly now I do. I have been using the 32-bit x86 ghc > > binary that I downloaded from http://www.haskell.org and running on > > Ubuntu Linux. I am pretty I can repeat now. Everything is ok until I > > do "sudo runhaskell Setup.hs install" which installs a new "unix" > > package that I just built. Of course the "intall" installs > > into /usr/local/lib/unix-2.3.0.0/ghc-6.8.2. The "install" seems to > > destroy some ghc compiler state under /usr/local ... > > That sounds right. You're replacing the unix-2.3.0.0 library that comes > with ghc-6.8.2 with your own version. It is highly unlikely to be ABI > compatible with the one you are replacing and so all the other packages > that already depends on the existing unix-2.3.0.0 library end up broken. > You'd expect this kind of breakage to be exposed as link errors and > segfaults. > > I suggest you do not replace any of the libraries that come with ghc. To > be more precise, it is perfectly ok to *add new versions* but it is not > ok to *replace existing versions* without rebuilding all the other libs > that depend on it. > > Make sense? > > So if you really want to make changes to the unix lib, make sure you > change the version number too. I also suggest not installing the > packages as root, just install them locally. That way you can guarantee > you never mess up your ghc install. You would be able to revert to a > clean ghc install just by removing your > ~/.ghc/$arch/ghc-6.8.2/package.conf file which will unregister *all* > locally registered packages. To unregister individual packages use > ghc-pkg --user unregister $pkgname > > Duncan > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080602/9975f150/attachment.htm From ajb at spamcop.net Tue Jun 3 00:47:30 2008 From: ajb at spamcop.net (ajb@spamcop.net) Date: Tue Jun 3 00:40:20 2008 Subject: [Haskell-cafe] Mutually Recursive Modules In-Reply-To: <4843FBCD.8000001@charter.net> References: <4843F81B.7060808@richardg.name> <4843FBCD.8000001@charter.net> Message-ID: <20080603004730.dzo6cyduskgsgo0w-nwo@webmail.spamcop.net> G'day all. Quoting Isaac Dupree : > Luckily, > it is very often the case that your code will be better off anyway if > refactored to have less module recursion. (though not always.) Nonetheless, I prefer not to leave the robustness of my code to luck. Besides, if I liked structuring code around artificial language restrictions, I'd be programming in C, not Haskell. Cheers, Andrew Bromage From vigalchin at gmail.com Tue Jun 3 01:04:26 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Tue Jun 3 00:57:07 2008 Subject: [Haskell-cafe] ghc 6.8.2 issue In-Reply-To: <1212403100.15010.133.camel@localhost> References: <5ae4f2ba0806012207i2797be95kf773d0cf75d6b39@mail.gmail.com> <1212403100.15010.133.camel@localhost> Message-ID: <5ae4f2ba0806022204u51fb86dbs202783e73bb08573@mail.gmail.com> Duncan, By installing localling, I "runhaskell Setup.hs configure --prefix=$HOME" plus add local path to LD_LIBRARY_PATH and LD_RUN_PATH? On Linux, does ghc use .so's or is it linked statically? Vasili On Mon, Jun 2, 2008 at 5:38 AM, Duncan Coutts wrote: > > On Mon, 2008-06-02 at 00:07 -0500, Galchin, Vasili wrote: > > Hello, > > > > I have been developing new code for the "unix" package. I have > > run into what I think are ghc 6.8.2 anomalies but couldn't see a > > pattern. Possibly now I do. I have been using the 32-bit x86 ghc > > binary that I downloaded from http://www.haskell.org and running on > > Ubuntu Linux. I am pretty I can repeat now. Everything is ok until I > > do "sudo runhaskell Setup.hs install" which installs a new "unix" > > package that I just built. Of course the "intall" installs > > into /usr/local/lib/unix-2.3.0.0/ghc-6.8.2. The "install" seems to > > destroy some ghc compiler state under /usr/local ... > > That sounds right. You're replacing the unix-2.3.0.0 library that comes > with ghc-6.8.2 with your own version. It is highly unlikely to be ABI > compatible with the one you are replacing and so all the other packages > that already depends on the existing unix-2.3.0.0 library end up broken. > You'd expect this kind of breakage to be exposed as link errors and > segfaults. > > I suggest you do not replace any of the libraries that come with ghc. To > be more precise, it is perfectly ok to *add new versions* but it is not > ok to *replace existing versions* without rebuilding all the other libs > that depend on it. > > Make sense? > > So if you really want to make changes to the unix lib, make sure you > change the version number too. I also suggest not installing the > packages as root, just install them locally. That way you can guarantee > you never mess up your ghc install. You would be able to revert to a > clean ghc install just by removing your > ~/.ghc/$arch/ghc-6.8.2/package.conf file which will unregister *all* > locally registered packages. To unregister individual packages use > ghc-pkg --user unregister $pkgname > > Duncan > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080603/b5f7f5f5/attachment.htm From aruiz at um.es Tue Jun 3 03:27:54 2008 From: aruiz at um.es (Alberto Ruiz) Date: Tue Jun 3 03:20:38 2008 Subject: [Haskell-cafe] Re: hmatrix In-Reply-To: References: <484277D3.9020604@um.es> <4843BF4A.2080800@um.es> Message-ID: <4844F27A.2080208@um.es> Anatoly Yakovenko wrote: >>> do you have any plans to provide an interface for inplace updates? >> Yes, I will try to write a simple version of Data.Array.ST... >> > > I can try to help you, although I still dont quite grok monads. > Wouldn't it be more efficient to use StorableArray, so you can cast > from and to C? I am not sure how vectors and matrixes are represented > in C, but I imagine it should be possible to manipulate them without > resorting to copying between haskell and C. > That's right, the correspondence with StorableArray is direct, and efficient conversion can be easily added to the library. I mentioned the idea of Data.Array.ST to have also the possibility of writing pure code, without IO, internally implemented with inplace updates. Alberto From bulat.ziganshin at gmail.com Tue Jun 3 03:37:21 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Jun 3 03:32:52 2008 Subject: [Haskell-cafe] Re: hmatrix In-Reply-To: <4844F27A.2080208@um.es> References: <484277D3.9020604@um.es> <4843BF4A.2080800@um.es> <4844F27A.2080208@um.es> Message-ID: <731290342.20080603113721@gmail.com> Hello Alberto, Tuesday, June 3, 2008, 11:27:54 AM, you wrote: >>> Yes, I will try to write a simple version of Data.Array.ST... > That's right, the correspondence with StorableArray is direct, and > efficient conversion can be easily added to the library. I mentioned the > idea of Data.Array.ST to have also the possibility of writing pure code, > without IO, internally implemented with inplace updates. STRef/STArray operations are just IORef/IOArray operations imported in some way/ you can easily import any other operations to ST monad as far as you use rank-2 types to guarantee that impureness will not escape the runST call. look into unsafeIOtoST function providing unmovable STUArray variant may be a good idea -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From ketil at malde.org Tue Jun 3 04:26:47 2008 From: ketil at malde.org (Ketil Malde) Date: Tue Jun 3 04:19:12 2008 Subject: [Haskell-cafe] [ANN] bloomfilter 1.0 - Fast immutable and mutable Bloom filters In-Reply-To: <910ddf450805310933l668697b6w5816c98c7305c6cd@mail.gmail.com> (Thomas Hartman's message of "Sat\, 31 May 2008 09\:33\:52 -0700") References: <48408014.30401@serpentine.com> <910ddf450805310933l668697b6w5816c98c7305c6cd@mail.gmail.com> Message-ID: <87tzgancu0.fsf@malde.org> "Thomas Hartman" writes: > What kind of speed do you get on your laptop for Data.Set? How much > faster is the bloom filter? I tried to modify examples/Words.hs to use Data.Set insted. The results look like this (first Bloom, second Data.Set, both compiled with -O2): nmd9999:..filter/examples % ./Words 57025 words 0.013326ss to count words Bloom { 4194304 bits } 0.050608ss to construct filter 0.034806ss to query every element nmd9999:..filter/examples % ./WordsS 57025 words 0.013291ss to count words False 0.755115ss to construct filter 0.423289ss to query every element In order to avoid printing the entire set, while still evaluating it, I replaced the printing of the set with printing the result of a search for a non-existing element - I should really use a strict insert, I guess. Anyway, this hopefully gives an indication - looks like a factor of 10 in this case, but it will depend on the size of the data - more data, greater improvement. BTW, Nice work, Bryan! I have plans for this. -k -- If I haven't seen further, it is by standing in the footprints of giants From aruiz at um.es Tue Jun 3 04:56:50 2008 From: aruiz at um.es (Alberto Ruiz) Date: Tue Jun 3 04:52:49 2008 Subject: [Haskell-cafe] Re: hmatrix In-Reply-To: <731290342.20080603113721@gmail.com> References: <484277D3.9020604@um.es> <4843BF4A.2080800@um.es> <4844F27A.2080208@um.es> <731290342.20080603113721@gmail.com> Message-ID: <48450752.4080307@um.es> Bulat Ziganshin wrote: > Hello Alberto, > > Tuesday, June 3, 2008, 11:27:54 AM, you wrote: > >>>> Yes, I will try to write a simple version of Data.Array.ST... >> That's right, the correspondence with StorableArray is direct, and >> efficient conversion can be easily added to the library. I mentioned the >> idea of Data.Array.ST to have also the possibility of writing pure code, >> without IO, internally implemented with inplace updates. > > STRef/STArray operations are just IORef/IOArray operations imported in > some way/ you can easily import any other operations to ST monad as > far as you use rank-2 types to guarantee that impureness will not > escape the runST call. look into unsafeIOtoST function Good! So you can easily "hide" the IO operations in the ST monad. I will definitely look into it. > providing unmovable STUArray variant may be a good idea > > Many thanks Bulat! From duncan.coutts at worc.ox.ac.uk Tue Jun 3 05:05:26 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Tue Jun 3 04:54:45 2008 Subject: [Haskell-cafe] ghc 6.8.2 issue In-Reply-To: <5ae4f2ba0806022111l33fecf27xfbd6ee5f7dabf35f@mail.gmail.com> References: <5ae4f2ba0806012207i2797be95kf773d0cf75d6b39@mail.gmail.com> <1212403100.15010.133.camel@localhost> <5ae4f2ba0806022111l33fecf27xfbd6ee5f7dabf35f@mail.gmail.com> Message-ID: <1212483926.15010.192.camel@localhost> On Mon, 2008-06-02 at 23:11 -0500, Galchin, Vasili wrote: > at this point rebuild and install the "unix" package ... > > vigalchin@ubuntu:~/FTP/Haskell/bytestring-mmap-0.2.0$ runhaskell > Setup.lhs clean > cleaning... > vigalchin@ubuntu:~/FTP/Haskell/bytestring-mmap-0.2.0$ runhaskell > Setup.lhs configure > Configuring bytestring-mmap-0.2.0... > vigalchin@ubuntu:~/FTP/Haskell/bytestring-mmap-0.2.0$ runhaskell > Setup.lhs build > Setup.lhs: error reading dist/setup-config; run "setup configure" > command? > > "dist/setup-config" is not being populated at the end. In your > response below, are you saying that teh segfaults occur because ghc > itself relies on the "unix" package? Something like that yes. You're running runhaskell Setup.lhs and that loads and runs code from the Cabal library. The Cabal library depends on the process library which depends on the unix library. So by replacing the same version of the unix package you're breaking everything else which depends on it, including Cabal and thus runhaskell Setup.lhs. So the solution is to not do that. Don't re-install the exact same version of any of the core libs that come with ghc. Adding new versions is fine, replacing existing versions is not fine because it breaks all the other packages that were already built against that package. Duncan From duncan.coutts at worc.ox.ac.uk Tue Jun 3 05:11:06 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Tue Jun 3 05:00:23 2008 Subject: [Haskell-cafe] ghc 6.8.2 issue In-Reply-To: <5ae4f2ba0806022204u51fb86dbs202783e73bb08573@mail.gmail.com> References: <5ae4f2ba0806012207i2797be95kf773d0cf75d6b39@mail.gmail.com> <1212403100.15010.133.camel@localhost> <5ae4f2ba0806022204u51fb86dbs202783e73bb08573@mail.gmail.com> Message-ID: <1212484266.15010.199.camel@localhost> On Tue, 2008-06-03 at 00:04 -0500, Galchin, Vasili wrote: > Duncan, > > By installing localling, I "runhaskell Setup.hs configure > --prefix=$HOME" plus add local path to LD_LIBRARY_PATH and > LD_RUN_PATH? On Linux, does ghc use .so's or is it linked statically? ghc is linked statically but when you do things like runhaskell Setup.hs you're asking ghc to dynamically load packages. runhaskell/runghc is basically a form of ghci, and ghci does dynamic code loading. If you've broken some of the packages that ghci loads and runs code from then you'll run into problems, mysterious segfaults and the like. As I understand it, in the next version of ghc it will track the ABI of each package so we would be able to detect when people replace packages with ones with the same version but with a different ABI (as you've been doing) and refuse to link or run in those cases rather than running and ending up with segfaults. Duncan From apfelmus at quantentunnel.de Tue Jun 3 05:14:58 2008 From: apfelmus at quantentunnel.de (apfelmus) Date: Tue Jun 3 05:07:51 2008 Subject: [Haskell-cafe] Re: appending an element to a list In-Reply-To: <3c4d5adf0806012204p25133bdaxbc22955b70f094ff@mail.gmail.com> References: <483EE208.2010601@inf.fu-berlin.de> <483EF36B.5040100@daimi.au.dk> <48404039.6030605@cisco.com> <48405717.20206@daimi.au.dk> <87r6bja609.fsf@hbox.dyndns.org> <3c4d5adf0805302159o23113ad2sb24754e02789bb06@mail.gmail.com> <48414C2B.9010606@daimi.au.dk> <3c4d5adf0806012204p25133bdaxbc22955b70f094ff@mail.gmail.com> Message-ID: Abhay Parvate wrote: > I somehow thought it would be easy to talk about complexity of calculating > individual elements in an infinite list should be sufficient, but that seems > to be involved, and my over-generalization doesn't seem to work. Thanks for > the link; particularly it has reference to Wadler's papers exactly on this > problem. Note however that Wadler's and similar formalisms are still a unsatisfactory in that they are quite clumsy to work with, it's quite tedious/impossible to analyze examples with a lot of lazy evaluation. But they are a good guideline. In his book about purely functional data structures [1], Okasaki takes a different approach; each node of a data structure is given a debit, a cost to evaluate it. For instance, consider xs = x1 : x2 : x3 : ... : xn : [] 1 1 1 ... 1 1 0 ys = y1 : y2 : y3 : ... : ym : [] 1 1 1 ... 1 1 0 The numbers below indicate the time it takes to evaluate the node to weak head normal form. For demonstration purposes, I arbitrarily chose 1 for each (:) here. The combined list will then have debits like xs ++ ys = x1 : x2 : x3 : ... : xn : y1 : y2 : y3 : ... : ym : [] 2 2 2 ... 2 2 1 1 1 ... 1 1 0 In other words, the ys list is copied verbatim but each element of xs incurs an additional cost of 1, corresponding to one step in the evaluation of the concatenation with (++). In order to force/inspect a constructor/node, you have to pay off its debits first. In the above example, head (xs ++ ys) would have to pay 2 units of time (one unit for head xs and one for the (++)). Now, the thing about debits is that we can relocate them to the top and only overestimate the total running time if we do that. For instance, we could push all debits to the top xs ++ ys = x1 : x2 : x3 : ... : xn : y1 : y2 : y3 : ... : ym : [] 2n+m 0 0 ... 0 0 0 0 0 ... 0 0 0 so that evaluating head (xs ++ ys) is now estimated to cost (2n+m) units of time while the rest is free/fully evaluated. The above example is rather useless, but consider the case n == m and xs = x1 : x2 : x3 : ... : xn : [] 0 0 0 ... 0 0 0 ys = y1 : y2 : y3 : ... : yn : [] 0 0 0 ... 0 0 0 i.e. two fully evaluated lists of the same length. Then, we have xs ++ reverse ys = x1 : x2 : x3 : ... : xn : yn : y{n-1} : ... : y1 : [] 1 1 1 ... 1 1 n 0 ... 0 0 0 because reversing the list ys is "monolithic", i.e. looking at its head already forces the tail of the list. But now, we can distribute the debits upwards xs ++ reverse ys = x1 : x2 : x3 : ... : xn : yn : y{n-1} : ... : y1 : [] 2 2 2 ... 2 2 0 0 ... 0 0 0 and thereby amortize the cost of reversing the second lists over the n elements of the first list. This is used in the implementation of purely functional queues, see also Okasaki's book. [1]: Chris Okasaki. Purely Function Data Structures. http://www.cs.cmu.edu/~rwh/theses/okasaki.pdf (This is the thesis on which the book is based.) Regards, apfelmus From bulat.ziganshin at gmail.com Tue Jun 3 05:42:11 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Jun 3 05:37:59 2008 Subject: [Haskell-cafe] Re: hmatrix In-Reply-To: <48450752.4080307@um.es> References: <484277D3.9020604@um.es> <4843BF4A.2080800@um.es> <4844F27A.2080208@um.es> <731290342.20080603113721@gmail.com> <48450752.4080307@um.es> Message-ID: <483842413.20080603134211@gmail.com> Hello Alberto, Tuesday, June 3, 2008, 12:56:50 PM, you wrote: > Good! So you can easily "hide" the IO operations in the ST monad. I will > definitely look into it. from implementation POV ST monad is nothing but renamed IO monad which exports only subset of its operations which are guaranteed to safe. or, saying in other words, it's just type hackery around IO monad that provides safe operations it's possible to define ST monad and its operations as following: newtype ST s a = forall s. ST_Constructor (IO a) unsafeIOtoSt action = ST_Constructor action runST (ST_Constructor action) = unsafePerformIO action newtype STRef s a = forall s. STRef (IORef a) readSTRef (STRef ref) = unsafeIOtoSt (readIORef ref) and so on. GHC uses technically (but not ideologically!) different implementation where both monads are specializations of one generic type. while Hugs afair uses exactly this approach. you may also look at ArrayRef lib which reimplements arrays/refs for both compilers in more unified way anyway, because ST is just IO monad modulo type tricks, you can execute any IO action inside ST by lifting it with unsafeIOtoSt -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From yann at kierun.org Tue Jun 3 06:30:26 2008 From: yann at kierun.org (Yann Golanski) Date: Tue Jun 3 06:23:09 2008 Subject: [Haskell-cafe] Rotating backdrop (aka learning Haskell) In-Reply-To: <20080520081557.GA18833@kierun.org> References: <20080520081557.GA18833@kierun.org> Message-ID: <20080603103026.GA10131@kierun.org> First version is available at: http://www.kierun.org/backdropper-1.0.tbz2 It is minimal but does the trick of randomly rotating backgrounds. Features to add are only rotate during work hours, making sure that all images are shown within a day and a nice GUI. Criticism welcome. -- yann@kierun.org -= H+ =- www.kierun.org PGP: 009D 7287 C4A7 FD4F 1680 06E4 F751 7006 9DE2 6318 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080603/3ac7216c/attachment.bin From gale at sefer.org Tue Jun 3 07:45:11 2008 From: gale at sefer.org (Yitzchak Gale) Date: Tue Jun 3 07:37:51 2008 Subject: [Haskell-cafe] Implementing ParseChart with Data.Map In-Reply-To: <404396ef0806021541v6d62f6ffgb198714f105100ff@mail.gmail.com> References: <404396ef0806021507r312db11ak8eefb6e4087afccf@mail.gmail.com> <404396ef0806021541v6d62f6ffgb198714f105100ff@mail.gmail.com> Message-ID: <2608b8a80806030445x5272d3e2o78e3cb4aef6821ed@mail.gmail.com> Krasimir Angelov wrote: >> but notice that the set is still traversed twice. Neil Mitchell wrote: > I don't see any way of reducing that Yeah, it looks like the Data.Set (and Data.IntSet) library is missing the functions insertMember :: Ord a => a -> Set a -> (Bool, Set a) deleteMember :: Ord a => a -> Set a -> (Bool, Set a) analagous to splitMember. It should be easy to write those functions. If you do that for yourself, consider making a patch of them and submitting the patch as a library proposal. But anyway, a set lookup is very cheap, even for a set that is quite large. You may want to try just doing the extra lookup, it might be good enough for you. At least you eliminated the Map lookup. Regards, Yitz From kr.angelov at gmail.com Tue Jun 3 07:54:03 2008 From: kr.angelov at gmail.com (Krasimir Angelov) Date: Tue Jun 3 07:46:43 2008 Subject: [Haskell-cafe] Implementing ParseChart with Data.Map In-Reply-To: <2608b8a80806030445x5272d3e2o78e3cb4aef6821ed@mail.gmail.com> References: <404396ef0806021507r312db11ak8eefb6e4087afccf@mail.gmail.com> <404396ef0806021541v6d62f6ffgb198714f105100ff@mail.gmail.com> <2608b8a80806030445x5272d3e2o78e3cb4aef6821ed@mail.gmail.com> Message-ID: I actually made my own copy of Data.Map and added an extra: alterLook?p :: Ord k => (Maybe a -> (b,Maybe a)) -> k -> Map k a -> (b,Map k a) function. I also changed my data type to: type ParseChart k v = Map k (Map v ()) so I don't have to copy the Data.Set module also. Unfortunately this doesn't give much better performance - 5734 msec instead of 5828 msec. Fortunately I found that there is a way to avoid to use Map at all in one common case. This gave me time about 5024 msec. Regards, Krasimir On 6/3/08, Yitzchak Gale wrote: > Krasimir Angelov wrote: > >> but notice that the set is still traversed twice. > > Neil Mitchell wrote: > > I don't see any way of reducing that > > Yeah, it looks like the Data.Set (and Data.IntSet) library > is missing the functions > > insertMember :: Ord a => a -> Set a -> (Bool, Set a) > deleteMember :: Ord a => a -> Set a -> (Bool, Set a) > > analagous to splitMember. It should be easy to write > those functions. If you do that for yourself, consider > making a patch of them and submitting the patch > as a library proposal. > > But anyway, a set lookup is very cheap, even for a > set that is quite large. You may want to try just doing > the extra lookup, it might be good enough for you. > At least you eliminated the Map lookup. > > Regards, > Yitz > From ahey at iee.org Tue Jun 3 09:28:29 2008 From: ahey at iee.org (Adrian Hey) Date: Tue Jun 3 09:21:13 2008 Subject: [Haskell-cafe] Implementing ParseChart with Data.Map In-Reply-To: References: Message-ID: <484546FD.5050005@iee.org> Hello Krasimir, Krasimir Angelov wrote: > Hi, > > I have to write ParseChart implementation with Data.Map/Set. The chart > is type like this: > > type Chart k v = Map k (Set v) > > now I need operation like: > > insert :: k -> v -> Chart k v -> Maybe (Chart k v) > > where the result is (Just _) if the (k,v) is actually added to the > chart or Nothing if it was already there and nothing have to be done. > The straight forward implementation is: > > case Map.lookup k chart of > Nothing -> Just (Map.insert k (Set.singleton v) chart) > Just set | Set.member v set -> Nothing > | otherwise -> Just (Map.insert k > (Set.insert v set) chart) > You can do this quite easily with the AVL library, something like this (untested code) import Data.Cordering import Data.Tree.AVL type Chart k v = AVL (k, AVL v) insert :: (Ord k, Ord v) => k -> v -> Chart k v -> Maybe (Chart k v) insert k v tk = case genOpenPathWith cmpk tk of EmptyBP pthk -> Just $! insertPath pthk (k, singleton v) tk FullBP pthk tv -> case genOpenPath (compare v) tv of EmptyBP pthv -> let tv' = insertPath pthv v tv in tv' `seq` (Just $! writePath pthk (k, tv') tk) FullBP _ _ -> Nothing where cmpk (k',tv) = case compare k k' of LT -> Lt EQ -> Eq tv GT -> Gt ..or something like that (maybe you don't want all that strictness) The insertPath & writePath functions do involve a second traversal but do not repeat all the comparisons. Also, provided not too much has happened in between, they should be very fast as the nodes on the path are probably still in cache. The important thing is that in the case where Nothing is returned you'll have burned very little heap. Regards -- Adrian Hey From jtod at dcs.gla.ac.uk Tue Jun 3 10:07:33 2008 From: jtod at dcs.gla.ac.uk (John O'Donnell) Date: Tue Jun 3 10:00:43 2008 Subject: [Haskell-cafe] hs-plugins compile error References: <20080602130511.GA24905@netsoc.tcd.ie><20080602172401.GB7534@scytale.galois.com> <20080602192332.GB24905@netsoc.tcd.ie> Message-ID: Hi, What is the status of hs-plugins? I recently tried to install the version plugins-1.2 on hackage, using a Gnu/Linux box with Fedora 9 and ghc-6.8.2, but didn't get past the configure stage (see config.log below). The installation script is invoking gcc with a -V command line argument but according to gcc documentation -V requires an argument. Has anyone managed to get hs-plugins to work? If so, what platform, which version of ghc and gcc, and where did you find the hs-plugins source? Best wishes, John O'Donnell ... from config.log... gcc version 4.3.0 20080428 (Red Hat 4.3.0-8) (GCC) configure:1852: $? = 0 configure:1854: gcc -V &5 gcc: '-V' option must have argument configure:1857: $? = 1 configure:1880: checking for C compiler default output file name configure:1883: gcc conftest.c >&5 conftest.c:9:13: warning: missing terminating " character conftest.c:10: error: stray '\33' in program conftest.c:10: error: expected identifier or '(' before '[' token conftest.c:10:4: error: invalid suffix "h" on integer constant conftest.c:10:9: warning: missing terminating " character conftest.c:10: error: missing terminating " character configure:1886: $? = 1 configure: failed program was: | /* confdefs.h. */ | | #define PACKAGE_NAME "" | #define PACKAGE_TARNAME "" | #define PACKAGE_VERSION "" | #define PACKAGE_STRING "" | #define PACKAGE_BUGREPORT "" | #define LEADING_UNDERSCORE 0 | #define TOP "/home/jtod/system/installs/hs-plugins/hs-plugins-1.2 | ESC[?1034h" | #define WITH_GHC "ghc" | #define GHC_LIB_PATH "/usr/local/lib/ghc-6.8.2" | /* end confdefs.h. */ | | int | main () | { | | ; | return 0; | } configure:1925: error: C compiler cannot create executables -----Original Message----- From: haskell-cafe-bounces@haskell.org on behalf of Edsko de Vries Sent: Mon 2008-06-02 20:23 To: Don Stewart Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] hs-plugins compile error Hi Don, Is this the kind of thing you mean (I'm not really a darcs user; this is the patch created by darcs record): [Hide some names to remove ambiguity errors Edsko de Vries **20080602202001] { hunk ./src/System/Plugins/Env.hs 76 -import Distribution.Package +import Distribution.Package hiding (packageName) hunk ./src/System/Plugins/PackageAPI.hs 43 -import Distribution.Package +import Distribution.Package hiding (depends, packageName) hunk ./src/System/Plugins/ParsePkgConfCabal.hs 9 -import Distribution.Package +import Distribution.Package hiding (depends) } Edsko _______________________________________________ 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/20080603/3d54391b/attachment-0001.htm From darrinth at gmail.com Tue Jun 3 10:35:03 2008 From: darrinth at gmail.com (Darrin Thompson) Date: Tue Jun 3 10:27:41 2008 Subject: [Haskell-cafe] [ANNOUNCE] git-darcs-import 0.1 In-Reply-To: <20080601184446.GA27750@zombie.inf.tu-dresden.de> References: <20080601184446.GA27750@zombie.inf.tu-dresden.de> Message-ID: On Sun, Jun 1, 2008 at 2:44 PM, Bertram Felgenhauer wrote: > Hi, > > I'm pleased to announce yet another tool for importing darcs repositories > to git. Unlike darcs2git [1] and darcs-to-git [2], it's written in > Haskell, on top of the darcs2 source code. The result is a much faster > program - it can convert the complete ghc 6.9 branch (without libraries) > in less than 15 minutes on my slightly dated machine (Athlon XP 2500+), > which is quite fast [3]. Incremental updates work, too. > What's the appeal of this? I personally love git, but I thought all the cool kids at this school used darcs and that was that. -- Darrin From devriese at cs.tcd.ie Tue Jun 3 10:35:16 2008 From: devriese at cs.tcd.ie (Edsko de Vries) Date: Tue Jun 3 10:27:56 2008 Subject: [Haskell-cafe] hs-plugins compile error In-Reply-To: References: <20080602192332.GB24905@netsoc.tcd.ie> Message-ID: <20080603143515.GB17501@netsoc.tcd.ie> On Tue, Jun 03, 2008 at 03:07:33PM +0100, John O'Donnell wrote: > Hi, > > What is the status of hs-plugins? I recently tried to install the > version plugins-1.2 on hackage, using a Gnu/Linux box with Fedora 9 > and ghc-6.8.2, but didn't get past the configure stage (see config.log > below). > > The installation script is invoking gcc with a -V command line argument > but according to gcc documentation -V requires an argument. > > Has anyone managed to get hs-plugins to work? If so, what platform, > which version of ghc and gcc, and where did you find the hs-plugins > source? It's working fine for me (after applying the patch I submitted), on Debian Lenny (which currently comes with ghc 6.8.2, gcc 4.2.4) and the source from Hackage. Source from the darcs repository also works fine (after applying the same patch). I *am* getting an application crash sometimes when I close my application, but I have not yet been able to track that down so I'm not 100% sure it's due to hs-plugins. Edsko From jtod at dcs.gla.ac.uk Tue Jun 3 10:49:06 2008 From: jtod at dcs.gla.ac.uk (John O'Donnell) Date: Tue Jun 3 10:41:45 2008 Subject: [Haskell-cafe] hs-plugins compile error References: <20080602192332.GB24905@netsoc.tcd.ie> <20080603143515.GB17501@netsoc.tcd.ie> Message-ID: Thanks, Edsko. My version of gcc is 4.3.0. It may well be that some other piece of software in the Fedora 9 distribution is incompatible with the hs-plugins installation script. Has anyone installed hs-plugins on Fedora? I was able to get it to compile on Fedora 4, using ghc-6.4, two or three years ago, but it's never worked on any of my systems since then. John -----Original Message----- From: Edsko de Vries [mailto:devriese@cs.tcd.ie] Sent: Tue 2008-06-03 15:35 To: John O'Donnell Cc: Edsko de Vries; Don Stewart; haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] hs-plugins compile error On Tue, Jun 03, 2008 at 03:07:33PM +0100, John O'Donnell wrote: > Hi, > > What is the status of hs-plugins? I recently tried to install the > version plugins-1.2 on hackage, using a Gnu/Linux box with Fedora 9 > and ghc-6.8.2, but didn't get past the configure stage (see config.log > below). > > The installation script is invoking gcc with a -V command line argument > but according to gcc documentation -V requires an argument. > > Has anyone managed to get hs-plugins to work? If so, what platform, > which version of ghc and gcc, and where did you find the hs-plugins > source? It's working fine for me (after applying the patch I submitted), on Debian Lenny (which currently comes with ghc 6.8.2, gcc 4.2.4) and the source from Hackage. Source from the darcs repository also works fine (after applying the same patch). I *am* getting an application crash sometimes when I close my application, but I have not yet been able to track that down so I'm not 100% sure it's due to hs-plugins. Edsko -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080603/daad2cb7/attachment.htm From loup.vaillant at gmail.com Tue Jun 3 10:57:02 2008 From: loup.vaillant at gmail.com (Loup Vaillant) Date: Tue Jun 3 10:49:40 2008 Subject: [Haskell-cafe] [ANNOUNCE] git-darcs-import 0.1 In-Reply-To: References: <20080601184446.GA27750@zombie.inf.tu-dresden.de> Message-ID: <6f9f8f4a0806030757y142f0710lb05754429e4b6515@mail.gmail.com> 2008/6/3 Darrin Thompson : > On Sun, Jun 1, 2008 at 2:44 PM, Bertram Felgenhauer > wrote: >> Hi, >> >> I'm pleased to announce yet another tool for importing darcs repositories >> to git. Unlike darcs2git [1] and darcs-to-git [2], it's written in >> Haskell, on top of the darcs2 source code. The result is a much faster >> program - it can convert the complete ghc 6.9 branch (without libraries) >> in less than 15 minutes on my slightly dated machine (Athlon XP 2500+), >> which is quite fast [3]. Incremental updates work, too. >> > > What's the appeal of this? I personally love git, but I thought all > the cool kids at this school used darcs and that was that. Disclaimer: I'm no expert, this is what I've heard. Anyone please confirm or deny the following? Basically, git is waaay faster than Darcs on a number of use cases. So, maybe the point of using this converter is when you just cannot use Darcs any more (too old/big project, merging huge branch with loads of conflicts, I don't know). Another point may be "broadcast-ability": It is possible to expose two repositories: one Darcs, one Git. If I use Git and not Darcs (please don't sue me), it will be simpler for me to get the source from the Git snapshot, provided there is one. Well, if I want to contribute back... maybe I should switch. I think the True Heresy (and most useful, if practical) would be to convert back and forth between the two version control systems, accepting patches from both :-) Loup From darrinth at gmail.com Tue Jun 3 11:53:07 2008 From: darrinth at gmail.com (Darrin Thompson) Date: Tue Jun 3 11:45:45 2008 Subject: [Haskell-cafe] Rewrite class with fundeps in pure h98? Message-ID: I thought that I should be able to write something like the toHtml function below with pure H98, but when I went to write it I ended up needing fundeps. Is there a way to express this without using any extensions? The idea was to take a remotely Dom-like tree and flatten it into a string, but not require any particular string type. Mostly I'm ripping off HStringTemplate for the fun of it. {-# OPTIONS -fglasgow-exts #-} module Control.WebWidget where import Data.Monoid import Data.String data (IsString s, Monoid s) => Dom s = Element s [Attr s] [Dom s] | Text s data (IsString s, Monoid s) => Attr s = Attr s s class (Monoid s, IsString s) => HTML d s | d -> s where toHtml :: d -> s instance (Monoid s, IsString s) => HTML (Dom s) s where toHtml (Element name attrs children) = mconcat [ fromString "<", name, mconcat $ map toHtml attrs, fromString ">", mconcat $ map toHtml children, fromString "" ] toHtml (Text s) = s instance (Monoid s, IsString s) => HTML (Attr s) s where toHtml (Attr key value) = mconcat [ fromString " '", key, fromString "'='", value, fromString "' " ] -- Darrin From isaacdupree at charter.net Tue Jun 3 11:56:55 2008 From: isaacdupree at charter.net (Isaac Dupree) Date: Tue Jun 3 11:49:43 2008 Subject: [Haskell-cafe] Implementing ParseChart with Data.Map In-Reply-To: <1212445709.15010.144.camel@localhost> References: <1212445709.15010.144.camel@localhost> Message-ID: <484569C7.7090602@charter.net> Duncan Coutts wrote: > modify :: k -> Map k e -> (e, Maybe e -> Map k e) > > so it's a lookup that returns the element at k and also a continuation > that lets you rebuild a new map with an altered element. I guess that > doesn't account for the element not existing. There's probably a > generalisation that does. isn't it just adding the necessary Maybe?: modify :: k -> Map k e -> (Maybe e, Maybe e -> Map k e) ? -Isaac From phercek at gmail.com Tue Jun 3 12:42:44 2008 From: phercek at gmail.com (Peter Hercek) Date: Tue Jun 3 12:35:33 2008 Subject: [Haskell-cafe] Re: [ANNOUNCE] git-darcs-import 0.1 In-Reply-To: <6f9f8f4a0806030757y142f0710lb05754429e4b6515@mail.gmail.com> References: <20080601184446.GA27750@zombie.inf.tu-dresden.de> <6f9f8f4a0806030757y142f0710lb05754429e4b6515@mail.gmail.com> Message-ID: Loup Vaillant wrote: > 2008/6/3 Darrin Thompson : >> <--cut--> >> What's the appeal of this? I personally love git, but I thought all >> the cool kids at this school used darcs and that was that. > > Disclaimer: I'm no expert, this is what I've heard. Anyone please > confirm or deny the following? > > Basically, git is waaay faster than Darcs on a number of use cases. Other reason can be "git rebase". Of course there is a question how good practice it is ... but it is being used. Peter. From tphyahoo at gmail.com Tue Jun 3 13:08:19 2008 From: tphyahoo at gmail.com (Thomas Hartman) Date: Tue Jun 3 13:00:59 2008 Subject: [Haskell-cafe] ANN (2 Libs) -- hvac 0.1b, a lightweight web framework and HStringTemplate 0.3 In-Reply-To: References: Message-ID: <910ddf450806031008u4f3432b9hcaf26ca388fdad81@mail.gmail.com> I just tried out hvac. I was trying to run the hvac examples after following the readme in the samples directory. sudo lighttpd -D -f lh.conf [sudo] password for thartman: 2008-06-03 09:30:02: (log.c.75) server started so that's okay, but http://localhost:3000/hvac-board/board/1 in firefox attempted to open a binary file "1". Same result for http://localhost:3000/hvac-board I don't know if this is an hvac issue or a fastcgi issue (seems more likely) but any advice? Thomas. 2008/3/22 Sterling Clover : > 1) hvac 0.1b: transactional, declarative framework for lightweight web > applications. > 2) HStringTemplate 0.3 > > 1) hvac 0.1b > > hvac (short for http view and controller) has been my project for the last > little while, and is finally in a fairly usable state, so I'm opening up the > repo (darcs get http://community.haskell.org/~sclv/hvac/) for folks to play > with and to get some feedback. While not quite yet ready for hackage, the > package as provided should be fully cabal installable. Documentation is > available at http://community.haskell.org/~sclv/hvac/html_docs/hvac/ > > The aim of hvac is to provide an environment that makes the creation of > lightweight fastcgi based web applications as simple as possible, with an > emphasis on concise, declarative style code, correct concurrent > transactional logic, and transparency in adding caching combinators. > > There are two included example programs, naturally neither of which is > feature complete. They share a common login module of about 50 lines of > code, excluding imports, templates, and database schema. > > The first program is a classic, greenspun-style message board with basic > login functionality. It totals roughly 40 lines and tends to use just under > 4mb of resident memory on my system. > > The second is a wiki based on Pandoc and the PandocWiki code. The code > totals roughly 30 lines (rendering borrowed from PandocWiki aside) and uses > about 5mb of memory. > > hvac processes all requests in the STM monad, with some bells attached to > properly interleave STM with session, database and filesystem operations > such that they all conceptually occur together in a single transaction per > request. Currently it is only fully tested with sqlite, but it should > operate, modulo a few tweaks, with any database accessible via HDBC. > > hvac is particularly designed to use the HStringTemplate library as an > output layer, in a simple declarative fashion. As the StringTemplate grammar > is explicitly sub-turing, this ensures a clean separation of program logic > from presentation, while providing a nonetheless fairly powerful language to > express typical display tasks. > > The included cache combinators, still experimental, should allow a simple > and fine-grained control over the level of caching of various disk-bound > operations. Phantom types are used to ensure that no functions that modify > state may be cached. > > To give a flavor of hvac code, the following is the complete (twenty lines!) > source of the wiki controller (due to sql statements, some lines are rather > long): > > wikiController tmpl = > h |/ "login" *> login_plug tmpl > <|> > (h |/ "wiki" |\\ \pageName -> h |// "POST" *> > withValidation [ ("contents", return) ] > (\ [contents] -> do > pageId <- selectVal "id from pages where name=?" [toSql > pageName] > maybe (addErrors [("Login","must be logged in.")] >> continue) > (\user -> case fromSql pageId of > Just (_::Int) -> > execStat "insert into > page_hist(pageId,contents,author) values(?,?,?)" [pageId, toSql contents, > toSql . userName $ user] > Nothing -> do > execStat "insert into pages(name,locked) > values(?,?)" [toSql pageName, toSql (0::Int)] > pid <- selectVal "max(id) from pages" [] > execStat "insert into > page_hist(pageId,contents,author) values(?,?,?)" [pid, toSql contents, toSql > . userName $ user]) =<< getSes > continue) > <|> do > pageId <- selectVal "id from pages where name=?" [toSql pageName] > (join $ renderf (tmpl "showPage") ("pageName", pageName) > <$> "pageContents" |= selectRow "* from page_hist where > pageId=? order by time desc limit 1" [pageId] )) > <|> (redirect . ( ++ "/wiki/Index") =<< scriptName) > > Future directions for work on hvac include: Stress testing for correctness > of transactional logic and benchmarks. Exploration of various efficiency > tweaks. Unit tests. Further development of the cache combinator API. > Improvement of the example apps and addition of a few others (a blog maybe). > Expansion of the library of validator functions. Exploration of transferring > hvac to the standard FastCGI bindings (currently it uses a custom modified > version to work properly with STM). Improvement of the database layer, > particularly with regards to common paging functions. Creation of a set of > simple combinators for generating CRUD (create read update delete) pages. > Creation of a minimal set of standard templates (maybe). > > 2) HStringTemplate 0.3.1 > > This release of HStringTemplate (up now at Hackage) fixes a number of bugs > pointed out to me by its small but growing user base (thanks, cinema, > elliottt!) ranging from the minor (a particular two-level iteration pattern > wasn't working properly) to the truly irritating (poor handling of file > groups). It's still unfortunately skimpy on the docs, outside of the > haddocks and the main StringTemplate grammar documentation at > http://www.stringtemplate.org (although the examples from hvac should also > prove helpful). However, it does have a set of very nice and handy new > features for development. > > * renderf, a function similar in spirit to printf, that takes an arbitrary > number of heterogeneous (String, value) tuples as arguments. This should cut > down considerably on long setAttribute chains. Additionally, with custom > instances (not, I'll grant, trivial to write) it can be used to > declaratively chain together strings of attribute retrieval functions in > arbitrary monads, as in the above code example from hvac. > > * dumpAttribs, a function/template that prints out the tree of the entire > attribute environment a template is operating in -- extremely handy for > development. > > * nullGroup, also for use in development, a simple way to display more > information about templates that can't be found. Error messages in > usafeVolatileDirectoryGroup have also been significantly improved. > > * getStringTemplate', a version of getStringTemplate guaranteed not to be > inlined. While the optimizer will still sometimes rearrange code such that a > volatile group is not updated properly, this at least helps remedy the > situation (I think). > > * Some minor changes: For grammar reasons, dots have been removed from > template names -- however, underscores and slashes are now available. > Additionally, there's a much improved logic for which aspects of a local > environment are overridden and preserved when a template is called from > another. > > For both of these libraries, patches, comments, bug reports, requests, and > of course contributions more than welcome! > > Regards, > Sterl._______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From wnoise at ofb.net Tue Jun 3 13:15:47 2008 From: wnoise at ofb.net (Aaron Denney) Date: Tue Jun 3 13:08:32 2008 Subject: [Haskell-cafe] Re: [ANNOUNCE] git-darcs-import 0.1 References: <20080601184446.GA27750@zombie.inf.tu-dresden.de> <6f9f8f4a0806030757y142f0710lb05754429e4b6515@mail.gmail.com> Message-ID: On 2008-06-03, Peter Hercek wrote: > Loup Vaillant wrote: >> 2008/6/3 Darrin Thompson : >>> <--cut--> >>> What's the appeal of this? I personally love git, but I thought all >>> the cool kids at this school used darcs and that was that. >> >> Disclaimer: I'm no expert, this is what I've heard. Anyone please >> confirm or deny the following? >> >> Basically, git is waaay faster than Darcs on a number of use cases. > > Other reason can be "git rebase". Of course there is a question > how good practice it is ... but it is being used. Darcs patches are pretty much an implicit rebase. -- Aaron Denney -><- From apfelmus at quantentunnel.de Tue Jun 3 13:17:45 2008 From: apfelmus at quantentunnel.de (apfelmus) Date: Tue Jun 3 13:10:34 2008 Subject: [Haskell-cafe] Re: Rewrite class with fundeps in pure h98? In-Reply-To: References: Message-ID: Darrin Thompson wrote: > I thought that I should be able to write something like the toHtml > function below with pure H98, but when I went to write it I ended up > needing fundeps. Is there a way to express this without using any > extensions? > > The idea was to take a remotely Dom-like tree and flatten it into a > string, but not require any particular string type. > > data (IsString s, Monoid s) => Dom s = > Element s [Attr s] [Dom s] | > Text s > > data (IsString s, Monoid s) => Attr s = Attr s s > > class (Monoid s, IsString s) => HTML d s | d -> s where > toHtml :: d -> s > > instance (Monoid s, IsString s) => HTML (Dom s) s where > > instance (Monoid s, IsString s) => HTML (Attr s) s where The H98 way is to make a class for type constructors: class HTML d where toHTML :: (Monoid s, IsString s) => d s -> s instance HTML Dom where ... instance HTML Attr where ... Btw, naming the class "HTML" is feels wrong, something like Serialize is probably a better fit. Regards, apfelmus From tphyahoo at gmail.com Tue Jun 3 13:20:56 2008 From: tphyahoo at gmail.com (Thomas Hartman) Date: Tue Jun 3 13:13:42 2008 Subject: [Haskell-cafe] What is the maturity of Haskell Web Frameworks In-Reply-To: <20080602172131.GA7534@scytale.galois.com> References: <20080602172131.GA7534@scytale.galois.com> Message-ID: <910ddf450806031020i2e09b83bo4cd13f395b612e1@mail.gmail.com> Note however that hpaste runs off an earlier version of HAppS, which has changed radically from v8 to v9. I seem to remember discussion of porting hpaste to the latest HAppS as a demo app... are there still plans to do that? Thomas. 2008/6/2 Don Stewart : > aditya_siram: >> >> I am building a web-app that, in broad strokes, allows a leader to >> assign tasks to team members and allows team members to >> accept/reject/pick tasks that they want to do. >> >> I really like Haskell and I would like to use it to implement the >> solution. Are frameworks like Happs ready? Not so much in terms of >> documentation, but in functionality and stability. > > HAppS is nice (see hpaste.org for example, which is nice and simple, and > has been running for over a year). > > Another nice option in Haskell is using something like HStringTemplate > or the xhtml combinators with fastcgi hooked into GHC's concurrency > mechanisms. > > You can find *many* more things here, > > http://hackage.haskell.org/packages/archive/pkg-list.html#cat:Network > http://hackage.haskell.org/packages/archive/pkg-list.html#cat:Web > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From dons at galois.com Tue Jun 3 13:23:03 2008 From: dons at galois.com (Don Stewart) Date: Tue Jun 3 13:15:45 2008 Subject: [Haskell-cafe] What is the maturity of Haskell Web Frameworks In-Reply-To: <910ddf450806031020i2e09b83bo4cd13f395b612e1@mail.gmail.com> References: <20080602172131.GA7534@scytale.galois.com> <910ddf450806031020i2e09b83bo4cd13f395b612e1@mail.gmail.com> Message-ID: <20080603172303.GA22053@scytale.galois.com> A new version of happs was written on a Monday a couple of months ago, using fastcgi and takusen. We're running it at galois, and you can find the code on code.haskell.org/hpaste. So not quite what you wanted, but another data point. -- Don tphyahoo: > Note however that hpaste runs off an earlier version of HAppS, which > has changed radically from v8 to v9. > > I seem to remember discussion of porting hpaste to the latest HAppS as > a demo app... are there still plans to do that? > > Thomas. > > 2008/6/2 Don Stewart : > > aditya_siram: > >> > >> I am building a web-app that, in broad strokes, allows a leader to > >> assign tasks to team members and allows team members to > >> accept/reject/pick tasks that they want to do. > >> > >> I really like Haskell and I would like to use it to implement the > >> solution. Are frameworks like Happs ready? Not so much in terms of > >> documentation, but in functionality and stability. > > > > HAppS is nice (see hpaste.org for example, which is nice and simple, and > > has been running for over a year). > > > > Another nice option in Haskell is using something like HStringTemplate > > or the xhtml combinators with fastcgi hooked into GHC's concurrency > > mechanisms. > > > > You can find *many* more things here, > > > > http://hackage.haskell.org/packages/archive/pkg-list.html#cat:Network > > http://hackage.haskell.org/packages/archive/pkg-list.html#cat:Web > > _______________________________________________ > > 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 tphyahoo at gmail.com Tue Jun 3 13:37:21 2008 From: tphyahoo at gmail.com (Thomas Hartman) Date: Tue Jun 3 13:30:22 2008 Subject: [Haskell-cafe] What is the maturity of Haskell Web Frameworks In-Reply-To: <20080603172303.GA22053@scytale.galois.com> References: <20080602172131.GA7534@scytale.galois.com> <910ddf450806031020i2e09b83bo4cd13f395b612e1@mail.gmail.com> <20080603172303.GA22053@scytale.galois.com> Message-ID: <910ddf450806031037n38f29034l4a4dcba81ef7269a@mail.gmail.com> note to the curious that this is a git and not a darcs repo git clone http://code.haskell.org/hpaste.git thomas. 2008/6/3 Don Stewart : > A new version of happs was written on a Monday a couple of months ago, > using fastcgi and takusen. We're running it at galois, and you can > find the code on code.haskell.org/hpaste. So not quite what you wanted, > but another data point. > > -- Don > > tphyahoo: >> Note however that hpaste runs off an earlier version of HAppS, which >> has changed radically from v8 to v9. >> >> I seem to remember discussion of porting hpaste to the latest HAppS as >> a demo app... are there still plans to do that? >> >> Thomas. >> >> 2008/6/2 Don Stewart : >> > aditya_siram: >> >> >> >> I am building a web-app that, in broad strokes, allows a leader to >> >> assign tasks to team members and allows team members to >> >> accept/reject/pick tasks that they want to do. >> >> >> >> I really like Haskell and I would like to use it to implement the >> >> solution. Are frameworks like Happs ready? Not so much in terms of >> >> documentation, but in functionality and stability. >> > >> > HAppS is nice (see hpaste.org for example, which is nice and simple, and >> > has been running for over a year). >> > >> > Another nice option in Haskell is using something like HStringTemplate >> > or the xhtml combinators with fastcgi hooked into GHC's concurrency >> > mechanisms. >> > >> > You can find *many* more things here, >> > >> > http://hackage.haskell.org/packages/archive/pkg-list.html#cat:Network >> > http://hackage.haskell.org/packages/archive/pkg-list.html#cat:Web >> > _______________________________________________ >> > 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 dons at galois.com Tue Jun 3 13:47:04 2008 From: dons at galois.com (Don Stewart) Date: Tue Jun 3 13:39:43 2008 Subject: [Haskell-cafe] More on performance Message-ID: <20080603174704.GB22053@scytale.galois.com> I wrote up the second part of the tour of understanding low level performance in GHC here, http://reddit.com/r/programming/info/6lx36/comments/ Follows on from the discussion last week about various performance related things. Enjoy. -- Don From dons at galois.com Tue Jun 3 13:50:42 2008 From: dons at galois.com (Don Stewart) Date: Tue Jun 3 13:43:23 2008 Subject: [Haskell-cafe] What is the maturity of Haskell Web Frameworks In-Reply-To: <910ddf450806031037n38f29034l4a4dcba81ef7269a@mail.gmail.com> References: <20080602172131.GA7534@scytale.galois.com> <910ddf450806031020i2e09b83bo4cd13f395b612e1@mail.gmail.com> <20080603172303.GA22053@scytale.galois.com> <910ddf450806031037n38f29034l4a4dcba81ef7269a@mail.gmail.com> Message-ID: <20080603175042.GC22053@scytale.galois.com> Ah yes, the url was incorrect. Well spotted. tphyahoo: > note to the curious that this is a git and not a darcs repo > > git clone http://code.haskell.org/hpaste.git > > thomas. > > 2008/6/3 Don Stewart : > > A new version of happs was written on a Monday a couple of months ago, > > using fastcgi and takusen. We're running it at galois, and you can > > find the code on code.haskell.org/hpaste. So not quite what you wanted, > > but another data point. > > > > -- Don > > > > tphyahoo: > >> Note however that hpaste runs off an earlier version of HAppS, which > >> has changed radically from v8 to v9. > >> > >> I seem to remember discussion of porting hpaste to the latest HAppS as > >> a demo app... are there still plans to do that? > >> > >> Thomas. > >> > >> 2008/6/2 Don Stewart : > >> > aditya_siram: > >> >> > >> >> I am building a web-app that, in broad strokes, allows a leader to > >> >> assign tasks to team members and allows team members to > >> >> accept/reject/pick tasks that they want to do. > >> >> > >> >> I really like Haskell and I would like to use it to implement the > >> >> solution. Are frameworks like Happs ready? Not so much in terms of > >> >> documentation, but in functionality and stability. > >> > > >> > HAppS is nice (see hpaste.org for example, which is nice and simple, and > >> > has been running for over a year). > >> > > >> > Another nice option in Haskell is using something like HStringTemplate > >> > or the xhtml combinators with fastcgi hooked into GHC's concurrency > >> > mechanisms. > >> > > >> > You can find *many* more things here, > >> > > >> > http://hackage.haskell.org/packages/archive/pkg-list.html#cat:Network > >> > http://hackage.haskell.org/packages/archive/pkg-list.html#cat:Web > >> > _______________________________________________ > >> > 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 phercek at gmail.com Tue Jun 3 14:44:09 2008 From: phercek at gmail.com (Peter Hercek) Date: Tue Jun 3 14:40:31 2008 Subject: [Haskell-cafe] Re: [ANNOUNCE] git-darcs-import 0.1 In-Reply-To: References: <20080601184446.GA27750@zombie.inf.tu-dresden.de> <6f9f8f4a0806030757y142f0710lb05754429e4b6515@mail.gmail.com> Message-ID: Aaron Denney wrote: > On 2008-06-03, Peter Hercek wrote: >> Loup Vaillant wrote: >>> 2008/6/3 Darrin Thompson : >>>> <--cut--> >>>> What's the appeal of this? I personally love git, but I thought all >>>> the cool kids at this school used darcs and that was that. >>> Disclaimer: I'm no expert, this is what I've heard. Anyone please >>> confirm or deny the following? >>> >>> Basically, git is waaay faster than Darcs on a number of use cases. >> Other reason can be "git rebase". Of course there is a question >> how good practice it is ... but it is being used. > > Darcs patches are pretty much an implicit rebase. You cannot push patch B if it depends on patch A without also pushing A. And darcs currently does not alow you to reorder B before A (which is what git rebase actually does). Git rebase works quite well even in cloned repositories. See: http://bugs.darcs.net/issue891 Some discussin about it is also here: http://lists.osuosl.org/pipermail/darcs-users/2008-February/011564.html When the issue is fixed then darcs will be really patch based and will become the ultimate DSCM :-) From alfonso.acosta at gmail.com Tue Jun 3 14:55:05 2008 From: alfonso.acosta at gmail.com (Alfonso Acosta) Date: Tue Jun 3 14:47:46 2008 Subject: [Haskell-cafe] Re: type-level integers using type families In-Reply-To: <483E1FCF.9000101@gmail.com> References: <483E1FCF.9000101@gmail.com> Message-ID: <6a7c66fc0806031155s3562cbbag7990814a0aeeeb56@mail.gmail.com> On Thu, May 29, 2008 at 5:15 AM, Peter Gavin wrote: > Has anyone else tried implementing type-level integers using type families? When I started to work on thetype-level and parameterized data packages, I considered using type-families and GADTs, but I found quite a few problems which have been nicely summarized by Benedikt in this thread. From s.clover at gmail.com Tue Jun 3 14:59:11 2008 From: s.clover at gmail.com (Sterling Clover) Date: Tue Jun 3 14:51:53 2008 Subject: [Haskell-cafe] ANN (2 Libs) -- hvac 0.1b, a lightweight web framework and HStringTemplate 0.3 In-Reply-To: <910ddf450806031008u4f3432b9hcaf26ca388fdad81@mail.gmail.com> References: <910ddf450806031008u4f3432b9hcaf26ca388fdad81@mail.gmail.com> Message-ID: Probably best not to keep this discussion in -cafe after this, as this is more of a debugging-type issue, but in my experience, I bet the lighttpd server is trying to serve the hvac-board fcgi file directly as a binary, rather than launching it as a fastcgi instance at all. The configurations files I've built have worked fine for me, but your milage may vary -- getting fastcgi up and running can be a bit of a bear at times. At a minimum, you should make sure that the lh.conf file points correctly to your binary in the fastcgi.server variable, and that you have all the proper fastcgi libraries installed on your system. Regards, Sterl On Jun 3, 2008, at 1:08 PM, Thomas Hartman wrote: > I just tried out hvac. I was trying to run the hvac examples > after following the readme in the samples directory. > > sudo lighttpd -D -f lh.conf > [sudo] password for thartman: > 2008-06-03 09:30:02: (log.c.75) server started > > so that's okay, but > > http://localhost:3000/hvac-board/board/1 > > in firefox attempted to open a binary file "1". > > Same result for http://localhost:3000/hvac-board > > I don't know if this is an hvac issue or a fastcgi issue (seems more > likely) but any > advice? > > Thomas. > > 2008/3/22 Sterling Clover : >> 1) hvac 0.1b: transactional, declarative framework for lightweight >> web >> applications. >> 2) HStringTemplate 0.3 >> >> 1) hvac 0.1b >> >> hvac (short for http view and controller) has been my project for >> the last >> little while, and is finally in a fairly usable state, so I'm >> opening up the >> repo (darcs get http://community.haskell.org/~sclv/hvac/) for >> folks to play >> with and to get some feedback. While not quite yet ready for >> hackage, the >> package as provided should be fully cabal installable. >> Documentation is >> available at http://community.haskell.org/~sclv/hvac/html_docs/hvac/ >> >> The aim of hvac is to provide an environment that makes the >> creation of >> lightweight fastcgi based web applications as simple as possible, >> with an >> emphasis on concise, declarative style code, correct concurrent >> transactional logic, and transparency in adding caching combinators. >> >> There are two included example programs, naturally neither of >> which is >> feature complete. They share a common login module of about 50 >> lines of >> code, excluding imports, templates, and database schema. >> >> The first program is a classic, greenspun-style message board with >> basic >> login functionality. It totals roughly 40 lines and tends to use >> just under >> 4mb of resident memory on my system. >> >> The second is a wiki based on Pandoc and the PandocWiki code. The >> code >> totals roughly 30 lines (rendering borrowed from PandocWiki aside) >> and uses >> about 5mb of memory. >> >> hvac processes all requests in the STM monad, with some bells >> attached to >> properly interleave STM with session, database and filesystem >> operations >> such that they all conceptually occur together in a single >> transaction per >> request. Currently it is only fully tested with sqlite, but it should >> operate, modulo a few tweaks, with any database accessible via HDBC. >> >> hvac is particularly designed to use the HStringTemplate library >> as an >> output layer, in a simple declarative fashion. As the >> StringTemplate grammar >> is explicitly sub-turing, this ensures a clean separation of >> program logic >> from presentation, while providing a nonetheless fairly powerful >> language to >> express typical display tasks. >> >> The included cache combinators, still experimental, should allow a >> simple >> and fine-grained control over the level of caching of various disk- >> bound >> operations. Phantom types are used to ensure that no functions >> that modify >> state may be cached. >> >> To give a flavor of hvac code, the following is the complete >> (twenty lines!) >> source of the wiki controller (due to sql statements, some lines >> are rather >> long): >> >> wikiController tmpl = >> h |/ "login" *> login_plug tmpl >> <|> >> (h |/ "wiki" |\\ \pageName -> h |// "POST" *> >> withValidation [ ("contents", return) ] >> (\ [contents] -> do >> pageId <- selectVal "id from pages where name=?" [toSql >> pageName] >> maybe (addErrors [("Login","must be logged in.")] >> >> continue) >> (\user -> case fromSql pageId of >> Just (_::Int) -> >> execStat "insert into >> page_hist(pageId,contents,author) values(?,?,?)" [pageId, toSql >> contents, >> toSql . userName $ user] >> Nothing -> do >> execStat "insert into pages(name,locked) >> values(?,?)" [toSql pageName, toSql (0::Int)] >> pid <- selectVal "max(id) from pages" [] >> execStat "insert into >> page_hist(pageId,contents,author) values(?,?,?)" [pid, toSql >> contents, toSql >> . userName $ user]) =<< getSes >> continue) >> <|> do >> pageId <- selectVal "id from pages where name=?" [toSql >> pageName] >> (join $ renderf (tmpl "showPage") ("pageName", pageName) >> <$> "pageContents" |= selectRow "* from page_hist where >> pageId=? order by time desc limit 1" [pageId] )) >> <|> (redirect . ( ++ "/wiki/Index") =<< scriptName) >> >> Future directions for work on hvac include: Stress testing for >> correctness >> of transactional logic and benchmarks. Exploration of various >> efficiency >> tweaks. Unit tests. Further development of the cache combinator API. >> Improvement of the example apps and addition of a few others (a >> blog maybe). >> Expansion of the library of validator functions. Exploration of >> transferring >> hvac to the standard FastCGI bindings (currently it uses a custom >> modified >> version to work properly with STM). Improvement of the database >> layer, >> particularly with regards to common paging functions. Creation of >> a set of >> simple combinators for generating CRUD (create read update delete) >> pages. >> Creation of a minimal set of standard templates (maybe). >> >> 2) HStringTemplate 0.3.1 >> >> This release of HStringTemplate (up now at Hackage) fixes a number >> of bugs >> pointed out to me by its small but growing user base (thanks, cinema, >> elliottt!) ranging from the minor (a particular two-level >> iteration pattern >> wasn't working properly) to the truly irritating (poor handling of >> file >> groups). It's still unfortunately skimpy on the docs, outside of the >> haddocks and the main StringTemplate grammar documentation at >> http://www.stringtemplate.org (although the examples from hvac >> should also >> prove helpful). However, it does have a set of very nice and handy >> new >> features for development. >> >> * renderf, a function similar in spirit to printf, that takes an >> arbitrary >> number of heterogeneous (String, value) tuples as arguments. This >> should cut >> down considerably on long setAttribute chains. Additionally, with >> custom >> instances (not, I'll grant, trivial to write) it can be used to >> declaratively chain together strings of attribute retrieval >> functions in >> arbitrary monads, as in the above code example from hvac. >> >> * dumpAttribs, a function/template that prints out the tree of the >> entire >> attribute environment a template is operating in -- extremely >> handy for >> development. >> >> * nullGroup, also for use in development, a simple way to display >> more >> information about templates that can't be found. Error messages in >> usafeVolatileDirectoryGroup have also been significantly improved. >> >> * getStringTemplate', a version of getStringTemplate guaranteed >> not to be >> inlined. While the optimizer will still sometimes rearrange code >> such that a >> volatile group is not updated properly, this at least helps remedy >> the >> situation (I think). >> >> * Some minor changes: For grammar reasons, dots have been removed >> from >> template names -- however, underscores and slashes are now available. >> Additionally, there's a much improved logic for which aspects of a >> local >> environment are overridden and preserved when a template is called >> from >> another. >> >> For both of these libraries, patches, comments, bug reports, >> requests, and >> of course contributions more than welcome! >> >> Regards, >> Sterl._______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> From s.clover at gmail.com Tue Jun 3 15:02:49 2008 From: s.clover at gmail.com (Sterling Clover) Date: Tue Jun 3 14:55:29 2008 Subject: [Haskell-cafe] Re: Rewrite class with fundeps in pure h98? In-Reply-To: References: Message-ID: This was how it was originally done in HStringTemplate, as I recall. The mptcs were introduced in order to maintain lookup-maps of the correct type, and particularly to allow embedding of templates within one another. There may have been some other corner-cases involved as well. However, unless you run into them, the H98 way is certainly cleaner. --Sterl On Jun 3, 2008, at 1:17 PM, apfelmus wrote: > Darrin Thompson wrote: >> I thought that I should be able to write something like the toHtml >> function below with pure H98, but when I went to write it I ended up >> needing fundeps. Is there a way to express this without using any >> extensions? >> The idea was to take a remotely Dom-like tree and flatten it into a >> string, but not require any particular string type. >> data (IsString s, Monoid s) => Dom s = >> Element s [Attr s] [Dom s] | >> Text s >> data (IsString s, Monoid s) => Attr s = Attr s s >> class (Monoid s, IsString s) => HTML d s | d -> s where >> toHtml :: d -> s >> instance (Monoid s, IsString s) => HTML (Dom s) s where >> instance (Monoid s, IsString s) => HTML (Attr s) s where > > The H98 way is to make a class for type constructors: > > class HTML d where > toHTML :: (Monoid s, IsString s) => d s -> s > > instance HTML Dom where ... > > instance HTML Attr where ... > > > Btw, naming the class "HTML" is feels wrong, something like > Serialize is probably a better fit. > > > Regards, > apfelmus > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From jgoerzen at complete.org Tue Jun 3 16:00:20 2008 From: jgoerzen at complete.org (John Goerzen) Date: Tue Jun 3 15:53:06 2008 Subject: [Haskell-cafe] HDBC-odbc 1.1.4.4 fixes Windows linking problems Message-ID: <20080603200020.GA13041@complete.org> Hi, HDBC-odbc version 1.1.4.4 has been uploaded to Hackage. It fixes the problems some here have encountered regarding ODBC crashes or other similar odd behavior on Windows. Thanks to Andrew Appleyard for tracking down the problem and sending me a patch. The detailed explanation, if you're interested, is a ccall vs. stdcall issue in FFI. Details here: http://git.complete.org/hdbc-odbc?a=commit;h=cca312d9891d227094494dcee518f436042e14b4 People that are not using HDBC-odbc on Windows will not find any difference or other changes in this version. -- John Goerzen Author, Foundations of Python Network Programming http://www.amazon.com/exec/obidos/tg/detail/-/1590593715 From vigalchin at gmail.com Tue Jun 3 16:40:08 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Tue Jun 3 16:32:50 2008 Subject: [Haskell-cafe] ghc 6.8.2 issue In-Reply-To: <1212483926.15010.192.camel@localhost> References: <5ae4f2ba0806012207i2797be95kf773d0cf75d6b39@mail.gmail.com> <1212403100.15010.133.camel@localhost> <5ae4f2ba0806022111l33fecf27xfbd6ee5f7dabf35f@mail.gmail.com> <1212483926.15010.192.camel@localhost> Message-ID: <5ae4f2ba0806031340h64bc888bs209f75e8eadb3545@mail.gmail.com> > Something like that yes. > > You're running runhaskell Setup.lhs and that loads and runs code from > the Cabal library. The Cabal library depends on the process library > which depends on the unix library. So by replacing the same version of > the unix package you're breaking everything else which depends on it, > including Cabal and thus runhaskell Setup.lhs. > > So the solution is to not do that. Don't re-install the exact same > version of any of the core libs that come with ghc. Adding new versions > is fine, replacing existing versions is not fine because it breaks all > the other packages that were already built against that package. > But Duncan, let's suppose I build "unix" putting in a "local" directory with a different version number than the released version of "unix". 1) How do I get the "local" package.conf built and populated? 2) How do I get a test case to link against this experimental local version of "unix"? Is there a "--prefix" or something like that I pass on runhaskell Setup.hs build? Regards, Vasili > Duncan > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080603/084ea833/attachment.htm From wnoise at ofb.net Tue Jun 3 16:54:38 2008 From: wnoise at ofb.net (Aaron Denney) Date: Tue Jun 3 16:47:25 2008 Subject: [Haskell-cafe] Re: [ANNOUNCE] git-darcs-import 0.1 References: <20080601184446.GA27750@zombie.inf.tu-dresden.de> <6f9f8f4a0806030757y142f0710lb05754429e4b6515@mail.gmail.com> Message-ID: This is drifting off-topic, but... On 2008-06-03, Peter Hercek wrote: > Aaron Denney wrote: >> On 2008-06-03, Peter Hercek wrote: >>> Loup Vaillant wrote: >>>> 2008/6/3 Darrin Thompson : >>>>> <--cut--> >>>>> What's the appeal of this? I personally love git, but I thought all >>>>> the cool kids at this school used darcs and that was that. >>>> Disclaimer: I'm no expert, this is what I've heard. Anyone please >>>> confirm or deny the following? >>>> >>>> Basically, git is waaay faster than Darcs on a number of use cases. >>> Other reason can be "git rebase". Of course there is a question >>> how good practice it is ... but it is being used. >> >> Darcs patches are pretty much an implicit rebase. > > You cannot push patch B if it depends on patch A without also > pushing A. And darcs currently does not alow you to reorder > B before A True. This is a *feature* not a bug. You shouldn't be able to do this automatically, because it can't be done right. You need to do this sort of thing manually. If you don't, the heuristics used will bite you at some point. When they do commute, there is no problem. > Git rebase works quite well even in cloned repositories. Meh. It can, if you're really really lucky. > See: http://bugs.darcs.net/issue891 > Some discussin about it is also here: > http://lists.osuosl.org/pipermail/darcs-users/2008-February/011564.html > > When the issue is fixed then darcs will be really patch based and > will become the ultimate DSCM :-) Rebasing is doable in git as a one-repository operation because each repository has multiple branches. As darcs has one repo per branch, it fundamentally needs to be done in multiple repos. There are naturally two repos, upstream, and your-feature-development. your-feature-development has a patch A that you want to rebase. What you should do is pull upstream into new-tracking, then pull patch A from your-feature-development into new-tracking. If it applies with no problem, great: mv your-feature-development your-feature-development-old; new-tracking your-feature-development. Of course, in this case, you could have just pulled into your-feature-development. If there weren't any other patches to save in the old your-feature-development, you can delete it instead of moving it. When there is a conflict, then you need to handle it somehow. Neither git nor darcs can do it automatically. You can just record the merge conflict and your resolution. This keeps repos that pulled from you valid, but this won't give you the "clean history" that you presumably want. So you need to combine the merger and cleanup into a new patch with the same log message, etc. It's true that git does make *this* process very nice. There is one thing that git rebase does easily (and correctly) that darcs doesn't do nicely: rewriting history by merging commits "prior" to the head. I put prior in quotes, because darcs doesn't preserve history in the first place. I don't find that a compelling use, as opposed to maintaing topic branches. -- Aaron Denney -><- From oddron at gmail.com Tue Jun 3 16:57:34 2008 From: oddron at gmail.com (Ronald Guida) Date: Tue Jun 3 16:50:12 2008 Subject: [Haskell-cafe] Re: appending an element to a list In-Reply-To: References: <483EE208.2010601@inf.fu-berlin.de> <483EF36B.5040100@daimi.au.dk> <48404039.6030605@cisco.com> <48405717.20206@daimi.au.dk> <87r6bja609.fsf@hbox.dyndns.org> <3c4d5adf0805302159o23113ad2sb24754e02789bb06@mail.gmail.com> <48414C2B.9010606@daimi.au.dk> <3c4d5adf0806012204p25133bdaxbc22955b70f094ff@mail.gmail.com> Message-ID: <62728db30806031357k4eb64655w7af1371cc6fe974d@mail.gmail.com> Thank you, apfelmus. That was a wonderful explanation; the debit method in [1] finally makes sense. [1]: Chris Okasaki. Purely Function Data Structures. http://www.cs.cmu.edu/~rwh/theses/okasaki.pdf From oddron at gmail.com Tue Jun 3 17:14:30 2008 From: oddron at gmail.com (Ronald Guida) Date: Tue Jun 3 17:07:09 2008 Subject: [Haskell-cafe] Laziness leaks Message-ID: <62728db30806031414p19593f40x5ad1bfd32e2dfc4b@mail.gmail.com> I was looking at the real time queues in [1] and I wanted to see what would happen if I tried to write one in Haskell. The easy part was translating the real time queue from [1], p43 into Haskell. The hard part is testing to see if the rotations really happen what they should. Basically, I decided to use Debug.Trace.trace to see when rotations were actually occurring. I pushed the numbers 1 to 10 into the queue, and then I popped the queue ten times. What I found is that none of the rotations would actually take place until the first time I actually tried to /display the value/ of a popped element. What I realized is that my test driver is lazy. I figured out that I could put a bunch of 'seq' functions in the test driver to get the rotations to happen. My demonstration code is in: http://hpaste.org/8080 This leads to two questions: 1. If I find a laziness leak, is 'seq' the appropriate way to plug it? 2. Is there any way to systematically search for or detect laziness leaks? From dons at galois.com Tue Jun 3 17:18:30 2008 From: dons at galois.com (Don Stewart) Date: Tue Jun 3 17:11:10 2008 Subject: [Haskell-cafe] Laziness leaks In-Reply-To: <62728db30806031414p19593f40x5ad1bfd32e2dfc4b@mail.gmail.com> References: <62728db30806031414p19593f40x5ad1bfd32e2dfc4b@mail.gmail.com> Message-ID: <20080603211830.GF22053@scytale.galois.com> oddron: > I was looking at the real time queues in [1] and I wanted to see what > would happen if I tried to write one in Haskell. The easy part was > translating the real time queue from [1], p43 into Haskell. > > The hard part is testing to see if the rotations really happen what > they should. Basically, I decided to use Debug.Trace.trace to see > when rotations were actually occurring. > > I pushed the numbers 1 to 10 into the queue, and then I popped the > queue ten times. What I found is that none of the rotations would > actually take place until the first time I actually tried to /display > the value/ of a popped element. What I realized is that my test > driver is lazy. I figured out that I could put a bunch of 'seq' > functions in the test driver to get the rotations to happen. > Right, you have a requirement that things are evaluated earlier, but you're representing this with a lazy list which will evaluate them as late as possible. Using something like weak strictness (seq) or deep strictness (rnf), to enforce the requried level of evaluation prior to pushing things onto the queue is one way. Making the queue a stricter structure would also work. > My demonstration code is in: > http://hpaste.org/8080 > > This leads to two questions: > > 1. If I find a laziness leak, is 'seq' the appropriate way to plug it? * Strict data structures, for where you require stricness i.e. data Queue a = Nil | Node !a (Queue a) * Bang patterns on variables: foo !x = ... push x .... * Seq, foo x = x `seq` ... x ... * Deep seq: foo x = x `rnf` ... x ... Are the main ways. > 2. Is there any way to systematically search for or detect laziness > leaks? Profiling, and looking at the Core. Being explicit about the evaluation strategy you want is a fine idea though. -- Don From t.h at gmx.info Tue Jun 3 17:25:28 2008 From: t.h at gmx.info (Timo B. =?utf-8?q?H=C3=BCbel?=) Date: Tue Jun 3 17:18:08 2008 Subject: [Haskell-cafe] hs-plugins compile error In-Reply-To: References: <20080602130511.GA24905@netsoc.tcd.ie> <20080602192332.GB24905@netsoc.tcd.ie> Message-ID: <200806032325.28694.t.h@gmx.info> > What is the status of hs-plugins? I recently tried to install the > version plugins-1.2 on hackage, using a Gnu/Linux box with Fedora 9 > and ghc-6.8.2, but didn't get past the configure stage (see config.log > below). I am getting exactly the same error on a Gentoo box. I've tracked it down to some awkward escape character sequence in the TOP variable defined in config.h. The following patch makes it work for me, but I've no idea if this is the right way to fix this problem: hunk ./configure 1385 -TOP=`echo "Directory.getCurrentDirectory >>= putStrLn.init.tail.show " | ghc --interactive -ignore-dot-ghci -v0 | tr -d '\r'` +TOP=`echo "Directory.getCurrentDirectory >>= putStr." | ghc --interactive -ignore-dot-ghci -v0` hunk ./configure.ac 66 -TOP=`echo "Directory.getCurrentDirectory >>= putStrLn.init.tail.show " | ghc --interactive -ignore-dot-ghci -v0 | tr -d '\r'` +TOP=`echo "Directory.getCurrentDirectory >>= putStr" | ghc --interactive -ignore-dot-ghci -v0` Regards, T. From allbery at ece.cmu.edu Tue Jun 3 18:12:16 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue Jun 3 18:04:59 2008 Subject: [Haskell-cafe] ghc 6.8.2 issue In-Reply-To: <5ae4f2ba0806031340h64bc888bs209f75e8eadb3545@mail.gmail.com> References: <5ae4f2ba0806012207i2797be95kf773d0cf75d6b39@mail.gmail.com> <1212403100.15010.133.camel@localhost> <5ae4f2ba0806022111l33fecf27xfbd6ee5f7dabf35f@mail.gmail.com> <1212483926.15010.192.camel@localhost> <5ae4f2ba0806031340h64bc888bs209f75e8eadb3545@mail.gmail.com> Message-ID: <312D446F-B2AF-4A39-8F3E-5A1959A525DC@ece.cmu.edu> On 2008 Jun 3, at 16:40, Galchin, Vasili wrote: > 1) How do I get the "local" package.conf built and populated? > > 2) How do I get a test case to link against this experimental > local version of "unix"? Is there a "--prefix" or something like > that I pass on runhaskell Setup.hs build? both cases the answer is the same: --user --prefix=whatever -- 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 -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080603/d3afd6e9/attachment.htm From duncan.coutts at worc.ox.ac.uk Tue Jun 3 19:06:22 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Tue Jun 3 18:55:35 2008 Subject: [Haskell-cafe] What is the maturity of Haskell Web Frameworks In-Reply-To: <20080603172303.GA22053@scytale.galois.com> References: <20080602172131.GA7534@scytale.galois.com> <910ddf450806031020i2e09b83bo4cd13f395b612e1@mail.gmail.com> <20080603172303.GA22053@scytale.galois.com> Message-ID: <1212534382.15010.227.camel@localhost> On Tue, 2008-06-03 at 10:23 -0700, Don Stewart wrote: > A new version of happs was written on a Monday a couple of months ago, > using fastcgi and takusen. We're running it at galois, and you can > find the code on code.haskell.org/hpaste. So not quite what you wanted, > but another data point. That's very interesting. I hope we will also see a version with the same feature set implemented with the latest HAppS. It would give an interesting comparison of the web frameworks to see the same app implemented in both. Duncan From sic at lerp.com Tue Jun 3 19:03:33 2008 From: sic at lerp.com (Scott Cruzen) Date: Tue Jun 3 18:56:11 2008 Subject: [Haskell-cafe] Re: [ANN] bloomfilter 1.0 - Fast immutable and mutable Bloom filters In-Reply-To: <4841CFB2.1020203@cs.pdx.edu> References: <48408014.30401@serpentine.com> <20080531005127.4b330ff7@solaris> <20080531202904.45054b49@solaris> <4841CFB2.1020203@cs.pdx.edu> Message-ID: <20080603230333.GA14629@harlan.lerp.com> * Jim Snow [080531 15:23]: > Without looking at the code to verify that this is how it has really > been implemented, a bloom filter is like a series of hash tables, where > the hash table entries are one bit. The bit is set if there is an item > that hashes to that value in the bloom filter. So, assuming a single > hash table where half the bits are set, there's a 50% false positive > rate and no false negatives when you do a membership test. > > To reduce the false positives, we can add another hash table with a > different hash function. Assuming it also is half full, we can check if > an item is in both tables, and our false positive rate drops to 25%. > > In practice, one might use something like 32 hash tables. This yields a > false positive rate of 1/(2^32). Their most obvious application is to > store the dictionary for a spell checker in a space-efficient way, > though I have a friend who wrote a paper on using them for router caches. > > There was a google tech talk on bloom filters awhile ago: > http://www.youtube.com/watch?v=947gWqwkhu0 One other use: LOAF is a simple extension to email that lets you append your entire address book to outgoing mail message without compromising your privacy. Correspondents can use this information to prioritize their mail, and learn more about their social networks. The LOAF home page is at http://loaf.cantbedone.org. From trebla at vex.net Tue Jun 3 19:16:08 2008 From: trebla at vex.net (Albert Y. C. Lai) Date: Tue Jun 3 19:08:46 2008 Subject: [Haskell-cafe] Laziness leaks In-Reply-To: <62728db30806031414p19593f40x5ad1bfd32e2dfc4b@mail.gmail.com> References: <62728db30806031414p19593f40x5ad1bfd32e2dfc4b@mail.gmail.com> Message-ID: <4845D0B8.6040802@vex.net> Ronald Guida wrote: > I was looking at the real time queues in [1] and I wanted to see what > would happen if I tried to write one in Haskell. The easy part was > translating the real time queue from [1], p43 into Haskell. > > The hard part is testing to see if the rotations really happen what > they should. Basically, I decided to use Debug.Trace.trace to see > when rotations were actually occurring. > > I pushed the numbers 1 to 10 into the queue, and then I popped the > queue ten times. What I found is that none of the rotations would > actually take place until the first time I actually tried to /display > the value/ of a popped element. What I realized is that my test > driver is lazy. I figured out that I could put a bunch of 'seq' > functions in the test driver to get the rotations to happen. > > My demonstration code is in: > http://hpaste.org/8080 > > This leads to two questions: > > 1. If I find a laziness leak, is 'seq' the appropriate way to plug it? > > 2. Is there any way to systematically search for or detect laziness > leaks? > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > I want to point out several non-causes of laziness. For a no-magic, no-surprise understanding, it is important to know both what causes laziness and what does not. A. The lazy list at rtqRear, which is originally a strict list. It is an invariant that every thunk you put there is [] or x:y. (As a result, it is unnecessary to make RTQueue a strict record, since you want two of the fields to be lazy, and the remaining field rtqRear is de facto strict.) B. rtqueue's thunked call to rotate, i.e., rtqueue f r [] = let f' = rotate f r [] in RTQueue f' [] f' Originally f' is forced before the record is returned (SML convention). In Haskell the rotate call is thunked as f' and the record is returned. But there will not be an accumulation of such rotate thunks. For example if you snoc twice in succession and the first instance builds a rotate thunk: snoc p (snoc q (RTQueue f r [])) -> snoc p (rtqueue f (q:r) []) -> snoc p (RTQueue f' [] f') where f' = thunk -> rtqueue f' p:[] f' where f' = thunk -> f' is now forced by rtqueue's pattern matching on the 3rd param So if one snoc builds a rotate thunk, the next snoc kills it. And similarly any interleaving of queue operations. (head and tail add their extra pattern matching.) Thus it can be proved that Haskell lags behind the original by just one step in this regard. This is ok unless you're done with reducing asymptotic cost and start looking at constant factor cost. A true cause of laziness is in accumulating a chain of tail's and snocs without intermediate forcing, as observed. From adam.smyczek at gmail.com Tue Jun 3 20:11:33 2008 From: adam.smyczek at gmail.com (Adam Smyczek) Date: Tue Jun 3 20:04:11 2008 Subject: [Haskell-cafe] A simple beginner question Message-ID: <0F2FB381-056A-45E2-A046-ED80466F6608@gmail.com> Example: data SampleType = A | B Int | C String | D -- .... etc. sampleTypes = [A, B 5, C "test"] :: [SampleType] How do I find for example element A in the sampleTypes list? Do I have to create e.g.: isA :: SampleType -> Bool isA A = True isA _ = False for every constructor and use find? It feels like this is not the quicker method. Thanks, Adam From oddron at gmail.com Tue Jun 3 20:12:12 2008 From: oddron at gmail.com (Ronald Guida) Date: Tue Jun 3 20:04:50 2008 Subject: [Haskell-cafe] Laziness leaks In-Reply-To: <4845D0B8.6040802@vex.net> References: <62728db30806031414p19593f40x5ad1bfd32e2dfc4b@mail.gmail.com> <4845D0B8.6040802@vex.net> Message-ID: <62728db30806031712w32421ae5scbf84920ecd71193@mail.gmail.com> Don Stewart wrote: >> 2. Is there any way to systematically search for or detect laziness >> leaks? > > Profiling, and looking at the Core. Being explicit about the > evaluation strategy you want is a fine idea though. Albert Y. C. Lai wrote > A true cause of laziness is in accumulating a chain of tail's and > snocs without intermediate forcing, as observed. So I just thought of something. If laziness leads to laziness leaks, then is there such a thing as a strictness leak? I realized that the answer is yes. A lazy leak is a situation where I'm wasting resources to delay a sequence of calculations instead of just doing them now. But in a strict language, I might waste resources to compute things that I'll never need. I would call that a strictness leak. Now I could ask the dual question, "How do I detect strictness leaks," and I would probably get the same answers: profiling, looking at object code, and being explicit about the evaluation strategy. Both types of leaks share a lot in common. In both cases, I'm wasting resources. If I have a real-time system, then either type of leak can cause me to a miss a deadline. With a strict evaluation strategy, I might miss a nearby deadline because I'm busy calculating things that I don't need until the distant future. With a lazy evaluation strategy, I might miss a distant deadline because I'm lazily putting off a calculation now. If I were a college student, then this would be a laziness leak: Professor X assigns a report, due in a month. Two days before the report is due, I'll head to the drugstore, load up on caffeine, and work for 48 hours straight to get it done. And this would be a strictness leak: Professor X assigns a report, due in a month. As soon as I leave the classroom, I'll head to the drugstore, load up on caffeine, and work for 48 hours straight to get it done. And this would be an effective solution: Professor X assigns a report, due in a month. I'll select 15 days, spaced out over the next month, and allocate four hours per day to work on the report. By default, a lazy language will procrastinate. By default, a strict language will "anticrastinate". Either way, I can waste resources by blindly accepting the default time management plan. So the real question is "How do I avoid laziness leaks or strictness leaks" and apparently, the real answers are (1) learn how to recognize when the default plan will waste resources, and (2) learn how to express reasonable evaluation strategies in code. I would ask, "how do I examine the evaluation order of my code", but the answer is already available: use a debugger. Haskell already has debugging tools that do exactly what I need. (http://www.haskell.org/haskellwiki/Debugging) In particular, HOOD looks extremely interesting. From ryani.spam at gmail.com Tue Jun 3 20:33:33 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue Jun 3 20:26:11 2008 Subject: [Haskell-cafe] More on performance In-Reply-To: <20080603174704.GB22053@scytale.galois.com> References: <20080603174704.GB22053@scytale.galois.com> Message-ID: <2f9b2d30806031733p390c1590l9cedbfc5a405c704@mail.gmail.com> I think it's hard to overstate how awesome the RULES pragma is. Thanks for the example. -- ryan On 6/3/08, Don Stewart wrote: > I wrote up the second part of the tour of understanding low level > performance in GHC here, > > http://reddit.com/r/programming/info/6lx36/comments/ > > Follows on from the discussion last week about various performance > related things. > > Enjoy. > > -- Don > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From philip.weaver at gmail.com Tue Jun 3 20:48:24 2008 From: philip.weaver at gmail.com (Philip Weaver) Date: Tue Jun 3 20:41:01 2008 Subject: [Haskell-cafe] A simple beginner question In-Reply-To: <0F2FB381-056A-45E2-A046-ED80466F6608@gmail.com> References: <0F2FB381-056A-45E2-A046-ED80466F6608@gmail.com> Message-ID: On Tue, Jun 3, 2008 at 5:11 PM, Adam Smyczek wrote: > Example: > > data SampleType = A | B Int | C String | D -- .... etc. > > sampleTypes = [A, B 5, C "test"] :: [SampleType] > > How do I find for example element A in the sampleTypes list? > Do I have to create e.g.: > > isA :: SampleType -> Bool > isA A = True > isA _ = False > > for every constructor and use find? isA is already defined for every constructor, so all you have to do is "find isA" > It feels like this is not the quicker method. > > Thanks, > Adam > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From oddron at gmail.com Tue Jun 3 20:48:39 2008 From: oddron at gmail.com (Ronald Guida) Date: Tue Jun 3 20:41:16 2008 Subject: [Haskell-cafe] A simple beginner question In-Reply-To: <0F2FB381-056A-45E2-A046-ED80466F6608@gmail.com> References: <0F2FB381-056A-45E2-A046-ED80466F6608@gmail.com> Message-ID: <62728db30806031748qdf37398i8e725fee00700e87@mail.gmail.com> Adam Smyczek wrote: > data SampleType = A | B Int | C String | D -- .... etc. > > sampleTypes = [A, B 5, C "test"] :: [SampleType] > > How do I find for example element A in the sampleTypes list? Here's one way to do it: filter (\x -> case x of A -> True; otherwise -> False) sampleTypes ==> [A] filter (\x -> case x of B _ -> True; otherwise -> False) sampleTypes ==> [B 5] filter (\x -> case x of C _ -> True; otherwise -> False) sampleTypes ==> [C "test"] Your idea works just as well: > isA :: SampleType -> Bool > isA A = True > isA _ = False filter isA sampleTypes ==> [A] There is a third possibility: Have you learned about the maybe function or the either function yet? maybe :: b -> (a -> b) -> Maybe a -> b either :: (a -> c) -> (b -> c) -> Either a b -> c I would call these "mediating morphisms", where "morphism" is techno- babble for "function". You could write your own version of one of these for SampleType. Assuming you have: data SampleType = A | B Int | C String You could write: sampletype :: t -> (Int -> t) -> (String -> t) -> SampleType -> t sampletype a bf cf s = case s of A -> a B n -> bf n C s -> cf s isA = sampletype True (const False) (const False) isB = sampletype False (const True) (const False) isC = sampletype False (const False) (const True) filter isA sampleTypes ==> [A] This (the mediating morphism) is probably overkill for what you want to do, though. From barsoap at web.de Tue Jun 3 20:51:09 2008 From: barsoap at web.de (Achim Schneider) Date: Tue Jun 3 20:44:03 2008 Subject: [Haskell-cafe] Re: A simple beginner question References: <0F2FB381-056A-45E2-A046-ED80466F6608@gmail.com> Message-ID: <20080604025109.5a83976d@solaris> Adam Smyczek wrote: > data SampleType = A | B Int | C String | D -- .... etc. deriving (Eq) > sampleTypes = [A, B 5, C "test"] :: [SampleType] > If you derive from Eq, you can do isA = (==) A filter isA sampleTypes or ad-hoc: filter ((==) A) sampleTypes things like filter (\x -> case x of { A -> True ; B b | b > 2 -> True ; C c | c == "foo" -> True ; _ -> False}) sampleTypes work, too. Admittedly, I'm lambda-spoilt. -- (c) this sig last receiving data processing entity. Inspect headers for past copyright information. All rights reserved. Unauthorised copying, hiring, renting, public performance and/or broadcasting of this signature prohibited. From barsoap at web.de Tue Jun 3 21:02:43 2008 From: barsoap at web.de (Achim Schneider) Date: Tue Jun 3 20:55:27 2008 Subject: [Haskell-cafe] Re: A simple beginner question References: <0F2FB381-056A-45E2-A046-ED80466F6608@gmail.com> <20080604025109.5a83976d@solaris> Message-ID: <20080604030243.50c565d3@solaris> Achim Schneider wrote: > filter (\x -> case x of > { A -> True > ; B b | b > 2 -> True > ; C c | c == "foo" -> True > ; _ -> False}) sampleTypes coming to think of it: Why can't I write filter (\A -> True \B b | b > 2 -> True \C c | c == "foo" -> True _ -> False ) sampleTypes ? AFAICT it's syntactically unambiguous. -- (c) this sig last receiving data processing entity. Inspect headers for past copyright information. All rights reserved. Unauthorised copying, hiring, renting, public performance and/or broadcasting of this signature prohibited. From derek.a.elkins at gmail.com Tue Jun 3 21:08:26 2008 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Tue Jun 3 21:01:20 2008 Subject: [Haskell-cafe] Laziness leaks In-Reply-To: <62728db30806031712w32421ae5scbf84920ecd71193@mail.gmail.com> References: <62728db30806031414p19593f40x5ad1bfd32e2dfc4b@mail.gmail.com> <4845D0B8.6040802@vex.net> <62728db30806031712w32421ae5scbf84920ecd71193@mail.gmail.com> Message-ID: <1212541707.7306.22.camel@derek-laptop> On Tue, 2008-06-03 at 20:12 -0400, Ronald Guida wrote: > Don Stewart wrote: > >> 2. Is there any way to systematically search for or detect laziness > >> leaks? > > > > Profiling, and looking at the Core. Being explicit about the > > evaluation strategy you want is a fine idea though. > > Albert Y. C. Lai wrote > > A true cause of laziness is in accumulating a chain of tail's and > > snocs without intermediate forcing, as observed. > > So I just thought of something. If laziness leads to laziness leaks, > then is there such a thing as a strictness leak? I realized that the > answer is yes. I ask a similar question here albeit for a much narrower and more technical notion: http://lambda-the-ultimate.org/node/2273#comment-40156 and come to the same conclusion (at least for an even more narrow notion). From westondan at imageworks.com Tue Jun 3 21:09:39 2008 From: westondan at imageworks.com (Dan Weston) Date: Tue Jun 3 21:02:18 2008 Subject: [Haskell-cafe] A simple beginner question In-Reply-To: <0F2FB381-056A-45E2-A046-ED80466F6608@gmail.com> References: <0F2FB381-056A-45E2-A046-ED80466F6608@gmail.com> Message-ID: <4845EB53.1070606@imageworks.com> There's always one more way to do things in Haskell! :) Here's yet another way to get at the payloads in a list. You don't have to know how this works to use it: data SampleType = A | B Int | C String unA :: SampleType -> [()] unA A = return () unA _ = fail "Not an A" unB :: SampleType -> [Int] unB (B b) = return b unB _ = fail "Not a B" unC :: SampleType -> [String] unC (C c) = return c unC _ = fail "Not a C" -- I can check for more than one constructor... -- Note that a single type must be returned, -- so for C I return e.g. the length of the string unBorC :: SampleType -> [Int] unBorC (B b) = return b unBorC (C c) = return (length c) unBorC _ = fail "Not a B or C" For lists, the >>= operator knows to ignore failure and collect anything else into a new list. The technobabble for this is that [] is a Monad. *Main> let sampleTypes = [A, B 5, C "test", A, A, B 7, C "go"] *Main> sampleTypes >>= unA [(),(),()] *Main> sampleTypes >>= unB [5,7] *Main> sampleTypes >>= unC ["test","go"] *Main> sampleTypes >>= unBorC [5,4,7,2] Adam Smyczek wrote: > Example: > > data SampleType = A | B Int | C String | D -- .... etc. > > sampleTypes = [A, B 5, C "test"] :: [SampleType] > > How do I find for example element A in the sampleTypes list? > Do I have to create e.g.: > > isA :: SampleType -> Bool > isA A = True > isA _ = False > > for every constructor and use find? > It feels like this is not the quicker method. > > Thanks, > Adam > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From barsoap at web.de Tue Jun 3 21:50:36 2008 From: barsoap at web.de (Achim Schneider) Date: Tue Jun 3 21:43:22 2008 Subject: [Haskell-cafe] Re: A simple beginner question References: <0F2FB381-056A-45E2-A046-ED80466F6608@gmail.com> <4845EB53.1070606@imageworks.com> Message-ID: <20080604035036.5ae7861e@solaris> Dan Weston wrote: > There's always one more way to do things in Haskell! :) > > Here's yet another way to get at the payloads in a list. You don't > have to know how this works to use it: > Bastard. He's going to try and find out how it works. To get back to the filters: module Main where import Control.Monad data SampleType = A | B Int | C String deriving Show noA :: SampleType -> [SampleType] noA A = mzero noA e = return e noB :: SampleType -> [SampleType] noB (B _) = mzero noB e = return e noAB :: SampleType -> [SampleType] noAB m = [m] >>= noA >>= noB sampleTypes = [A, B 5, C "test", A, A, B 7, C "go"] *Main> sampleTypes >>= noA [B 5,C "test",B 7,C "go"] *Main> sampleTypes >>= noB [A,C "test",A,A,C "go"] *Main> sampleTypes >>= noAB [C "test",C "go"] -- (c) this sig last receiving data processing entity. Inspect headers for past copyright information. All rights reserved. Unauthorised copying, hiring, renting, public performance and/or broadcasting of this signature prohibited. From greg at momotaro.chinmin.edu.tw Tue Jun 3 23:05:41 2008 From: greg at momotaro.chinmin.edu.tw (Greg Matheson) Date: Tue Jun 3 23:10:15 2008 Subject: [Haskell-cafe] HDBC-odbc 1.1.4.4 fixes Windows linking problems In-Reply-To: <20080603200020.GA13041@complete.org> References: <20080603200020.GA13041@complete.org> Message-ID: <20080604030541.GA26462@momotaro.chinmin.edu.tw> On Tue, 03 Jun 2008, John Goerzen wrote: > Hi, > HDBC-odbc version 1.1.4.4 has been uploaded to Hackage. It fixes the > problems some here have encountered regarding ODBC crashes or other > similar odd behavior on Windows. I'm getting a 'Parse error in pattern' error. C:\Documents and Settings\Administrator>ghci GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help Loading package base ... linking ... done. Prelude> :m Database.HDBC.ODBC Database.HDBC Prelude Database.HDBC Database.HDBC.ODBC> conn <- connectODBC "dictation" Loading package array-0.1.0.0 ... linking ... done. Loading package containers-0.1.0.1 ... linking ... done. Loading package bytestring-0.9.0.1 ... linking ... done. Loading package old-locale-1.0.0.0 ... linking ... done. Loading package old-time-1.0.0.0 ... linking ... done. Loading package mtl-1.1.0.0 ... linking ... done. Loading package HDBC-1.1.4 ... linking ... done. Loading package HDBC-odbc-1.1.4.4 ... linking ... done. *** Exception: (unknown) Prelude Database.HDBC Database.HDBC.ODBC> handleSqlError $ conn <- connectODBC " dictation" :1:0: Parse error in pattern -- Dr Bean If there is one thing we learn from the study of language learning, it is that language learners learn more than we learn. From andrew.appleyard at gmail.com Tue Jun 3 23:37:06 2008 From: andrew.appleyard at gmail.com (Andrew Appleyard) Date: Tue Jun 3 23:31:49 2008 Subject: [Haskell-cafe] HDBC-odbc 1.1.4.4 fixes Windows linking problems In-Reply-To: <20080604030541.GA26462@momotaro.chinmin.edu.tw> References: <20080603200020.GA13041@complete.org> <20080604030541.GA26462@momotaro.chinmin.edu.tw> Message-ID: <48460DE2.5080602@gmail.com> On 4/06/2008 1:05 PM, Greg Matheson wrote: > I'm getting a 'Parse error in pattern' error. > > C:\Documents and Settings\Administrator>ghci > GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help > Loading package base ... linking ... done. > Prelude> :m Database.HDBC.ODBC Database.HDBC > [...] > Prelude Database.HDBC Database.HDBC.ODBC> handleSqlError $ conn <- connectODBC " > dictation" > :1:0: Parse error in pattern Try: conn <- handleSqlError $ connectODBC "dictation" You can only use '<-' in a do expression, or at the GHCi prompt. -- Andrew From dons at galois.com Tue Jun 3 23:56:32 2008 From: dons at galois.com (Don Stewart) Date: Tue Jun 3 23:49:10 2008 Subject: [Haskell-cafe] A simple beginner question In-Reply-To: <0F2FB381-056A-45E2-A046-ED80466F6608@gmail.com> References: <0F2FB381-056A-45E2-A046-ED80466F6608@gmail.com> Message-ID: <20080604035632.GA12175@scytale.galois.com> adam.smyczek: > Example: > > data SampleType = A | B Int | C String | D -- .... etc. > > sampleTypes = [A, B 5, C "test"] :: [SampleType] > > How do I find for example element A in the sampleTypes list? > Do I have to create e.g.: > > isA :: SampleType -> Bool > isA A = True > isA _ = False > > for every constructor and use find? > It feels like this is not the quicker method. This is where the implicit filtering in a list comprehension comes in really handy, data T = A | B Int | C String | D deriving Show xs = [A, B 5, C "test", D] main = do print [ A | A <- xs ] -- filter A's print [ x | x@(C _) <- xs ] -- filter C's {- *Main> main [A] [C "test"] -} From lrpalmer at gmail.com Wed Jun 4 00:28:15 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Wed Jun 4 00:20:52 2008 Subject: [Haskell-cafe] A simple beginner question In-Reply-To: <62728db30806031748qdf37398i8e725fee00700e87@mail.gmail.com> References: <0F2FB381-056A-45E2-A046-ED80466F6608@gmail.com> <62728db30806031748qdf37398i8e725fee00700e87@mail.gmail.com> Message-ID: <7ca3f0160806032128s44b03eeaw63242e20e8bd21ea@mail.gmail.com> On Tue, Jun 3, 2008 at 6:48 PM, Ronald Guida wrote: > filter (\x -> case x of A -> True; otherwise -> False) sampleTypes > ==> [A] > > filter (\x -> case x of B _ -> True; otherwise -> False) sampleTypes > ==> [B 5] There's a neat little mini-trick for these types of pattern matches: filter (\x -> case x of B {} -> True; otherwise -> False) sampleTypes Does the same thing, but works no matter how many arguments the constructor B takes. Luke From bertram.felgenhauer at googlemail.com Wed Jun 4 00:45:52 2008 From: bertram.felgenhauer at googlemail.com (Bertram Felgenhauer) Date: Wed Jun 4 00:38:34 2008 Subject: [Haskell-cafe] [ANNOUNCE] git-darcs-import 0.1 In-Reply-To: References: <20080601184446.GA27750@zombie.inf.tu-dresden.de> Message-ID: <20080604044552.GC4262@zombie.inf.tu-dresden.de> Darrin Thompson wrote: > On Sun, Jun 1, 2008 at 2:44 PM, Bertram Felgenhauer > wrote: > > I'm pleased to announce yet another tool for importing darcs repositories > > to git. [...] > > What's the appeal of this? I personally love git, but I thought all > the cool kids at this school used darcs and that was that. For myself, git-darcs-import itself is an opportunity to learn more about both darcs and git. It wasn't meant to be argument in the git vs. darcs discussion, although it was inevitable that it would be seen as such. I really like darcs' concepts, but in my opinion, darcs doesn't get enough power out of the theory of patches to really shine so far. This is a hard problem, and I can't offer solutions. Ideally, you'd have semantic patches which just commute with virtually all other patches because they "know" what they are about. The only thing that darcs offers in that direction - besides handling conflicts, mergers and undos gracefully, which is quite useful in itself - is a keyword substitution patch type. In the meantime, I prefer git to darcs, mainly because I'm sort of attached to seeing the development history, i.e. I prefer to think of patches as (partially) ordered instead of being a cloud of patches that darcs uses as a model. Bertram From ronwalf at volus.net Wed Jun 4 02:21:45 2008 From: ronwalf at volus.net (Ron Alford) Date: Wed Jun 4 02:14:23 2008 Subject: [Haskell-cafe] Wouter-style expressions Message-ID: Here's something that should be an easy extension of Wouter's approach to extensible datatypes, but I'm failing (possibly since it's 2:20am). I several classes of expressions I'm trying to represent (thus, Wouter's approach), and my first operation to implement over them is printing. Attached is a simplified version of what I'm doing. Expressions are composed of conjunctives (and) and atoms. Atoms are composed of a predicate string and a list of fillers (taken from 'Const' and 'Var'). For example (in a lisp like syntax): (and (pred c ?var1) (pred ?var1 ?var2)) To do this, I defined a 'Printable' class: class Functor f => Printable f where exprDoc :: f t -> Doc I think the 't' here will get me into trouble later. Combinations of printable types are also printable: instance (Printable f, Printable g) => Printable (f :+: g) where exprDoc (Inr x) = exprDoc x exprDoc (Inl y) = exprDoc y Constants, variables, and atoms are defined to be printable: instance Printable Var where exprDoc (Var name) = text ('?':name) instance Printable Const where exprDoc (Const name) = text name instance Printable f => Printable (Atomic (Expr f)) where exprDoc (Atomic p tl) = parens $ hsep $ (text p) : (map (\ (In t) -> exprDoc t) tl) But the obvious definition for conjunction doesn't work: instance Printable And where exprDoc (And el) = sep (map exprDoc el) GHC barfs, throwing: Couldn't match expected type `f t' against inferred type `t1' `t1' is a rigid type variable bound by the type signature for `exprDoc' at WouterTest.hs:62:17 Expected type: [f t] Inferred type: [t1] In the second argument of `map', namely `el' In the first argument of `sep', namely `(map exprDoc el)' I've attached the code. Compile and inspect with: $ ghci -fglasgow-exts -fallow-overlapping-instances WouterTest.hs test1 works great (other than needing some redundant typing, any hints?). test2 needs the definition of 'Printable And' to print, but I haven't gotten that to work yet. It also needs the redundant typing. -Ron However, I tried making more complex expression (conjunction, in this case), but I can't get the types to align. In particular, if I uncomment the obvious definition -------------- next part -------------- A non-text attachment was scrubbed... Name: WouterTest.hs Type: application/octet-stream Size: 2502 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080604/0eb8ece1/WouterTest.obj From lemming at henning-thielemann.de Wed Jun 4 03:32:04 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Wed Jun 4 03:24:39 2008 Subject: [Haskell-cafe] More on performance In-Reply-To: <20080603174704.GB22053@scytale.galois.com> References: <20080603174704.GB22053@scytale.galois.com> Message-ID: On Tue, 3 Jun 2008, Don Stewart wrote: > I wrote up the second part of the tour of understanding low level > performance in GHC here, > > http://reddit.com/r/programming/info/6lx36/comments/ > > Follows on from the discussion last week about various performance > related things. Now the difficult question: How to write the 'mean' function in terms of 'sum' and 'length' while getting the same performance? From bjpop at csse.unimelb.edu.au Wed Jun 4 03:57:50 2008 From: bjpop at csse.unimelb.edu.au (Bernie Pope) Date: Wed Jun 4 03:43:05 2008 Subject: [Haskell-cafe] Laziness leaks In-Reply-To: <62728db30806031712w32421ae5scbf84920ecd71193@mail.gmail.com> References: <62728db30806031414p19593f40x5ad1bfd32e2dfc4b@mail.gmail.com> <4845D0B8.6040802@vex.net> <62728db30806031712w32421ae5scbf84920ecd71193@mail.gmail.com> Message-ID: <68006573-98CC-44E8-97DC-B025DEA033E7@csse.unimelb.edu.au> On 04/06/2008, at 10:12 AM, Ronald Guida wrote: > I would ask, "how do I examine the evaluation order of my code", but > the answer is already available: use a debugger. Haskell already has > debugging tools that do exactly what I need. > (http://www.haskell.org/haskellwiki/Debugging) > > In particular, HOOD looks extremely interesting. I would recommend the GHCi debugger for looking at the evaluation order of code. Single stepping can be very illuminating. Bernie. From wss at Cs.Nott.AC.UK Wed Jun 4 04:22:06 2008 From: wss at Cs.Nott.AC.UK (Wouter Swierstra) Date: Wed Jun 4 04:15:38 2008 Subject: [Haskell-cafe] Wouter-style expressions In-Reply-To: References: Message-ID: <06B81692-7391-420A-B476-F328FF743633@Cs.Nott.AC.UK> Hi Ron, I've attached a revised file that solves your problem. The solution is actually quite subtle. If you define the class as: class Functor f => Printable f where exprDoc :: f t -> Doc you can't make recursive calls to sub-expressions. There is, after all, no reason to believe that "t" is Printable. The following choice of class is better: class Functor f => Printable f where exprDoc :: Printable g => f (Expr g) -> Doc Now when you define the instance for And, you can safely make recursive calls to the list of subchildren. To define the function you want, just add a wrapper to exprDoc: ppExpr : Printable f => Expr f -> Doc ppExpr (In t) = exprDoc t All the best, Wouter PS - You may want to add: infixr 6 :+: to you code. It'll save you a lot of parentheses! This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. -------------- next part -------------- A non-text attachment was scrubbed... Name: WouterTest.hs Type: application/octet-stream Size: 2694 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080604/9b3a1d9c/WouterTest.obj -------------- next part -------------- From gale at sefer.org Wed Jun 4 04:24:22 2008 From: gale at sefer.org (Yitzchak Gale) Date: Wed Jun 4 04:16:58 2008 Subject: [Haskell-cafe] A simple beginner question In-Reply-To: <0F2FB381-056A-45E2-A046-ED80466F6608@gmail.com> References: <0F2FB381-056A-45E2-A046-ED80466F6608@gmail.com> Message-ID: <2608b8a80806040124n2afb7cbcx931461a01d1e0e14@mail.gmail.com> Adam Smyczek wrote: > data SampleType = A | B Int | C String | D -- .... etc. > sampleTypes = [A, B 5, C "test"] :: [SampleType] > How do I find for example element A in the sampleTypes list? There have been many useful replies. But since Adam originally announced that this is a "beginner question", I think some perspective is in order. In Haskell, there is often no need at all for boolean-valued functions to deconstruct a data structure. Usually pattern matching does the job beautifully, and you structure your program to exploit that. In the case that you do need them, though, the previous responses are excellent suggestions. In my experience, the ways that I get data out of an ADT, from most common to most rare, are: 1. Just use pattern matching 2. Use record syntax to get selector functions 3. Define an Eq instance 4. Define per-constructor modifiers when the ADT is used as state in a state monad (this one is admittedly a pain in the neck) I can't remember the last time I needed to write a function like "isA" - it almost never comes up. My opinion, YMMV. Regards, Yitz From phercek at gmail.com Wed Jun 4 04:37:10 2008 From: phercek at gmail.com (Peter Hercek) Date: Wed Jun 4 04:29:54 2008 Subject: [Haskell-cafe] Re: [ANNOUNCE] git-darcs-import 0.1 In-Reply-To: References: <20080601184446.GA27750@zombie.inf.tu-dresden.de> <6f9f8f4a0806030757y142f0710lb05754429e4b6515@mail.gmail.com> Message-ID: Aaron Denney wrote: > This is drifting off-topic, but... > On 2008-06-03, Peter Hercek wrote: >> Aaron Denney wrote: <--- cut ---> >>> Darcs patches are pretty much an implicit rebase. >> You cannot push patch B if it depends on patch A without also >> pushing A. And darcs currently does not alow you to reorder >> B before A > > True. This is a *feature* not a bug. You shouldn't be able to do this > automatically, because it can't be done right. You need to do this sort > of thing manually. If you don't, the heuristics used will bite you at > some point. When they do commute, there is no problem. Sorry, I did not intend to indicate it should be done without doing the reordering first (by providing manual conflict resolution). >> Git rebase works quite well even in cloned repositories. > > Meh. It can, if you're really really lucky. Actually you are probably right, I needed to use a non-complicated workaround once (but I did it only about two times!). I might have been just lucky. I liked though that it did tell me what was wrong, in contrast to mercurial queues which just replicated both original branch and the rebased branch (so I finished with two copies on both sides at the end :-( ). <--- cut ---> > Rebasing is doable in git as a one-repository operation because each > repository has multiple branches. As darcs has one repo per branch, > it fundamentally needs to be done in multiple repos. > > There are naturally two repos, upstream, and your-feature-development. > > your-feature-development has a patch A that you want to rebase. > > What you should do is pull upstream into new-tracking, then pull patch A > from your-feature-development into new-tracking. > > If it applies with no problem, great: mv your-feature-development > your-feature-development-old; new-tracking your-feature-development. > Of course, in this case, you could have just pulled into > your-feature-development. If there weren't any other patches to save in > the old your-feature-development, you can delete it instead of moving > it. > > When there is a conflict, then you need to handle it somehow. Neither > git nor darcs can do it automatically. You can just record the merge > conflict and your resolution. This keeps repos that pulled from you > valid, but this won't give you the "clean history" that you presumably > want. So you need to combine the merger and cleanup into a new patch > with the same log message, etc. It's true that git does make *this* > process very nice. Ok, in such a simple case darcs can preserve the message too if the repository is not cloned (and you indicated that it does not really work with cloned repositories in git - I'm not an experienced git user). Just pull to the original repository and use amend-record to resolve the conflict and the message will be preserved. So I would tell that for *this* *simple* case darcs is better. But what about this git rebasing option? How to do it more easily (than the solution I know and I described it later) in darcs? using "git-rebase --onto master next topic" to get from: o---o---o---o---o master \ o---o---o---o---o next \ o---o---o topic to: o---o---o---o---o master | \ | o'--o'--o' topic \ o---o---o---o---o next This is the reason why I mentioned reordering depending patches AB to BA (with manual conflict resolution) would be needed in darcs to support (I believe a better) alternative to git rebase. I do not know how to do this in darcs (without doing manual addition of "topic" changes with gnu patch utility in a new darcs repository clone which would not have "topic" changes (and "next" changes as well) pulled in and throwing avay the old one at the end). > There is one thing that git rebase does easily (and correctly) that darcs > doesn't do nicely: rewriting history by merging commits "prior" to the > head. I put prior in quotes, because darcs doesn't preserve history > in the first place. I don't find that a compelling use, as opposed to > maintaing topic branches. I do not know what you mean here. Can you point me to some example? I hope that this is not too off-topic for haskell cafe ... and so far I believe this is not a flame war :-) I just like that Bertram's code exists and I think it (as well as git) should not be dismissed, since AFAIK there is more than performance to git as well as there is more to darcs than it not imposing patch order on us (which is the darcs feature I like). Peter. From jules at jellybean.co.uk Wed Jun 4 04:39:58 2008 From: jules at jellybean.co.uk (Jules Bean) Date: Wed Jun 4 04:32:35 2008 Subject: [Haskell-cafe] Laziness leaks In-Reply-To: <62728db30806031712w32421ae5scbf84920ecd71193@mail.gmail.com> References: <62728db30806031414p19593f40x5ad1bfd32e2dfc4b@mail.gmail.com> <4845D0B8.6040802@vex.net> <62728db30806031712w32421ae5scbf84920ecd71193@mail.gmail.com> Message-ID: <484654DE.9090907@jellybean.co.uk> Ronald Guida wrote: [snip] > By default, a lazy language will procrastinate. By default, a strict > language will "anticrastinate". Either way, I can waste resources by > blindly accepting the default time management plan. Nice analysis. Would you like to put that (the whole thing, not just that last para) on the wiki? Jules From simonpj at microsoft.com Wed Jun 4 05:09:47 2008 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Wed Jun 4 05:02:35 2008 Subject: [Haskell-cafe] problems with derive/TH In-Reply-To: <910ddf450805230811v164ee48bp92544d433f086238@mail.gmail.com> References: <910ddf450805230811v164ee48bp92544d433f086238@mail.gmail.com> Message-ID: <638ABD0A29C8884A91BC5FB5C349B1C32AE5944FE8@EA-EXMSG-C334.europe.corp.microsoft.com> | World.hs:42:0: | No instances for (Eq (a (M.Map String Player)), | Eq (a (M.Map ItemId Item)), | Eq (a (M.Map PlayerId Player)), | Eq (a (M.Map RoomId Room)), | Eq (a RoomId)) | arising from the 'deriving' clause of a data type declaration | at World.hs:(42,0)-(50,14) Yes, automatic 'deriving' in GHC became a little more restrictive in GHC 6.8 (I think), for very good reasons. I think that's what your problem is. The darcs repo http://cdsmith.twu.net/demos/mud seems to be offline today, so I can't look, but I think that's highly likely. The solution is invariably to add a manual instance declaration, as you have done in your subsequent message. Simon From greg at momotaro.chinmin.edu.tw Wed Jun 4 05:03:17 2008 From: greg at momotaro.chinmin.edu.tw (Greg Matheson) Date: Wed Jun 4 05:07:39 2008 Subject: [Haskell-cafe] HDBC-odbc 1.1.4.4 fixes Windows linking problems In-Reply-To: <48460DE2.5080602@gmail.com> References: <20080603200020.GA13041@complete.org> <20080604030541.GA26462@momotaro.chinmin.edu.tw> <48460DE2.5080602@gmail.com> Message-ID: <20080604090317.GA26893@momotaro.chinmin.edu.tw> On Wed, 04 Jun 2008, Andrew Appleyard wrote: > >Prelude Database.HDBC Database.HDBC.ODBC> handleSqlError $ conn <- > >connectODBC "dictation" > >:1:0: Parse error in pattern > Try: > conn <- handleSqlError $ connectODBC "dictation" C:\cygwin\home\Administrator>dictation dictation: user error (SQL error: SqlError {seState = "[\"IM002\",\"01S00\"]", s eNativeError = -1, seErrorMsg = "connectODBC/sqlDriverConnect: [\"0: [Microsoft] [ODBC \\197X\\176\\202\\181{\\166\\161\\186\\222\\178z\\173\\251] \\167\\228\\16 4\\163\\168\\236\\184\\234\\174\\198\\168\\211\\183\\189\\166W\\186\\217\\165B\\ 165\\188\\171\\252\\169w\\185w\\179]\\170\\186\\197X\\176\\202\\181{\\166\\161\" ,\"0: [Microsoft][ODBC \\197X\\176\\202\\181{\\166\\161\\186\\222\\178z\\173\\25 1] \\181L\\174\\196\\170\\186\\179s\\189u\\166r\\166\\234\\196\\221\\169\\202\"] "}) ghc can't handle Chinese Big5, it appears, but HDBC also does appear to be talking ODBC. -- Dr Bean If there is one thing we know after studying experts, it is that experts know more than we know. From duncan.coutts at worc.ox.ac.uk Wed Jun 4 05:30:22 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Jun 4 05:19:31 2008 Subject: [Haskell-cafe] More on performance In-Reply-To: References: <20080603174704.GB22053@scytale.galois.com> Message-ID: <1212571822.15010.266.camel@localhost> On Wed, 2008-06-04 at 09:32 +0200, Henning Thielemann wrote: > On Tue, 3 Jun 2008, Don Stewart wrote: > > > I wrote up the second part of the tour of understanding low level > > performance in GHC here, > > > > http://reddit.com/r/programming/info/6lx36/comments/ > > > > Follows on from the discussion last week about various performance > > related things. > > Now the difficult question: How to write the 'mean' function in terms of > 'sum' and 'length' while getting the same performance? There's another rather harder fusion transformation that notices when two left folds are demanded in the same strictness context and they fold over the same input list then they can be performed together. sum = foldl (\s x -> s + x) 0 length = foldl (\l x -> l + 1) 0 mean xs = sum xs / length xs So we must note that sum and length are demanded at the same time and since they are both foldl's will consume the whole of xs. So we can merge the two foldl's into one just by tupling them up: sumlength = foldl (\(s, l) x -> (s + x, l + 1)) (0, 0) mean xs = s / l where (s, l) = sumlength xs The Fortran people have been doing this kind of loop fusion for some years. What makes it a bit harder for us is that we cannot do it with rules because it's not a simple local transformation. It could probably be done with a special compiler pass, though it'd need strictness analysis to be done much earlier. Duncan From apfelmus at quantentunnel.de Wed Jun 4 05:42:40 2008 From: apfelmus at quantentunnel.de (apfelmus) Date: Wed Jun 4 05:35:31 2008 Subject: [Haskell-cafe] Re: Laziness leaks In-Reply-To: <62728db30806031712w32421ae5scbf84920ecd71193@mail.gmail.com> References: <62728db30806031414p19593f40x5ad1bfd32e2dfc4b@mail.gmail.com> <4845D0B8.6040802@vex.net> <62728db30806031712w32421ae5scbf84920ecd71193@mail.gmail.com> Message-ID: Ronald Guida wrote: > So I just thought of something. If laziness leads to laziness leaks, > then is there such a thing as a strictness leak? I realized that the > answer is yes. > > A lazy leak is a situation where I'm wasting resources to delay a > sequence of calculations instead of just doing them now. But in a > strict language, I might waste resources to compute things that I'll > never need. I would call that a strictness leak. > > Now I could ask the dual question, "How do I detect strictness leaks," > and I would probably get the same answers: profiling, looking at > object code, and being explicit about the evaluation strategy. > > Both types of leaks share a lot in common. In both cases, I'm wasting > resources. If I have a real-time system, then either type of leak can > cause me to a miss a deadline. I haven't heard the terms "laziness leak" and "strictness leak" before, imho they sound a bit spooky because it's not clear to me what the situation without leak would be. (Time vs Space? Is an O(n) algorithm a strictness leak compared to an O(log n) algorithm?) Note that lazy evaluation never wastes time; evaluating a term with lazy evaluation will always take less reduction steps than doing so eagerly or partly eagerly. But it can waste space (-> "space leak"), for instance by accumulating a big expression like (..) -> ((..)+1) -> (((..) + 1) + 1) -> etc. instead of evaluating x+1 immediately 5 -> 6 -> 7 -> etc. However, this would be wasted time in case the whole expression will not be evaluated but just thrown away. So, it's a trade-off. The effect you have in mind only appears in real-time systems, where lazy evaluation procrastinates everything by default. So, trying to implement a real-time system in a lazy language is more or less a paradox :) as Okasaki already points out in his book. Eager evaluation may "waste" both time and space compared to alternative course of reduction. Regards, apfelmus PS: The reduction strategies we compare to don't evaluate under lambdas. From loup.vaillant at gmail.com Wed Jun 4 05:48:18 2008 From: loup.vaillant at gmail.com (Loup Vaillant) Date: Wed Jun 4 05:40:55 2008 Subject: [Haskell-cafe] More on performance In-Reply-To: <1212571822.15010.266.camel@localhost> References: <20080603174704.GB22053@scytale.galois.com> <1212571822.15010.266.camel@localhost> Message-ID: <6f9f8f4a0806040248x5f502f6eoae2a95dc8dc83778@mail.gmail.com> [Forgot to post to the list, sorry] 2008/6/4 Duncan Coutts : > > On Wed, 2008-06-04 at 09:32 +0200, Henning Thielemann wrote: >> On Tue, 3 Jun 2008, Don Stewart wrote: >> >> > I wrote up the second part of the tour of understanding low level >> > performance in GHC here, >> > >> > http://reddit.com/r/programming/info/6lx36/comments/ >> > >> > Follows on from the discussion last week about various performance >> > related things. >> >> Now the difficult question: How to write the 'mean' function in terms of >> 'sum' and 'length' while getting the same performance? > > There's another rather harder fusion transformation that notices when > two left folds are demanded in the same strictness context and they fold > over the same input list then they can be performed together. > > sum = foldl (\s x -> s + x) 0 > length = foldl (\l x -> l + 1) 0 > > mean xs = sum xs / length xs > > So we must note that sum and length are demanded at the same time and > since they are both foldl's will consume the whole of xs. > > So we can merge the two foldl's into one just by tupling them up: > > sumlength = foldl (\(s, l) x -> (s + x, l + 1)) (0, 0) > > mean xs = s / l > where (s, l) = sumlength xs I see a problem with this particular fusion, though: It changes the space complexity of the program, from linear to constant. Therefore, with some programs, relying on this "optimization" can be a matter of correctness, not just performance. Therefore, if it is not clear when the compiler will optimize this, I'd rather not use it. (A counter example is tail calls, which are rather easily deducible, at least in a strict context) At least, with more simple fusions, the difference was between stressing the GC or not. The space and time complexities of the problem didn't change at all. Only the constants did. Loup From ketil at malde.org Wed Jun 4 05:49:49 2008 From: ketil at malde.org (Ketil Malde) Date: Wed Jun 4 05:42:09 2008 Subject: [Haskell-cafe] More on performance In-Reply-To: (Henning Thielemann's message of "Wed\, 04 Jun 2008 09\:32\:04 +0200 \(MEST\)") References: <20080603174704.GB22053@scytale.galois.com> Message-ID: <87lk1l34xu.fsf@malde.org> Henning Thielemann writes: > Now the difficult question: How to write the 'mean' function in terms of > 'sum' and 'length' while getting the same performance? Write a RULE pragma converting \xs -> (foldl' f y0 xs,foldl' g z0 xs) into \xs -> foldl' (\(y,z) x -> (f y x,g z x)) (y0,z0) xs ? To actually work, it'd have to work for arbitrary top level function, not just the (,) constructor. No idea if it's feasible at all, of course :-) -k -- If I haven't seen further, it is by standing in the footprints of giants From lemming at henning-thielemann.de Wed Jun 4 05:51:42 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Wed Jun 4 05:44:24 2008 Subject: [Haskell-cafe] More on performance In-Reply-To: <1212571822.15010.266.camel@localhost> References: <20080603174704.GB22053@scytale.galois.com> <1212571822.15010.266.camel@localhost> Message-ID: On Wed, 4 Jun 2008, Duncan Coutts wrote: > On Wed, 2008-06-04 at 09:32 +0200, Henning Thielemann wrote: >> >> Now the difficult question: How to write the 'mean' function in terms of >> 'sum' and 'length' while getting the same performance? > > There's another rather harder fusion transformation that notices when > two left folds are demanded in the same strictness context and they fold > over the same input list then they can be performed together. > > sum = foldl (\s x -> s + x) 0 > length = foldl (\l x -> l + 1) 0 > > mean xs = sum xs / length xs > > So we must note that sum and length are demanded at the same time and > since they are both foldl's will consume the whole of xs. > > So we can merge the two foldl's into one just by tupling them up: > > sumlength = foldl (\(s, l) x -> (s + x, l + 1)) (0, 0) > > mean xs = s / l > where (s, l) = sumlength xs How about assisting the compiler with a helper function named 'parallel' ? parallel :: ([a] -> b, [a] -> c) -> [a] -> (b,c) parallel (f,g) xs = (f xs, g xs) mean xs = uncurry (/) $ parallel (sum,length) xs ? We could state RULES in terms of 'parallel'. By calling 'parallel', the user tells, that he wants fusion here. Say "parallel/foldl/foldl" forall f, g, x0, y0. parallel (foldl f x0, foldl g y0) = foldl (\(x,y) z -> (f x z, g y z)) (x0,y0) From apfelmus at quantentunnel.de Wed Jun 4 06:00:34 2008 From: apfelmus at quantentunnel.de (apfelmus) Date: Wed Jun 4 05:53:25 2008 Subject: [Haskell-cafe] Re: [ANNOUNCE] git-darcs-import 0.1 In-Reply-To: References: <20080601184446.GA27750@zombie.inf.tu-dresden.de> <6f9f8f4a0806030757y142f0710lb05754429e4b6515@mail.gmail.com> Message-ID: Peter Hercek wrote: > But what about this git rebasing option? How to do it more easily > (than the solution I know and I described it later) in darcs? > > using "git-rebase --onto master next topic" to get from: > o---o---o---o---o master > \ > o---o---o---o---o next > \ > o---o---o topic > to: > > o---o---o---o---o master > | \ > | o'--o'--o' topic > \ > o---o---o---o---o next > > This is the reason why I mentioned reordering depending patches AB > to BA (with manual conflict resolution) would be needed in darcs > to support (I believe a better) alternative to git rebase. I don't understand (probably because I haven't use either dvcs). Either the changes in the next->topic path don't depend on the changes in the fork->next path. Then, the patches commute and it's no problem for darcs. Or the next->topic path relies on features from next that are not present in master . But then, you're screwed anyway and should merge some parts from next into master so as to advance the point where master and next fork. o---o---o---o---o master \ x---x---o---o---o next \ o---o---o topic (Of course, you don't actually advance the fork but rather add patches at the end of master . Hm, set of patches semantics seem to be a lot nicer here anyway. To me, the whole point of rebasing seems to be to somehow bring set semantics into the tree semantics.) Regards, apfelmus From lrpalmer at gmail.com Wed Jun 4 06:05:52 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Wed Jun 4 05:58:29 2008 Subject: [Haskell-cafe] More on performance In-Reply-To: <6f9f8f4a0806040248x5f502f6eoae2a95dc8dc83778@mail.gmail.com> References: <20080603174704.GB22053@scytale.galois.com> <1212571822.15010.266.camel@localhost> <6f9f8f4a0806040248x5f502f6eoae2a95dc8dc83778@mail.gmail.com> Message-ID: <7ca3f0160806040305x4bc0dd27tf8621b88acdf8c1e@mail.gmail.com> On Wed, Jun 4, 2008 at 9:48 AM, Loup Vaillant wrote: > I see a problem with this particular fusion, though: It changes the > space complexity of the program, from linear to constant. Therefore, > with some programs, relying on this "optimization" can be a matter of > correctness, not just performance. Therefore, if it is not clear when > the compiler will optimize this, I'd rather not use it. (A counter > example is tail calls, which are rather easily deducible, at least in > a strict context) Haskell is not required to be lazy, only non-strict. That is, Haskell as a language is free to re-evaluate expressions bound in let clauses. This can change the time and space complexity of a program. To me, time and space complexity is not about correctness but performance. Given unbounded time and space, you will still arrive at the same result regardless of the complexity. What makes the asymptotic class more blessed than the associated constants? However I still see your point. If optimizations cannot be guaranteed--the conditions under which they fire are brittle--then the language can be yet harder to predict (which is not something Haskell needs!). It's hard to turn down an optimization which will accidentally asymptotically improve your program, however. I wonder what can be said about "stable" optimizations which are insensitive to their environments in some sense. Luke From marlowsd at gmail.com Wed Jun 4 06:33:35 2008 From: marlowsd at gmail.com (Simon Marlow) Date: Wed Jun 4 06:26:17 2008 Subject: [Haskell-cafe] Re: Ubuntu and ghc In-Reply-To: <008001c8bbf7$63753100$d0357ad5@cr3lt> References: <5ae4f2ba0805211532l35bef8eas9a10ff6df3e0f843@mail.gmail.com> <1211448821.5824.504.camel@localhost> <008001c8bbf7$63753100$d0357ad5@cr3lt> Message-ID: <48466F7F.8090600@gmail.com> Claus Reinke wrote: > - i don't want to have to remove anything explicitly, because that > would mean bypassing the haskell installation managers > - i would want to see a single haskell installation manager > for each system, I think that's fundamentally the wrong approach. We shouldn't have to build a "Haskell installation manager". Would you also want installation managers for Perl, Python, Ruby, C, C++, etc. each with their own different user interfaces and feature sets? I think not - you want a single package manager for the whole system from which you can install/uninstall libraries for any language. This is something that Windows gets completely wrong. Why do I have twelve icons in my status bar all representing little programs that are running in the background checking for updates to their own bits of software? Why on earth do I have a Printer Driver Update Manager? And I'd be wondering the same thing about a "Haskell installation manager": installation and dependencies are not something specific to Haskell. Cheers, Simon From wnoise at ofb.net Wed Jun 4 06:51:07 2008 From: wnoise at ofb.net (Aaron Denney) Date: Wed Jun 4 06:44:01 2008 Subject: [Haskell-cafe] Re: [ANNOUNCE] git-darcs-import 0.1 References: <20080601184446.GA27750@zombie.inf.tu-dresden.de> <6f9f8f4a0806030757y142f0710lb05754429e4b6515@mail.gmail.com> Message-ID: On 2008-06-04, Peter Hercek wrote: > But what about this git rebasing option? How to do it more easily > (than the solution I know and I described it later) in darcs? > > using "git-rebase --onto master next topic" to get from: > o---o---o---o---o master > \ > o---o---o---o---o next > \ > o---o---o topic > to: > > o---o---o---o---o master > | \ > | o'--o'--o' topic > \ > o---o---o---o---o next apfelmus answered this. I might expand on his reply. >> There is one thing that git rebase does easily (and correctly) that darcs >> doesn't do nicely: rewriting history by merging commits "prior" to the >> head. I put prior in quotes, because darcs doesn't preserve history >> in the first place. I don't find that a compelling use, as opposed to >> maintaing topic branches. > > I do not know what you mean here. Can you point me to some example? Letting capitals be commits, and lowercase be trees at the point of these commits. Suppose your history is: A -> B -> C -> D | | | | a b c d And that B somehow doesn't make sense except with the additional changes in C. You don't want to deal with this, or have anyone see B. All it does is clutter up the history. So you want to expunged it from the history. git rebase can rewrite this to A ------> C' -> D' | | | a c d Doing this in darcs would require unrecording B and C, and then rerecording C'. But, if D is in the repo, then it is likely that B and C can't be commuted past it to be unrecorded. (If they can, no problem!) Unrecording D (and possible E, F, G, etc.) lets you do this, but if you then pull it back from another repo, it will depend on B and C, and pull these in, which are now doppelgangers of C'. Not having used darcs 2, I'm not sure if that's still quite so fatal, but it remains bad news AIUI. The bottom line is that darcs is a tool for managing sets of always existing patches. and ordering them lazily, as needed. In particular, no history generally exists, unless each patch depends on exactly one previous. It has a "differential" view of software development, in that the changes, and not the sum at each point matter (though of course, the current sum does matter.) On the other hand, git is a tool for managing (and munging) histories of development in many weird and wacky ways. It has an "integral" view of software development, the changes are lazily derived from the saved state at each point, and are strictly ordered even when they're independent. It can, when needed, work with these changes to accomplish fairly interesting history-altering tasks, but as soon as they're used to construct a new history, they're discarded. (Yes, git uses deltas, but this is "merely" an optimization.) The two models are dual to each other in many ways. -- Aaron Denney -><- From wnoise at ofb.net Wed Jun 4 07:11:56 2008 From: wnoise at ofb.net (Aaron Denney) Date: Wed Jun 4 07:04:46 2008 Subject: [Haskell-cafe] Re: [ANNOUNCE] git-darcs-import 0.1 References: <20080601184446.GA27750@zombie.inf.tu-dresden.de> <6f9f8f4a0806030757y142f0710lb05754429e4b6515@mail.gmail.com> Message-ID: On 2008-06-04, apfelmus wrote: > Peter Hercek wrote: >> But what about this git rebasing option? How to do it more easily >> (than the solution I know and I described it later) in darcs? >> >> using "git-rebase --onto master next topic" to get from: >> to: >> >> o---o---o---o---o master >> \ >> o---o---o---o---o next >> \ >> o---o---o topic >> >> o---o---o---o---o master >> | \ >> | o'--o'--o' topic >> \ >> o---o---o---o---o next >> >> This is the reason why I mentioned reordering depending patches AB >> to BA (with manual conflict resolution) would be needed in darcs >> to support (I believe a better) alternative to git rebase. > > I don't understand (probably because I haven't use either dvcs). > > Either the changes in the next->topic path don't depend on the changes > in the fork->next path. Then, the patches commute and it's no problem > for darcs. Right. Then >> o---o---o---o---o master >> \ >> o---o---o---o---o next >> \ >> o---o---o topic is not a good model for what darcs has. What it has is more like >> o---o---o---o---o master >> |\ >> | o---o---o---o---o next >> \ | >> o---o---o--------+ topic The patches in "topic" that are in "next" are indepent of the ones that aren't in "next", so it's another (virtual) line-of-development, that darcs can lazily construct as needed. These lines-of-development are similar to branches of git that have been merged, but you also have access to the "unmerged" versions until a patch comes in that depends on the merger. If I commit three new features that don't interact, a darcs repo will essentially look like: ---- topicA - / \ history --- topicB --+-- \ / ---- topicC - Where the merger is "virtual". Darcs will implicitly linearize this to any of history --- topicA --- topicB --- topicC --- history --- topicA --- topicC --- topicB --- history --- topicB --- topicA --- topicC --- history --- topicB --- topicC --- topicA --- history --- topicC --- topicA --- topicB --- history --- topicC --- topicB --- topicA --- /as needed/. git constructs one of these, based on how you did the commits, and gives you ways to alter it to the others. > Or the next->topic path relies on features from next that are not > present in master . But then, you're screwed anyway Yep. > and should merge some parts from next into master so as to advance the > point where master and next fork. That's one solution. Of course, darcs doesn't have semantic dependency, but syntactic dependency. (You can add extra dependencies to model semantic dependencies, but you can't take away the syntactic dependencies.) Another solution, if there's syntactic, but not semantic dependencies, is to manually use patch and diff to get 90% there, and then cleanup and record. -- Aaron Denney -><- From ganesh.sittampalam at credit-suisse.com Wed Jun 4 07:13:28 2008 From: ganesh.sittampalam at credit-suisse.com (Sittampalam, Ganesh) Date: Wed Jun 4 07:07:12 2008 Subject: [Haskell-cafe] More on performance In-Reply-To: <7ca3f0160806040305x4bc0dd27tf8621b88acdf8c1e@mail.gmail.com> References: <20080603174704.GB22053@scytale.galois.com> <1212571822.15010.266.camel@localhost> <6f9f8f4a0806040248x5f502f6eoae2a95dc8dc83778@mail.gmail.com> <7ca3f0160806040305x4bc0dd27tf8621b88acdf8c1e@mail.gmail.com> Message-ID: <78A3C5650E28124399107F21A1FA41945B342E@ELON17P32002A.csfb.cs-group.com> > I wonder what can be said about "stable" optimizations which are insensitive to their environments in some sense. http://citeseer.ist.psu.edu/veldhuizen02guaranteed.html Ganesh ============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html ============================================================================== From jon at ffconsultancy.com Wed Jun 4 07:13:55 2008 From: jon at ffconsultancy.com (Jon Harrop) Date: Wed Jun 4 07:10:46 2008 Subject: [Haskell-cafe] More on performance In-Reply-To: <7ca3f0160806040305x4bc0dd27tf8621b88acdf8c1e@mail.gmail.com> References: <20080603174704.GB22053@scytale.galois.com> <6f9f8f4a0806040248x5f502f6eoae2a95dc8dc83778@mail.gmail.com> <7ca3f0160806040305x4bc0dd27tf8621b88acdf8c1e@mail.gmail.com> Message-ID: <200806041213.55484.jon@ffconsultancy.com> On Wednesday 04 June 2008 11:05:52 Luke Palmer wrote: > To me, time and space complexity is not about correctness but > performance. IRL the specification often dictates the complexity. If your code fails to satisfy the spec then it is wrong. Are you saying that Haskell code can never satisfy any such specification? > Given unbounded time and space, you will still arrive at the same result > regardless of the complexity. Given that the set of computers with unbounded time and space is empty, is it not fruitless to discuss its properties? -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/products/?e From lemming at henning-thielemann.de Wed Jun 4 08:14:08 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Wed Jun 4 08:07:36 2008 Subject: [Haskell-cafe] More on performance In-Reply-To: <7ca3f0160806040305x4bc0dd27tf8621b88acdf8c1e@mail.gmail.com> References: <20080603174704.GB22053@scytale.galois.com> <1212571822.15010.266.camel@localhost> <6f9f8f4a0806040248x5f502f6eoae2a95dc8dc83778@mail.gmail.com> <7ca3f0160806040305x4bc0dd27tf8621b88acdf8c1e@mail.gmail.com> Message-ID: On Wed, 4 Jun 2008, Luke Palmer wrote: > On Wed, Jun 4, 2008 at 9:48 AM, Loup Vaillant wrote: >> I see a problem with this particular fusion, though: It changes the >> space complexity of the program, from linear to constant. Therefore, >> with some programs, relying on this "optimization" can be a matter of >> correctness, not just performance. Therefore, if it is not clear when >> the compiler will optimize this, I'd rather not use it. (A counter >> example is tail calls, which are rather easily deducible, at least in >> a strict context) > > Haskell is not required to be lazy, only non-strict. That is, Haskell > as a language is free to re-evaluate expressions bound in let clauses. > This can change the time and space complexity of a program. > > To me, time and space complexity is not about correctness but > performance. Given unbounded time and space, you will still arrive at > the same result regardless of the complexity. What makes the > asymptotic class more blessed than the associated constants? Is it possible to extend the garbage collector that way, that it does not only check whether references to a piece of data exist, but that it also tries to eliminate these references by further evaluations. Consider again mean xs = sum xs / fromIntegral (length xs) If 'sum' forces construction of xs, unevaluated 'length' still points to the first element of xs. Could the garbage collector start counting for 'length' in order to free the first elements of xs? From barsoap at web.de Wed Jun 4 08:36:50 2008 From: barsoap at web.de (Achim Schneider) Date: Wed Jun 4 08:29:37 2008 Subject: [Haskell-cafe] Re: Ubuntu and ghc References: <5ae4f2ba0805211532l35bef8eas9a10ff6df3e0f843@mail.gmail.com> <1211448821.5824.504.camel@localhost> <008001c8bbf7$63753100$d0357ad5@cr3lt> <48466F7F.8090600@gmail.com> Message-ID: <20080604143650.72978202@solaris> Simon Marlow wrote: > Claus Reinke wrote: > > > - i don't want to have to remove anything explicitly, because > > that would mean bypassing the haskell installation managers > > - i would want to see a single haskell installation manager > > for each system, > > I think that's fundamentally the wrong approach. We shouldn't have > to build a "Haskell installation manager". Would you also want > installation managers for Perl, Python, Ruby, C, C++, etc. each with > their own different user interfaces and feature sets? I think not - > you want a single package manager for the whole system from which you > can install/uninstall libraries for any language. > > This is something that Windows gets completely wrong. Why do I have > twelve icons in my status bar all representing little programs that > are running in the background checking for updates to their own bits > of software? Why on earth do I have a Printer Driver Update > Manager? And I'd be wondering the same thing about a "Haskell > installation manager": installation and dependencies are not > something specific to Haskell. > Well, then there are developers who don't want to do .ebuilds, .rpms for 20 distributions, .debs for 20 distributions, .cabs... Meaning that if you have a project with 5 developers using 3 1/2 distributions, you will have a hard time installing. Haskell code tends to be platform unspecific, one shouldn't have to write platform-specific installation code just to make users happy. You have a point, though, and I wouldn't mind at all cabal-install being integrated into portage, that is, make portage _understand_ .cabal files and introduce another field in them that specifies non-haskell (e.g. gtk) dependencies. That is: I'd like to see a cabal-install for every system, using native package management where possible. Aren't there any usable third-party package managers for windoze? Maybe we can hook properly into cygwin, though it's surely not meant to support non-binary packages. Maybe gentoo should start to do binary releases, too, superseding debian and any other distribution. On another approach vector, I wouldn't want to update my Eve client using portage. It has to check whether there's a patch available before it connects to the server, anyway, so it can as well update. -- (c) this sig last receiving data processing entity. Inspect headers for past copyright information. All rights reserved. Unauthorised copying, hiring, renting, public performance and/or broadcasting of this signature prohibited. From ketil at malde.org Wed Jun 4 08:54:11 2008 From: ketil at malde.org (Ketil Malde) Date: Wed Jun 4 08:46:31 2008 Subject: [Haskell-cafe] Re: Ubuntu and ghc In-Reply-To: <20080604143650.72978202@solaris> (Achim Schneider's message of "Wed\, 4 Jun 2008 14\:36\:50 +0200") References: <5ae4f2ba0805211532l35bef8eas9a10ff6df3e0f843@mail.gmail.com> <1211448821.5824.504.camel@localhost> <008001c8bbf7$63753100$d0357ad5@cr3lt> <48466F7F.8090600@gmail.com> <20080604143650.72978202@solaris> Message-ID: <87wsl5xswc.fsf@malde.org> Achim Schneider writes: Caveat: I have only a vague grasp on what exactly is being criticized here - using a modern Linux distribution, tons of packages are available, and almost all issues Claus point out seem to be taken care of - at least as far as I can see. > Well, then there are developers who don't want to do .ebuilds, .rpms > for 20 distributions, .debs for 20 distributions, .cabs... Meaning that > if you have a project with 5 developers using 3 1/2 distributions, you > will have a hard time installing. I think you should either require your developers to use the system that is provided to them, or be able and willing to maintain their own system. Most large Linux distributions seem to come with lots of Haskell-related stuff nowadays - 139 packages on my Ubuntu install (divide by something close to 3, as most library stuff comes in -dev, -doc and -prof variants). > You have a point, though, and I wouldn't mind at all cabal-install > being integrated into portage, I'm not too familiar with portage, but I think a better solution is to provide tools to automatically generate packages for the various systems. How would you specify dependencies on non-haskell components in a portable way? > Aren't there any usable third-party package managers for windoze? The most usable one I've seen is Steam from Valve, IIRC. It'd be cool if Haskell packages were provided this way. > Maybe gentoo should start to do binary releases, too, superseding > debian and any other distribution. Yeah, that'll happen. :-) -k -- If I haven't seen further, it is by standing in the footprints of giants From duncan.coutts at worc.ox.ac.uk Wed Jun 4 09:13:21 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Jun 4 09:02:29 2008 Subject: [Haskell-cafe] Re: Ubuntu and ghc In-Reply-To: <87wsl5xswc.fsf@malde.org> References: <5ae4f2ba0805211532l35bef8eas9a10ff6df3e0f843@mail.gmail.com> <1211448821.5824.504.camel@localhost> <008001c8bbf7$63753100$d0357ad5@cr3lt> <48466F7F.8090600@gmail.com> <20080604143650.72978202@solaris> <87wsl5xswc.fsf@malde.org> Message-ID: <1212585201.15010.270.camel@localhost> On Wed, 2008-06-04 at 14:54 +0200, Ketil Malde wrote: > > You have a point, though, and I wouldn't mind at all cabal-install > > being integrated into portage, > > I'm not too familiar with portage, but I think a better solution is to > provide tools to automatically generate packages for the various > systems. Yeah, we've got one for gentoo/portage called hackport. That's why we have so many packages in the haskell overlay. We didn't do them all manually :-) > How would you specify dependencies on non-haskell components in a > portable way? Unfortunately the same packages get named differently on different package systems, eg "zlib", "libzlib", "libzlib-dev" etc. It's probably possible to use reasonably standard names and map to the distro-names. Doing that reliably is not going to be easy though. Duncan From Joseph.Re at MorganStanley.com Wed Jun 4 09:13:34 2008 From: Joseph.Re at MorganStanley.com (Re, Joseph (IT)) Date: Wed Jun 4 09:07:51 2008 Subject: [Haskell-cafe] Re: Ubuntu and ghc In-Reply-To: <87wsl5xswc.fsf@malde.org> References: <5ae4f2ba0805211532l35bef8eas9a10ff6df3e0f843@mail.gmail.com><1211448821.5824.504.camel@localhost><008001c8bbf7$63753100$d0357ad5@cr3lt> <48466F7F.8090600@gmail.com><20080604143650.72978202@solaris> <87wsl5xswc.fsf@malde.org> Message-ID: <507725E31752A74CB00728FA6C17D99C09D4AEB1@NYWEXMB29.msad.ms.com> Not sure about it's current state, but a friend was working on this until he graduated recently: http://www.acm.uiuc.edu/projects/Wipt -----Original Message----- From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Ketil Malde > Aren't there any usable third-party package managers for windoze? The most usable one I've seen is Steam from Valve, IIRC. It'd be cool if Haskell packages were provided this way. -k -------------------------------------------------------- NOTICE: If received in error, please destroy and notify sender. Sender does not intend to waive confidentiality or privilege. Use of this email is prohibited when received in error. From duncan.coutts at worc.ox.ac.uk Wed Jun 4 09:22:07 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Jun 4 09:11:19 2008 Subject: [Haskell-cafe] Re: Ubuntu and ghc In-Reply-To: <48466F7F.8090600@gmail.com> References: <5ae4f2ba0805211532l35bef8eas9a10ff6df3e0f843@mail.gmail.com> <1211448821.5824.504.camel@localhost> <008001c8bbf7$63753100$d0357ad5@cr3lt> <48466F7F.8090600@gmail.com> Message-ID: <1212585727.15010.281.camel@localhost> On Wed, 2008-06-04 at 11:33 +0100, Simon Marlow wrote: > Claus Reinke wrote: > > > - i don't want to have to remove anything explicitly, because that > > would mean bypassing the haskell installation managers > > - i would want to see a single haskell installation manager > > for each system, > > I think that's fundamentally the wrong approach. We shouldn't have to > build a "Haskell installation manager". Would you also want installation > managers for Perl, Python, Ruby, C, C++, etc. each with their own different > user interfaces and feature sets? I think not - you want a single package > manager for the whole system from which you can install/uninstall libraries > for any language. As I see it we need both. We need to make it easy to translate cabal packages into distro packages. We do have tools to do that at the moment for Gentoo, Debian and Fedora. I'm sure they could be improved. However we cannot expect all distros (esp Windows) to have all packages that are on hackage at all times. That's where it makes sense to have a tool like cabal-install as a secondary package manager. There's also the fact that most distro package managers do not handle unprivileged per-user installations very well. A further issue is that the dependencies that Haskell packages have are pretty complex and more so than can actually be expressed in some distro package systems. In particular Gentoo portage. Binary distros are better off in that respect since the deps of binary haskell packages are considerably simpler. Duncan From barsoap at web.de Wed Jun 4 09:25:52 2008 From: barsoap at web.de (Achim Schneider) Date: Wed Jun 4 09:18:35 2008 Subject: [Haskell-cafe] Re: Ubuntu and ghc References: <5ae4f2ba0805211532l35bef8eas9a10ff6df3e0f843@mail.gmail.com> <1211448821.5824.504.camel@localhost> <008001c8bbf7$63753100$d0357ad5@cr3lt> <48466F7F.8090600@gmail.com> <20080604143650.72978202@solaris> <87wsl5xswc.fsf@malde.org> Message-ID: <20080604152552.56c2cc1d@solaris> Ketil Malde wrote: > Achim Schneider writes: > > Caveat: I have only a vague grasp on what exactly is being criticized > here - using a modern Linux distribution, tons of packages are > available, and almost all issues Claus point out seem to be taken care > of - at least as far as I can see. > > > Well, then there are developers who don't want to do .ebuilds, .rpms > > for 20 distributions, .debs for 20 distributions, .cabs... Meaning > > that if you have a project with 5 developers using 3 1/2 > > distributions, you will have a hard time installing. > > I think you should either require your developers to use the system > that is provided to them, or be able and willing to maintain their own > system. Most large Linux distributions seem to come with lots of > Haskell-related stuff nowadays - 139 packages on my Ubuntu install > (divide by something close to 3, as most library stuff comes in -dev, > -doc and -prof variants). > Well, you have a point but still don't have one. Many of gentoo's haskell .ebuilds are seriously outdated, eg. wxhaskell still depends on ghc 6.4. See "Damnit, we need a CPAN" The haskell overlay features about 240 packages from alex to yi, hackage currently lists 596 packages. There are always things that a distribution doesn't include, especially sparsely used special purpose software. Compiling a LADSPA plugin by hand isn't that much of an issue, but you'll get into problems as soon as you want your programs to find it without touching paths that only your system's package manager should touch. I'm proud to say that my current gentoo installation is still the first one, surviving several world updates and at least 4 years of hacking around, using a lot of unstable and masked packages. > > You have a point, though, and I wouldn't mind at all cabal-install > > being integrated into portage, > > I'm not too familiar with portage, but I think a better solution is to > provide tools to automatically generate packages for the various > systems. How would you specify dependencies on non-haskell components > in a portable way? > By using portage ;) Seriously: Gentoo isn't a distribution, but a meta-distribution. It wouldn't make much sense to support the generation of alien binary packages, though, as dependency names will surely differ, and if you have to generate the whole distribution, you can equally well just use portage to install it. Regarding non-haskell dependencies: It's already a problem from distribution to distribution. In portage, you would have to depend on e.g. either gtk+ or emul-linux-x86-gtklibs (if you want to build 32bit software...), in debian on gtk-dev. Each distribution would have to make a list on how cabal's non-haskell dependencies map to their own package names, which is seriously less work than figuring these out by hand. -- (c) this sig last receiving data processing entity. Inspect headers for past copyright information. All rights reserved. Unauthorised copying, hiring, renting, public performance and/or broadcasting of this signature prohibited. From dfkettle at gmail.com Wed Jun 4 09:38:34 2008 From: dfkettle at gmail.com (David) Date: Wed Jun 4 09:31:10 2008 Subject: [Haskell-cafe] Installing Haskore under Windows Message-ID: Hi! I'm currently running ghc under Windows XP and want to play around with Haskore, but I'm a little confused about how to install it, or if it's even possible to use it with ghc. The 'readme' file contains this note: "Note that the file ghc_add/IOExtensions.hs is a partial replacement of a library file of the same name under Hugs. It does not work yet on Windows/GHC (where one has to distinguish between binary and text IO)." Does this mean I have to use Hugs rather than ghc? I have both Hugs and ghc installed, but I'd prefer to use ghc if possible. In either case, I find the install instructions (for Haskore, that is) a little confusing, probably because I'm also new to Haskell. Any help would be greatly appreciated. Thanks. From phercek at gmail.com Wed Jun 4 09:39:40 2008 From: phercek at gmail.com (Peter Hercek) Date: Wed Jun 4 09:32:20 2008 Subject: [Haskell-cafe] Re: [ANNOUNCE] git-darcs-import 0.1 In-Reply-To: References: <20080601184446.GA27750@zombie.inf.tu-dresden.de> <6f9f8f4a0806030757y142f0710lb05754429e4b6515@mail.gmail.com> Message-ID: Aaron Denney wrote: > On 2008-06-04, apfelmus wrote: <-- cut --> >> Or the next->topic path relies on features from next that are not >> present in master . But then, you're screwed anyway > > Yep. Well not really, depends what kind the dependency is, this kind of rebase is useful when "topic" depends only syntactically (as you pointed later) on "next" or when the semantic dependency is only on a small part of "next". Git rebase allows you get the syntax or the small part of semantics to the rebased "topic" by asking you for (manual) conflict resolution. This would correspond to commuting darcs patches which depend on each other (again possible by providing manual conflict resolution). Of course this happens only when it was anticipated that upstream merge of "next" happens before "topic", but then the upstream maintainers decided that "topic" should go upstream first. So, not often. >> and should merge some parts from next into master so as to advance the >> point where master and next fork. > > That's one solution. Of course, darcs doesn't have semantic dependency, > but syntactic dependency. (You can add extra dependencies to > model semantic dependencies, but you can't take away the syntactic > dependencies.) Another solution, if there's syntactic, > but not semantic dependencies, is to manually use patch and diff to get > 90% there, and then cleanup and record. OK, so I think this is what I expected for such a case. Thanks for the explanation of the meaning of "merging patches prior head". Peter. From wqeqweuqy at hotmail.com Wed Jun 4 09:40:55 2008 From: wqeqweuqy at hotmail.com (Neal Alexander) Date: Wed Jun 4 09:33:55 2008 Subject: [Haskell-cafe] Re: library for drawing charts In-Reply-To: <12204.203.185.215.144.1211767776.squirrel@dockerz.net> References: <82B3919B-BE28-4D65-9A3B-957B5EC51D27@gmail.com> <12204.203.185.215.144.1211767776.squirrel@dockerz.net> Message-ID: Tim Docker wrote: > Peter wrote: >> Has anyone got some code for drawing charts? I don't mean >> graphs of functions, ala >> >> http://dockerz.net/twd/HaskellCharts >> ... >> I would like something that can generate PNGs in memory, i.e. not >> directly to a file. > > The library at the above URL supports a range of backends through the > (nice to use) cairo graphics API. In memory images are supported. Also, > it's by no means just graphs of functions - that just happens to be > several of the demos. > >> I'd like 2D pie charts, bar charts and something like a google-o-meter. > > An the moment it does line charts and a few variants of these. I'll add > pie and bar charts when I need them - patches in the meantime gratefully > accepted. > > Tim I was using the HaskellCharts library and needed the same two things; so i rolled a quick and dirty pie chart generator (Barchart is on the TODO list). http://72.167.145.184:8000/Screenshot.png http://72.167.145.184:8000/PieChart.hs ---- x <- widgetGetDrawWindow canvas y <- widgetGetSize canvas renderWithDrawable x (f y) where f = PieChart.graph "title" 0x548B54 [(50.0,"A"), (50.0,"B")] From lemming at henning-thielemann.de Wed Jun 4 09:46:22 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Wed Jun 4 09:38:58 2008 Subject: [Haskell-cafe] Installing Haskore under Windows In-Reply-To: References: Message-ID: On Wed, 4 Jun 2008, David wrote: > I'm currently running ghc under Windows XP and want to play around > with Haskore, but I'm a little confused about how to install it, or if > it's even possible to use it with ghc. The 'readme' file contains this > note: You can also use Haskore with GHC. For an extended version using Cabal see: http://darcs.haskell.org/haskore/ From ross at soi.city.ac.uk Wed Jun 4 09:56:14 2008 From: ross at soi.city.ac.uk (Ross Paterson) Date: Wed Jun 4 09:48:52 2008 Subject: [Haskell-cafe] Re: Ubuntu and ghc In-Reply-To: <1212585727.15010.281.camel@localhost> References: <5ae4f2ba0805211532l35bef8eas9a10ff6df3e0f843@mail.gmail.com> <1211448821.5824.504.camel@localhost> <008001c8bbf7$63753100$d0357ad5@cr3lt> <48466F7F.8090600@gmail.com> <1212585727.15010.281.camel@localhost> Message-ID: <20080604135614.GA11968@soi.city.ac.uk> On Wed, Jun 04, 2008 at 02:22:07PM +0100, Duncan Coutts wrote: > As I see it we need both. We need to make it easy to translate cabal > packages into distro packages. We do have tools to do that at the moment > for Gentoo, Debian and Fedora. I'm sure they could be improved. > > However we cannot expect all distros (esp Windows) to have all packages > that are on hackage at all times. That's where it makes sense to have a > tool like cabal-install as a secondary package manager. There's also the > fact that most distro package managers do not handle unprivileged > per-user installations very well. cabal-install probably needs extra features to work in this way. If you ask it to install a package and its prerequisites, each of those packages will either be (1) already installed, (2) absent but available from the native package manager, (3) available from hackage. In the second case you'd probably want to break out of cabal-install to install the pre-packaged ones before building the new ones. From claus.reinke at talk21.com Wed Jun 4 10:14:22 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Wed Jun 4 10:07:04 2008 Subject: cabal and platform-independent haskell installation management (again) (Re: [Haskell-cafe] Re: Ubuntu and ghc) References: <5ae4f2ba0805211532l35bef8eas9a10ff6df3e0f843@mail.gmail.com> <1211448821.5824.504.camel@localhost><008001c8bbf7$63753100$d0357ad5@cr3lt> <48466F7F.8090600@gmail.com> Message-ID: <016d01c8c64d$4ac1dea0$73357ad5@cr3lt> > I think that's fundamentally the wrong approach. We shouldn't have to > build a "Haskell installation manager". Would you also want installation > managers for Perl, Python, Ruby, C, C++, etc. each with their own different > user interfaces and feature sets? I think not - you want a single package > manager for the whole system from which you can install/uninstall libraries > for any language. > > This is something that Windows gets completely wrong. Why do I have twelve > icons in my status bar all representing little programs that are running in > the background checking for updates to their own bits of software? Why on > earth do I have a Printer Driver Update Manager? And I'd be wondering the > same thing about a "Haskell installation manager": installation and > dependencies are not something specific to Haskell. why then do we have ghc-pkg, or cabal? surely the native package managers should handle all that? there are (at least) two dimensions of uniformity: across different kind of software on a single kind of system, and with a single kind of software across different kinds of system. platform-specific package managers hide the software-specific notions of package dependency maintainence, haskell-specific package managers hide the platform-specific notions of package dependency maintainence. there is no need for platform- and haskell-specific tools to be entirely separate or in conflict with each other: where both exist, one can be a view on the other (if you are on linux-of-the-day, you can use its package manage, independent of whether your packages are haskell or lisp; and if you are using haskell, you should be able to use its package manager, independent of whether you are on unix-variant-of-today or on unix-variant-of-yesterday). there seems to be a lot of confusion here, some of us not understanding the issues because we happen to be using systems where "everything just works", others among us not understanding the issues because we happen to be using systems where "such things would never work anyway", and yet others insisting on "i'll do it my way, so i know what works" (and then, of course, there are those who are actively working on improving the situation who will see my criticism as constructive, i hope!-). 1. there are no systems where "packages just work"! there are systems where a few people ensure that many people can live in such an illusion, though. 2. systems with native package manager software still need help from haskell-specific toolchains (unless you want the human package managers on those systems to code all haskell-specific dependencies by hand). 3. systems without native package managers (or perhaps i should say: systems on which users with unix background traditionally avoid getting acquainted with the details and usage of whatever might pass as installation management on those systems) are still in *very* wide-spread use, and if haskell users on those systems are left out in the rain, haskell developers will not be able to support those systems. this limits the user and application base of haskell on those systems, making haskell less relevant than it could be. 4. haskell enables programming at a very high level of abstraction, with fairly good support for mostly platform independent code. but that code needs to be installed, and integrated with dependencies and dependents, and the integrated haskell installations needs to be maintained. and that should "just work", even if the developer is on (1;2) and the user is on (3), or vice versa, or if developers and users are on different flavours of (1;2) or (3). with these clarifications out of the way, my interpretation of cabal was that it set out to provide two things (A) a uniform platform-independent interface to such a haskell package installation manager. (B) a uniform platform-independent toolchain to support such a haskell package installation manager. on systems in the (1;2) class, human package managers would use (B) to integrate haskell packages into the native package management software, so users might never even encounter cabal. even so, (A) might offer a haskell-specific view on the general platform package management (when you want to see the haskell gui libs rather than all gui libs). on systems in the (3) class, users and developers would interface with (A/B) directly, for lack of a better alternative. and developers/users in the (4) class would simply use (A/B), without having to check whether they are "real" or just a view on the platform-specific software. it is this cross platform view of software development that i'm most interested in (i'm one of those who use bash, vim, opera, and haskell, no matter whether i'm on windows, solaris, or whatever, and the cross-platform availability of those tools has saved me many a headache;-). returning to my earlier message, it seems that my concerns were mainly these: - it isn't sufficient to worry about installation management, one has to worry about integration, lifetime and uninstall management as well. in short, maintain the dependency graphs over any of "install"/"upgrade"/"uninstall". - for this to work, cabal needs to maintain not only libraries as packages, but tools and compilers as well. without this, some dependencies are not recorded (this haddock depends on that ghc; to build this package i need that tool; that tool was built with this ghc version, from those sources, etc). and if the dependencies are not even recorded, they are likely to be broken if one does install/upgrade or uninstall any haskell software, be it library, tool, or compiler. i hope this clarifies things?-) claus ps. i'd cc to libraries or cabal, but i don't know which would be most appropriate (perhaps someone could point readers there to this thread if that sounds relevant?). From duncan.coutts at worc.ox.ac.uk Wed Jun 4 10:31:40 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Jun 4 10:20:48 2008 Subject: [Haskell-cafe] Re: Ubuntu and ghc In-Reply-To: <20080604152552.56c2cc1d@solaris> References: <5ae4f2ba0805211532l35bef8eas9a10ff6df3e0f843@mail.gmail.com> <1211448821.5824.504.camel@localhost> <008001c8bbf7$63753100$d0357ad5@cr3lt> <48466F7F.8090600@gmail.com> <20080604143650.72978202@solaris> <87wsl5xswc.fsf@malde.org> <20080604152552.56c2cc1d@solaris> Message-ID: <1212589900.15010.302.camel@localhost> On Wed, 2008-06-04 at 15:25 +0200, Achim Schneider wrote: > Well, you have a point but still don't have one. Many of gentoo's > haskell .ebuilds are seriously outdated, eg. wxhaskell still depends on > ghc 6.4. See "Damnit, we need a CPAN" > > The haskell overlay features about 240 packages from alex to yi, > hackage currently lists 596 packages. You may be interested to know I just tried to install 564 packages from hackage using cabal-install (others excluded due to missing or inconsistent dependencies). Of those, 156 failed to install (direct failure or because they depended on another package that failed). I now have 157 programs installed in ~/.cabal/bin and ghc-pkg take two and a half seconds to tell me that I have 454 libraries installed (some were installed previously via portage). Duncan From duncan.coutts at worc.ox.ac.uk Wed Jun 4 10:43:48 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Jun 4 10:32:59 2008 Subject: cabal and platform-independent haskell installation management (again) (Re: [Haskell-cafe] Re: Ubuntu and ghc) In-Reply-To: <016d01c8c64d$4ac1dea0$73357ad5@cr3lt> References: <5ae4f2ba0805211532l35bef8eas9a10ff6df3e0f843@mail.gmail.com> <1211448821.5824.504.camel@localhost><008001c8bbf7$63753100$d0357ad5@cr3lt> <48466F7F.8090600@gmail.com> <016d01c8c64d$4ac1dea0$73357ad5@cr3lt> Message-ID: <1212590628.15010.312.camel@localhost> On Wed, 2008-06-04 at 15:14 +0100, Claus Reinke wrote: > > I think that's fundamentally the wrong approach. We shouldn't have to > > build a "Haskell installation manager". Would you also want installation > > managers for Perl, Python, Ruby, C, C++, etc. each with their own different > > user interfaces and feature sets? I think not - you want a single package > > manager for the whole system from which you can install/uninstall libraries > > for any language. > > > > This is something that Windows gets completely wrong. Why do I have twelve > > icons in my status bar all representing little programs that are running in > > the background checking for updates to their own bits of software? Why on > > earth do I have a Printer Driver Update Manager? And I'd be wondering the > > same thing about a "Haskell installation manager": installation and > > dependencies are not something specific to Haskell. > > why then do we have ghc-pkg, or cabal? surely the native package > managers should handle all that? > > there are (at least) two dimensions of uniformity: across different > kind of software on a single kind of system, and with a single kind > of software across different kinds of system. platform-specific > package managers hide the software-specific notions of package > dependency maintainence, haskell-specific package managers > hide the platform-specific notions of package dependency > maintainence. > > there is no need for platform- and haskell-specific tools to be > entirely separate or in conflict with each other: where both exist, > one can be a view on the other (if you are on linux-of-the-day, > you can use its package manage, independent of whether your > packages are haskell or lisp; and if you are using haskell, you > should be able to use its package manager, independent of > whether you are on unix-variant-of-today or on > unix-variant-of-yesterday). > > there seems to be a lot of confusion here, some of us not > understanding the issues because we happen to be using > systems where "everything just works", others among us > not understanding the issues because we happen to be > using systems where "such things would never work anyway", > and yet others insisting on "i'll do it my way, so i know what > works" (and then, of course, there are those who are > actively working on improving the situation who will see > my criticism as constructive, i hope!-). > > 1. there are no systems where "packages just work"! > there are systems where a few people ensure that > many people can live in such an illusion, though. Yes indeed! :-) > 2. systems with native package manager software still > need help from haskell-specific toolchains (unless > you want the human package managers on those > systems to code all haskell-specific dependencies > by hand). Yes. As an illustration: gentoo has an "haskell-cabal.eclass" that interfaces between ebuilds and cabal as the build manager and there is a tool to generate ebuilds that use the haskell-cabal.eclass from .cabal descriptions (so we get correct deps automatically). > 3. systems without native package managers (or perhaps > i should say: systems on which users with unix background > traditionally avoid getting acquainted with the details and > usage of whatever might pass as installation management > on those systems) are still in *very* wide-spread use, > and if haskell users on those systems are left out in the > rain, haskell developers will not be able to support those > systems. this limits the user and application base of haskell > on those systems, making haskell less relevant than it could be. Eg Windows, OSX, Solaris. > 4. haskell enables programming at a very high level of > abstraction, with fairly good support for mostly platform > independent code. but that code needs to be installed, > and integrated with dependencies and dependents, and > the integrated haskell installations needs to be maintained. > and that should "just work", even if the developer is on > (1;2) and the user is on (3), or vice versa, or if developers > and users are on different flavours of (1;2) or (3). > > with these clarifications out of the way, my interpretation > of cabal was that it set out to provide two things > > (A) a uniform platform-independent interface to such a > haskell package installation manager. > (B) a uniform platform-independent toolchain to support > such a haskell package installation manager. I guess so. > on systems in the (1;2) class, human package managers > would use (B) to integrate haskell packages into the native > package management software, so users might never even > encounter cabal. As in my example with the gentoo haskell packages above. > even so, (A) might offer a haskell-specific > view on the general platform package management (when > you want to see the haskell gui libs rather than all gui libs). > > on systems in the (3) class, users and developers would > interface with (A/B) directly, for lack of a better alternative. > > and developers/users in the (4) class would simply use > (A/B), without having to check whether they are "real" > or just a view on the platform-specific software. it is this > cross platform view of software development that i'm > most interested in (i'm one of those who use bash, vim, > opera, and haskell, no matter whether i'm on windows, > solaris, or whatever, and the cross-platform availability > of those tools has saved me many a headache;-). > > returning to my earlier message, it seems that my > concerns were mainly these: > > - it isn't sufficient to worry about installation management, > one has to worry about integration, lifetime and uninstall > management as well. in short, maintain the dependency > graphs over any of "install"/"upgrade"/"uninstall". For users in (1;2) class we would expect the native package manager to do this. > - for this to work, cabal needs to maintain not only > libraries as packages, but tools and compilers as > well. without this, some dependencies are not > recorded (this haddock depends on that ghc; to > build this package i need that tool; that tool was > built with this ghc version, from those sources, etc). > > and if the dependencies are not even recorded, they > are likely to be broken if one does install/upgrade or > uninstall any haskell software, be it library, tool, or > compiler. Right. Currently cabal-install in its roll as a secondary package manager is very weak on that front. It does not record anything about what it installs. There's clearly plenty of work to be done there. > ps. i'd cc to libraries or cabal, but i don't know which > would be most appropriate (perhaps someone could > point readers there to this thread if that sounds relevant?). You can cc both. Duncan From darrinth at gmail.com Wed Jun 4 11:14:46 2008 From: darrinth at gmail.com (Darrin Thompson) Date: Wed Jun 4 11:07:22 2008 Subject: cabal and platform-independent haskell installation management (again) (Re: [Haskell-cafe] Re: Ubuntu and ghc) In-Reply-To: <016d01c8c64d$4ac1dea0$73357ad5@cr3lt> References: <5ae4f2ba0805211532l35bef8eas9a10ff6df3e0f843@mail.gmail.com> <1211448821.5824.504.camel@localhost> <008001c8bbf7$63753100$d0357ad5@cr3lt> <48466F7F.8090600@gmail.com> <016d01c8c64d$4ac1dea0$73357ad5@cr3lt> Message-ID: On Wed, Jun 4, 2008 at 10:14 AM, Claus Reinke wrote: > - it isn't sufficient to worry about installation management, > one has to worry about integration, lifetime and uninstall > management as well. in short, maintain the dependency > graphs over any of "install"/"upgrade"/"uninstall". > It's sufficient to worry about the problem at hand. Everything you've mentioned can be done incrementally once the depsolver is happy. After that it's quite likely that the set of people who care about lifetimes and integration stuff will intersect with the people who want to work on said stuff. -- Darrin From barsoap at web.de Wed Jun 4 11:22:52 2008 From: barsoap at web.de (Achim Schneider) Date: Wed Jun 4 11:15:36 2008 Subject: [Haskell-cafe] Re: cabal and platform-independent haskell installation management (again) (Re: Re: Ubuntu and ghc) References: <5ae4f2ba0805211532l35bef8eas9a10ff6df3e0f843@mail.gmail.com> <1211448821.5824.504.camel@localhost> <008001c8bbf7$63753100$d0357ad5@cr3lt> <48466F7F.8090600@gmail.com> <016d01c8c64d$4ac1dea0$73357ad5@cr3lt> <1212590628.15010.312.camel@localhost> Message-ID: <20080604172252.34df14f7@solaris> Duncan Coutts wrote: > > On Wed, 2008-06-04 at 15:14 +0100, Claus Reinke wrote: > > > I think that's fundamentally the wrong approach. We shouldn't > > > have to build a "Haskell installation manager". Would you also > > > want installation managers for Perl, Python, Ruby, C, C++, etc. > > > each with their own different user interfaces and feature sets? > > > I think not - you want a single package manager for the whole > > > system from which you can install/uninstall libraries for any > > > language. > > > > > > This is something that Windows gets completely wrong. Why do I > > > have twelve icons in my status bar all representing little > > > programs that are running in the background checking for updates > > > to their own bits of software? Why on earth do I have a Printer > > > Driver Update Manager? And I'd be wondering the same thing about > > > a "Haskell installation manager": installation and dependencies > > > are not something specific to Haskell. > > > > why then do we have ghc-pkg, or cabal? surely the native package > > managers should handle all that? > > > > there are (at least) two dimensions of uniformity: across different > > kind of software on a single kind of system, and with a single kind > > of software across different kinds of system. platform-specific > > package managers hide the software-specific notions of package > > dependency maintainence, haskell-specific package managers > > hide the platform-specific notions of package dependency > > maintainence. > > > > there is no need for platform- and haskell-specific tools to be > > entirely separate or in conflict with each other: where both exist, > > one can be a view on the other (if you are on linux-of-the-day, > > you can use its package manage, independent of whether your > > packages are haskell or lisp; and if you are using haskell, you > > should be able to use its package manager, independent of > > whether you are on unix-variant-of-today or on > > unix-variant-of-yesterday). > > > > there seems to be a lot of confusion here, some of us not > > understanding the issues because we happen to be using > > systems where "everything just works", others among us > > not understanding the issues because we happen to be > > using systems where "such things would never work anyway", > > and yet others insisting on "i'll do it my way, so i know what > > works" (and then, of course, there are those who are > > actively working on improving the situation who will see > > my criticism as constructive, i hope!-). > > > > 1. there are no systems where "packages just work"! > > there are systems where a few people ensure that > > many people can live in such an illusion, though. > > Yes indeed! :-) > > > 2. systems with native package manager software still > > need help from haskell-specific toolchains (unless > > you want the human package managers on those > > systems to code all haskell-specific dependencies > > by hand). > > Yes. As an illustration: gentoo has an "haskell-cabal.eclass" that > interfaces between ebuilds and cabal as the build manager and there > is a tool to generate ebuilds that use the haskell-cabal.eclass > from .cabal descriptions (so we get correct deps automatically). > > > 3. systems without native package managers (or perhaps > > i should say: systems on which users with unix background > > traditionally avoid getting acquainted with the details and > > usage of whatever might pass as installation management > > on those systems) are still in *very* wide-spread use, > > and if haskell users on those systems are left out in the > > rain, haskell developers will not be able to support those > > systems. this limits the user and application base of haskell > > on those systems, making haskell less relevant than it could be. > > Eg Windows, OSX, Solaris. > > > 4. haskell enables programming at a very high level of > > abstraction, with fairly good support for mostly platform > > independent code. but that code needs to be installed, > > and integrated with dependencies and dependents, and > > the integrated haskell installations needs to be maintained. > > and that should "just work", even if the developer is on > > (1;2) and the user is on (3), or vice versa, or if developers > > and users are on different flavours of (1;2) or (3). > > > > with these clarifications out of the way, my interpretation > > of cabal was that it set out to provide two things > > > > (A) a uniform platform-independent interface to such a > > haskell package installation manager. > > (B) a uniform platform-independent toolchain to support > > such a haskell package installation manager. > > I guess so. > > > on systems in the (1;2) class, human package managers > > would use (B) to integrate haskell packages into the native > > package management software, so users might never even > > encounter cabal. > > As in my example with the gentoo haskell packages above. > > > even so, (A) might offer a haskell-specific > > view on the general platform package management (when > > you want to see the haskell gui libs rather than all gui libs). > > > > on systems in the (3) class, users and developers would > > interface with (A/B) directly, for lack of a better alternative. > > > > and developers/users in the (4) class would simply use > > (A/B), without having to check whether they are "real" > > or just a view on the platform-specific software. it is this > > cross platform view of software development that i'm > > most interested in (i'm one of those who use bash, vim, > > opera, and haskell, no matter whether i'm on windows, > > solaris, or whatever, and the cross-platform availability > > of those tools has saved me many a headache;-). > > > > returning to my earlier message, it seems that my > > concerns were mainly these: > > > > - it isn't sufficient to worry about installation management, > > one has to worry about integration, lifetime and uninstall > > management as well. in short, maintain the dependency > > graphs over any of "install"/"upgrade"/"uninstall". > > For users in (1;2) class we would expect the native package manager to > do this. > > > - for this to work, cabal needs to maintain not only > > libraries as packages, but tools and compilers as > > well. without this, some dependencies are not > > recorded (this haddock depends on that ghc; to > > build this package i need that tool; that tool was > > built with this ghc version, from those sources, etc). > > > > and if the dependencies are not even recorded, they > > are likely to be broken if one does install/upgrade or > > uninstall any haskell software, be it library, tool, or > > compiler. > > Right. Currently cabal-install in its roll as a secondary package > manager is very weak on that front. It does not record anything about > what it installs. There's clearly plenty of work to be done there. > I'm wondering whether a hacked version of darcs could be used for this. Together with sandboxing and support of alien packages, it would already look like a full-fledged distribution... binary packages could be a set of zipped darcs patches. Add USE-flag derived dependencies and package and flag based stable/unstable marks and I'll switch without hesition. The question, IMHO, seems to be "How would a package manager for a posix-compilant kinetic look like?" I'd rather like a package manager to find them, rule them all and in obsoletion bind them than attempting to hack around package managers * packages incompatibilities. PS: If you don't know why sandboxing is a MUST, read http://myeve.eve-online.com/devblog.asp?a=blog&bid=526 -- (c) this sig last receiving data processing entity. Inspect headers for past copyright information. All rights reserved. Unauthorised copying, hiring, renting, public performance and/or broadcasting of this signature prohibited. From jgoerzen at complete.org Wed Jun 4 12:39:53 2008 From: jgoerzen at complete.org (John Goerzen) Date: Wed Jun 4 12:32:34 2008 Subject: [Haskell-cafe] What is the maturity of Haskell Web Frameworks In-Reply-To: <1212534382.15010.227.camel@localhost> References: <20080602172131.GA7534@scytale.galois.com> <910ddf450806031020i2e09b83bo4cd13f395b612e1@mail.gmail.com> <20080603172303.GA22053@scytale.galois.com> <1212534382.15010.227.camel@localhost> Message-ID: <4846C559.9020201@complete.org> Duncan Coutts wrote: > On Tue, 2008-06-03 at 10:23 -0700, Don Stewart wrote: >> A new version of happs was written on a Monday a couple of months ago, >> using fastcgi and takusen. We're running it at galois, and you can >> find the code on code.haskell.org/hpaste. So not quite what you wanted, >> but another data point. > > That's very interesting. I hope we will also see a version with the same > feature set implemented with the latest HAppS. It would give an > interesting comparison of the web frameworks to see the same app > implemented in both. I haven't looked at that particular version, but when I last looked at web frameworks, I was somewhat disappointed. HAppS seemed to have little documentation on the current version anyhow, and especially little coverage on what to do if your app revolved around serving data from an existing SQL database or other data source rather than its own. hvac sounds interesting but at that time at least it was not clear whether it was stable or would continue to be maintained. xhtml and HStringTemplate were overkill for what I wanted, so I wound up just using the FastCGI and CGI toolkits themselves. They are surprisingly nice, and with a little bit of wrappers around them for things like validating forms, have worked exceptionally well. My needs for that project were not complex, the layout was not very important, and the presentation never changes (only the business logic). So I understand that my needs may have been opposite from what most people face. -- John From jgoerzen at complete.org Wed Jun 4 12:43:23 2008 From: jgoerzen at complete.org (John Goerzen) Date: Wed Jun 4 12:36:00 2008 Subject: [Haskell-cafe] HDBC-odbc 1.1.4.4 fixes Windows linking problems In-Reply-To: <20080604030541.GA26462@momotaro.chinmin.edu.tw> References: <20080603200020.GA13041@complete.org> <20080604030541.GA26462@momotaro.chinmin.edu.tw> Message-ID: <4846C62B.2050503@complete.org> Greg Matheson wrote: > On Tue, 03 Jun 2008, John Goerzen wrote: > >> Hi, > >> HDBC-odbc version 1.1.4.4 has been uploaded to Hackage. It fixes the >> problems some here have encountered regarding ODBC crashes or other >> similar odd behavior on Windows. > > I'm getting a 'Parse error in pattern' error. > > C:\Documents and Settings\Administrator>ghci > GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help > Loading package base ... linking ... done. > Prelude> :m Database.HDBC.ODBC Database.HDBC > Prelude Database.HDBC Database.HDBC.ODBC> conn <- connectODBC "dictation" Please note that this is not a valid connection string. The HDBC-odbc API docs are available at http://software.complete.org/static/hdbc-odbc/doc//HDBC-odbc/Database-HDBC-ODBC.html and give the example string of: "DSN=hdbctest1" as well as a link to the Microsoft document that describes the string, which lives at: http://msdn.microsoft.com/en-us/library/ms715433(VS.85).aspx That URL also contains error message descriptions. For your state 01S00, it lists: Invalid connection string attribute An invalid attribute keyword was specified in the connection string (InConnectionString), but the driver was able to connect to the data source anyway. (Function returns SQL_SUCCESS_WITH_INFO.) Your fix may be as simple as prepending the string with "DSN=". -- John From jgoerzen at complete.org Wed Jun 4 12:51:05 2008 From: jgoerzen at complete.org (John Goerzen) Date: Wed Jun 4 12:43:40 2008 Subject: [Haskell-cafe] [ANNOUNCE] git-darcs-import 0.1 In-Reply-To: <6f9f8f4a0806030757y142f0710lb05754429e4b6515@mail.gmail.com> References: <20080601184446.GA27750@zombie.inf.tu-dresden.de> <6f9f8f4a0806030757y142f0710lb05754429e4b6515@mail.gmail.com> Message-ID: <4846C7F9.4010006@complete.org> Loup Vaillant wrote: > 2008/6/3 Darrin Thompson : >> On Sun, Jun 1, 2008 at 2:44 PM, Bertram Felgenhauer >> wrote: >>> Hi, >>> >>> I'm pleased to announce yet another tool for importing darcs repositories >>> to git. Unlike darcs2git [1] and darcs-to-git [2], it's written in >>> Haskell, on top of the darcs2 source code. The result is a much faster >>> program - it can convert the complete ghc 6.9 branch (without libraries) >>> in less than 15 minutes on my slightly dated machine (Athlon XP 2500+), >>> which is quite fast [3]. Incremental updates work, too. >>> >> What's the appeal of this? I personally love git, but I thought all >> the cool kids at this school used darcs and that was that. > > Disclaimer: I'm no expert, this is what I've heard. Anyone please > confirm or deny the following? I've never been a cool kid at school, but I switched from Darcs to Git recently. I have not regretted it. Git has quite a few features Darcs doesn't by now, and there is a little bit (but not much) in the other direction. That and the lack of the indempotent merge bug. Git's interface has really cleaned up in the last year, and it seems to be well on the way to becoming the defacto DVCS of choice. Maybe next week, when it's picked up the last of the superdelegates, we can say for sure, but of course bzr won't conceed anything at this point.... (OK, so we've had mind-numbing election coverage here in the US for too long) I've blogged about this. http://changelog.complete.org/plugin/tag/git will get you most of the relevant posts. -- John From icfp.publicity at googlemail.com Wed Jun 4 12:53:13 2008 From: icfp.publicity at googlemail.com (Matthew Fluet (ICFP Publicity Chair)) Date: Wed Jun 4 12:45:52 2008 Subject: [Haskell-cafe] ICFP2008 Call for Poster proposals Message-ID: <53ff55480806040953l730455cft7a8c4e89a0ded583@mail.gmail.com> ICFP 2008 poster session September 21, 2008 Call for presentation proposals ICFP 2008 will feature a poster session for researchers and practitioners, including students. The session will provide friendly feedback for work that is in gestation or ongoing, as well as opportunities to meet each other and exchange ideas. We welcome poster submissions on all ICFP topics, especially presentations of - applications of and to functional programming; - recent work presented at more distant venues; and - ongoing work, whether or not submitted to ICFP. There will be no formal proceedings, but presenters will be invited to submit working notes, demo code, and other materials to supplement their abstract and poster. These materials will be released informally on a Web page dedicated to the poster session. An accepted submission is not intended to replace conference or journal publication. Persons interested in presenting a poster are invited to submit a one-page abstract in SIGPLAN conference style http://www.acm.org/sigs/sigplan/authorInformation.htm to the Web site https://www.softconf.com/s08/icfp08-posters/submit.html by June 30, 2008. The program committee will review the submissions for relevance and interest, and notify the authors by July 14, 2008. Accepted posters must be presented by the authors in person on Sunday, September 21, 2008. Important dates: Submission: Monday, June 30, 2008 Notification: Monday, July 14, 2008 Presentation: Sunday, September 21, 2008 Program committee: Benjamin Pierce (University of Pennsylvania) Colin Runciman (University of York) Chung-chieh Shan (Rutgers University) From bertram.felgenhauer at googlemail.com Wed Jun 4 13:15:36 2008 From: bertram.felgenhauer at googlemail.com (Bertram Felgenhauer) Date: Wed Jun 4 13:08:19 2008 Subject: [Haskell-cafe] [ANN] hs-pgms 0.1 -- Programmer's Minesweeper in Haskell Message-ID: <20080604171535.GA4265@zombie.inf.tu-dresden.de> Hi, I've just uploaded hs-pgms to hackage. It is a Haskell implementation of Programmer's Minesweeper [1], which allows programmers to implement minesweeper strategies and run them. (Note: ghc >= 6.8 is required.) hs-pgms uses MonadPrompt to achieve a clean separation between strategies, game logic, and presentation. There are two frontends, one command line frontend which is mainly useful for collecting statistics, and a GUI frontend, using gtk2hs, for watching the strategies in action. There's a git repo, see http://repo.or.cz/w/hs-pgms.git . enjoy, Bertram [1] http://www.ccs.neu.edu/home/ramsdell/pgms/index.html From trebla at vex.net Wed Jun 4 14:37:07 2008 From: trebla at vex.net (Albert Y. C. Lai) Date: Wed Jun 4 14:29:43 2008 Subject: [Haskell-cafe] More on performance In-Reply-To: <200806041213.55484.jon@ffconsultancy.com> References: <20080603174704.GB22053@scytale.galois.com> <6f9f8f4a0806040248x5f502f6eoae2a95dc8dc83778@mail.gmail.com> <7ca3f0160806040305x4bc0dd27tf8621b88acdf8c1e@mail.gmail.com> <200806041213.55484.jon@ffconsultancy.com> Message-ID: <4846E0D3.4070608@vex.net> Jon Harrop wrote: > IRL the specification often dictates the complexity. If your code fails to > satisfy the spec then it is wrong. Are you saying that Haskell code can never > satisfy any such specification? In addition to RL, it it should and it can in theory too: http://www.cs.toronto.edu/~hehner/aPToP/ in particular chapter 4 sections 4.2 and 4.3. I also admire that Musser and Saini give asymptotic costs as an indispensible part of the STL specification. Everyone should at least do that much. From trebla at vex.net Wed Jun 4 14:52:12 2008 From: trebla at vex.net (Albert Y. C. Lai) Date: Wed Jun 4 14:44:46 2008 Subject: [Haskell-cafe] Re: Laziness leaks In-Reply-To: References: <62728db30806031414p19593f40x5ad1bfd32e2dfc4b@mail.gmail.com> <4845D0B8.6040802@vex.net> <62728db30806031712w32421ae5scbf84920ecd71193@mail.gmail.com> Message-ID: <4846E45C.3040402@vex.net> apfelmus wrote: > I haven't heard the terms "laziness leak" and "strictness leak" before, > imho they sound a bit spooky because it's not clear to me what the > situation without leak would be. (Time vs Space? Is an O(n) algorithm a > strictness leak compared to an O(log n) algorithm?) "Leak" refers to a surprise. You didn't expect Firefox to use Omega(n) memory where n is the number of times you refresh a rather plain static HTML page, but it does, and you call it a memory "leak". You didn't expect foldl to lump a big thunk, but it does, and you call it a lazy "leak". Therefore "leak" refers to a program failing your expectation - even if you yourself wrote the program. ("Leak", "bug", "issue"... We surely are very creative in how to avoid calling a shovel a shovel, or an error an error.) The solution is better education, better reasoning, and Intelligent Design. As you write every line of code, you should already know what to expect. No magic, no surprise, just science. From s.clover at gmail.com Wed Jun 4 15:00:08 2008 From: s.clover at gmail.com (Sterling Clover) Date: Wed Jun 4 14:52:48 2008 Subject: [Haskell-cafe] What is the maturity of Haskell Web Frameworks In-Reply-To: <4846C559.9020201@complete.org> References: <20080602172131.GA7534@scytale.galois.com> <910ddf450806031020i2e09b83bo4cd13f395b612e1@mail.gmail.com> <20080603172303.GA22053@scytale.galois.com> <1212534382.15010.227.camel@localhost> <4846C559.9020201@complete.org> Message-ID: <84455758-6AD3-4FE9-ABF8-C1FC739FE0ED@gmail.com> > > hvac sounds interesting but at that time at least it was not clear > whether it was stable or would continue to be maintained. > > xhtml and HStringTemplate were overkill for what I wanted, so I > wound up > just using the FastCGI and CGI toolkits themselves. They are > surprisingly nice, and with a little bit of wrappers around them for > things like validating forms, have worked exceptionally well. > I'm in a position now where I can make a reasonable promise that hvac will not only be maintained but undergoing continued development. I just, for example, hooked in some basic postgresql support yesterday (although the changes are not tested/pushed to the repo yet). (Speaking of which, I noticed that the HDBC postgresql bindings don't set seState on an error -- is this intentional, or something that should be fixed up?) As such though, I also can't promise that hvac as it stands is officially stable, although most work I imagine that will be done on it will consist of extensions rather than API-breaking changes. I've also been working on a lightweight testing API for programs using the CGI monad, integrated with quickcheck. Although this project isn't "final" yet either, there's a working repo at http:// code.haskell.org/~sclv/cgicheck/ if anyone wants to play with it/use it. I plan to use this quite a bit to test hvac, and any applications produced using it. Additionally, the hvac code now has a nice, though also incomplete orm/dsl-type library for database access (also built on top of HDBC). When I feel more confident/polished in the code there, I plan to split it out and hackage it as well. Of course, folks with a little time/inclination who play with these things a bit and put them through the paces are a big help in working out the kinks such that I feel they're closer to "release- quality" (even if that "release" *is* only 0.1). :-) Relatedly, I'd be very interested in developing a single common library for encoding/escaping/decoding/unescaping of common web formats (urls, javascript, basic xss escaping, rss-valid character escapes to html-valid ones, etc.) that uses a lightweight invertible combinator approach as described in Pierce's work on lenses (various papers at http://www.seas.upenn.edu/~harmony/) such that the encode/ decode methods are correct-by-construction bijections. There are various encoding bits scattered among the Haskell web libraries at the moment, each with varying degrees of correctness and conformance. It would be nice to direct energy here to a single centralized project, which would have some upfront architecture, and then, unfortunately, probably no small degree of spec-translation. If anyone else is interested in working on such a thing, I'd be delighted for ideas/collaboration (or better yet, if someone just picked up the idea and ran with it themselves!) (hmm... maybe galois has some internal libraries it wouldn't mind sharing as a partial basis?) Regards, Sterl. From s.clover at gmail.com Wed Jun 4 15:11:31 2008 From: s.clover at gmail.com (Sterling Clover) Date: Wed Jun 4 15:04:10 2008 Subject: [Haskell-cafe] More on performance In-Reply-To: References: <20080603174704.GB22053@scytale.galois.com> <1212571822.15010.266.camel@localhost> Message-ID: > On Jun 4, 2008, at 5:51 AM, Henning Thielemann wrote: > How about assisting the compiler with a helper function named > 'parallel' ? > > parallel :: ([a] -> b, [a] -> c) -> [a] -> (b,c) > parallel (f,g) xs = (f xs, g xs) > > mean xs = > uncurry (/) $ parallel (sum,length) xs > > > ? We could state RULES in terms of 'parallel'. By calling > 'parallel', the user tells, that he wants fusion here. > > Say > "parallel/foldl/foldl" forall f, g, x0, y0. > parallel (foldl f x0, foldl g y0) = foldl (\(x,y) z -> (f x > z, g y z)) (x0,y0) > Well, we already have &&&. Would a sufficiently specialized rule over that be a useful addition to Control.Arrow? Regards, Sterl. From dons at galois.com Wed Jun 4 16:11:53 2008 From: dons at galois.com (Don Stewart) Date: Wed Jun 4 16:04:30 2008 Subject: [Haskell-cafe] What is the maturity of Haskell Web Frameworks In-Reply-To: <84455758-6AD3-4FE9-ABF8-C1FC739FE0ED@gmail.com> References: <20080602172131.GA7534@scytale.galois.com> <910ddf450806031020i2e09b83bo4cd13f395b612e1@mail.gmail.com> <20080603172303.GA22053@scytale.galois.com> <1212534382.15010.227.camel@localhost> <4846C559.9020201@complete.org> <84455758-6AD3-4FE9-ABF8-C1FC739FE0ED@gmail.com> Message-ID: <20080604201153.GG19197@scytale.galois.com> s.clover: > > > >hvac sounds interesting but at that time at least it was not clear > >whether it was stable or would continue to be maintained. > > > >xhtml and HStringTemplate were overkill for what I wanted, so I > >wound up > >just using the FastCGI and CGI toolkits themselves. They are > >surprisingly nice, and with a little bit of wrappers around them for > >things like validating forms, have worked exceptionally well. > > > > I'm in a position now where I can make a reasonable promise that hvac > will not only be maintained but undergoing continued development. I > just, for example, hooked in some basic postgresql support yesterday > (although the changes are not tested/pushed to the repo yet). > (Speaking of which, I noticed that the HDBC postgresql bindings don't > set seState on an error -- is this intentional, or something that > should be fixed up?) Sterling, Would you like to add some text on hvac and your other web libs to our web programming wiki/faq, http://haskell.org/haskellwiki/Practical_web_programming_in_Haskell Ideally, in a few months time, with enough additions, the full story will be covered on this wiki page, and it will be a great boon to developers wanting to work in Haskell, in this hot area. -- Don From andrewcoppin at btinternet.com Wed Jun 4 14:33:00 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Wed Jun 4 16:05:06 2008 Subject: [Haskell-cafe] How would you hack it? Message-ID: <4846DFDC.5020905@btinternet.com> So anyway, today I found myself wanting to build a program that generates some test data. I managed to make it *work* without too much difficulty, but it wasn't exactly "elegant". I'm curios to know how higher-order minds would approach this problem. It's not an especially "hard" problem, and I'm sure there are several good solutions possible. I have a file that contains several thousand words, seperated by white space. [I gather that on Unix there's a standard location for this file?] I want to end up with a file that contains a randomly-chosen selection of words. Actually, I'd like the end result to be a LaTeX file, containing sections, subsections, paragraphs and sentences. (Although obviously the actual sentences will be gibberish.) I'd like to be able to select how big the file should be, to within a few dozen characters anyway. Exact precision is not required. How would you do this? The approach I came up with is to slurp up the words like so: raw <- readFile "words.txt" let ws = words raw let n = length ws let wa = listArray (1,n) ws (I actually used lazy ByteStrings of characters.) So now I have an array of packed ByteStrings, and I can pick array indexes at random and use "unwords" to build my gibberish "sentences". The fun part is making a sentence come out the right size. There are two obvious possibilities: - Assume that all words are approximately N characters long, and estimate how many words a sentence therefore needs to contain to have the required length. - Start with an empty list and *actually count* the characters as you add each word. (You can prepend them rather than append them for extra efficiency.) I ended up taking the latter approach - at least at the sentence level. What I actually did was to write a function that builds lists of words. There is then another function that builds several sublists of approximately the prescribed lengths, inserts some commas, capitalises the first letter and appends a fullstop. This therefore generates a "sentence". After that, there's a function that builds several sentences of random size with random numbers of commas and makes a "paragraph" out of them. Next a function gathers several paragraphs and inserts a randomly-generated subsection heading. A similar function takes several subsections and adds a random section heading. In my current implementation, all of this is in the IO monad (so I can pick things randomly). Also, the whole thing looks very repetative and really if I thought about it harder, it ought to be possible to factor it out into something smaller and more ellegant. The clause function builds clauses of "approximately" the right size, and each function above that (sentence, paragraph, subsection, section) becomes progressively less accurate in its sizing. On the other hand, the final generated text always for example has 4 subsections to each section, and they always look visually the same size. I'd like to make it more random, but all the code works by estimating "roughly" how big a particular construct is, and therefore how many of then are required to full N characters. For larger and larger N, actually counting this stuff would seem somewhat inefficient, so I'm estimating. But that makes it hard to add more randomness without losing overall size control. The final file can end up being a fair way different in size to what I requested, and has an annoyingly regular internal structure. But essentially, it works. It would be nice to modify the code to generate HTML - but since it's coded so simple-mindedly, that would be a copy & paste job. Clearly, what I *should* have done is think more about a good abstraction before writing miles of code. ;-) So how would you guys do this? From newsham at lava.net Wed Jun 4 16:26:33 2008 From: newsham at lava.net (Tim Newsham) Date: Wed Jun 4 16:19:09 2008 Subject: [Haskell-cafe] very hard to build darcs with win32 ghc-6.8.2! Message-ID: I built darcs for win32 recently and it was much more difficult than it should be. Probably most of the blame goes to ghc-6.8.2 binary release for win32. Half of the effort is getting the zlib prereq working. Previously to build zlib for win32 ghc I did the following: http://www.haskell.org/pipermail/haskell-cafe/2007-March/023059.html However, now, the gcc binary for ghc-6.8.2 does not work as well as I would like which requires a bit more effort: - It did not automatically add mingw headers during compilation, and to fix this I had to force some extra flags. I built a shell script "xcc": #!/bin/sh GHC=/ghc/ghc-6.8.2 PATH=/c$GHC/gcc-lib:$PATH export PATH /c$GHC/gcc -I $GHC/include -I $GHC/include/mingw \ -I $GHC/gcc-lib/include -L $GHC/gcc-lib "$@" - During linking it did not find crt2.o and adding it to PATH and -L did not help, so I just copied wholesale all of /c/ghc/ghc-6.8.2/gcc-lib into my zlib source directory. - At this point I was able to build with: CC=./xcc ./configure --prefix=/c/ghc/ghc-6.8.2 \ --libdir=/c/ghc/ghc-6.8.2 make make install Why is the gcc in ghc's directory so non-functional? Ok, so with zlib (the C library) installed, the zlib haskell package installs properly. Dependency resolved. Next, to build darcs I had to configure it without libcurl support (or alternately spend time chasing down that dep, pass for now). Using cygwin I ran "./configure" which falsely uses the cygwin gcc for configuration checks, but since gcc is never used directly during the compilation process, that doesn't matter that much. I could have tried the "xcc" trick here again, but didn't bother. I ran into two problems during the build: - -Werror is specified in the GNUMakefile and there are many warnings. I just removed -Werror for now. - During linking it was not able to resolve "SleepEx" from src/win32/System/Posix.hs. I could not figure out what is going on here. I tried adding "-lkernel32" and "-L /ghc/ghc-6.8.2/gcc-lib -Lkernel32" to the Makefile and it still did not work even though /ghc/ghc-6.8.2/gcc-lib/libkernel32.a has SleepEx@8 defined(!) Finally I bit the bullet and hacked around this by noticing that mingw headers have _sleep() defined. I replaced the code in Posix.hs with: foreign import ccall "_sleep" c_sleep :: CULong -> IO () sleep :: Integer -> IO CInt sleep n = c_sleep (fromIntegral n) >> return (toEnum $ fromIntegral n) At this point darcs builds and the binary seems to work (so far). I don't know the implication of my sleep hack (which doesn't return the actual time slept). Here's a small test program which uses FFI to SleepEx which I was not able to get working with win32 ghc-6.8.2. ------ {-# OPTIONS -fglasgow-exts -fffi #-} module Main where import Foreign.C.Types foreign import ccall "SleepEx" c_SleepEx :: CUInt -> CInt -> IO CInt main = do putStrLn "start" n <- c_SleepEx (2*1000) 1 print n ------- So, what is going on with ghc-6.8.2? Why is the gcc so hard to use now? Why can't I get FFI working with standard win32 functions? Why aren't there prebuilt win32 darcs binaries anymore? Tim Newsham http://www.thenewsh.com/~newsham/ From bulat.ziganshin at gmail.com Wed Jun 4 16:21:18 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Jun 4 16:21:08 2008 Subject: [Haskell-cafe] How would you hack it? In-Reply-To: <4846DFDC.5020905@btinternet.com> References: <4846DFDC.5020905@btinternet.com> Message-ID: <908301814.20080605002118@gmail.com> Hello Andrew, Wednesday, June 4, 2008, 10:33:00 PM, you wrote: > I have a file that contains several thousand words, seperated by white > space. [I gather that on Unix there's a standard location for this > file?] I want to end up with a file that contains a randomly-chosen > selection of words. does this letter was generated automatically? :) good work! :))) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From greg at maptuit.com Wed Jun 4 16:18:12 2008 From: greg at maptuit.com (Gregory Collins) Date: Wed Jun 4 16:25:12 2008 Subject: [Haskell-cafe] How would you hack it? In-Reply-To: <4846DFDC.5020905@btinternet.com> (Andrew Coppin's message of "Wed, 04 Jun 2008 19:33:00 +0100") References: <4846DFDC.5020905@btinternet.com> Message-ID: Andrew Coppin writes: > Clearly, what I *should* have done is think more about a good > abstraction before writing miles of code. ;-) So how would you guys do > this? If you want text that roughly resembles English, you're better off getting a corpus of real English text and running it through a Markov chain. Mark Dominus has written a few blog posts about this topic recently, see http://blog.plover.com/lang/finnpar.html. G. From barsoap at web.de Wed Jun 4 16:32:28 2008 From: barsoap at web.de (Achim Schneider) Date: Wed Jun 4 16:25:19 2008 Subject: [Haskell-cafe] Re: How would you hack it? References: <4846DFDC.5020905@btinternet.com> Message-ID: <20080604223228.284254b5@solaris> Andrew Coppin wrote: > I have a file that contains several thousand words, seperated by > white space. [I gather that on Unix there's a standard location for > this file?] > Looking at /usr/share/dict/words, I'm assured that the proper seperator is \n. > Clearly, what I *should* have done is think more about a good > abstraction before writing miles of code. ;-) So how would you guys > do this? > Generate a Map Int [String] map, with the latter list being an infinite list of words with that particular size. Now assume that you want to have a 100 character sentence. You start by looking if you got any 100 character word, if yes it's your sentence, if not you divide it in half (maybe offset by a weighted random factor [1]) and start over again. You can then specify your whole document along the lines of (capitalise $ words 100) ++ ". " ++ (capitalise $ words 10) ++ "?" ++ (capitalise $ words 20) ++ "oneone1!" [1] Random midpoint displacement is a very interesting topic by itself. -- (c) this sig last receiving data processing entity. Inspect headers for past copyright information. All rights reserved. Unauthorised copying, hiring, renting, public performance and/or broadcasting of this signature prohibited. From jgoerzen at complete.org Wed Jun 4 16:51:15 2008 From: jgoerzen at complete.org (John Goerzen) Date: Wed Jun 4 16:43:53 2008 Subject: [Haskell-cafe] What is the maturity of Haskell Web Frameworks In-Reply-To: <84455758-6AD3-4FE9-ABF8-C1FC739FE0ED@gmail.com> References: <20080602172131.GA7534@scytale.galois.com> <910ddf450806031020i2e09b83bo4cd13f395b612e1@mail.gmail.com> <20080603172303.GA22053@scytale.galois.com> <1212534382.15010.227.camel@localhost> <4846C559.9020201@complete.org> <84455758-6AD3-4FE9-ABF8-C1FC739FE0ED@gmail.com> Message-ID: <48470043.6020400@complete.org> Sterling Clover wrote: >> hvac sounds interesting but at that time at least it was not clear >> whether it was stable or would continue to be maintained. >> >> xhtml and HStringTemplate were overkill for what I wanted, so I >> wound up >> just using the FastCGI and CGI toolkits themselves. They are >> surprisingly nice, and with a little bit of wrappers around them for >> things like validating forms, have worked exceptionally well. >> > > I'm in a position now where I can make a reasonable promise that hvac > will not only be maintained but undergoing continued development. I > just, for example, hooked in some basic postgresql support yesterday > (although the changes are not tested/pushed to the repo yet). > (Speaking of which, I noticed that the HDBC postgresql bindings don't > set seState on an error -- is this intentional, or something that > should be fixed up?) That would be a bug, I think. Could you submit it over at software.complete.org, ideally with test code? (Even more ideally, with a patch ) -- John From barsoap at web.de Wed Jun 4 16:52:20 2008 From: barsoap at web.de (Achim Schneider) Date: Wed Jun 4 16:45:11 2008 Subject: [Haskell-cafe] Re: How would you hack it? References: <4846DFDC.5020905@btinternet.com> Message-ID: <20080604225220.40e0fa76@solaris> Gregory Collins wrote: > Andrew Coppin writes: > > > Clearly, what I *should* have done is think more about a good > > abstraction before writing miles of code. ;-) So how would you guys > > do this? > > If you want text that roughly resembles English, you're better off > getting a corpus of real English text and running it through a Markov > chain. Mark Dominus has written a few blog posts about this topic > recently, see http://blog.plover.com/lang/finnpar.html. > If you run one over obscure academic papers, you can even generate publishable results. I don't have a link ready, but there was a fun incident involving this. -- (c) this sig last receiving data processing entity. Inspect headers for past copyright information. All rights reserved. Unauthorised copying, hiring, renting, public performance and/or broadcasting of this signature prohibited. From lemming at henning-thielemann.de Wed Jun 4 16:55:19 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Wed Jun 4 16:47:52 2008 Subject: [Haskell-cafe] How would you hack it? In-Reply-To: <4846DFDC.5020905@btinternet.com> References: <4846DFDC.5020905@btinternet.com> Message-ID: On Wed, 4 Jun 2008, Andrew Coppin wrote: > How would you do this? > > The approach I came up with is to slurp up the words like so: > > raw <- readFile "words.txt" > let ws = words raw > let n = length ws > let wa = listArray (1,n) ws > > (I actually used lazy ByteStrings of characters.) So now I have an array > of packed ByteStrings, and I can pick array indexes at random and use > "unwords" to build my gibberish "sentences". Sounds like a generator for scientific articles. :-) Maybe http://hackage.haskell.org/cgi-bin/hackage-scripts/package/markov-chain can be of help for you. It's also free of randomIO. > In my current implementation, all of this is in the IO monad (so I can > pick things randomly). You know of http://www.haskell.org/pipermail/haskell-cafe/2006-December/020005.html ? From lemming at henning-thielemann.de Wed Jun 4 16:58:05 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Wed Jun 4 16:50:37 2008 Subject: [Haskell-cafe] Re: How would you hack it? In-Reply-To: <20080604225220.40e0fa76@solaris> References: <4846DFDC.5020905@btinternet.com> <20080604225220.40e0fa76@solaris> Message-ID: On Wed, 4 Jun 2008, Achim Schneider wrote: > Gregory Collins wrote: > > > Andrew Coppin writes: > > > > > Clearly, what I *should* have done is think more about a good > > > abstraction before writing miles of code. ;-) So how would you guys > > > do this? > > > > If you want text that roughly resembles English, you're better off > > getting a corpus of real English text and running it through a Markov > > chain. Mark Dominus has written a few blog posts about this topic > > recently, see http://blog.plover.com/lang/finnpar.html. > > > If you run one over obscure academic papers, you can even generate > publishable results. I don't have a link ready, but there was a fun > incident involving this. A famous paper generator is http://pdos.csail.mit.edu/scigen/ From andrewcoppin at btinternet.com Wed Jun 4 16:50:28 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Wed Jun 4 16:59:36 2008 Subject: [Haskell-cafe] How would you hack it? In-Reply-To: References: <4846DFDC.5020905@btinternet.com> Message-ID: <48470014.4000804@btinternet.com> Gregory Collins wrote: > Andrew Coppin writes: > > >> Clearly, what I *should* have done is think more about a good >> abstraction before writing miles of code. ;-) So how would you guys do >> this? >> > > If you want text that roughly resembles English, you're better off > getting a corpus of real English text and running it through a Markov > chain. Mark Dominus has written a few blog posts about this topic > recently, see http://blog.plover.com/lang/finnpar.html. > This is probably overkill for my purposes. However, if you can find me a source that explains what a "Markov chain" actually *is*, I'd be quite interested. [I've seen it mentioned several times in relation to data compression, but Wikipedia's article is too cryptic for me to comprehend. I think Wikipedia is just a poor way to learn completely new concepts; Wikipedia's description of digital filters is also utterly incomprehensible, but it turns out the subject isn't actually that hard.] From andrewcoppin at btinternet.com Wed Jun 4 16:54:57 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Wed Jun 4 16:59:53 2008 Subject: [Haskell-cafe] Re: How would you hack it? In-Reply-To: <20080604223228.284254b5@solaris> References: <4846DFDC.5020905@btinternet.com> <20080604223228.284254b5@solaris> Message-ID: <48470121.6090408@btinternet.com> Achim Schneider wrote: > Andrew Coppin wrote: > > >> I have a file that contains several thousand words, seperated by >> white space. [I gather that on Unix there's a standard location for >> this file?] > Looking at /usr/share/dict/words, I'm assured that the proper seperator > is \n. > Thanks. I did look around trying to find this, but ultimately failed. (Is it a standard component, or is it installed as part of some specific application?) As I understand it, Haskell's "words" function will work on any kind of white space - spaces, line feeds, caridge returns, tabs, etc. - so it should be fine. ;-) Since I'm developing on Windows, what I actually did was have Google find me a file online that I can download. [Remember my post a while back? "GHC panic"? Apparently GHC doesn't like it if you try to represent the entire 400 KB file as a single [String]...] > Generate a Map Int [String] map, with the latter list being an infinite > list of words with that particular size. > > Now assume that you want to have a 100 character sentence. You start by > looking if you got any 100 character word, if yes it's your sentence, > if not you divide it in half (maybe offset by a weighted random > factor [1]) and start over again. > > You can then specify your whole document along the lines of > > (capitalise $ words 100) ++ ". " ++ (capitalise $ words 10) ++ "?" ++ > (capitalise $ words 20) ++ "oneone1!" > > [1] Random midpoint displacement is a very interesting topic by itself. > I'm not following your logic, sorry... From barsoap at web.de Wed Jun 4 17:25:07 2008 From: barsoap at web.de (Achim Schneider) Date: Wed Jun 4 17:17:55 2008 Subject: [Haskell-cafe] Re: How would you hack it? References: <4846DFDC.5020905@btinternet.com> <20080604223228.284254b5@solaris> <48470121.6090408@btinternet.com> Message-ID: <20080604232507.7fd9fd81@solaris> Andrew Coppin wrote: > Achim Schneider wrote: > > Andrew Coppin wrote: > > > > > >> I have a file that contains several thousand words, seperated by > >> white space. [I gather that on Unix there's a standard location for > >> this file?] > > Looking at /usr/share/dict/words, I'm assured that the proper > > seperator is \n. > > > > Thanks. I did look around trying to find this, but ultimately failed. > (Is it a standard component, or is it installed as part of some > specific application?) > ksf@solaris ~ % equery b /usr/share/dict/words [ Searching for file(s) /usr/share/dict/words in *... ] sys-apps/miscfiles-1.4.2 (/usr/share/dict/words) ksf@solaris ~ % eix miscfiles [I] sys-apps/miscfiles Available versions: 1.4.2 {minimal} Installed versions: 1.4.2(18:27:27 02/14/07)(-minimal) Homepage: http://www.gnu.org/directory/miscfiles.html Description: Miscellaneous files > > Generate a Map Int [String] map, with the latter list being an > > infinite list of words with that particular size. > > > > Now assume that you want to have a 100 character sentence. You > > start by looking if you got any 100 character word, if yes it's > > your sentence, if not you divide it in half (maybe offset by a > > weighted random factor [1]) and start over again. > > > > You can then specify your whole document along the lines of > > > > (capitalise $ words 100) ++ ". " ++ (capitalise $ words 10) ++ "?" > > ++ (capitalise $ words 20) ++ "oneone1!" > > > > [1] Random midpoint displacement is a very interesting topic by > > itself. > > I'm not following your logic, sorry... > That's probably because I just described the points and not the rest of the morphisms... imagine some plumbing and tape between my sentences. Midpoint displacement is a great way to achieve randomness while still keeping a uniform appearance. In the defining paper, that I don't have ready right now, an example was shown where a realistic outline of Australia was generated from ten or so data points: If you display it next to the actual outline, only a geographer could tell which one's the fake. -- (c) this sig last receiving data processing entity. Inspect headers for past copyright information. All rights reserved. Unauthorised copying, hiring, renting, public performance and/or broadcasting of this signature prohibited. From daniel.is.fischer at web.de Wed Jun 4 17:28:52 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Jun 4 17:19:32 2008 Subject: [Haskell-cafe] very hard to build darcs with win32 ghc-6.8.2! In-Reply-To: References: Message-ID: <200806042328.52170.daniel.is.fischer@web.de> Am Mittwoch, 4. Juni 2008 22:26 schrieb Tim Newsham: > > Here's a small test program which uses FFI to SleepEx which I was > not able to get working with win32 ghc-6.8.2. > > ------ > {-# OPTIONS -fglasgow-exts -fffi #-} > module Main where > import Foreign.C.Types > > foreign import ccall "SleepEx" c_SleepEx :: CUInt -> CInt -> IO CInt I seem to remember it should be "stdcall" on windows. That might also have a role in not finding SleepEx@8. > > main = do > putStrLn "start" > n <- c_SleepEx (2*1000) 1 > print n > ------- > > So, what is going on with ghc-6.8.2? Why is the gcc so hard to use > now? Why can't I get FFI working with standard win32 functions? > Why aren't there prebuilt win32 darcs binaries anymore? > > Tim Newsham > http://www.thenewsh.com/~newsham/ From andrewcoppin at btinternet.com Wed Jun 4 17:19:51 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Wed Jun 4 17:25:40 2008 Subject: [Haskell-cafe] How would you hack it? In-Reply-To: References: <4846DFDC.5020905@btinternet.com> Message-ID: <484706F7.8000407@btinternet.com> Henning Thielemann wrote: > Sounds like a generator for scientific articles. :-) > Maybe > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/markov-chain > can be of help for you. It's also free of randomIO. > That certainly looks interesting. Presumably if I train it right, it'll figure out that sentences need to start uppercase and end with a full-stop, and maybe have a few other punctuation marks thrown in. I'm not sure I trust it to generate valid LaTeX markup, but I can give it a try! ;-) At any rate, thanks for the link - the possibilities for this look very interesting. (All sorts of data to be generated. And hey, maybe if I read the source I can even learn some of the theory behind it too...) From list at phaedrusdeinus.org Wed Jun 4 17:33:21 2008 From: list at phaedrusdeinus.org (John Melesky) Date: Wed Jun 4 17:26:04 2008 Subject: [Haskell-cafe] How would you hack it? In-Reply-To: <48470014.4000804@btinternet.com> References: <4846DFDC.5020905@btinternet.com> <48470014.4000804@btinternet.com> Message-ID: <79F4406C-52CA-4467-9826-8819E3D8DEE3@phaedrusdeinus.org> On Jun 4, 2008, at 3:50 PM, Andrew Coppin wrote: > However, if you can find me a source that explains what a "Markov > chain" actually *is*, I'd be quite interested. In a non-rigorous nutshell: You have the word "star". You want to pick another word to follow it. It turns out that, based on analyzing a corpus ("corpus", here means "bunch of text you extract information from"), the following word pairs occur: star wars (20% of the time) star cluster (5% of the time) star dust (10% of the time) star system (25% of the time) star -end-of-sentence- (5% of the time) . . . So you use those occurrence statistics to pick a feasible next word (let's choose "system", since it's the highest probability here -- in practice you'd probably choose one randomly based on a weighted likelihood). Then you look for all the word pairs which start with "system", and choose the next word in the same fashion. Repeat for as long as you want. Those word-pair statistics, when you have them for all the words in your vocabulary, comprise the first-level Markov data for your corpus. When you extend it to word triplets, it's second-level Markov data (and it will generate more reasonable fake text). You can build higher and higher Markov levels if you'd like. And, ultimately, though the example is about text, you can use this method to generate "realistic" sequences of any sequential data. Hope that helps. -johnnnnnnn From lanny at cisco.com Wed Jun 4 18:23:20 2008 From: lanny at cisco.com (Lanny Ripple) Date: Wed Jun 4 18:15:44 2008 Subject: [Haskell-cafe] How would you hack it? In-Reply-To: <484706F7.8000407@btinternet.com> References: <4846DFDC.5020905@btinternet.com> <484706F7.8000407@btinternet.com> Message-ID: <484715D8.8090803@cisco.com> You might want to skim Shannon's 'A Mathematical Theory of Communcations'. Part 1, Section 2 and 3 are almost exactly your topic. (Or at least the direction you've headed in. :) http://plan9.bell-labs.com/cm/ms/what/shannonday/shannon1948.pdf -ljr Andrew Coppin wrote: > Henning Thielemann wrote: >> Sounds like a generator for scientific articles. :-) >> Maybe >> >> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/markov-chain >> can be of help for you. It's also free of randomIO. >> > > That certainly looks interesting. Presumably if I train it right, it'll > figure out that sentences need to start uppercase and end with a > full-stop, and maybe have a few other punctuation marks thrown in. I'm > not sure I trust it to generate valid LaTeX markup, but I can give it a > try! ;-) > > At any rate, thanks for the link - the possibilities for this look very > interesting. (All sorts of data to be generated. And hey, maybe if I > read the source I can even learn some of the theory behind it too...) > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From duncan.coutts at worc.ox.ac.uk Wed Jun 4 19:48:50 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Jun 4 19:37:53 2008 Subject: [Haskell-cafe] Re: cabal and platform-independent haskell installation management (again) (Re: Re: Ubuntu and ghc) In-Reply-To: <20080604172252.34df14f7@solaris> References: <5ae4f2ba0805211532l35bef8eas9a10ff6df3e0f843@mail.gmail.com> <1211448821.5824.504.camel@localhost> <008001c8bbf7$63753100$d0357ad5@cr3lt> <48466F7F.8090600@gmail.com> <016d01c8c64d$4ac1dea0$73357ad5@cr3lt> <1212590628.15010.312.camel@localhost> <20080604172252.34df14f7@solaris> Message-ID: <1212623330.15010.318.camel@localhost> On Wed, 2008-06-04 at 17:22 +0200, Achim Schneider wrote: > The question, IMHO, seems to be > > "How would a package manager for a posix-compilant kinetic look like?" http://nixos.org/index.html Duncan From duncan.coutts at worc.ox.ac.uk Wed Jun 4 19:53:13 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Jun 4 19:42:16 2008 Subject: [Haskell-cafe] very hard to build darcs with win32 ghc-6.8.2! In-Reply-To: References: Message-ID: <1212623593.15010.322.camel@localhost> On Wed, 2008-06-04 at 10:26 -1000, Tim Newsham wrote: > I built darcs for win32 recently and it was much more difficult than > it should be. Probably most of the blame goes to ghc-6.8.2 binary > release for win32. Half of the effort is getting the zlib prereq > working. > > Previously to build zlib for win32 ghc I did the following: > http://www.haskell.org/pipermail/haskell-cafe/2007-March/023059.html The recent versions of the zlib package on hackage bundle a complete copy of the zlib C library for the benefit of windows users (it uses the system zlib on all other systems). So it should "Just Work"tm. Duncan From ryani.spam at gmail.com Wed Jun 4 22:16:59 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Wed Jun 4 22:09:33 2008 Subject: [Haskell-cafe] Re: Laziness leaks In-Reply-To: References: <62728db30806031414p19593f40x5ad1bfd32e2dfc4b@mail.gmail.com> <4845D0B8.6040802@vex.net> <62728db30806031712w32421ae5scbf84920ecd71193@mail.gmail.com> Message-ID: <2f9b2d30806041916x3e0088acw26e45033ee586b9a@mail.gmail.com> On 6/4/08, apfelmus wrote: > Note that lazy evaluation never wastes time; evaluating a term with lazy > evaluation will always take less reduction steps than doing so eagerly or > partly eagerly. True, but you can still have a "time leak"; this is particularily relevant in soft-real-time apps (like almost every app you use on a regular basis, from your editor to games); a time leak is when a computation that would take X time if evaluated every "time step" is left for many timesteps without being evaluated, leading to a hitch in responsiveness when it eventually is demanded N frames later taking N*X time. Eager applications almost never have this sort of "time leak", but it's easy for it to happen with lazy evaluation. A simple example: consider a variable that holds the number of timesteps since the app launched, for example. Every time step it gets incremented by 1. If the result is evaluated every time step, it takes a constant amount of time per timestep. But if you go a long time without evaluating it, you end up with both a space leak (as the +1 thunks build up) but a time leak as well--when you eventually evaluate it, it takes O(n) time, where n is the number of frames since the variable was last evaluated. -- ryan From ninegua at gmail.com Wed Jun 4 22:30:49 2008 From: ninegua at gmail.com (Paul L) Date: Wed Jun 4 22:23:24 2008 Subject: [Haskell-cafe] What is the maturity of Haskell Web Frameworks In-Reply-To: References: Message-ID: <856033f20806041930t7499bda6n394938086ce38ecd@mail.gmail.com> Pardon me to hijack this thread, but I have an idea to build a different kind of Web Framework and am not sure if somebody has already done it. The idea is to take REST further: every HTML page you see is a program in its running state (as a continuation monad). Each click on its link or form submission is seen as feeding data to resume its continuation. So instead of writing a server-side program that responds to many CGI calls, you write a single ordinary program that describe the application logic, which during its execution gets represented as a HTML page and interpreted by the server. The server is then very much like a VM or an interpreter of an embedded language, with execution stacks entirely encoded and stored in each HTML page sent to the user and back from the user as an encoded URL or form data. So the server is entirely stateless. Besides providing scalability, the main advantage of this framework is that web program can be written in a natural way which total ignores stuffs like HTTP/CGI, protocol, session, client-server, etc, etc. Its compiler or interpreter will figure out what part of the program data (e.g. the code, the static environment) resides on the server side, and what part is encoded into the HTML pages (e.g., the heap, the dynamic environment). Does such a beast exist or am I entirely day dreaming? From donnie at darthik.com Wed Jun 4 22:54:32 2008 From: donnie at darthik.com (Donnie Jones) Date: Wed Jun 4 22:47:28 2008 Subject: [Haskell-cafe] Re: Having trouble with parallel Haskell In-Reply-To: <4846FB27.1010105@serpentine.com> References: <4846FB27.1010105@serpentine.com> Message-ID: Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: ParSort-post.parprof.ps Type: application/postscript Size: 2613617 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080604/355ef1c4/ParSort-post.parprof-0001.ps From barsoap at web.de Wed Jun 4 23:05:15 2008 From: barsoap at web.de (Achim Schneider) Date: Wed Jun 4 22:58:05 2008 Subject: [Haskell-cafe] Re: What is the maturity of Haskell Web Frameworks References: <856033f20806041930t7499bda6n394938086ce38ecd@mail.gmail.com> Message-ID: <20080605050515.2656b747@solaris> "Paul L" wrote: > Does such a beast exist or am I entirely day dreaming? > Daydreaming, at least partly: Just consider state that can't be stored client-side at all, e.g. the contents of a wiki page. Networking or HTML as interface isn't the real problem: It's the multi-headedness of applications that make things complicated. As soon as you have multiple programs or multiple instances of the same program modify shared data, things get involved. Traffic is another problem if state accumulates. Thinking about REST, a nice feature to have would be session timeout notifying: The server can keep the connection open and replace the displayed page with one notifying the user that he's too slow for current timeout settings. -- (c) this sig last receiving data processing entity. Inspect headers for past copyright information. All rights reserved. Unauthorised copying, hiring, renting, public performance and/or broadcasting of this signature prohibited. From qdunkan at gmail.com Wed Jun 4 23:14:41 2008 From: qdunkan at gmail.com (Evan Laforge) Date: Wed Jun 4 23:07:16 2008 Subject: [Haskell-cafe] How would you hack it? In-Reply-To: <484715D8.8090803@cisco.com> References: <4846DFDC.5020905@btinternet.com> <484706F7.8000407@btinternet.com> <484715D8.8090803@cisco.com> Message-ID: <2518b95d0806042014m3b40937cj1ecf05011e6dae77@mail.gmail.com> On Wed, Jun 4, 2008 at 3:23 PM, Lanny Ripple wrote: > You might want to skim Shannon's 'A Mathematical Theory of > Communcations'. Part 1, Section 2 and 3 are almost exactly your > topic. (Or at least the direction you've headed in. :) > > http://plan9.bell-labs.com/cm/ms/what/shannonday/shannon1948.pdf Rob Pike's "Practice of Programming" has a few chapters with a markov generator in several different languages as a case study. None of them are functional, but it's a pretty clear description of the idea. The "plan9" in the url reminded me :) From barsoap at web.de Wed Jun 4 23:28:25 2008 From: barsoap at web.de (Achim Schneider) Date: Wed Jun 4 23:21:13 2008 Subject: [Haskell-cafe] Re: Laziness leaks References: <62728db30806031414p19593f40x5ad1bfd32e2dfc4b@mail.gmail.com> <4845D0B8.6040802@vex.net> <62728db30806031712w32421ae5scbf84920ecd71193@mail.gmail.com> <2f9b2d30806041916x3e0088acw26e45033ee586b9a@mail.gmail.com> Message-ID: <20080605052825.7002ce4e@solaris> "Ryan Ingram" wrote: > On 6/4/08, apfelmus wrote: > > Note that lazy evaluation never wastes time; evaluating a term with > > lazy evaluation will always take less reduction steps than doing so > > eagerly or partly eagerly. > > True, but you can still have a "time leak"; this is particularily > relevant in soft-real-time apps (like almost every app you use on a > regular basis, from your editor to games); a time leak is when a > computation that would take X time if evaluated every "time step" is > left for many timesteps without being evaluated, leading to a hitch in > responsiveness when it eventually is demanded N frames later taking > N*X time. > > Eager applications almost never have this sort of "time leak", but > it's easy for it to happen with lazy evaluation. > > A simple example: consider a variable that holds the number of > timesteps since the app launched, for example. Every time step it > gets incremented by 1. If the result is evaluated every time step, it > takes a constant amount of time per timestep. But if you go a long > time without evaluating it, you end up with both a space leak (as the > +1 thunks build up) but a time leak as well--when you eventually > evaluate it, it takes O(n) time, where n is the number of frames since > the variable was last evaluated. > There won't ever be a space leak without a time leak nor a time leak without a space leak. I'd just call it a leak. You don't come across space-leaks in strict programs often because data is usually allocated statically even if execution is non-strict. Piping /dev/zero into a program that just sleeps does leak space, though. -- (c) this sig last receiving data processing entity. Inspect headers for past copyright information. All rights reserved. Unauthorised copying, hiring, renting, public performance and/or broadcasting of this signature prohibited. From allbery at ece.cmu.edu Thu Jun 5 00:14:25 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Thu Jun 5 00:06:59 2008 Subject: [Haskell-cafe] What is the maturity of Haskell Web Frameworks In-Reply-To: <856033f20806041930t7499bda6n394938086ce38ecd@mail.gmail.com> References: <856033f20806041930t7499bda6n394938086ce38ecd@mail.gmail.com> Message-ID: <388504A5-E615-478A-9D45-859FAAFE654F@ece.cmu.edu> On 2008 Jun 4, at 22:30, Paul L wrote: > The server is then very much like a VM or an interpreter of an > embedded language, with execution stacks entirely encoded and stored > in each HTML page sent to the user and back from the user as an > encoded URL or form data. So the server is entirely stateless. Mmm, if any of that HTML-stored state is sensitive server information, this becomes a problem. (E.g. can I trick your application into thinking I'm an admin and then go starting/stopping processes, changing passwords. etc.?) You need to use extra care if anything sensitive is put where the client can munge 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 From bulat.ziganshin at gmail.com Thu Jun 5 00:20:13 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Jun 5 00:19:00 2008 Subject: [Haskell-cafe] How would you hack it? In-Reply-To: References: <4846DFDC.5020905@btinternet.com> Message-ID: <1444025595.20080605082013@gmail.com> Hello Henning, Thursday, June 5, 2008, 12:55:19 AM, you wrote: > Sounds like a generator for scientific articles. :-) > Maybe > > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/markov-chain > can be of help for you. It's also free of randomIO. once i've used something like this to generate this brilliant text: can INR-s O, by thenion, Laertes, These at these haste is defeling and mornione. KING CLAUDIUS Heat killowers, and our vowst' GUILDENSTERN Ay, magamovinob vow; And lo leave they come, and he sole tobly all you, And, or spomir: So, wherefore hiacriful at ast, my lord, I have no orason; Frous stonbitter; at I'll I think himbers, seempended body jooke! That would be tracious arest, Rt: sor 'tis timeake or bifuchol gugnme: If thoughRqublest they are gave with this cercric if, for the no POLONIUS] KING CLAUDIUS I will violect of the queen with Dity. ROSENCRANTZ 'Stive to came fat: the ne further then, which he his worldy, it is means me. i've put a full copy to http://haskell.org/bz/not_exactly_hamlet.txt -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bulat.ziganshin at gmail.com Thu Jun 5 00:24:10 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Jun 5 00:28:20 2008 Subject: [Haskell-cafe] How would you hack it? In-Reply-To: <48470014.4000804@btinternet.com> References: <4846DFDC.5020905@btinternet.com> <48470014.4000804@btinternet.com> Message-ID: <546528799.20080605082410@gmail.com> Hello Andrew, Thursday, June 5, 2008, 12:50:28 AM, you wrote: > However, if you can find me a source that explains what a "Markov chain" > actually *is*, I'd be quite interested. *afaik*, the idea is simple: order-1 Markov chain is just text generated with respect of probability of each char, and order-n is a text generated using probability of each char in context of previous n-1 chars. you just need to gather stats using previous papers :) you can use this idea both to generate new naturally-looking words and to gather stats about words itself and generate naturally-looking sentences -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From twd2 at dockerz.net Thu Jun 5 01:35:32 2008 From: twd2 at dockerz.net (Tim Docker) Date: Thu Jun 5 01:28:07 2008 Subject: [Haskell-cafe] Re: library for drawing charts In-Reply-To: References: <82B3919B-BE28-4D65-9A3B-957B5EC51D27@gmail.com> <12204.203.185.215.144.1211767776.squirrel@dockerz.net> Message-ID: <30547.203.185.215.144.1212644132.squirrel@dockerz.net> Neal Alexander wrote: > I was using the HaskellCharts library and needed the same two things; so > i rolled a quick and dirty pie chart generator (Barchart is on the TODO > list). > > > http://72.167.145.184:8000/Screenshot.png > http://72.167.145.184:8000/PieChart.hs Nice! Do you mind if I refactor that a bit and add it to the HaskellCharts library? The license is BSD. Tim From lemming at henning-thielemann.de Thu Jun 5 01:43:01 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Jun 5 01:32:13 2008 Subject: [Haskell-cafe] How would you hack it? In-Reply-To: <484706F7.8000407@btinternet.com> References: <4846DFDC.5020905@btinternet.com> <484706F7.8000407@btinternet.com> Message-ID: On Wed, 4 Jun 2008, Andrew Coppin wrote: > Henning Thielemann wrote: > > Sounds like a generator for scientific articles. :-) > > Maybe > > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/markov-chain > > can be of help for you. It's also free of randomIO. > > That certainly looks interesting. Presumably if I train it right, it'll > figure out that sentences need to start uppercase and end with a > full-stop, and maybe have a few other punctuation marks thrown in. If you use different encodings for periods for abbreviations and sentence ends, this is warranted. > I'm not sure I trust it to generate valid LaTeX markup, but I can give > it a try! ;-) You may not want to construct a Markov Chain for characters but for larger objects, say words and LaTeX commands. However when it comes to correct parentheses, a Markov Chain might not be the appropriate tool, but a grammar. From lemming at henning-thielemann.de Thu Jun 5 01:46:45 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Jun 5 01:36:21 2008 Subject: [Haskell-cafe] How would you hack it? In-Reply-To: <79F4406C-52CA-4467-9826-8819E3D8DEE3@phaedrusdeinus.org> References: <4846DFDC.5020905@btinternet.com> <48470014.4000804@btinternet.com> <79F4406C-52CA-4467-9826-8819E3D8DEE3@phaedrusdeinus.org> Message-ID: On Wed, 4 Jun 2008, John Melesky wrote: > So you use those occurrence statistics to pick a feasible next word > (let's choose "system", since it's the highest probability here -- in > practice you'd probably choose one randomly based on a weighted > likelihood). Then you look for all the word pairs which start with > "system", and choose the next word in the same fashion. Repeat for as > long as you want. "Markov chain" means, that you have a sequence of random experiments, where the outcome of each experiment depends exclusively on a fixed number (the level) of experiments immediately before the current one. > Those word-pair statistics, when you have them for all the words in > your vocabulary, comprise the first-level Markov data for your corpus. > > When you extend it to word triplets, it's second-level Markov data > (and it will generate more reasonable fake text). You can build higher > and higher Markov levels if you'd like. If the level is too high, you will just reproduce the training text. From martindemello at gmail.com Thu Jun 5 02:07:05 2008 From: martindemello at gmail.com (Martin DeMello) Date: Thu Jun 5 01:59:38 2008 Subject: [Haskell-cafe] getting set up in ubuntu Message-ID: I finally ditched sabayon for ubuntu (one wireless problem too many), and now I'm slowly getting stuff set up on it. Any Ubuntu people care to share their experiences? I'm especially looking for guidelines on what to install via apt-get and what to install independently. Also, while I'm making Major Life Changes I might as well check out xmonad :) If anyone has made the switch from fluxbox, do share how it went. martin From jules at jellybean.co.uk Thu Jun 5 02:26:32 2008 From: jules at jellybean.co.uk (Jules Bean) Date: Thu Jun 5 02:19:04 2008 Subject: [Haskell-cafe] Re: Laziness leaks In-Reply-To: <20080605052825.7002ce4e@solaris> References: <62728db30806031414p19593f40x5ad1bfd32e2dfc4b@mail.gmail.com> <4845D0B8.6040802@vex.net> <62728db30806031712w32421ae5scbf84920ecd71193@mail.gmail.com> <2f9b2d30806041916x3e0088acw26e45033ee586b9a@mail.gmail.com> <20080605052825.7002ce4e@solaris> Message-ID: <48478718.7090102@jellybean.co.uk> Achim Schneider wrote: > You don't come across space-leaks in strict programs often because > data is usually allocated statically even if execution is non-strict. > > Piping /dev/zero into a program that just sleeps does leak space, > though. > It only leaks 8K or whatever size your system buffers pipes until it suspends the writer though... or do I misunderstand your analogy? From wqeqweuqy at hotmail.com Thu Jun 5 02:39:43 2008 From: wqeqweuqy at hotmail.com (Neal Alexander) Date: Thu Jun 5 02:32:35 2008 Subject: [Haskell-cafe] Re: library for drawing charts In-Reply-To: <30547.203.185.215.144.1212644132.squirrel@dockerz.net> References: <82B3919B-BE28-4D65-9A3B-957B5EC51D27@gmail.com> <12204.203.185.215.144.1211767776.squirrel@dockerz.net> <30547.203.185.215.144.1212644132.squirrel@dockerz.net> Message-ID: Tim Docker wrote: > Neal Alexander wrote: >> I was using the HaskellCharts library and needed the same two things; so >> i rolled a quick and dirty pie chart generator (Barchart is on the TODO >> list). >> >> >> http://72.167.145.184:8000/Screenshot.png >> http://72.167.145.184:8000/PieChart.hs > > Nice! Do you mind if I refactor that a bit and add it to the HaskellCharts > library? The license is BSD. > > Tim Yea whatever is cool, it needs some tweaks no doubt. From ketil at malde.org Thu Jun 5 03:25:43 2008 From: ketil at malde.org (Ketil Malde) Date: Thu Jun 5 03:17:56 2008 Subject: [Haskell-cafe] Re: Laziness leaks In-Reply-To: <4846E45C.3040402@vex.net> (Albert Y. C. Lai's message of "Wed\, 04 Jun 2008 14\:52\:12 -0400") References: <62728db30806031414p19593f40x5ad1bfd32e2dfc4b@mail.gmail.com> <4845D0B8.6040802@vex.net> <62728db30806031712w32421ae5scbf84920ecd71193@mail.gmail.com> <4846E45C.3040402@vex.net> Message-ID: <87abi0l4w8.fsf@malde.org> "Albert Y. C. Lai" writes: >> I haven't heard the terms "laziness leak" and "strictness leak" >> before > "Leak" refers to a surprise. I the meaning of "leak" is in a bit of flux. Originally, I believe it refers to a memory leak, where the programmer forgot to call free() before losing the pointer, thus making the program consume memory it can't recover, and can't use. With automatic memory management, this doesn't happen, so "memory leak" then started to mean retaining objects longer than necessary. (Aside: am I the only one who is shocked by the memory consumption of modern programs? I use a simple time tracker (gnotime), a calendar with a handful of entries (evolution), and they both typically consume half to one gigabyte of memory. In all fairness, it seems to be much better under Ubuntu 8.04 than 7.10, but again, they haven't been running for very long yet.) I'm not sure I'll use terms like strictness and laziness leak, I think it's hard to see what's being lost here, and if you have a laziness leak, it is unclear if it's too much laziness or too little? > ("Leak", "bug", "issue"... We surely are very creative in how to avoid > calling a shovel a shovel, or an error an error.) At least one text insisted on "defect". Too much laziness or strictness may be harmful to performance, but it's only a defect if it means the program fails to meet its requirements. -k -- If I haven't seen further, it is by standing in the footprints of giants From vigalchin at gmail.com Thu Jun 5 03:38:26 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Thu Jun 5 03:31:01 2008 Subject: [Haskell-cafe] example of FFI FunPtr Message-ID: <5ae4f2ba0806050038k1e0aea1exe6d81b22b1151eeb@mail.gmail.com> Hello, I want to model a Haskell function that is a callback from C. I have only found one example in the unix package's Semaphore.hsc, which apparently is not used. I want to be able to marshall a Haskell function that is a first class citizen residing in a Haskell data type and pass to a C function via FFI. Are there examples of this? Thanks, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080605/e0e8c413/attachment.htm From ketil at malde.org Thu Jun 5 03:40:50 2008 From: ketil at malde.org (Ketil Malde) Date: Thu Jun 5 03:33:02 2008 Subject: cabal and platform-independent haskell installation management (again) (Re: [Haskell-cafe] Re: Ubuntu and ghc) In-Reply-To: <016d01c8c64d$4ac1dea0$73357ad5@cr3lt> (Claus Reinke's message of "Wed\, 4 Jun 2008 15\:14\:22 +0100") References: <5ae4f2ba0805211532l35bef8eas9a10ff6df3e0f843@mail.gmail.com> <1211448821.5824.504.camel@localhost> <008001c8bbf7$63753100$d0357ad5@cr3lt> <48466F7F.8090600@gmail.com> <016d01c8c64d$4ac1dea0$73357ad5@cr3lt> Message-ID: <878wxkl471.fsf@malde.org> "Claus Reinke" writes: > 1. there are no systems where "packages just work"! > there are systems where a few people ensure that > many people can live in such an illusion, though. Exactly. Integrating Cabal packages into the system package manager is still non-trivial, and a package maintainer is necessary for this to work. Which is why it's rather utopian to hope that all of Hackage can be found in even the most widely used distributions, since many of those are way to narrow in scope for somebody to take on the work of providing package management. I bet some aren't even maintained, and possibly don't work with current GHC or Cabal. But I digress. > - it isn't sufficient to worry about installation management, > one has to worry about integration, lifetime and uninstall > management as well. in short, maintain the dependency > graphs over any of "install"/"upgrade"/"uninstall". There is an important difference between Hackage and, say, Ubuntu, and that is that the latter does releases. If I use a particular Ubuntu version, I get a particular GHC version, and a particular version of some dozens of libraries and applications. They are all compiled with that GHC version, tested, and can to a reasonable degree, be expected to work together. Sometimes they don't, but the good news is that a zillion other users are in the same boat (well, even for Haskell, it's probably dozens, at least), and chances are the bug will be fixed. If I upgrade to the next version of Ubuntu, I can reasonably expect all packages to be updated to current versions, and some to be replaced. In contrast, for my packages on Hackage, I'm reasonably certain it worked on my particular system at the time I uploaded it. And dependencies are none too specific - the package might work with different versions than I compiled with or not. I think for Cabal to provide the convenience currently afforded by system package managers, you'd need to do Hackage-wide releases, and test everything together. This is a lot of work, but not impossible, it's what Gnome and KDE does, for instance. It would probably make things easier for system package maintainers, too. Alternatives, like pessimistic dependencies: only exact versions in cabal files, will probably make you end up with installing every version of every package, and still suffer dependency hell. Exhaustive testing of all version combinations, which will require a lot of computational resources, even if it could be done automatically. -- I generally install most libraries from the distribution's repository, and let the system worry about updates etc. I think it's also an advantage if my programs avoid depending on stuff that's not in the repo, since it's likely to be is less widely used and maintained. I install manually the stuff I need the distribution doesn't provide, and also when I want to look at the code, or just have the latest and greatest. I tend to get the darcs version, rather than the Hackage one, though. The downside is that I need to reinstall these when I do a system upgrade, but it's rare enough that it doesn't bother me much, and chances are that more libraries are provided with my distribution for every release, so a cleanup is probably a good idea anyway. Anyway, this works pretty well for me - if I'm living on an illusion, it's at least a good one. :-) -k -- If I haven't seen further, it is by standing in the footprints of giants From ketil at malde.org Thu Jun 5 03:47:38 2008 From: ketil at malde.org (Ketil Malde) Date: Thu Jun 5 03:39:50 2008 Subject: [Haskell-cafe] getting set up in ubuntu In-Reply-To: (Martin DeMello's message of "Wed\, 4 Jun 2008 23\:07\:05 -0700") References: Message-ID: <874p88l3vp.fsf@malde.org> "Martin DeMello" writes: > Any Ubuntu people care to share their experiences? Ask, and ye shall receive..at least some kind of answer. > I'm especially looking for guidelines on what to install via apt-get > and what to install independently. I'd get as much as possible via apt-get, and only install manually when that fails. Libraries - which is probably what you will need most often, have names that start with 'libghc6'. For the whole list: apt-cache search libghc6 To see what the package is about, use e.g.: apt-cache show libghc6-quickcheck-dev There are (usually?) three packages for each library, -dev, -doc, and -prof. Unless you have very little diskspace or a thin network connection, get them all, e.g: sudo apt-get install libghc6-quickcheck-\* You are then set up to unit-test your code. > Also, while I'm making Major Life Changes I might as well check out > xmonad :) If anyone has made the switch from fluxbox, do share how it > went. You're basically leaving it all (window management, icons, trays, whatever) behind, so it doesn't matter much what you switch from. Just: sudo apt-get install xmonad -k -- If I haven't seen further, it is by standing in the footprints of giants From marlowsd at gmail.com Thu Jun 5 04:01:39 2008 From: marlowsd at gmail.com (Simon Marlow) Date: Thu Jun 5 03:54:17 2008 Subject: [Haskell-cafe] Re: Ubuntu and ghc In-Reply-To: <87wsl5xswc.fsf@malde.org> References: <5ae4f2ba0805211532l35bef8eas9a10ff6df3e0f843@mail.gmail.com> <1211448821.5824.504.camel@localhost> <008001c8bbf7$63753100$d0357ad5@cr3lt> <48466F7F.8090600@gmail.com> <20080604143650.72978202@solaris> <87wsl5xswc.fsf@malde.org> Message-ID: <48479D63.1010004@gmail.com> Ketil Malde wrote: > The most usable one I've seen is Steam from Valve, IIRC. It'd be cool > if Haskell packages were provided this way. Cygwin's installer seems to work pretty well, too. Cheers, Simon From cetin.sert at gmail.com Thu Jun 5 04:03:22 2008 From: cetin.sert at gmail.com (Cetin Sert) Date: Thu Jun 5 03:55:56 2008 Subject: [Haskell-cafe] automatically deriving Map and Filter on datatypes etc. Message-ID: <1ff5dedc0806050103h1639d907r7ac731de016787bc@mail.gmail.com> Hi ^_^, Let's say we have the following data type and functions: data Tab a = (:?:) | a :?: Tab a | Tab a :??: (Tab a,Tab a) deriving (Eq, Show, Read) map f (:?:) = (:?:) map f (a :?: t) = f a :?: map f t map f (h :??: (l,r)) = map f h :??: (map f l, map f r) filter p (:?:) = (:?:) filter p (a :?: t) | p a = filter p t | otherwise = a :?: filter p t filter p (h :??: (l,r)) = filter p h :??: (filter p l, filter p r) is it possible to automatically derive map and filter? data Tab a = (:?:) | a :?: Tab a | Tab a :??: (Tab a,Tab a) deriving (Eq, Show, Read, Map, Filter) If not, do you think it might be nice to have something like this in the future? Best Regards, Cetin Sert -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080605/0510637d/attachment.htm From marlowsd at gmail.com Thu Jun 5 04:05:05 2008 From: marlowsd at gmail.com (Simon Marlow) Date: Thu Jun 5 03:57:42 2008 Subject: [Haskell-cafe] Re: Ubuntu and ghc In-Reply-To: <20080604143650.72978202@solaris> References: <5ae4f2ba0805211532l35bef8eas9a10ff6df3e0f843@mail.gmail.com> <1211448821.5824.504.camel@localhost> <008001c8bbf7$63753100$d0357ad5@cr3lt> <48466F7F.8090600@gmail.com> <20080604143650.72978202@solaris> Message-ID: <48479E31.9050909@gmail.com> Achim Schneider wrote: > Simon Marlow wrote: > >> Claus Reinke wrote: >> >>> - i don't want to have to remove anything explicitly, because >>> that would mean bypassing the haskell installation managers >>> - i would want to see a single haskell installation manager >>> for each system, >> I think that's fundamentally the wrong approach. We shouldn't have >> to build a "Haskell installation manager". Would you also want >> installation managers for Perl, Python, Ruby, C, C++, etc. each with >> their own different user interfaces and feature sets? I think not - >> you want a single package manager for the whole system from which you >> can install/uninstall libraries for any language. >> >> This is something that Windows gets completely wrong. Why do I have >> twelve icons in my status bar all representing little programs that >> are running in the background checking for updates to their own bits >> of software? Why on earth do I have a Printer Driver Update >> Manager? And I'd be wondering the same thing about a "Haskell >> installation manager": installation and dependencies are not >> something specific to Haskell. >> > Well, then there are developers who don't want to do .ebuilds, .rpms > for 20 distributions, .debs for 20 distributions, .cabs... Meaning that > if you have a project with 5 developers using 3 1/2 distributions, you > will have a hard time installing. But the whole point is that the Haskell library developer doesn't have to make all these packages: they just make a Cabal package, and the distro maintainers have tools that turn a Cabal package into a .ebuild, .deb, .rpm etc. There was also a tool to make Windows installers from Cabal packages in the works, but I haven't heard anything on that front for a while. Cheers, Simon From marlowsd at gmail.com Thu Jun 5 04:16:17 2008 From: marlowsd at gmail.com (Simon Marlow) Date: Thu Jun 5 04:08:55 2008 Subject: [Haskell-cafe] Re: Ubuntu and ghc In-Reply-To: <1212585727.15010.281.camel@localhost> References: <5ae4f2ba0805211532l35bef8eas9a10ff6df3e0f843@mail.gmail.com> <1211448821.5824.504.camel@localhost> <008001c8bbf7$63753100$d0357ad5@cr3lt> <48466F7F.8090600@gmail.com> <1212585727.15010.281.camel@localhost> Message-ID: <4847A0D1.3040306@gmail.com> Duncan Coutts wrote: > On Wed, 2008-06-04 at 11:33 +0100, Simon Marlow wrote: >> Claus Reinke wrote: >> >>> - i don't want to have to remove anything explicitly, because that >>> would mean bypassing the haskell installation managers >>> - i would want to see a single haskell installation manager >>> for each system, >> I think that's fundamentally the wrong approach. We shouldn't have to >> build a "Haskell installation manager". Would you also want installation >> managers for Perl, Python, Ruby, C, C++, etc. each with their own different >> user interfaces and feature sets? I think not - you want a single package >> manager for the whole system from which you can install/uninstall libraries >> for any language. > > As I see it we need both. We need to make it easy to translate cabal > packages into distro packages. We do have tools to do that at the moment > for Gentoo, Debian and Fedora. I'm sure they could be improved. > > However we cannot expect all distros (esp Windows) to have all packages > that are on hackage at all times. That's where it makes sense to have a > tool like cabal-install as a secondary package manager. There's also the > fact that most distro package managers do not handle unprivileged > per-user installations very well. Well, that's true. I guess what I'm really objecting to in Claus's message is the implication that we should always use a Haskell Installation Manager, even on systems with good built-in package management. Yes, I agree we need good support for managing packages for the other scenarios: no system package manager, home-directory installs, no pre-prepared system package. I just don't want whatever provision we make for these cases to replace the system package manager for global package installs on systems where that is well supported. Cheers, Simon From miguelimo38 at yandex.ru Thu Jun 5 04:28:02 2008 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Thu Jun 5 04:20:51 2008 Subject: [Haskell-cafe] automatically deriving Map and Filter on datatypes etc. In-Reply-To: <1ff5dedc0806050103h1639d907r7ac731de016787bc@mail.gmail.com> References: <1ff5dedc0806050103h1639d907r7ac731de016787bc@mail.gmail.com> Message-ID: <0D31F43A-4404-40EA-8628-45A033FB6493@yandex.ru> Well, it's certainly not possible for "filter", at least, not without additional hints to the compiler. For example, consider this type: data Weird a = A | B a (Weird a) (Weird a) filter p A = A filter p (B x w1 w2) | p x = B x (filter p w1) (filter p w2) | otherwise = ????? On 5 Jun 2008, at 12:03, Cetin Sert wrote: > Hi ^_^, > > Let's say we have the following data type and functions: > data Tab a = (:?:) > > | a :?: Tab a > | Tab a :??: (Tab a,Tab a) > deriving (Eq, Show, Read) > > map f (:?:) = (:?:) > map f (a :?: t) = f a :?: map f t > map f (h :??: (l,r)) = map f h :??: (map f l, map f r) > > > filter p (:?:) = (:?:) > filter p (a :?: t) | p a = filter p t > | otherwise = a :?: filter p t > filter p (h :??: (l,r)) = filter p h :??: (filter p l, filter > p r) > > is it possible to automatically derive map and filter? > data Tab a = (:?:) > | a :?: Tab a > | Tab a :??: (Tab a,Tab a) > deriving (Eq, Show, Read, Map, Filter) > > If not, do you think it might be nice to have something like this in > the future? > > Best Regards, > Cetin Sert > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From tom.davie at gmail.com Thu Jun 5 04:39:16 2008 From: tom.davie at gmail.com (Thomas Davie) Date: Thu Jun 5 04:31:51 2008 Subject: [Haskell-cafe] automatically deriving Map and Filter on datatypes etc. In-Reply-To: <0D31F43A-4404-40EA-8628-45A033FB6493@yandex.ru> References: <1ff5dedc0806050103h1639d907r7ac731de016787bc@mail.gmail.com> <0D31F43A-4404-40EA-8628-45A033FB6493@yandex.ru> Message-ID: <2638D507-4427-4A04-96E5-C8208F3F0D2F@gmail.com> Even deriving an instance of Functor seems rather implausable, what should it do for data Wierd a b = Nil | A a (Wierd a b) | B b (Wierd a b) Should fmap's function argument operate on 'a's, 'b's, or both? Bob On 5 Jun 2008, at 10:28, Miguel Mitrofanov wrote: > Well, it's certainly not possible for "filter", at least, not > without additional hints to the compiler. For example, consider this > type: > > data Weird a = A | B a (Weird a) (Weird a) > > filter p A = A > filter p (B x w1 w2) | p x = B x (filter p w1) (filter p w2) > | otherwise = ????? > > On 5 Jun 2008, at 12:03, Cetin Sert wrote: > >> Hi ^_^, >> >> Let's say we have the following data type and functions: >> data Tab a = (:?:) >> >> | a :?: Tab a >> | Tab a :??: (Tab a,Tab a) >> deriving (Eq, Show, Read) >> >> map f (:?:) = (:?:) >> map f (a :?: t) = f a :?: map f t >> map f (h :??: (l,r)) = map f h :??: (map f l, map f r) >> >> >> filter p (:?:) = (:?:) >> filter p (a :?: t) | p a = filter p t >> | otherwise = a :?: filter p t >> filter p (h :??: (l,r)) = filter p h :??: (filter p l, >> filter p r) >> >> is it possible to automatically derive map and filter? >> data Tab a = (:?:) >> | a :?: Tab a >> | Tab a :??: (Tab a,Tab a) >> deriving (Eq, Show, Read, Map, Filter) >> >> If not, do you think it might be nice to have something like this >> in the future? >> >> Best Regards, >> Cetin Sert >> _______________________________________________ >> 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 voigt at tcs.inf.tu-dresden.de Thu Jun 5 04:49:33 2008 From: voigt at tcs.inf.tu-dresden.de (Janis Voigtlaender) Date: Thu Jun 5 04:38:04 2008 Subject: [Haskell-cafe] automatically deriving Map and Filter on datatypes etc. In-Reply-To: <2638D507-4427-4A04-96E5-C8208F3F0D2F@gmail.com> References: <1ff5dedc0806050103h1639d907r7ac731de016787bc@mail.gmail.com> <0D31F43A-4404-40EA-8628-45A033FB6493@yandex.ru> <2638D507-4427-4A04-96E5-C8208F3F0D2F@gmail.com> Message-ID: <4847A89D.8010004@tcs.inf.tu-dresden.de> Thomas Davie wrote: > Even deriving an instance of Functor seems rather implausable, what > should it do for > > data Wierd a b = Nil | A a (Wierd a b) | B b (Wierd a b) > > Should fmap's function argument operate on 'a's, 'b's, or both? But for many datatypes it is quite natural. Just google for "theory of containers". Ciao, Janis. -- Dr. Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:voigt@tcs.inf.tu-dresden.de From loup.vaillant at gmail.com Thu Jun 5 04:49:09 2008 From: loup.vaillant at gmail.com (Loup Vaillant) Date: Thu Jun 5 04:41:42 2008 Subject: [Haskell-cafe] Re: Laziness leaks In-Reply-To: References: <62728db30806031414p19593f40x5ad1bfd32e2dfc4b@mail.gmail.com> <4845D0B8.6040802@vex.net> <62728db30806031712w32421ae5scbf84920ecd71193@mail.gmail.com> Message-ID: <6f9f8f4a0806050149j3d320413n9b376cae010dc377@mail.gmail.com> 2008/6/4 apfelmus : > [...] > But it can waste space (-> "space leak"), for instance by > accumulating a big expression like > > (..) -> ((..)+1) -> (((..) + 1) + 1) -> etc. > > instead of evaluating x+1 immediately > > 5 -> 6 -> 7 -> etc. So, it is called a "space leak" because the asymptotic space required is greater in a lazy setting compared to a strict setting. Then, what about: sum . map (\x -> 2 * x + 42) $ [1..9999999] Provided sum works in constant space (needs proper tail calls and the right level of stricness), this runs in constant space in Haskell, deforestation or not. However, the equivalent code in, say, Ocaml, will work in linear space in the absence of deforestation. So, in this case, I find legitimate to talk about a "strictness space leak". Well, is it? Of course it uses linear space, there is no "leak"! hummm. It feels like only lazy evaluation can be accused of space leak, while strict evaluation cannot. Are we biased in favour of strict evaluation? I mean, if we take strict evaluation as the default (because it's mainstream), it is easy to think that lazy evaluation is cool when better, but unacceptable when worse. Hence the word "leak". Just my two cents, Loup From miguelimo38 at yandex.ru Thu Jun 5 04:49:06 2008 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Thu Jun 5 04:41:57 2008 Subject: [Haskell-cafe] automatically deriving Map and Filter on datatypes etc. In-Reply-To: <2638D507-4427-4A04-96E5-C8208F3F0D2F@gmail.com> References: <1ff5dedc0806050103h1639d907r7ac731de016787bc@mail.gmail.com> <0D31F43A-4404-40EA-8628-45A033FB6493@yandex.ru> <2638D507-4427-4A04-96E5-C8208F3F0D2F@gmail.com> Message-ID: <45A93A68-A76A-4C35-B748-FD0CF1022E98@yandex.ru> It can be even worse: data X a b = X (X b a -> b) Here (X a) is certainly a functor, but the implementation must also act on "a" contravariantly: mapX :: (a -> a') -> X a' b -> X a b mapX f (X h) = X $ h . fmap f instance Functor (X a) where fmap f (X h) = X $ f . h . mapX f On 5 Jun 2008, at 12:39, Thomas Davie wrote: > Even deriving an instance of Functor seems rather implausable, what > should it do for > > data Wierd a b = Nil | A a (Wierd a b) | B b (Wierd a b) > > Should fmap's function argument operate on 'a's, 'b's, or both? > > Bob > > On 5 Jun 2008, at 10:28, Miguel Mitrofanov wrote: > >> Well, it's certainly not possible for "filter", at least, not >> without additional hints to the compiler. For example, consider >> this type: >> >> data Weird a = A | B a (Weird a) (Weird a) >> >> filter p A = A >> filter p (B x w1 w2) | p x = B x (filter p w1) (filter p w2) >> | otherwise = ????? >> >> On 5 Jun 2008, at 12:03, Cetin Sert wrote: >> >>> Hi ^_^, >>> >>> Let's say we have the following data type and functions: >>> data Tab a = (:?:) >>> >>> | a :?: Tab a >>> | Tab a :??: (Tab a,Tab a) >>> deriving (Eq, Show, Read) >>> >>> map f (:?:) = (:?:) >>> map f (a :?: t) = f a :?: map f t >>> map f (h :??: (l,r)) = map f h :??: (map f l, map f r) >>> >>> >>> filter p (:?:) = (:?:) >>> filter p (a :?: t) | p a = filter p t >>> | otherwise = a :?: filter p t >>> filter p (h :??: (l,r)) = filter p h :??: (filter p l, >>> filter p r) >>> >>> is it possible to automatically derive map and filter? >>> data Tab a = (:?:) >>> | a :?: Tab a >>> | Tab a :??: (Tab a,Tab a) >>> deriving (Eq, Show, Read, Map, Filter) >>> >>> If not, do you think it might be nice to have something like this >>> in the future? >>> >>> Best Regards, >>> Cetin Sert >>> _______________________________________________ >>> 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 > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From duncan.coutts at worc.ox.ac.uk Thu Jun 5 05:11:57 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Jun 5 05:00:59 2008 Subject: [Haskell-cafe] Re: Ubuntu and ghc In-Reply-To: <4847A0D1.3040306@gmail.com> References: <5ae4f2ba0805211532l35bef8eas9a10ff6df3e0f843@mail.gmail.com> <1211448821.5824.504.camel@localhost> <008001c8bbf7$63753100$d0357ad5@cr3lt> <48466F7F.8090600@gmail.com> <1212585727.15010.281.camel@localhost> <4847A0D1.3040306@gmail.com> Message-ID: <1212657117.15010.327.camel@localhost> On Thu, 2008-06-05 at 09:16 +0100, Simon Marlow wrote: > > As I see it we need both. We need to make it easy to translate cabal > > packages into distro packages. We do have tools to do that at the moment > > for Gentoo, Debian and Fedora. I'm sure they could be improved. > > > > However we cannot expect all distros (esp Windows) to have all packages > > that are on hackage at all times. That's where it makes sense to have a > > tool like cabal-install as a secondary package manager. There's also the > > fact that most distro package managers do not handle unprivileged > > per-user installations very well. > > Well, that's true. I guess what I'm really objecting to in Claus's message > is the implication that we should always use a Haskell Installation > Manager, even on systems with good built-in package management. > > Yes, I agree we need good support for managing packages for the other > scenarios: no system package manager, home-directory installs, no > pre-prepared system package. I just don't want whatever provision we make > for these cases to replace the system package manager for global package > installs on systems where that is well supported. Indeed. I wholly agree. Duncan From greg at momotaro.chinmin.edu.tw Thu Jun 5 05:03:27 2008 From: greg at momotaro.chinmin.edu.tw (Greg Matheson) Date: Thu Jun 5 05:07:56 2008 Subject: [Haskell-cafe] HDBC-odbc 1.1.4.4 fixes Windows linking problems In-Reply-To: <4846C62B.2050503@complete.org> References: <20080603200020.GA13041@complete.org> <20080604030541.GA26462@momotaro.chinmin.edu.tw> <4846C62B.2050503@complete.org> Message-ID: <20080605090327.GA28588@momotaro.chinmin.edu.tw> On Wed, 04 Jun 2008, John Goerzen wrote: > > Prelude Database.HDBC Database.HDBC.ODBC> conn <- connectODBC "dictation" > Please note that this is not a valid connection string. I need to remember the connection functions are specific to the drivers and there are differences between connectODBC and connectSqlite3. > The HDBC-odbc API docs ... give the example string of: "DSN=hdbctest1" > as well as a link to the Microsoft document that describes the string: > http://msdn.microsoft.com/en-us/library/ms715433(VS.85).aspx > That URL also contains error message descriptions. For your state > 01S00, it lists: > Invalid connection string attribute > Your fix may be as simple as prepending the string with "DSN=". That did the trick. And I can insert and query the database. So HDBC-odbc-1.1.4.4 is good here. -- Dr Bean Make a mistake. Try it, you'll like it. --Dr Bean From devriese at cs.tcd.ie Thu Jun 5 05:16:09 2008 From: devriese at cs.tcd.ie (Edsko de Vries) Date: Thu Jun 5 05:08:45 2008 Subject: [Haskell-cafe] What is the maturity of Haskell Web Frameworks In-Reply-To: <856033f20806041930t7499bda6n394938086ce38ecd@mail.gmail.com> References: <856033f20806041930t7499bda6n394938086ce38ecd@mail.gmail.com> Message-ID: <20080605091609.GA8533@netsoc.tcd.ie> On Wed, Jun 04, 2008 at 10:30:49PM -0400, Paul L wrote: > Pardon me to hijack this thread, but I have an idea to build a > different kind of Web Framework and am not sure if somebody has > already done it. Have a look at iTasks, written in Clean. Not *quite* Haskell, I know, but close enough. I does what you suggest, it does what the OP suggested (assigning tasks to people etc) and much more. For example, read the following ICFP paper: http://www.st.cs.ru.nl/papers/2007/plar2007-ICFP07-iTasks.pdf Edsko From devriese at cs.tcd.ie Thu Jun 5 05:20:21 2008 From: devriese at cs.tcd.ie (Edsko de Vries) Date: Thu Jun 5 05:12:55 2008 Subject: [Haskell-cafe] automatically deriving Map and Filter on datatypes etc. In-Reply-To: <2638D507-4427-4A04-96E5-C8208F3F0D2F@gmail.com> References: <1ff5dedc0806050103h1639d907r7ac731de016787bc@mail.gmail.com> <0D31F43A-4404-40EA-8628-45A033FB6493@yandex.ru> <2638D507-4427-4A04-96E5-C8208F3F0D2F@gmail.com> Message-ID: <20080605092021.GA6483@netsoc.tcd.ie> On Thu, Jun 05, 2008 at 10:39:16AM +0200, Thomas Davie wrote: > Even deriving an instance of Functor seems rather implausable, what > should it do for > > data Wierd a b = Nil | A a (Wierd a b) | B b (Wierd a b) > > Should fmap's function argument operate on 'a's, 'b's, or both? Generic Haskell can do all that. Read Ralf Hinze's "Generic Programs and Proofs" for the theory: http://www.informatik.uni-bonn.de/~ralf/publications/habilitation.pdf Edsko From claudiusmaximus at goto10.org Thu Jun 5 05:21:41 2008 From: claudiusmaximus at goto10.org (Claude Heiland-Allen) Date: Thu Jun 5 05:14:14 2008 Subject: [Haskell-cafe] example of FFI FunPtr In-Reply-To: <5ae4f2ba0806050038k1e0aea1exe6d81b22b1151eeb@mail.gmail.com> References: <5ae4f2ba0806050038k1e0aea1exe6d81b22b1151eeb@mail.gmail.com> Message-ID: <4847B025.8030800@goto10.org> Galchin, Vasili wrote: > Hello, > > I want to model a Haskell function that is a callback from C. I have > only found one example in the unix package's Semaphore.hsc, which apparently > is not used. I want to be able to marshall a Haskell function that is a > first class citizen residing in a Haskell data type and pass to a C function > via FFI. Are there examples of this? Attached is a simple example. The main thing to note is 'foreign import ccall "wrapper"' which gives you a factory for turning Haskell functions into foreign function pointers. More information: http://www.cse.unsw.edu.au/~chak/haskell/ffi/ Claude -- http://claudiusmaximus.goto10.org -------------- next part -------------- A non-text attachment was scrubbed... Name: CallBacker.hs Type: text/x-haskell Size: 512 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080605/7b622443/CallBacker.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: callerback.c Type: text/x-csrc Size: 78 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080605/7b622443/callerback.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: callerback.h Type: text/x-chdr Size: 110 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080605/7b622443/callerback-0001.bin -------------- next part -------------- CallBacker: CallBacker.hs callerback.c callerback.h ghc -O2 -Wall -fffi -o CallBacker CallBacker.hs callerback.c From vigalchin at gmail.com Thu Jun 5 06:02:15 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Thu Jun 5 05:54:49 2008 Subject: [Haskell-cafe] example of FFI FunPtr In-Reply-To: <4847B025.8030800@goto10.org> References: <5ae4f2ba0806050038k1e0aea1exe6d81b22b1151eeb@mail.gmail.com> <4847B025.8030800@goto10.org> Message-ID: <5ae4f2ba0806050302i61d5efadvfc18a6612dbdc5d8@mail.gmail.com> thank you, Claude! Vasili On Th, Jun 5, 2008 at 4:21 AM, Claude Heiland-Allen < claudiusmaximus@goto10.org> wrote: > Galchin, Vasili wrote: > >> Hello, >> >> I want to model a Haskell function that is a callback from C. I have >> only found one example in the unix package's Semaphore.hsc, which >> apparently >> is not used. I want to be able to marshall a Haskell function that is a >> first class citizen residing in a Haskell data type and pass to a C >> function >> via FFI. Are there examples of this? >> > > Attached is a simple example. > > The main thing to note is 'foreign import ccall "wrapper"' which gives you > a factory for turning Haskell functions into foreign function pointers. > > More information: > > http://www.cse.unsw.edu.au/~chak/haskell/ffi/ > > > Claude > -- > http://claudiusmaximus.goto10.org > > > CallBacker: CallBacker.hs callerback.c callerback.h > ghc -O2 -Wall -fffi -o CallBacker CallBacker.hs callerback.c > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080605/70654135/attachment.htm From claus.reinke at talk21.com Thu Jun 5 06:21:07 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Thu Jun 5 06:13:45 2008 Subject: [Haskell-cafe] Re: Ubuntu and ghc References: <5ae4f2ba0805211532l35bef8eas9a10ff6df3e0f843@mail.gmail.com><1211448821.5824.504.camel@localhost><008001c8bbf7$63753100$d0357ad5@cr3lt> <48466F7F.8090600@gmail.com><1212585727.15010.281.camel@localhost> <4847A0D1.3040306@gmail.com> <1212657117.15010.327.camel@localhost> Message-ID: <013901c8c6f5$df826110$961a8351@cr3lt> >> Well, that's true. I guess what I'm really objecting to in Claus's message >> is the implication that we should always use a Haskell Installation >> Manager, even on systems with good built-in package management. what was implied was that haskell installation manager (HIM) and native package managers (NPM) (where they exist) should collaborate, so that NPMs know how to extract dependencies from haskell packages, and HIM knows how to extract dependencies (haskell or otherwise) from NPMs. for the NPM-calls-HIM direction, that could be dynamically or, as in current practice, in a separate phase converting HIM to NPM packages. for the HIM-calls-NPM direction, that would simply present a haskell view on the native software (ie, cabal install/list/.. negotiating with NPM). whereas, currently, if i understand correctly, systems with NPM will have many haskell packages under NPM control and some haskell packages under HIM control and some haskell packages under no control whatsoever (eg, installing tools or compilers leaves no record, necessitating use of autoconf & co). i'm not saying "reimplement and ignore NPMs", i'm saying "NPMs and HIM should collaborate". if anything, that would reduce the number of exceptions where haskell packages are installed without the NPM knowing about them. and i'd like to see fewer cases where HIM forgets about what it or NPM have installed. so, on systems with NPM, users have a choice of interface, but nothing bad will happen no matter whether they choose NPM directly or HIM as an interface to it. and haskell book and tutorial authors only need to explain HIM, and its commands will just work - independent of the variant or lack of NPM on the reader's system. is that still objectionable?-) claus ps. it is a lot like using fmap, no matter what the Functor is, or using something like System.Process, no matter whether or not the OS supports that easily. >> Yes, I agree we need good support for managing packages for the other >> scenarios: no system package manager, home-directory installs, no >> pre-prepared system package. I just don't want whatever provision we make >> for these cases to replace the system package manager for global package >> installs on systems where that is well supported. > > Indeed. I wholly agree. > > Duncan > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From jules at jellybean.co.uk Thu Jun 5 06:26:56 2008 From: jules at jellybean.co.uk (Jules Bean) Date: Thu Jun 5 06:19:30 2008 Subject: [Haskell-cafe] Re: How would you hack it? In-Reply-To: <20080604225220.40e0fa76@solaris> References: <4846DFDC.5020905@btinternet.com> <20080604225220.40e0fa76@solaris> Message-ID: <4847BF70.9030205@jellybean.co.uk> Achim Schneider wrote: > If you run one over obscure academic papers, you can even generate > publishable results. I don't have a link ready, but there was a fun > incident involving this. http://www.physics.nyu.edu/faculty/sokal/dawkins.html From apfelmus at quantentunnel.de Thu Jun 5 06:31:27 2008 From: apfelmus at quantentunnel.de (apfelmus) Date: Thu Jun 5 06:24:13 2008 Subject: [Haskell-cafe] Re: What is the maturity of Haskell Web Frameworks In-Reply-To: <856033f20806041930t7499bda6n394938086ce38ecd@mail.gmail.com> References: <856033f20806041930t7499bda6n394938086ce38ecd@mail.gmail.com> Message-ID: Paul L wrote: > Pardon me to hijack this thread, but I have an idea to build a > different kind of Web Framework and am not sure if somebody has > already done it. > > The idea is to take REST further: every HTML page you see is a program > in its running state (as a continuation monad). Each click on its link > or form submission is seen as feeding data to resume its continuation. > > So instead of writing a server-side program that responds to many CGI > calls, you write a single ordinary program that describe the > application logic, which during its execution gets represented as a > HTML page and interpreted by the server. WASH/CGI has something in that direction. I don't know a short introduction, but have a look at sections 4 and 8 of the implementation notes http://www.informatik.uni-freiburg.de/~thiemann/WASH/draft.pdf The basic idea is that displayForm in a CGI-script like main = do password <- displayForm $ (label "Enter password" <-> editbox) ... displays a HTML-page to the client, "waits" for a response and then resumes execution. It does not actually wait, but captures the continuation in the transmitted HTML page, for instance by saving a log of the previous events. This is related to [MonadPrompt], which has a similar purpose, and to [Unimo], which is pretty much the same but from the slightly different viewpoint of implementing any monad directly from its operational semantics. [Unimo]: Chuan-Kai Lin. Programming Monads Operationally with Unimo. http://web.cecs.pdx.edu/~cklin/papers/unimo-143.pdf [MonadPrompt]: Ryan Ingram. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/MonadPrompt Regards, apfelmus From barsoap at web.de Thu Jun 5 06:32:39 2008 From: barsoap at web.de (Achim Schneider) Date: Thu Jun 5 06:25:18 2008 Subject: [Haskell-cafe] Re: Laziness leaks References: <62728db30806031414p19593f40x5ad1bfd32e2dfc4b@mail.gmail.com> <4845D0B8.6040802@vex.net> <62728db30806031712w32421ae5scbf84920ecd71193@mail.gmail.com> <2f9b2d30806041916x3e0088acw26e45033ee586b9a@mail.gmail.com> <20080605052825.7002ce4e@solaris> <48478718.7090102@jellybean.co.uk> Message-ID: <20080605123239.01b379b4@solaris> Jules Bean wrote: > Achim Schneider wrote: > > You don't come across space-leaks in strict programs often because > > data is usually allocated statically even if execution is > > non-strict. > > > > Piping /dev/zero into a program that just sleeps does leak space, > > though. > > > > It only leaks 8K or whatever size your system buffers pipes until it > suspends the writer though... or do I misunderstand your analogy? > I don't think so. I would say that it leaks 8k memory and infinite time. I did not intend the example to be implementation-dependent, but then that kind of proves my point. -- (c) this sig last receiving data processing entity. Inspect headers for past copyright information. All rights reserved. Unauthorised copying, hiring, renting, public performance and/or broadcasting of this signature prohibited. From peteg42 at gmail.com Thu Jun 5 06:50:18 2008 From: peteg42 at gmail.com (Peter Gammie) Date: Thu Jun 5 06:43:35 2008 Subject: [Haskell-cafe] Re: What is the maturity of Haskell Web Frameworks In-Reply-To: References: <856033f20806041930t7499bda6n394938086ce38ecd@mail.gmail.com> Message-ID: On 05/06/2008, at 5:31 PM, apfelmus wrote: > WASH/CGI has something in that direction. I don't know a short > introduction, but have a look at sections 4 and 8 of the > implementation notes > > http://www.informatik.uni-freiburg.de/~thiemann/WASH/draft.pdf I think there is also some work done about using Arrows for this problem, cf John Hughes' original paper. (I hear the use of Arrows was inessential, see the followup by Thiemann.) IMH-and-probably-offtopic-O, the continuation-based approach is semantically nice but I don't think anyone has reconciled it with the general desire for clean and tidy URIs. Going to: http://example.com/continuations/45345345 is not anywhere near as aesthetic / phishing proof / ... as going to e.g. http://example.com/comments/edit/16 (Though I grant that hpaste URIs are tantalisingly mysterious.) The general problem is providing a way for the programmer to (schematically) specify the URIs and handlers without getting bogged down in state machine encodings. If someone's got some good ideas here, I'd love to hear about it (on the web-devel mailing list, perhaps). cheers peter -- http://peteg.org/ From barsoap at web.de Thu Jun 5 06:51:42 2008 From: barsoap at web.de (Achim Schneider) Date: Thu Jun 5 06:44:31 2008 Subject: [Haskell-cafe] Re: How would you hack it? References: <4846DFDC.5020905@btinternet.com> Message-ID: <20080605125142.50de0fc6@solaris> Henning Thielemann wrote: > Sounds like a generator for scientific articles. :-) > Maybe > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/markov-chain > can be of help for you. It's also free of randomIO. > I once invented this, though ungeneralised, for a map generator of a RTS... the river always went from the left to the right, at approximate the middle of the map, its direction being dependant on its current offset from that middle, its width (that is, a wide river can bend upwards and downwards more than one tile) and a random factor. You can also express this using a markoff chain. -- (c) this sig last receiving data processing entity. Inspect headers for past copyright information. All rights reserved. Unauthorised copying, hiring, renting, public performance and/or broadcasting of this signature prohibited. From apfelmus at quantentunnel.de Thu Jun 5 08:06:26 2008 From: apfelmus at quantentunnel.de (apfelmus) Date: Thu Jun 5 07:59:08 2008 Subject: [Haskell-cafe] Re: Laziness leaks In-Reply-To: <87abi0l4w8.fsf@malde.org> References: <62728db30806031414p19593f40x5ad1bfd32e2dfc4b@mail.gmail.com> <4845D0B8.6040802@vex.net> <62728db30806031712w32421ae5scbf84920ecd71193@mail.gmail.com> <4846E45C.3040402@vex.net> <87abi0l4w8.fsf@malde.org> Message-ID: Ketil Malde wrote: > I the meaning of "leak" is in a bit of flux. Originally, I believe > it refers to a memory leak, where the programmer forgot to call > free() before losing the pointer, thus making the program consume > memory it can't recover, and can't use. > > With automatic memory management, this doesn't happen, so "memory > leak" then started to mean retaining objects longer than necessary. I agree. This definition fits the "space leak" foldl (+1) 0 [1..10000] -> (((...)+1)+1) in the sense that the unevaluated expressions are retained in memory longer than necessary; the difference being of course that it's not garbage collection but beta-reduction that frees the memory in question. On the other hand, I think that the situation of foldl (+1) 0 [1..10000] in a strict language does not fit this definition of leak because evaluating the list [1..10000] eagerly does not retain memory longer than necessary, it consumes memory earlier than necessary. So, this notion of leak is spot-on. > I'm not sure I'll use terms like strictness and laziness leak, I > think it's hard to see what's being lost here, and if you have a > laziness leak, it is unclear if it's too much laziness or too little? Me too, I don't see a reason to muddy the word with other meanings. "Space leak" is a good word in the sense that "space" describes the "leak"; it's the space that leaks and goes down the drain. Neither laziness nor strictness can leak and be washed away with the rain. > (Aside: am I the only one who is shocked by the memory consumption of > modern programs? I use a simple time tracker (gnotime), a calendar > with a handful of entries (evolution), and they both typically > consume half to one gigabyte of memory. In all fairness, it seems to > be much better under Ubuntu 8.04 than 7.10, but again, they haven't > been running for very long yet.) Yeah :( When a piece of softwares wastes time and memory, they should have written it in Haskell, so that at least the other bugs wouldn't plague me as well. Regards, apfelmus From jonathanccast at fastmail.fm Thu Jun 5 10:40:53 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Thu Jun 5 10:33:28 2008 Subject: [Haskell-cafe] automatically deriving Map and Filter on datatypes etc. In-Reply-To: <2638D507-4427-4A04-96E5-C8208F3F0D2F@gmail.com> References: <1ff5dedc0806050103h1639d907r7ac731de016787bc@mail.gmail.com> <0D31F43A-4404-40EA-8628-45A033FB6493@yandex.ru> <2638D507-4427-4A04-96E5-C8208F3F0D2F@gmail.com> Message-ID: <28B5EEBB-7843-436D-9CFC-A01EEFDF1E9A@fastmail.fm> On 5 Jun 2008, at 1:39 AM, Thomas Davie wrote: > Even deriving an instance of Functor seems rather implausable, what > should it do for > > data Wierd a b = Nil | A a (Wierd a b) | B b (Wierd a b) > > Should fmap's function argument operate on 'a's, 'b's, or both? class Functor (f :: * -> *) where ... so, 'b's. jcc PS Why isn't Functor derivable? From aruiz at um.es Thu Jun 5 11:16:09 2008 From: aruiz at um.es (Alberto Ruiz) Date: Thu Jun 5 11:08:43 2008 Subject: [Haskell-cafe] Re: hmatrix In-Reply-To: <483842413.20080603134211@gmail.com> References: <484277D3.9020604@um.es> <4843BF4A.2080800@um.es> <4844F27A.2080208@um.es> <731290342.20080603113721@gmail.com> <48450752.4080307@um.es> <483842413.20080603134211@gmail.com> Message-ID: <48480339.6050900@um.es> Hello Bulat and Anatoly, I have written a first version of an interface to inplace updates in the ST monad for the hmatrix vectors and matrices. Many things must be improved (range checking, documentation, etc.) but I hope that the general idea makes sense. A few usage examples: http://perception.inf.um.es/~aruiz/darcs/hmatrix/examples/inplace.hs Code: http://perception.inf.um.es/~aruiz/darcs/hmatrix/lib/Data/Packed/ST.hs http://perception.inf.um.es/~aruiz/darcs/hmatrix/doc/html/Data-Packed-ST.html Any suggestion will be welcome. I'm impressed by the power of the ST monad, it is extremely useful and elegant. Thank you again for your help! In the future I will also try to include efficient conversions to/from standard Haskell arrays and those of other related libraries like Jed Brown's CArray. Thanks, Alberto Bulat Ziganshin wrote: > Hello Alberto, > > Tuesday, June 3, 2008, 12:56:50 PM, you wrote: > >> Good! So you can easily "hide" the IO operations in the ST monad. I will >> definitely look into it. > > from implementation POV ST monad is nothing but renamed IO monad which > exports only subset of its operations which are guaranteed to safe. > or, saying in other words, it's just type hackery around IO monad that > provides safe operations > > it's possible to define ST monad and its operations as following: > > newtype ST s a = forall s. ST_Constructor (IO a) > > unsafeIOtoSt action = ST_Constructor action > > runST (ST_Constructor action) = unsafePerformIO action > > newtype STRef s a = forall s. STRef (IORef a) > > readSTRef (STRef ref) = unsafeIOtoSt (readIORef ref) > > and so on. GHC uses technically (but not ideologically!) different > implementation where both monads are specializations of one generic > type. while Hugs afair uses exactly this approach. you may also look > at ArrayRef lib which reimplements arrays/refs for both compilers in > more unified way > > anyway, because ST is just IO monad modulo type tricks, you can > execute any IO action inside ST by lifting it with unsafeIOtoSt > From johan.tibell at gmail.com Thu Jun 5 11:19:28 2008 From: johan.tibell at gmail.com (Johan Tibell) Date: Thu Jun 5 11:12:01 2008 Subject: [Haskell-cafe] Design your modules for qualified import Message-ID: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> Hi! The last two weeks I've seen two new packages that add suffixes to identifiers instead of relying on them being imported qualified to distinguish them from identifiers in other modules. This is not a new thing in Haskell community and there are examples of this practice in libraries shipped with GHC. It is also common in papers (for good reasons as we will see later). Atomic channels and variables under Control.Concurrent.* are examples of using a prefix as a namespacing tool. Let me reiterate the arguments [1,2] against this practice and also speculate why this practice is more common in Haskell than in e.g. Python, Java or Ruby. * Cons of including a namespace prefix/suffix in identifiers 1. From experience these prefixes/suffixes tend to be short and non-descriptive, typically just one letter e.g. foldU or elemB. Very frequently used functions that every Haskell programmer is likely to use often can have shorter name as the cost of memorizing them is amortized over all their uses. Examples of short names that most Haskell programmers know by heart is map, fold*, etc. Given that your library won't see the same use as these functions your functions need more descriptive names (or in this case use a qualified import that makes them more descriptive e.g. Array.fold). 2. If your modules are imported qualified the suffix is redundant and thus wastes space. Consider for example foldU imported qualified from the module Data.Array as Array.foldU. Array.fold would have been better in this case. * Pros of using qualified imports 1. Your code will be more robust against additions to modules you depend on. Consider this snippet: import Some.Module -- An utility function that the author of the above module forgot to include. foo = ... Now the author of Some.Module releases a new version of his or her package which include `foo' and your code no longer compiles. If you have no imports on the form import Some.Module your package can specify more relaxed version dependencies on other packages [3]. 2. It's easier to see from where an identifier is imported. Just check the functions module prefix (e.g. Array in Array.foo). If you renamed the import using import Foo as F you might have to check the import list. * Explicit, unqualified imports An alternative to qualified imports that shares some of benefits is to import names unqualified but explicitly enumerate the function names e.g. import Some.Module (foo, bar) It is still not immediately obvious what module a name refers too when using this style (point 2 under pros above) but it is at least easier to find than when implicitly importing all names from a module. This is my current preference for infix operators as they look quite ugly qualified with a module name. It might also make sense if a few functions (e.g. parser combinators) are used a lot in the same module (e.g. an HTTP parser). * Why is this practice common in Haskell Here are some guesses: 1. It's common in papers. However, papers and libraries are quite different. The former usually build up a small vocabulary and having short names is a big win. Papers rarely make use of the module system at all. The latter are included as pieces of large programs and their names need to be adjusted accordingly. 2. It's the default. You have to add "qualified" to all your imports to make them qualified. In most language imports are qualified by default. I think the latter would have been a better choice but we have to live with the current design so bite the bullet and add those qualified keywords to your imports. 3. Lack of common interfaces. An example would be two different set implementations that essentially have the same interface but since there is no explicitly shared interface, defined using a type class, you sometimes end up with different names. The lack of type families might explain why e.g. collection classes don't share interfaces. 4. Haskell is a very expressive language. You can often write a whole function definition on one line! Adding those module qualifications makes your code slightly longer and it might just break your beautiful one liner into two lines. * Summary Whenever you write a library design it so it works well with qualified imports. That means leaving namespacing issues to the module system. Try to think of how code using your functions will look like if it uses them qualified. * References 1. http://www.haskell.org/haskellwiki/Import_modules_properly 2. http://www.haskell.org/haskellwiki/Qualified_names 3. See section 2 Version numbers - http://www.haskell.org/haskellwiki/Library_versioning_policy Cheers, Johan From mail at joachim-breitner.de Thu Jun 5 11:22:44 2008 From: mail at joachim-breitner.de (Joachim Breitner) Date: Thu Jun 5 11:15:29 2008 Subject: [Haskell-cafe] File locking wishlist Message-ID: <1212679364.3483.14.camel@otto.ehbuehl.net> Hi, for a program of mine (darcswatch[1]), a rather long running process is run at certain events (by cron, and by new emails). I want to achieve that: * Only one instance of the program runs at a time. * If new events come in while the program runs, it should re-run itself * There is information attached to the events (only one Bool ATM) So I?d like to implement something with this, or a similar, interface: ======================================================================= module MyLocking where -- | tries to get the lock. If it fails, notifies the running process -- to re-start itself afterwards, with the given information -- returns True if the lock was aquired lockOrMark :: Show a => FilePath -> a -> IO Bool -- | release the lock. If new events have come in, they are returned -- in the list, and the lock is still kept. If the list is empty, -- the lock was successfully released. releaseLock :: Read a => FilePath -> IO [a] ?======================================================================= I would use this module in this way: realWork args = do someStuff args newArgs <- releaseLock "someDir/" unless (null newArgs) $ do -- we missed some events, so re-run and then try again. let newArg = combineInSomeWay newArgs realWork newArg main = do args <- getArgs l <- lockOrMark "someDir/" args when l $ do -- we got the lock, so lets work realWork args I hope this makes the idea clear. How could a possible implementation look like, when all operations should be atomic? I was considering this, would it work fine? lockOrMark would try to create a directory in the path. Whoever creates the directory has the lock. If it works, create. If it fails, because the directory already exists, then write the given args to a temporary file with a unique name, and move it into that directory. If that fails (because the directory has disappeared, i.e. the lock released), start over with trying to create the directory. If it works, then you are done. releaseLock would try to rmdir the directory. If that succeeds, no files have been in there, so no events were missed. If it does not succeed, then there were files. Read and delete them and return the list of arguments contained in them. Greetings, Joachim [1] http://darcswatch.nomeata.de/ -- Joachim Breitner e-Mail: mail@joachim-breitner.de Homepage: http://www.joachim-breitner.de ICQ#: 74513189 Jabber-ID: nomeata@joachim-breitner.de -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: Dies ist ein digital signierter Nachrichtenteil Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080605/ace60177/attachment.bin From darrinth at gmail.com Thu Jun 5 12:30:45 2008 From: darrinth at gmail.com (Darrin Thompson) Date: Thu Jun 5 12:23:18 2008 Subject: [Haskell-cafe] Re: cabal and platform-independent haskell installation management (again) (Re: Re: Ubuntu and ghc) In-Reply-To: <1212623330.15010.318.camel@localhost> References: <5ae4f2ba0805211532l35bef8eas9a10ff6df3e0f843@mail.gmail.com> <1211448821.5824.504.camel@localhost> <008001c8bbf7$63753100$d0357ad5@cr3lt> <48466F7F.8090600@gmail.com> <016d01c8c64d$4ac1dea0$73357ad5@cr3lt> <1212590628.15010.312.camel@localhost> <20080604172252.34df14f7@solaris> <1212623330.15010.318.camel@localhost> Message-ID: On Wed, Jun 4, 2008 at 7:48 PM, Duncan Coutts wrote: > > On Wed, 2008-06-04 at 17:22 +0200, Achim Schneider wrote: > >> The question, IMHO, seems to be >> >> "How would a package manager for a posix-compilant kinetic look like?" > > http://nixos.org/index.html > How well does that coexist with other OS's? Could I have it manage only specific applications in it's store and trust the OS for the rest? -- Darrin From my.bulk.mail.account at gmail.com Thu Jun 5 12:31:16 2008 From: my.bulk.mail.account at gmail.com (A A) Date: Thu Jun 5 12:23:53 2008 Subject: [Haskell-cafe] GHCi gives type signature that won't compile. Message-ID: <6d5af6810806050931h104d31fcu77864609911acb05@mail.gmail.com> Hi All I can successfully compile the following code using ghci import Data.Array.IArray makeArray (lower, upper) f = listArray (lower, upper) [(f i) | i <- [lower..upper] tridiagonal_solve (a, b, c, d, (lower, upper)) = x where gen_array f = (makeArray (lower, upper) f) x = gen_array x_f where x_f i | i == upper = (d_dash ! upper) | otherwise = (d_dash ! i) - (c_dash ! i) * (x ! (i + 1)) d_dash = gen_array d_dash_f where d_dash_f i | i == lower = (d ! lower) / (b ! lower) | otherwise = ((d ! i) - (d_dash ! (i - 1)) * (a ! i)) / ((b ! i) - (c_dash ! (i - 1)) * (a ! i)) c_dash = gen_array c_dash_f where c_dash_f i | i == lower = (c ! lower) / (b ! lower) | otherwise = (c ! i) / ((b ! i) - (c_dash ! (i - 1)) * (a ! i)) I then attempted to write a type signature for tridiagonal_solve. I didn't succeed at this however, all of my type signatures gave compile errors when attempting to load them in ghci. I asked in the #haskell channel, and they suggested that I try the type signature from ghci :type function. So I removed any type signatures, and reloaded the file in ghci, and typed ":type tridiagonal_solve" which produced the following output: tridiagonal_solve :: (IArray a3 e, IArray a6 e, IArray a7 e, Fractional e, Ix a, Num a, IArray a4 e, IArray a2 e, IArray a5 e, IArray a1 e, Enum a) => (a4 a e, a2 a e, a1 a e, a5 a e, (a, a)) -> a7 a e I then attempted to paste this into my code, the resulting code looking like this: import Data.Array.IArray makeArray (lower, upper) f = listArray (lower, upper) [(f i) | i <- [lower..upper]] tridiagonal_solve :: (IArray a3 e, IArray a6 e, IArray a7 e, Fractional e, Ix a, Num a, IArray a4 e, IArray a2 e, IArray a5 e, IArray a1 e, Enum a) => (a4 a e, a2 a e, a1 a e, a5 a e, (a, a)) -> a7 a e tridiagonal_solve (a, b, c, d, (lower, upper)) = x where gen_array f = (makeArray (lower, upper) f) x = gen_array x_f where x_f i | i == upper = (d_dash ! upper) | otherwise = (d_dash ! i) - (c_dash ! i) * (x ! (i + 1)) d_dash = gen_array d_dash_f where d_dash_f i | i == lower = (d ! lower) / (b ! lower) | otherwise = ((d ! i) - (d_dash ! (i - 1)) * (a ! i)) / ((b ! i) - (c_dash ! (i - 1)) * (a ! i)) c_dash = gen_array c_dash_f where c_dash_f i | i == lower = (c ! lower) / (b ! lower) | otherwise = (c ! i) / ((b ! i) - (c_dash ! (i - 1)) * (a ! i)) When I attempt to load this into ghci, I recieve the following error: [1 of 1] Compiling Main ( main.lhs, interpreted ) main.lhs:29:11: Could not deduce (IArray a1 e) from the context (IArray a3 e, IArray a6 e, IArray a7 e, Fractional e, Ix a2, Num a2, IArray a4 e, IArray a21 e, IArray a5 e, IArray a11 e, Enum a2) arising from a use of `gen_array' at main.lhs:29:11-28 Possible fix: add (IArray a1 e) to the context of the type signature for `tridiagonal_solve' In the expression: gen_array d_dash_f In the definition of `d_dash': d_dash = gen_array d_dash_f where d_dash_f i | i == lower = (d ! lower) / (b ! lower) | otherwise = ((d ! i) - (d_dash ! (i - 1)) * (a ! i)) / ((b ! i) - (c_dash ! (i - 1)) * (a ! i)) In the definition of `tridiagonal_solve': tridiagonal_solve (a, b, c, d, (lower, upper)) = x where gen_array f = (makeArray (lower, upper) f) x = gen_array x_f where x_f i | i == upper = (d_dash ! upper) | otherwise = (d_dash ! i) - (c_dash ! i) * (x ! (i + 1)) d_dash = gen_array d_dash_f where d_dash_f i | i == lower = (d ! lower) / (b ! lower) | otherwise = ((d ! i) - (d_dash ! (i - 1)) * (a ! i)) / ((b ! i) - (c_dash ! (i - 1)) * (a ! i)) c_dash = gen_array c_dash_f where c_dash_f i | i == lower = (c ! lower) / (b ! lower) | otherwise = (c ! i) / ((b ! i) - (c_dash ! (i - 1)) * (a ! i)) main.lhs:35:11: Could not deduce (IArray a e) from the context (IArray a3 e, IArray a6 e, IArray a7 e, Fractional e, Ix a2, Num a2, IArray a4 e, IArray a21 e, IArray a5 e, IArray a11 e, Enum a2) arising from a use of `gen_array' at main.lhs:35:11-28 Possible fix: add (IArray a e) to the context of the type signature for `tridiagonal_solve' In the expression: gen_array c_dash_f In the definition of `c_dash': c_dash = gen_array c_dash_f where c_dash_f i | i == lower = (c ! lower) / (b ! lower) | otherwise = (c ! i) / ((b ! i) - (c_dash ! (i - 1)) * (a ! i)) In the definition of `tridiagonal_solve': tridiagonal_solve (a, b, c, d, (lower, upper)) = x where gen_array f = (makeArray (lower, upper) f) x = gen_array x_f where x_f i | i == upper = (d_dash ! upper) | otherwise = (d_dash ! i) - (c_dash ! i) * (x ! (i + 1)) d_dash = gen_array d_dash_f where d_dash_f i | i == lower = (d ! lower) / (b ! lower) | otherwise = ((d ! i) - (d_dash ! (i - 1)) * (a ! i)) / ((b ! i) - (c_dash ! (i - 1)) * (a ! i)) c_dash = gen_array c_dash_f where c_dash_f i | i == lower = (c ! lower) / (b ! lower) | otherwise = (c ! i) / ((b ! i) - (c_dash ! (i - 1)) * (a ! i)) My question is, what should the type signature for tridiagonal_solve actually be? I would like one that doesn't limit the generality of tridiagonal_solve because I would like to pass different array types in the one function invocation, as long as they have the same index and element types. I'm happy if other functions need type signatures as well. I'm using ghc 6.8.2 on windows, though I get a similar issue with ghc 6.4.1. Thanks. Clinton -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080606/bce56b19/attachment.htm From miguelimo38 at yandex.ru Thu Jun 5 12:36:21 2008 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Thu Jun 5 12:29:32 2008 Subject: [Haskell-cafe] GHCi gives type signature that won't compile. In-Reply-To: <6d5af6810806050931h104d31fcu77864609911acb05@mail.gmail.com> References: <6d5af6810806050931h104d31fcu77864609911acb05@mail.gmail.com> Message-ID: <87849DF8-BF80-48D5-8FA3-5134328B88D3@yandex.ru> Check your types for typos. On 5 Jun 2008, at 20:31, A A wrote: > Hi All > > I can successfully compile the following code using ghci > > import Data.Array.IArray > > makeArray (lower, upper) f = listArray (lower, upper) [(f i) | i <- > [lower..upper] > tridiagonal_solve (a, b, c, d, (lower, upper)) = x > where > gen_array f = (makeArray (lower, upper) f) > x = gen_array x_f > where > x_f i > | i == upper = (d_dash ! upper) > | otherwise = (d_dash ! i) - (c_dash ! > i) * (x ! (i + 1)) > d_dash = gen_array d_dash_f > where > d_dash_f i > | i == lower = (d ! lower) / (b ! lower) > | otherwise = ((d ! i) - (d_dash ! (i - > 1)) * (a ! i)) / > ((b ! i) - (c_dash ! (i - > 1)) * (a ! i)) > c_dash = gen_array c_dash_f > where > c_dash_f i > | i == lower = (c ! lower) / (b ! lower) > | otherwise = (c ! i) / > ((b ! i) - (c_dash ! (i - > 1)) * (a ! i)) > > I then attempted to write a type signature for tridiagonal_solve. I > didn't succeed at this however, all of my type signatures gave > compile errors when attempting to load them in ghci. I asked in the > #haskell channel, and they suggested that I try the type signature > from ghci :type function. > > So I removed any type signatures, and reloaded the file in ghci, and > typed ":type tridiagonal_solve" which produced the following output: > > tridiagonal_solve :: (IArray a3 e, > IArray a6 e, > IArray a7 e, > Fractional e, > Ix a, > Num a, > IArray a4 e, > IArray a2 e, > IArray a5 e, > IArray a1 e, > Enum a) => > (a4 a e, a2 a e, a1 a e, a5 a e, (a, a)) -> a7 > a e > > I then attempted to paste this into my code, the resulting code > looking like this: > > import Data.Array.IArray > > makeArray (lower, upper) f = listArray (lower, upper) [(f i) | i <- > [lower..upper]] > > tridiagonal_solve :: (IArray a3 e, > IArray a6 e, > IArray a7 e, > Fractional e, > Ix a, > Num a, > IArray a4 e, > IArray a2 e, > IArray a5 e, > IArray a1 e, > Enum a) => > (a4 a e, a2 a e, a1 a e, a5 a e, (a, a)) -> a7 > a e > > tridiagonal_solve (a, b, c, d, (lower, upper)) = x > where > gen_array f = (makeArray (lower, upper) f) > x = gen_array x_f > where > x_f i > | i == upper = (d_dash ! upper) > | otherwise = (d_dash ! i) - (c_dash ! i) > * (x ! (i + 1)) > d_dash = gen_array d_dash_f > where > d_dash_f i > | i == lower = (d ! lower) / (b ! lower) > | otherwise = ((d ! i) - (d_dash ! (i - > 1)) * (a ! i)) / > ((b ! i) - (c_dash ! (i - > 1)) * (a ! i)) > c_dash = gen_array c_dash_f > where > c_dash_f i > | i == lower = (c ! lower) / (b ! lower) > | otherwise = (c ! i) / > ((b ! i) - (c_dash ! (i - > 1)) * (a ! i)) > > When I attempt to load this into ghci, I recieve the following error: > > [1 of 1] Compiling Main ( main.lhs, interpreted ) > > main.lhs:29:11: > Could not deduce (IArray a1 e) > from the context (IArray a3 e, > IArray a6 e, > IArray a7 e, > Fractional e, > Ix a2, > Num a2, > IArray a4 e, > IArray a21 e, > IArray a5 e, > IArray a11 e, > Enum a2) > arising from a use of `gen_array' at main.lhs:29:11-28 > Possible fix: > add (IArray a1 e) to the context of > the type signature for `tridiagonal_solve' > In the expression: gen_array d_dash_f > In the definition of `d_dash': > d_dash = gen_array d_dash_f > where > d_dash_f i | i == lower = (d ! lower) / (b ! lower) > | otherwise > = ((d ! i) - (d_dash ! (i - 1)) * (a ! > i)) > / ((b ! i) - (c_dash ! (i - 1)) * (a ! > i)) > In the definition of `tridiagonal_solve': > tridiagonal_solve (a, b, c, d, (lower, upper)) > = x > where > gen_array f = (makeArray (lower, > upper) f) > x = gen_array x_f > where > x_f i | i == upper = (d_dash ! > upper) > | otherwise > = (d_dash ! i) - > (c_dash ! i) * (x ! (i + 1)) > d_dash = gen_array d_dash_f > where > d_dash_f i | i == lower = > (d ! lower) / (b ! lower) > | otherwise > = ((d ! i) - > (d_dash ! (i - 1)) * (a ! i)) > / ((b ! i) - > (c_dash ! (i - 1)) * (a ! i)) > c_dash = gen_array c_dash_f > where > c_dash_f i | i == lower = > (c ! lower) / (b ! lower) > | otherwise > = (c ! i) > / ((b ! i) - > (c_dash ! (i - 1)) * (a ! i)) > > main.lhs:35:11: > Could not deduce (IArray a e) > from the context (IArray a3 e, > IArray a6 e, > IArray a7 e, > Fractional e, > Ix a2, > Num a2, > IArray a4 e, > IArray a21 e, > IArray a5 e, > IArray a11 e, > Enum a2) > arising from a use of `gen_array' at main.lhs:35:11-28 > Possible fix: > add (IArray a e) to the context of > the type signature for `tridiagonal_solve' > In the expression: gen_array c_dash_f > In the definition of `c_dash': > c_dash = gen_array c_dash_f > where > c_dash_f i | i == lower = (c ! lower) / (b ! lower) > | otherwise = (c ! i) / ((b ! i) - > (c_dash ! (i - 1)) * (a ! i)) > In the definition of `tridiagonal_solve': > tridiagonal_solve (a, b, c, d, (lower, upper)) > = x > where > gen_array f = (makeArray (lower, > upper) f) > x = gen_array x_f > where > x_f i | i == upper = (d_dash ! > upper) > | otherwise > = (d_dash ! i) - > (c_dash ! i) * (x ! (i + 1)) > d_dash = gen_array d_dash_f > where > d_dash_f i | i == lower = > (d ! lower) / (b ! lower) > | otherwise > = ((d ! i) - > (d_dash ! (i - 1)) * (a ! i)) > / ((b ! i) - > (c_dash ! (i - 1)) * (a ! i)) > c_dash = gen_array c_dash_f > where > c_dash_f i | i == lower = > (c ! lower) / (b ! lower) > | otherwise > = (c ! i) > / ((b ! i) - > (c_dash ! (i - 1)) * (a ! i)) > > My question is, what should the type signature for tridiagonal_solve > actually be? I would like one that doesn't limit the generality of > tridiagonal_solve because I would like to pass different array types > in the one function invocation, as long as they have the same index > and element types. I'm happy if other functions need type signatures > as well. > > I'm using ghc 6.8.2 on windows, though I get a similar issue with > ghc 6.4.1. > > Thanks. > > Clinton > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From philip.weaver at gmail.com Thu Jun 5 12:51:23 2008 From: philip.weaver at gmail.com (Philip Weaver) Date: Thu Jun 5 12:44:00 2008 Subject: [Haskell-cafe] GHCi gives type signature that won't compile. In-Reply-To: <87849DF8-BF80-48D5-8FA3-5134328B88D3@yandex.ru> References: <6d5af6810806050931h104d31fcu77864609911acb05@mail.gmail.com> <87849DF8-BF80-48D5-8FA3-5134328B88D3@yandex.ru> Message-ID: On Thu, Jun 5, 2008 at 9:36 AM, Miguel Mitrofanov wrote: > Check your types for typos. > > On 5 Jun 2008, at 20:31, A A wrote: > >> Hi All >> >> I can successfully compile the following code using ghci >> >> import Data.Array.IArray >> >> makeArray (lower, upper) f = listArray (lower, upper) [(f i) | i <- >> [lower..upper] >> tridiagonal_solve (a, b, c, d, (lower, upper)) = x >> where >> gen_array f = (makeArray (lower, upper) f) >> x = gen_array x_f >> where >> x_f i >> | i == upper = (d_dash ! upper) >> | otherwise = (d_dash ! i) - (c_dash ! i) * (x >> ! (i + 1)) >> d_dash = gen_array d_dash_f >> where >> d_dash_f i >> | i == lower = (d ! lower) / (b ! lower) >> | otherwise = ((d ! i) - (d_dash ! (i - 1)) * (a >> ! i)) / >> ((b ! i) - (c_dash ! (i - 1)) * >> (a ! i)) >> c_dash = gen_array c_dash_f >> where >> c_dash_f i >> | i == lower = (c ! lower) / (b ! lower) >> | otherwise = (c ! i) / >> ((b ! i) - (c_dash ! (i - 1)) * >> (a ! i)) >> >> I then attempted to write a type signature for tridiagonal_solve. I didn't >> succeed at this however, all of my type signatures gave compile errors when >> attempting to load them in ghci. I asked in the #haskell channel, and they >> suggested that I try the type signature from ghci :type function. >> >> So I removed any type signatures, and reloaded the file in ghci, and typed >> ":type tridiagonal_solve" which produced the following output: >> >> tridiagonal_solve :: (IArray a3 e, >> IArray a6 e, >> IArray a7 e, >> Fractional e, >> Ix a, >> Num a, >> IArray a4 e, >> IArray a2 e, >> IArray a5 e, >> IArray a1 e, >> Enum a) => >> (a4 a e, a2 a e, a1 a e, a5 a e, (a, a)) -> a7 a e >> >> I then attempted to paste this into my code, the resulting code looking >> like this: >> >> import Data.Array.IArray >> >> makeArray (lower, upper) f = listArray (lower, upper) [(f i) | i <- >> [lower..upper]] >> >> tridiagonal_solve :: (IArray a3 e, >> IArray a6 e, >> IArray a7 e, >> Fractional e, >> Ix a, >> Num a, >> IArray a4 e, >> IArray a2 e, >> IArray a5 e, >> IArray a1 e, >> Enum a) => >> (a4 a e, a2 a e, a1 a e, a5 a e, (a, a)) -> a7 a e >> >> tridiagonal_solve (a, b, c, d, (lower, upper)) = x >> where >> gen_array f = (makeArray (lower, upper) f) >> x = gen_array x_f >> where >> x_f i >> | i == upper = (d_dash ! upper) >> | otherwise = (d_dash ! i) - (c_dash ! i) * (x ! >> (i + 1)) >> d_dash = gen_array d_dash_f >> where >> d_dash_f i >> | i == lower = (d ! lower) / (b ! lower) >> | otherwise = ((d ! i) - (d_dash ! (i - 1)) * (a >> ! i)) / >> ((b ! i) - (c_dash ! (i - 1)) * >> (a ! i)) >> c_dash = gen_array c_dash_f >> where >> c_dash_f i >> | i == lower = (c ! lower) / (b ! lower) >> | otherwise = (c ! i) / >> ((b ! i) - (c_dash ! (i - 1)) * >> (a ! i)) >> >> When I attempt to load this into ghci, I recieve the following error: >> >> [1 of 1] Compiling Main ( main.lhs, interpreted ) >> >> main.lhs:29:11: >> Could not deduce (IArray a1 e) >> from the context (IArray a3 e, >> IArray a6 e, >> IArray a7 e, >> Fractional e, >> Ix a2, >> Num a2, >> IArray a4 e, >> IArray a21 e, >> IArray a5 e, >> IArray a11 e, >> Enum a2) >> arising from a use of `gen_array' at main.lhs:29:11-28 >> Possible fix: >> add (IArray a1 e) to the context of >> the type signature for `tridiagonal_solve' >> In the expression: gen_array d_dash_f >> In the definition of `d_dash': >> d_dash = gen_array d_dash_f >> where >> d_dash_f i | i == lower = (d ! lower) / (b ! lower) >> | otherwise >> = ((d ! i) - (d_dash ! (i - 1)) * (a ! i)) >> / ((b ! i) - (c_dash ! (i - 1)) * (a ! i)) >> In the definition of `tridiagonal_solve': >> tridiagonal_solve (a, b, c, d, (lower, upper)) >> = x >> where >> gen_array f = (makeArray (lower, upper) f) >> x = gen_array x_f >> where >> x_f i | i == upper = (d_dash ! upper) >> | otherwise >> = (d_dash ! i) - (c_dash ! i) * >> (x ! (i + 1)) >> d_dash = gen_array d_dash_f >> where >> d_dash_f i | i == lower = (d ! >> lower) / (b ! lower) >> | otherwise >> = ((d ! i) - (d_dash >> ! (i - 1)) * (a ! i)) >> / ((b ! i) - (c_dash >> ! (i - 1)) * (a ! i)) >> c_dash = gen_array c_dash_f >> where >> c_dash_f i | i == lower = (c ! >> lower) / (b ! lower) >> | otherwise >> = (c ! i) >> / ((b ! i) - (c_dash >> ! (i - 1)) * (a ! i)) >> >> main.lhs:35:11: >> Could not deduce (IArray a e) >> from the context (IArray a3 e, >> IArray a6 e, >> IArray a7 e, >> Fractional e, >> Ix a2, >> Num a2, >> IArray a4 e, >> IArray a21 e, >> IArray a5 e, >> IArray a11 e, >> Enum a2) >> arising from a use of `gen_array' at main.lhs:35:11-28 >> Possible fix: >> add (IArray a e) to the context of >> the type signature for `tridiagonal_solve' >> In the expression: gen_array c_dash_f >> In the definition of `c_dash': >> c_dash = gen_array c_dash_f >> where >> c_dash_f i | i == lower = (c ! lower) / (b ! lower) >> | otherwise = (c ! i) / ((b ! i) - (c_dash ! >> (i - 1)) * (a ! i)) >> In the definition of `tridiagonal_solve': >> tridiagonal_solve (a, b, c, d, (lower, upper)) >> = x >> where >> gen_array f = (makeArray (lower, upper) f) >> x = gen_array x_f >> where >> x_f i | i == upper = (d_dash ! upper) >> | otherwise >> = (d_dash ! i) - (c_dash ! i) * >> (x ! (i + 1)) >> d_dash = gen_array d_dash_f >> where >> d_dash_f i | i == lower = (d ! >> lower) / (b ! lower) >> | otherwise >> = ((d ! i) - (d_dash >> ! (i - 1)) * (a ! i)) >> / ((b ! i) - (c_dash >> ! (i - 1)) * (a ! i)) >> c_dash = gen_array c_dash_f >> where >> c_dash_f i | i == lower = (c ! >> lower) / (b ! lower) >> | otherwise >> = (c ! i) >> / ((b ! i) - (c_dash >> ! (i - 1)) * (a ! i)) >> >> My question is, what should the type signature for tridiagonal_solve >> actually be? I would like one that doesn't limit the generality of >> tridiagonal_solve because I would like to pass different array types in the >> one function invocation, as long as they have the same index and element >> types. I'm happy if other functions need type signatures as well. >> >> I'm using ghc 6.8.2 on windows, though I get a similar issue with ghc >> 6.4.1. This sounds like a problem I've seen before. GHCi would infer some constraint like IArray a e, but when I put that into the type of the function it would then complain that there's no instance of IArray a1 e, and when I put IArray a1 e in, it complains that there is no instance for IArray a2 e.... and so on.... The problem was that there were terms of type "a" within the body of the function (the same "a" from the type of the function), but it wasn't figuring that out. The solution was to litter my function body with type ascriptions, and then in the type of the function introduce all of the type variables with a "forall". It also seems like all of your "as" should be the same? So... something like this might work: tridiagonal_solve :: forall a e . (IArray a e, Fractional e, Ix a, Num a.... Where you ascribe some of the terms in the body of your function to be of type "a". Hope that helps. Sorry if I couldn't explain this problem very well. >> >> Thanks. >> >> Clinton >> _______________________________________________ >> 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 bulat.ziganshin at gmail.com Thu Jun 5 12:45:48 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Jun 5 12:44:40 2008 Subject: [Haskell-cafe] File locking wishlist In-Reply-To: <1212679364.3483.14.camel@otto.ehbuehl.net> References: <1212679364.3483.14.camel@otto.ehbuehl.net> Message-ID: <693202115.20080605204548@gmail.com> Hello Joachim, Thursday, June 5, 2008, 7:22:44 PM, you wrote: > * Only one instance of the program runs at a time. > * If new events come in while the program runs, it should re-run itself > * There is information attached to the events (only one Bool ATM) > So I?d like to implement something with this, or a similar, interface: isn't it better to provide os-independent interface to semaphores? named semaphores both on windows and unix may be used to implement functionality you required and it's a more natural way there is useful article [1] which describes both windows and unix way to threads/events/semaphores/mutexes. how about implementing lightweight library which abstracts over these differences? OTOH, i've just recalled one C++ library which does exactly this job [2]. may be providing Haskell interface for it will be a better idea? [1] http://www.ibm.com/developerworks/linux/library/l-ipc2lin1.html [2] Abstraction of multitasking, file IO and socket IO for Unix and Windows systems http://www.garret.ru/~knizhnik/sal-108.zip -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From ndmitchell at gmail.com Thu Jun 5 12:54:51 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Thu Jun 5 12:47:25 2008 Subject: [Haskell-cafe] automatically deriving Map and Filter on datatypes etc. In-Reply-To: <28B5EEBB-7843-436D-9CFC-A01EEFDF1E9A@fastmail.fm> References: <1ff5dedc0806050103h1639d907r7ac731de016787bc@mail.gmail.com> <0D31F43A-4404-40EA-8628-45A033FB6493@yandex.ru> <2638D507-4427-4A04-96E5-C8208F3F0D2F@gmail.com> <28B5EEBB-7843-436D-9CFC-A01EEFDF1E9A@fastmail.fm> Message-ID: <404396ef0806050954i5a9d6b1cw2cde7d6091650048@mail.gmail.com> Hi > PS Why isn't Functor derivable? Derive can do it: http://www.cs.york.ac.uk/~ndm/derive I believe that Twan (the author of Functor deriving in Derive) is trying to get this suggested for Haskell' as a proper deriving. As for the original question, Uniplate will certainly do map, and will probably help with filter - as the definition of Filter is not obvious given the type. And you can have automatic deriving with Uniplate (see PlateData in the paper or the module structure) http://www.cs.york.ac.uk/~ndm/uniplate Thanks Neil From lanny at cisco.com Thu Jun 5 13:06:02 2008 From: lanny at cisco.com (Lanny Ripple) Date: Thu Jun 5 12:58:36 2008 Subject: [Haskell-cafe] How would you hack it? In-Reply-To: <2518b95d0806042014m3b40937cj1ecf05011e6dae77@mail.gmail.com> References: <4846DFDC.5020905@btinternet.com> <484706F7.8000407@btinternet.com> <484715D8.8090803@cisco.com> <2518b95d0806042014m3b40937cj1ecf05011e6dae77@mail.gmail.com> Message-ID: <48481CFA.5070104@cisco.com> Wow. Did I really quote the article as "Communcations"? (A new, little known work by Shannon! :/ The link is correct anyway. -ljr Evan Laforge wrote: > On Wed, Jun 4, 2008 at 3:23 PM, Lanny Ripple wrote: >> You might want to skim Shannon's 'A Mathematical Theory of >> Communcations'. Part 1, Section 2 and 3 are almost exactly your >> topic. (Or at least the direction you've headed in. :) >> >> http://plan9.bell-labs.com/cm/ms/what/shannonday/shannon1948.pdf > > Rob Pike's "Practice of Programming" has a few chapters with a markov > generator in several different languages as a case study. None of > them are functional, but it's a pretty clear description of the idea. > > The "plan9" in the url reminded me :) From paul at cogito.org.uk Thu Jun 5 13:06:20 2008 From: paul at cogito.org.uk (Paul Johnson) Date: Thu Jun 5 12:58:58 2008 Subject: [Haskell-cafe] Re: Laziness leaks In-Reply-To: <20080605052825.7002ce4e@solaris> References: <62728db30806031414p19593f40x5ad1bfd32e2dfc4b@mail.gmail.com> <4845D0B8.6040802@vex.net> <62728db30806031712w32421ae5scbf84920ecd71193@mail.gmail.com> <2f9b2d30806041916x3e0088acw26e45033ee586b9a@mail.gmail.com> <20080605052825.7002ce4e@solaris> Message-ID: <48481D0C.1070206@cogito.org.uk> Achim Schneider wrote: > There won't ever be a space leak without a time leak nor a time leak > without a space leak. I'd just call it a leak. > Actually I think you can have a space leak without a time leak. For instance if every time around the main loop I cons data onto a linked list that never gets freed then I have a space leak. If the list never gets used (or more realistically, if the program only ever uses the first N entries) then there is no time leak. I agree that a time leak implies a space leak though. Paul. From barsoap at web.de Thu Jun 5 13:14:31 2008 From: barsoap at web.de (Achim Schneider) Date: Thu Jun 5 13:07:11 2008 Subject: [Haskell-cafe] Re: Laziness leaks References: <62728db30806031414p19593f40x5ad1bfd32e2dfc4b@mail.gmail.com> <4845D0B8.6040802@vex.net> <62728db30806031712w32421ae5scbf84920ecd71193@mail.gmail.com> <2f9b2d30806041916x3e0088acw26e45033ee586b9a@mail.gmail.com> <20080605052825.7002ce4e@solaris> <48481D0C.1070206@cogito.org.uk> Message-ID: <20080605191431.5c6bd1d7@solaris> Paul Johnson wrote: > Achim Schneider wrote: > > There won't ever be a space leak without a time leak nor a time leak > > without a space leak. I'd just call it a leak. > > > Actually I think you can have a space leak without a time leak. For > instance if every time around the main loop I cons data onto a linked > list that never gets freed then I have a space leak. If the list > never gets used (or more realistically, if the program only ever uses > the first N entries) then there is no time leak. > Sure there is: you leaked time while constructing the list. The whole topic seems to degenerate into nit-picking for border cases. One could define a leak as "a property of an error-free program resulting in non-optimal performance", or much more concise, "a trap no sufficiently smart programmer runs into". -- (c) this sig last receiving data processing entity. Inspect headers for past copyright information. All rights reserved. Unauthorised copying, hiring, renting, public performance and/or broadcasting of this signature prohibited. From newsham at lava.net Thu Jun 5 13:28:07 2008 From: newsham at lava.net (Tim Newsham) Date: Thu Jun 5 13:20:40 2008 Subject: [Haskell-cafe] re: very hard to build darcs with win32 ghc-6.8.2! Message-ID: Here's the wrapup, thanks to those who replied: - the haskell zlib package on hackage no longer requires that zlib (the C library) be prebuilt. It includes sources itself and builds and installs them using Cabal. - the haskell zlib package is not used by darcs. It links against libz.a directly. You do need to have libz.a somehow to build darcs. - the darcs link error with "SleepEx" is caused because it uses "foreign import ccall" when it should use "foreign import stdcall". Fixing the decl in src/win32/System/Posix.hs to stdcall fixes this issue. I still think its odd that ghc's "gcc" is not very useable outside of Cabal, but in this case it has no bearing on the zlib package. If you choose to build "libz.a" (the C library) from sources using this gcc it will be hard, but you could also get it from an external source (such as the prebuilt libcurl library package). Tim Newsham http://www.thenewsh.com/~newsham/ From aeyakovenko at gmail.com Thu Jun 5 13:28:50 2008 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Thu Jun 5 13:21:22 2008 Subject: [Haskell-cafe] Re: hmatrix In-Reply-To: <48480339.6050900@um.es> References: <484277D3.9020604@um.es> <4843BF4A.2080800@um.es> <4844F27A.2080208@um.es> <731290342.20080603113721@gmail.com> <48450752.4080307@um.es> <483842413.20080603134211@gmail.com> <48480339.6050900@um.es> Message-ID: Thanks, that's exactly what i was looking for. On Thu, Jun 5, 2008 at 8:16 AM, Alberto Ruiz wrote: > Hello Bulat and Anatoly, > > I have written a first version of an interface to inplace updates in the ST > monad for the hmatrix vectors and matrices. Many things must be > improved (range checking, documentation, etc.) but I hope that the general > idea makes sense. > > A few usage examples: > > http://perception.inf.um.es/~aruiz/darcs/hmatrix/examples/inplace.hs > > Code: > > http://perception.inf.um.es/~aruiz/darcs/hmatrix/lib/Data/Packed/ST.hs > > http://perception.inf.um.es/~aruiz/darcs/hmatrix/doc/html/Data-Packed-ST.html > > Any suggestion will be welcome. I'm impressed by the power of the ST monad, > it is extremely useful and elegant. Thank you again for your help! > > In the future I will also try to include efficient conversions to/from > standard Haskell arrays and those of other related libraries like Jed > Brown's CArray. > > Thanks, > > Alberto > > > Bulat Ziganshin wrote: >> >> Hello Alberto, >> >> Tuesday, June 3, 2008, 12:56:50 PM, you wrote: >> >>> Good! So you can easily "hide" the IO operations in the ST monad. I will >>> definitely look into it. >> >> from implementation POV ST monad is nothing but renamed IO monad which >> exports only subset of its operations which are guaranteed to safe. >> or, saying in other words, it's just type hackery around IO monad that >> provides safe operations >> >> it's possible to define ST monad and its operations as following: >> >> newtype ST s a = forall s. ST_Constructor (IO a) >> >> unsafeIOtoSt action = ST_Constructor action >> >> runST (ST_Constructor action) = unsafePerformIO action >> >> newtype STRef s a = forall s. STRef (IORef a) >> >> readSTRef (STRef ref) = unsafeIOtoSt (readIORef ref) >> >> and so on. GHC uses technically (but not ideologically!) different >> implementation where both monads are specializations of one generic >> type. while Hugs afair uses exactly this approach. you may also look >> at ArrayRef lib which reimplements arrays/refs for both compilers in >> more unified way >> >> anyway, because ST is just IO monad modulo type tricks, you can >> execute any IO action inside ST by lifting it with unsafeIOtoSt >> > From martindemello at gmail.com Thu Jun 5 14:04:35 2008 From: martindemello at gmail.com (Martin DeMello) Date: Thu Jun 5 13:57:08 2008 Subject: [Haskell-cafe] getting set up in ubuntu In-Reply-To: <874p88l3vp.fsf@malde.org> References: <874p88l3vp.fsf@malde.org> Message-ID: On Thu, Jun 5, 2008 at 12:47 AM, Ketil Malde wrote: > "Martin DeMello" writes: >> I'm especially looking for guidelines on what to install via apt-get >> and what to install independently. > > I'd get as much as possible via apt-get, and only install manually > when that fails. > Thanks! Did you have any conflicts between manual and apt-got stuff? Is there any equivalent to gentoo's "package.provided" (which basically says 'I have installed this manually; please don't try to update it for me')? martin From barsoap at web.de Thu Jun 5 14:27:53 2008 From: barsoap at web.de (Achim Schneider) Date: Thu Jun 5 14:20:35 2008 Subject: [Haskell-cafe] Analysing music Message-ID: <20080605202753.139c8acc@solaris> The recent discussion about Markoff chains inspired me to try to train one with all the Bach midi's I have on my disk, collecting statistics on what intervals tend to get played simultaneously, which follow others and in which way the pitch offsets from its mean, so that melodies fall and raise "naturally". The rationale is that if it's Bach, it's harmonious but not respecting any kind of usual chord progression. So far, I got (a bit confused around the edges): getMid mf = do mid <- MidiLoad.fromFile mf return $ MidiRead.retrieveTracks mid toMelody :: MidiMusic.T -> StdMelody.T toMelody = Music.mapNote f where f note = let body = MidiMusic.body note in Melody.Note StdMelody.na (MidiMusic.pitch body) main = do args <- Env.getArgs let mf:[] = args m <- getMid mf putStr $ Format.prettyMelody $ Optimise.all $ Music.chord $ map (\m -> Music.line $ map toMelody m) m which results in chord [e 3 bn na, chord [b 2 wn na, line [hnr, d 3 wn na, hnr, cs 3 hn na, a 2 hn na, chord [cs 3 hn na, line [b 2 hn na, c 3 hn na]]]]] , for a set of random clicks in rosegarden's matrix editor. Right now, I'm desperately searching for functions that can help me analyse this beast, which afaict right now works best by having a multitude of transformations (e.g. one big top-level chord with maximum polyphony and a hell a lot of rests) that provide easy access to whatever information is needed. Does anyone of you know about previous work in this area? I don't want to break cultural imperatives by not being as lazy as possible. -- (c) this sig last receiving data processing entity. Inspect headers for past copyright information. All rights reserved. Unauthorised copying, hiring, renting, public performance and/or broadcasting of this signature prohibited. From dipankar at jfet.net Thu Jun 5 14:32:59 2008 From: dipankar at jfet.net (Dipankar Ray) Date: Thu Jun 5 14:25:38 2008 Subject: [Haskell-cafe] Analysing music In-Reply-To: <20080605202753.139c8acc@solaris> References: <20080605202753.139c8acc@solaris> Message-ID: a somewhat random sample of work done in this direction: http://arts.ucsc.edu/faculty/cope/experiments.htm On Thu, 5 Jun 2008, Achim Schneider wrote: > The recent discussion about Markoff chains inspired me to try to > train one with all the Bach midi's I have on my disk, collecting > statistics on what intervals tend to get played simultaneously, > which follow others and in which way the pitch offsets from its mean, > so that melodies fall and raise "naturally". > > The rationale is that if it's Bach, it's harmonious but not respecting > any kind of usual chord progression. > > So far, I got (a bit confused around the edges): > > getMid mf = do > mid <- MidiLoad.fromFile mf > return $ MidiRead.retrieveTracks mid > > > toMelody :: MidiMusic.T -> StdMelody.T > toMelody = Music.mapNote f > where > f note = > let body = MidiMusic.body note > in Melody.Note StdMelody.na (MidiMusic.pitch body) > > main = do > args <- Env.getArgs > let mf:[] = args > m <- getMid mf > putStr $ Format.prettyMelody $ Optimise.all > $ Music.chord $ map (\m -> Music.line $ map toMelody m) m > > > which results in > chord > [e 3 bn na, > chord > [b 2 wn na, > line > [hnr, d 3 wn na, hnr, cs 3 hn na, a 2 hn na, > chord [cs 3 hn na, line [b 2 hn na, c 3 hn na]]]]] > > , for a set of random clicks in rosegarden's matrix editor. > > Right now, I'm desperately searching for functions that can help me > analyse this beast, which afaict right now works best by having a > multitude of transformations (e.g. one big top-level chord with maximum > polyphony and a hell a lot of rests) that provide easy access to > whatever information is needed. > > Does anyone of you know about previous work in this area? I don't want > to break cultural imperatives by not being as lazy as possible. > > -- > (c) this sig last receiving data processing entity. Inspect headers for > past copyright information. All rights reserved. Unauthorised copying, > hiring, renting, public performance and/or broadcasting of this > signature prohibited. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ben.franksen at online.de Thu Jun 5 14:33:42 2008 From: ben.franksen at online.de (Ben Franksen) Date: Thu Jun 5 14:26:28 2008 Subject: [Haskell-cafe] Re: Re: cabal and platform-independent haskell installation management (again) (Re: Re: Ubuntu and ghc) References: <5ae4f2ba0805211532l35bef8eas9a10ff6df3e0f843@mail.gmail.com> <1211448821.5824.504.camel@localhost> <008001c8bbf7$63753100$d0357ad5@cr3lt> <48466F7F.8090600@gmail.com> <016d01c8c64d$4ac1dea0$73357ad5@cr3lt> <1212590628.15010.312.camel@localhost> <20080604172252.34df14f7@solaris> <1212623330.15010.318.camel@localhost> Message-ID: Darrin Thompson wrote: > On Wed, Jun 4, 2008 at 7:48 PM, Duncan Coutts > wrote: >> On Wed, 2008-06-04 at 17:22 +0200, Achim Schneider wrote: >> >>> The question, IMHO, seems to be >>> >>> "How would a package manager for a posix-compilant kinetic look like?" >> >> http://nixos.org/index.html > > How well does that coexist with other OS's? Could I have it manage > only specific applications in it's store and trust the OS for the > rest? Yes. You can install nix (the package manager) under linux (and, I think, other posix-compiant OS) and use it in parallel with native packages (.deb, .rpm, whatever). This means you'll get some duplication, since the nix store contains everything needed to build and run the installed packages. The nix /package database/ contains not only nix package descriptions but relies essentially on build-scripts, which are mostly written in shell. So to use that, you'd have to have a posix-shell on your system, too. Cheers Ben From barsoap at web.de Thu Jun 5 14:32:01 2008 From: barsoap at web.de (Achim Schneider) Date: Thu Jun 5 14:27:33 2008 Subject: [Haskell-cafe] Re: getting set up in ubuntu References: <874p88l3vp.fsf@malde.org> Message-ID: <20080605203201.3dfccc7b@solaris> "Martin DeMello" wrote: > Thanks! Did you have any conflicts between manual and apt-got stuff? > Is there any equivalent to gentoo's "package.provided" (which > basically says 'I have installed this manually; please don't try to > update it for me')? > package.provided is bad, mkay? It basically says "I messed up my system, try to continue anyway." Don't use it for anything else than kernel sources, you should write ebuilds for the rest and let portage do the managing. -- (c) this sig last receiving data processing entity. Inspect headers for past copyright information. All rights reserved. Unauthorised copying, hiring, renting, public performance and/or broadcasting of this signature prohibited. From a.biurvOir4 at asuhan.com Thu Jun 5 14:36:04 2008 From: a.biurvOir4 at asuhan.com (Kim-Ee Yeoh) Date: Thu Jun 5 14:28:37 2008 Subject: [Haskell-cafe] More on performance In-Reply-To: <200806041213.55484.jon@ffconsultancy.com> References: <20080603174704.GB22053@scytale.galois.com> <1212571822.15010.266.camel@localhost> <6f9f8f4a0806040248x5f502f6eoae2a95dc8dc83778@mail.gmail.com> <7ca3f0160806040305x4bc0dd27tf8621b88acdf8c1e@mail.gmail.com> <200806041213.55484.jon@ffconsultancy.com> Message-ID: <17676772.post@talk.nabble.com> Jon Harrop wrote: > > On Wednesday 04 June 2008 11:05:52 Luke Palmer wrote: >> Given unbounded time and space, you will still arrive at the same result >> regardless of the complexity. > > Given that the set of computers with unbounded time and space is empty, is > it > not fruitless to discuss its properties? > The set of omnipotent people is also empty. That has not stopped homo sapiens from discussing /its/ properties. All history is ever only such a discussion for nothing fires up the imagination nor provokes acts of brilliant foolhardiness like the unattainable. -- Kim-Ee -- View this message in context: http://www.nabble.com/More-on-performance-tp17629453p17676772.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From kenn at kenn.frap.net Thu Jun 5 14:46:56 2008 From: kenn at kenn.frap.net (Kenn Knowles) Date: Thu Jun 5 14:39:40 2008 Subject: [Haskell-cafe] Analysing music In-Reply-To: <20080605202753.139c8acc@solaris> References: <20080605202753.139c8acc@solaris> Message-ID: <476d7e8c0806051146i4b6129bfx8202e85c7056bcd@mail.gmail.com> David Cope's early research seems relevant. Some LISP code to train a Markov chain on Bach is available from the web page for his current class. http://arts.ucsc.edu/faculty/cope/music206b.html He eschews higher-order functions; using them, you should be able to port it to very concise and readable Haskell. For the musical side of things, the powerpoint presentations hint at additional data you can put into your states and transitions to get better results for e.g. cadences, characteristic embellishments, and melodic arcs. Hope this is helpful, - Kenn On Thu, Jun 5, 2008 at 11:27 AM, Achim Schneider wrote: > The recent discussion about Markoff chains inspired me to try to > train one with all the Bach midi's I have on my disk, collecting > statistics on what intervals tend to get played simultaneously, > which follow others and in which way the pitch offsets from its mean, > so that melodies fall and raise "naturally". > > The rationale is that if it's Bach, it's harmonious but not respecting > any kind of usual chord progression. > > So far, I got (a bit confused around the edges): > > getMid mf = do > mid <- MidiLoad.fromFile mf > return $ MidiRead.retrieveTracks mid > > > toMelody :: MidiMusic.T -> StdMelody.T > toMelody = Music.mapNote f > where > f note = > let body = MidiMusic.body note > in Melody.Note StdMelody.na (MidiMusic.pitch body) > > main = do > args <- Env.getArgs > let mf:[] = args > m <- getMid mf > putStr $ Format.prettyMelody $ Optimise.all > $ Music.chord $ map (\m -> Music.line $ map toMelody m) m > > > which results in > chord > [e 3 bn na, > chord > [b 2 wn na, > line > [hnr, d 3 wn na, hnr, cs 3 hn na, a 2 hn na, > chord [cs 3 hn na, line [b 2 hn na, c 3 hn na]]]]] > > , for a set of random clicks in rosegarden's matrix editor. > > Right now, I'm desperately searching for functions that can help me > analyse this beast, which afaict right now works best by having a > multitude of transformations (e.g. one big top-level chord with maximum > polyphony and a hell a lot of rests) that provide easy access to > whatever information is needed. > > Does anyone of you know about previous work in this area? I don't want > to break cultural imperatives by not being as lazy as possible. > > -- > (c) this sig last receiving data processing entity. Inspect headers for > past copyright information. All rights reserved. Unauthorised copying, > hiring, renting, public performance and/or broadcasting of this > signature prohibited. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From s.clover at gmail.com Thu Jun 5 15:14:26 2008 From: s.clover at gmail.com (Sterling Clover) Date: Thu Jun 5 15:07:02 2008 Subject: [Haskell-cafe] Analysing music In-Reply-To: <476d7e8c0806051146i4b6129bfx8202e85c7056bcd@mail.gmail.com> References: <20080605202753.139c8acc@solaris> <476d7e8c0806051146i4b6129bfx8202e85c7056bcd@mail.gmail.com> Message-ID: <8C2F3E93-9B2B-4694-BD4F-CB2C0CAB9516@gmail.com> Hofstadter (he of Godel Escher Bach) naturally has a lovely essay on Chopin reproduced in Metamagical Themas, which might be helpful as well. Regards, Sterl. On Jun 5, 2008, at 2:46 PM, Kenn Knowles wrote: > David Cope's early research seems relevant. Some LISP code to train a > Markov chain on Bach is available from the web page for his current > class. > > http://arts.ucsc.edu/faculty/cope/music206b.html > > He eschews higher-order functions; using them, you should be able to > port it to very concise and readable Haskell. For the musical side of > things, the powerpoint presentations hint at additional data you can > put into your states and transitions to get better results for e.g. > cadences, characteristic embellishments, and melodic arcs. > > Hope this is helpful, > > - Kenn > > On Thu, Jun 5, 2008 at 11:27 AM, Achim Schneider > wrote: > >> The recent discussion about Markoff chains inspired me to try to >> train one with all the Bach midi's I have on my disk, collecting >> statistics on what intervals tend to get played simultaneously, >> which follow others and in which way the pitch offsets from its mean, >> so that melodies fall and raise "naturally". >> >> The rationale is that if it's Bach, it's harmonious but not >> respecting >> any kind of usual chord progression. >> >> So far, I got (a bit confused around the edges): >> >> getMid mf = do >> mid <- MidiLoad.fromFile mf >> return $ MidiRead.retrieveTracks mid >> >> >> toMelody :: MidiMusic.T -> StdMelody.T >> toMelody = Music.mapNote f >> where >> f note = >> let body = MidiMusic.body note >> in Melody.Note StdMelody.na (MidiMusic.pitch body) >> >> main = do >> args <- Env.getArgs >> let mf:[] = args >> m <- getMid mf >> putStr $ Format.prettyMelody $ Optimise.all >> $ Music.chord $ map (\m -> Music.line $ map toMelody m) m >> >> >> which results in >> chord >> [e 3 bn na, >> chord >> [b 2 wn na, >> line >> [hnr, d 3 wn na, hnr, cs 3 hn na, a 2 hn na, >> chord [cs 3 hn na, line [b 2 hn na, c 3 hn na]]]]] >> >> , for a set of random clicks in rosegarden's matrix editor. >> >> Right now, I'm desperately searching for functions that can help me >> analyse this beast, which afaict right now works best by having a >> multitude of transformations (e.g. one big top-level chord with >> maximum >> polyphony and a hell a lot of rests) that provide easy access to >> whatever information is needed. >> >> Does anyone of you know about previous work in this area? I don't >> want >> to break cultural imperatives by not being as lazy as possible. >> >> -- >> (c) this sig last receiving data processing entity. Inspect >> headers for >> past copyright information. All rights reserved. Unauthorised >> copying, >> hiring, renting, public performance and/or broadcasting of this >> signature prohibited. >> >> _______________________________________________ >> 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 ben.franksen at online.de Thu Jun 5 15:36:20 2008 From: ben.franksen at online.de (Ben Franksen) Date: Thu Jun 5 15:29:07 2008 Subject: [Haskell-cafe] Re: How would you hack it? References: <4846DFDC.5020905@btinternet.com> <20080604223228.284254b5@solaris> <48470121.6090408@btinternet.com> <20080604232507.7fd9fd81@solaris> Message-ID: Achim Schneider wrote: > Andrew Coppin wrote: >> Achim Schneider wrote: >> > Andrew Coppin wrote: >> > >> >> I have a file that contains several thousand words, seperated by >> >> white space. [I gather that on Unix there's a standard location for >> >> this file?] >> > Looking at /usr/share/dict/words, I'm assured that the proper >> > seperator is \n. >> > >> >> Thanks. I did look around trying to find this, but ultimately failed. >> (Is it a standard component, or is it installed as part of some >> specific application?) >> > ksf@solaris ~ % equery b /usr/share/dict/words > [ Searching for file(s) /usr/share/dict/words in *... ] > sys-apps/miscfiles-1.4.2 (/usr/share/dict/words) > ksf@solaris ~ % eix miscfiles > [I] sys-apps/miscfiles > Available versions: 1.4.2 {minimal} > Installed versions: 1.4.2(18:27:27 02/14/07)(-minimal) > Homepage: http://www.gnu.org/directory/miscfiles.html > Description: Miscellaneous files On Ubuntu (and supposedly debian): ben@sarun[1]: ~ > dpkg -S /usr/share/dict/words dictionaries-common: /usr/share/dict/words Cheers Ben From andrewcoppin at btinternet.com Thu Jun 5 15:35:15 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Jun 5 15:44:53 2008 Subject: [Haskell-cafe] How would you hack it? In-Reply-To: References: <4846DFDC.5020905@btinternet.com> <48470014.4000804@btinternet.com> <79F4406C-52CA-4467-9826-8819E3D8DEE3@phaedrusdeinus.org> Message-ID: <48483FF3.4070908@btinternet.com> Henning Thielemann wrote: > "Markov chain" means, that you have a sequence of random experiments, > where the outcome of each experiment depends exclusively on a fixed number > (the level) of experiments immediately before the current one. > Right. So a "Markov chain" is actually a technical way of describing something that's intuitively pretty obvious? (E.g., PPM compression works by assuming that the input data is some sort of Markov chain with as-yet unknown transition probabilities.) > If the level is too high, you will just reproduce the training text. > Yeah, I can see that happening! ;-) The key, I think, is for the training set to be much larger than what you want to produce... From dons at galois.com Thu Jun 5 16:11:47 2008 From: dons at galois.com (Don Stewart) Date: Thu Jun 5 16:04:21 2008 Subject: [Haskell-cafe] Re: hmatrix In-Reply-To: <48480339.6050900@um.es> References: <484277D3.9020604@um.es> <4843BF4A.2080800@um.es> <4844F27A.2080208@um.es> <731290342.20080603113721@gmail.com> <48450752.4080307@um.es> <483842413.20080603134211@gmail.com> <48480339.6050900@um.es> Message-ID: <20080605201147.GE19896@scytale.galois.com> Good work, Alberto. hmatrix looks like a good solution answer to some of the nested arrays questions we have in Haskell aruiz: > Hello Bulat and Anatoly, > > I have written a first version of an interface to inplace updates in the > ST monad for the hmatrix vectors and matrices. Many things must be > improved (range checking, documentation, etc.) but I hope that the > general idea makes sense. > > A few usage examples: > > http://perception.inf.um.es/~aruiz/darcs/hmatrix/examples/inplace.hs > > Code: > > http://perception.inf.um.es/~aruiz/darcs/hmatrix/lib/Data/Packed/ST.hs > > http://perception.inf.um.es/~aruiz/darcs/hmatrix/doc/html/Data-Packed-ST.html > > Any suggestion will be welcome. I'm impressed by the power of the ST > monad, it is extremely useful and elegant. Thank you again for your help! > > In the future I will also try to include efficient conversions to/from > standard Haskell arrays and those of other related libraries like Jed > Brown's CArray. > > Thanks, > > Alberto > > > Bulat Ziganshin wrote: > >Hello Alberto, > > > >Tuesday, June 3, 2008, 12:56:50 PM, you wrote: > > > >>Good! So you can easily "hide" the IO operations in the ST monad. I will > >>definitely look into it. > > > >from implementation POV ST monad is nothing but renamed IO monad which > >exports only subset of its operations which are guaranteed to safe. > >or, saying in other words, it's just type hackery around IO monad that > >provides safe operations > > > >it's possible to define ST monad and its operations as following: > > > >newtype ST s a = forall s. ST_Constructor (IO a) > > > >unsafeIOtoSt action = ST_Constructor action > > > >runST (ST_Constructor action) = unsafePerformIO action > > > >newtype STRef s a = forall s. STRef (IORef a) > > > >readSTRef (STRef ref) = unsafeIOtoSt (readIORef ref) > > > >and so on. GHC uses technically (but not ideologically!) different > >implementation where both monads are specializations of one generic > >type. while Hugs afair uses exactly this approach. you may also look > >at ArrayRef lib which reimplements arrays/refs for both compilers in > >more unified way > > > >anyway, because ST is just IO monad modulo type tricks, you can > >execute any IO action inside ST by lifting it with unsafeIOtoSt > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From lemming at henning-thielemann.de Thu Jun 5 17:10:54 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Jun 5 17:00:36 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> Message-ID: On Thu, 5 Jun 2008, Johan Tibell wrote: > Hi! > > The last two weeks I've seen two new packages that add suffixes to > identifiers instead of relying on them being imported qualified to > distinguish them from identifiers in other modules. This is not a new > thing in Haskell community and there are examples of this practice in > libraries shipped with GHC. It is also common in papers (for good > reasons as we will see later). Atomic channels and variables under > Control.Concurrent.* are examples of using a prefix as a namespacing > tool. Let me reiterate the arguments [1,2] against this practice and > also speculate why this practice is more common in Haskell than in > e.g. Python, Java or Ruby. Thank you for emphasising these points, again! From conor at strictlypositive.org Thu Jun 5 17:17:09 2008 From: conor at strictlypositive.org (Conor McBride) Date: Thu Jun 5 17:09:11 2008 Subject: [Haskell-cafe] automatically deriving Map and Filter on datatypes etc. In-Reply-To: <28B5EEBB-7843-436D-9CFC-A01EEFDF1E9A@fastmail.fm> References: <1ff5dedc0806050103h1639d907r7ac731de016787bc@mail.gmail.com> <0D31F43A-4404-40EA-8628-45A033FB6493@yandex.ru> <2638D507-4427-4A04-96E5-C8208F3F0D2F@gmail.com> <28B5EEBB-7843-436D-9CFC-A01EEFDF1E9A@fastmail.fm> Message-ID: <460D5EB7-CF7F-4E33-963B-C0DEAC29A836@strictlypositive.org> Hi Statutory mathematics warning: lots. On 5 Jun 2008, at 15:40, Jonathan Cast wrote: > On 5 Jun 2008, at 1:39 AM, Thomas Davie wrote: > >> Even deriving an instance of Functor seems rather implausable, >> what should it do for >> >> data Wierd a b = Nil | A a (Wierd a b) | B b (Wierd a b) >> >> Should fmap's function argument operate on 'a's, 'b's, or both? > > class Functor (f :: * -> *) where ... > > so, 'b's. While application remains injective, that seems appropriate. But wouldn't we want more, eg, that Wierd is a bifunctor (and, moreover, bitraversable, bihalfzippable,...)? Of course, there's a whole ghastly family of these things for type constructors of varying arities, together with stuff like "the fixpoint of a bifunctor is a functor". > jcc > > PS Why isn't Functor derivable? It would be very handy, but it's the tip of the iceberg. Being an Ulsterman, I get nervous about engineering for machinery-iceberg collisions. Perhaps it's worth looking for a systematic approach to the more general situation (not necessarily kind polymorphism; a systematic library treatment of n-functors for n in {0,..,pickamax} would be a good start). An alterative, perhaps, is to replace arity by indexing. This may get hairy. Untested stuff... data Rewired f n where Nil :: Rewired f Zero A :: f Zero -> Rewired f Zero -> Rewired f Zero B :: f One -> Rewired f Zero -> Rewired f Zero data Pick a b n where -- clearly a bit specific PickA :: a -> Pick a b Zero PickB :: b -> Pick a b One type Wierd a b = Rewired (Pick a b) Zero Here Rewired :: (* -> *) -> (* -> *), but (* -> *) means "*-indexed type" not "container". I'd rather be more precise and work with (i -> *) -> (o -> *), but we have to take i = o = * for now. The idea is to transform a bunch of "input" datatypes indexed by i to a bunch of output datatypes indexed by o. In this example, we collect Bob's two element types into a single GADT which specializes differently at two distinct input indices. There's no variation in the output index, so I just made them all Zero. But here's another old friend data Vec f n where Nil :: Vec f Zero Cons :: f Zero -> Vec f n -> Vec f (Suc n) which has no input variation, but uses the output index to specify length. Anyhow, the point is that for these indexed structures, you get to define much of the generic kit once and for all, and you get one obvious notion of "map". type f :->: g = forall x. f x -> g x class IxMap c where ixMap :: (f :->: g) -> (c f :->: c g) Painless! Well, er, probably not. (Masochists may choose to generalize this notion by relaxing the index-preservation requirement to some sort of index-simulation, thus heading for Hancock's notion of "container driver". I digress.) Anyhow, it would be nice if kit developed once for indexed structures could be lifted automatically to the indexed encoding of the more specific types you'd actually like to work with. Maybe that's a thing to be deriving. {---------- Exercises for masochists (especially myself): (1) Show that simply-typed lambda-terms have IxMap structure (aka type-safe renaming) over notions of typed variable, just as untyped (de Bruijn) lambda-terms are an instance of Functor. It may help to think systematically about "notions of typed variable". (2) Define an indexed container transformer IxFix :: ((* -> *) -> (* -> *)) -> ((* -> *) -> (* -> *)) in such a way that instance IxMap c => IxMap (IxFix c) and present Vec, etc, with IxFix as the only source of recursive datatype definition. Hint, the more refined kind should be seen as (((i + o) -> *) -> (o -> *)) -> ((i -> *) -> (o -> *)) so that c has places both for i-indexed inputs and for o-indexed substructures. (3) Grok and adapt the rest of Jeremy Gibbons' "origami" apparatus. ----------} Meanwhile, if you want to derive filtering, think about what one-hole contexts for elements need to look like, especially if you might want to throw the element away. Fans of bifunctor fixpoints and multivariate partial differentiation may be amused to note that [x] = mu y. 1 + xy (d/dx) (1 + xy) = y and that Cetin's Tab x = mu y. 1 + xy + y^3 (d/dx) (1 + xy + y^3) = y so perhaps a pattern is emerging... It's been an interesting day: thanks to all for the food for thought. It's clear that Haskell (with recent extensions) can now express very powerful abstractions such as "indexed container", but not in a way which sits very comfortably with normal usage. I think that's a serious concern. Cheers Conor From ketil at malde.org Thu Jun 5 17:19:47 2008 From: ketil at malde.org (Ketil Malde) Date: Thu Jun 5 17:12:02 2008 Subject: [Haskell-cafe] getting set up in ubuntu In-Reply-To: (Martin DeMello's message of "Thu\, 5 Jun 2008 11\:04\:35 -0700") References: <874p88l3vp.fsf@malde.org> Message-ID: <87lk1jk2a4.fsf@malde.org> "Martin DeMello" writes: > Thanks! Did you have any conflicts between manual and apt-got stuff? Not yet, but I haven't really hammered my system with packages yet. > Is there any equivalent to gentoo's "package.provided" (which > basically says 'I have installed this manually; please don't try to > update it for me')? I'm not familar with Gentoo (anymore - I ran it briefly, but got tired of all the compiling), but I think the answer is 'no'. The native packages go in /usr/{bin,lib,..}, while manual installs -- i.e. cabal -- puts stuff under /usr/local (or in your home dir). Native packages can of course only depend on and be built against other native packages. For "manually" installed packages, I believe cabal will use the newest version wherever, as long as it's compatible with the dependency specification in the .cabal file. -k -- If I haven't seen further, it is by standing in the footprints of giants From lemming at henning-thielemann.de Thu Jun 5 17:22:31 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Jun 5 17:12:08 2008 Subject: [Haskell-cafe] Analysing music In-Reply-To: <20080605202753.139c8acc@solaris> References: <20080605202753.139c8acc@solaris> Message-ID: On Thu, 5 Jun 2008, Achim Schneider wrote: > The recent discussion about Markoff chains inspired me to try to > train one with all the Bach midi's I have on my disk, collecting > statistics on what intervals tend to get played simultaneously, > which follow others and in which way the pitch offsets from its mean, > so that melodies fall and raise "naturally". I don't know, if you already found that one: http://darcs.haskell.org/haskore/src/Haskore/Example/Kantate147.hs Surprisingly I also tried Markov Chain on a Bach song. But my approach was too simplistic in order to produce a nice new song. From dons at galois.com Thu Jun 5 18:47:35 2008 From: dons at galois.com (Don Stewart) Date: Thu Jun 5 18:40:11 2008 Subject: [Haskell-cafe] Package updates on haskell.org Message-ID: <20080605224735.GD20317@scytale.galois.com> The HWN, which I'm sadly too busy to maintain now, had a useful function of generating recent package releases and getting them on the wiki, and to people's inboxes. This facility has been replaced by two processes: 1) Users can subscribe to recent package updates via RSS: http://hackage.haskell.org/packages/archive/recent.rss 2) The 'hackage2hwn' script now runs to keep the http://haskell.org 'Recent Package Updates' section fresh, listing the latest updates. So you can always find the newest 20 packages by looking at haskell.org Cheers, Don From barsoap at web.de Thu Jun 5 18:50:03 2008 From: barsoap at web.de (Achim Schneider) Date: Thu Jun 5 18:42:49 2008 Subject: [Haskell-cafe] Analysing music References: <20080605202753.139c8acc@solaris> Message-ID: <20080606005003.295b5862@solaris> Henning Thielemann wrote: > > On Thu, 5 Jun 2008, Achim Schneider wrote: > > > The recent discussion about Markoff chains inspired me to try to > > train one with all the Bach midi's I have on my disk, collecting > > statistics on what intervals tend to get played simultaneously, > > which follow others and in which way the pitch offsets from its > > mean, so that melodies fall and raise "naturally". > > I don't know, if you already found that one: > http://darcs.haskell.org/haskore/src/Haskore/Example/Kantate147.hs > > Surprisingly I also tried Markov Chain on a Bach song. But my > approach was too simplistic in order to produce a nice new song. > Yes, you need to take both dimension of music into account, that is time and polyphony. Bach uses quite exceptional polyphony from time to time, but it always stays harmonious: You have to have eg. a 0% probability of ever playing a note and its minor second. The probability of a note and its quint will most likely be at least 50%, but then there are chords that sound atrocious if it's there. What I need is basically one view of the data as list of used chords, and one graph of all possible time-linear progressions... that is, voices, for a definition of "voice" that makes the guitarist in me shudder. Seems like I'm going to make close acquaintance with fgl, after all. -- (c) this sig last receiving data processing entity. Inspect headers for past copyright information. All rights reserved. Unauthorised copying, hiring, renting, public performance and/or broadcasting of this signature prohibited. From murray at sonology.net Thu Jun 5 19:37:11 2008 From: murray at sonology.net (Murray) Date: Thu Jun 5 19:30:02 2008 Subject: [Haskell-cafe] Analysing music In-Reply-To: <20080606005003.295b5862@solaris> References: <20080605202753.139c8acc@solaris> <20080606005003.295b5862@solaris> Message-ID: <200806052337.m55NbLVg008663@fiennes-ds.lumison.net> > What I need is basically one view of the data as list of used chords, > and one graph of all possible time-linear progressions... that is, > voices, for a definition of "voice" that makes the guitarist in me > shudder. > > Seems like I'm going to make close acquaintance with fgl, after all. Sorry if this is too far off-topic but have you seen this? http://music.princeton.edu/~dmitri/ I?ve yet to dig into the paper but it looks kind of fun. Clarence Barlow has an interesting algorithm for generating stochastic musical data with ?harmonicity? being one of the parameters. It is implemented in an Atari ST (there?s *got* to be a better way!) programme called Autobusk . ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~ Open your ears and your mind will follow. ~ ~ - www.sonology.net - ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From ajb at spamcop.net Thu Jun 5 20:40:43 2008 From: ajb at spamcop.net (ajb@spamcop.net) Date: Thu Jun 5 20:33:15 2008 Subject: [Haskell-cafe] How would you hack it? In-Reply-To: <48483FF3.4070908@btinternet.com> References: <4846DFDC.5020905@btinternet.com> <48470014.4000804@btinternet.com> <79F4406C-52CA-4467-9826-8819E3D8DEE3@phaedrusdeinus.org> <48483FF3.4070908@btinternet.com> Message-ID: <20080605204043.h0ikeqi9s0s8s84o-nwo@webmail.spamcop.net> G'day. Quoting Andrew Coppin : > Right. So a "Markov chain" is actually a technical way of describing > something that's intuitively pretty obvious? (E.g., PPM compression > works by assuming that the input data is some sort of Markov chain with > as-yet unknown transition probabilities.) Yes. In fact, DMC compression (which has been proven to be the same thing as PPM up to isomorphism) explicitly uses a Markov model. If you're curious, I recently put some code for building dynamic Markov models here. It's not pretty, but you might find it useful: http://andrew.bromage.org/darcs/dynamicmarkov/ Cheers, Andrew Bromage From barsoap at web.de Thu Jun 5 21:59:27 2008 From: barsoap at web.de (Achim Schneider) Date: Thu Jun 5 21:52:12 2008 Subject: [Haskell-cafe] Re: Analysing music References: <20080605202753.139c8acc@solaris> <20080606005003.295b5862@solaris> <200806052337.m55NbLVg008663@fiennes-ds.lumison.net> Message-ID: <20080606035927.53b97951@solaris> Murray wrote: > > What I need is basically one view of the data as list of used > > chords, and one graph of all possible time-linear progressions... > > that is, voices, for a definition of "voice" that makes the > > guitarist in me shudder. > > > > Seems like I'm going to make close acquaintance with fgl, after all. > > Sorry if this is too far off-topic but have you seen this? > For the cafe, yes. Follow up to gmane.comp.lang.haskell.backstage, please ;) > http://music.princeton.edu/~dmitri/ > > I?ve yet to dig into the paper but it looks kind of fun. > It looks... mathematical. It also looks strikingly right, I just spend a good quarter hour staring at the diagram and currently try to convince my visualisation that the geometry is possible. The key points to look out for are the diagonal lines featuring the same numbers, vertical lines featuring series and where (_,n) changes into (n,_), to get the mind accept the m?biusness. I could show you why it's mirrored and twisted around the tritone using a guitar and gnuplot, but I won't spoil the fun. Just observe that you can easily play a flageolet on the 5th, 7th and 12th fret but not on the 6th. Western music is defined by fifth and fourths. It's all wave mechanics, especially this darn problem of merging a linear scale to a logarithmic one and trying to make sense while doing such an insane thing. > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ~ Open your ears and your mind will follow. ~ > ~ - www.sonology.net - ~ > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > You listen too much Stockhausen. -- (c) this sig last receiving data processing entity. Inspect headers for past copyright information. All rights reserved. Unauthorised copying, hiring, renting, public performance and/or broadcasting of this signature prohibited. From ninegua at gmail.com Thu Jun 5 22:40:51 2008 From: ninegua at gmail.com (Paul L) Date: Thu Jun 5 22:33:21 2008 Subject: [Haskell-cafe] Re: What is the maturity of Haskell Web Frameworks In-Reply-To: References: <856033f20806041930t7499bda6n394938086ce38ecd@mail.gmail.com> Message-ID: <856033f20806051940y5feee0c6lbf5ed1696f91d845@mail.gmail.com> Thank you guys for all the good references! To address a few concerns with this approach: 1. By stateless I don't mean to strip away any persistency. The program can access file storage or DBMS just like any ordinary I/O operation. 2. If we take it to the extreme side, the entire program including its bytecode and all runtime data are in the page itself. The server is really just a VM to execute it to the next step. Security is a concern, but with proper cryptographic measures (e.g., a digitally signed hash for integrity check) I don't think it's any less secure (or insecure?) than existing web application frameworks. 3. The extreme scenario is perhaps not very practical, but still a nice abstraction and a start point to optimize. For example, program bytecode can just be its version number, which is matched against a code repository on the server side to retrieve. 4. As for cryptic URIs, well, I don't think it's a real problem. URIs meaningful to the users are often just starting point for a task flow. URIs that refers to somewhere in the middle of a task flow are often not meant to be readable anyway. Per-login-session data can be stuffed into the cookies and remain invisible. Any sizeable chunk of data should be handled as form data anyway. So what's left are the small pieces that gets attached to URIs, they are pretty harmless if you ask me. 5. I for one do not think multi-user scenario is that much harder as I was a MMOG developer. Sure, transactional behavior should be in place to ensure correctness, but user to user interactions aren't very complex for web applications to begin with. If they are, probably web aren't the most suitable platform. I took a quick look at the WASH paper, and the iData paper, and visited Seaside's website. They are all very relevant, which at least says something about a common vision. I'll just quote it from Seaside's about page: "Unlike servlet models which require a separate handler for each page or request, Seaside models an entire user session as a continuous piece of code, with natural, linear control flow." -- Regards, Paul Liu Yale Haskell Group http://www.haskell.org/yale From asumu at cyberberry.com Fri Jun 6 00:33:30 2008 From: asumu at cyberberry.com (Asumu Takikawa) Date: Fri Jun 6 00:26:14 2008 Subject: [Haskell-cafe] Vancouver Haskell users meeting In-Reply-To: <48444E7C.7050602@moonloop.net> References: <48444E7C.7050602@moonloop.net> Message-ID: <20080606043330.GA3478@cyberberry.com> Hi. I'd be interested in a meeting like this, but unfortunately since UBC is done for winter term I'm out of Canada for the summer. If anyone organizes a meet-up come fall I'd happily attend. Cheers, AT On 12:48 Mon 02 Jun , Jon Strait wrote: > Anyone else here from Vancouver (Canada)? I thought it would be great > to have a little informal get-together at a local cafe and share how > we're currently using Haskell, or really anything (problems, > comparisons, useful software tools, etc.) in relation to Haskell. > I'm scheduling a meeting for this Thursday, June 5th. for 7PM at > [1]Waazubee Cafe. (At Commercial Dr. and 1st Ave.) > They have wireless internet access. I'll get a table near the back, > bring my laptop, and will have a copy of Hudak's SOE book (the front > cover is impossible to miss) out on the table. > If anyone wants to meet, but this Thursday is not a good day for you, > let me know what days are better and we'll move the meeting. If anyone > is sure that they will come this Thursday, you might let me know, so I > can have an idea about the resistance in changing the day, if needed. > Thanks, > Jon > > References > > 1. http://www.waazubee.com/content/directions.php > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: Digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080605/5de6310d/attachment.bin From vigalchin at gmail.com Fri Jun 6 05:06:19 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Fri Jun 6 04:58:49 2008 Subject: [Haskell-cafe] example of FFI FunPtr In-Reply-To: <5ae4f2ba0806060008i659a3e16yb179e94cf32ee8ab@mail.gmail.com> References: <5ae4f2ba0806050038k1e0aea1exe6d81b22b1151eeb@mail.gmail.com> <4847B025.8030800@goto10.org> <5ae4f2ba0806060008i659a3e16yb179e94cf32ee8ab@mail.gmail.com> Message-ID: <5ae4f2ba0806060206v6a1b2385vee642df8ccaa01de@mail.gmail.com> Hi Claude, I want to do an incremental "experiment". I want just want to pass a C function to "callback" to a Haskell function. ??? Thanks, Vasili On Thu, Jun 5, 2008 at 4:21 AM, Claude Heiland-Allen < claudiusmaximus@goto10.org> wrote: > Galchin, Vasili wrote: > >> Hello, >> >> I want to model a Haskell function that is a callback from C. I have >> only found one example in the unix package's Semaphore.hsc, which >> apparently >> is not used. I want to be able to marshall a Haskell function that is a >> first class citizen residing in a Haskell data type and pass to a C >> function >> via FFI. Are there examples of this? >> > > Attached is a simple example. > > The main thing to note is 'foreign import ccall "wrapper"' which gives you > a factory for turning Haskell functions into foreign function pointers. > > More information: > > http://www.cse.unsw.edu.au/~chak/haskell/ffi/ > > > Claude > -- > http://claudiusmaximus.goto10.org > > > CallBacker: CallBacker.hs callerback.c callerback.h > ghc -O2 -Wall -fffi -o CallBacker CallBacker.hs callerback.c > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080606/6e62760e/attachment.htm From g9ks157k at acme.softbase.org Fri Jun 6 08:12:23 2008 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Fri Jun 6 08:04:59 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> Message-ID: <200806061412.23585.g9ks157k@acme.softbase.org> Am Donnerstag, 5. Juni 2008 17:19 schrieb Johan Tibell: > [?] > 2. It's the default. You have to add "qualified" to all your imports > to make them qualified. In most language imports are qualified by > default. I think the latter would have been a better choice but we > have to live with the current design so bite the bullet and add those > qualified keywords to your imports. If you leave out ?qualified?, you still get the qualified names imported. And if you use conflicting identifiers always qualified then there?s no problem. For example, you can use import Data.Set as Set import Data.List as List and then just say Set.null or List.null. > [?] > * Summary > > Whenever you write a library design it so it works well with qualified > imports. That means leaving namespacing issues to the module system. > Try to think of how code using your functions will look like if it > uses them qualified. I totally agree. > [?] Best wishes, Wolfgang From aruiz at um.es Fri Jun 6 08:36:08 2008 From: aruiz at um.es (Alberto Ruiz) Date: Fri Jun 6 08:28:37 2008 Subject: [Haskell-cafe] Patrick Perry's BLAS package Message-ID: <48492F38.3070107@um.es> Hello all, I have just noticed that yesterday this fantastic package has been uploaded to hackage: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/blas-0.4 We finally have a high quality library for numeric linear algebra. This is very good news for the Haskell community. Patrick, many thanks for your excellent work. Do you have similar plans for LAPACK? Alberto From jmaessen at alum.mit.edu Fri Jun 6 08:47:02 2008 From: jmaessen at alum.mit.edu (Jan-Willem Maessen) Date: Fri Jun 6 08:39:34 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: <200806061412.23585.g9ks157k@acme.softbase.org> References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <200806061412.23585.g9ks157k@acme.softbase.org> Message-ID: On Jun 6, 2008, at 8:12 AM, Wolfgang Jeltsch wrote: > Am Donnerstag, 5. Juni 2008 17:19 schrieb Johan Tibell: >> [?] > >> 2. It's the default. You have to add "qualified" to all your imports >> to make them qualified. In most language imports are qualified by >> default. I think the latter would have been a better choice but we >> have to live with the current design so bite the bullet and add those >> qualified keywords to your imports. > > If you leave out ?qualified?, you still get the qualified names > imported. And > if you use conflicting identifiers always qualified then there?s no > problem. > For example, you can use > > import Data.Set as Set > import Data.List as List > > and then just say Set.null or List.null. There's one caveat: Always choose descriptive names, even if you are assuming that you will usually use a qualified import. The following are wonderful names, even though they conflict with the prelude: null filter map lookup The following are terrible names: T C What's a T? What's a C? There's no excuse to give something a lousy name just because the enclosing module is descriptively named. I reject the naming conventions used by ML modules when writing Haskell code: Haskell modules are not ML modules. -Jan-Willem Maessen From barsoap at web.de Fri Jun 6 10:57:07 2008 From: barsoap at web.de (Achim Schneider) Date: Fri Jun 6 10:49:45 2008 Subject: [Haskell-cafe] Re: Design your modules for qualified import References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <200806061412.23585.g9ks157k@acme.softbase.org> Message-ID: <20080606165707.43133d30@solaris> Jan-Willem Maessen wrote: > On Jun 6, 2008, at 8:12 AM, Wolfgang Jeltsch wrote: > > > Am Donnerstag, 5. Juni 2008 17:19 schrieb Johan Tibell: > >> [?] > > > >> 2. It's the default. You have to add "qualified" to all your > >> imports to make them qualified. In most language imports are > >> qualified by default. I think the latter would have been a better > >> choice but we have to live with the current design so bite the > >> bullet and add those qualified keywords to your imports. > > > > If you leave out ?qualified?, you still get the qualified names > > imported. And > > if you use conflicting identifiers always qualified then there?s > > no problem. > > For example, you can use > > > > import Data.Set as Set > > import Data.List as List > > > > and then just say Set.null or List.null. > > There's one caveat: Always choose descriptive names, even if you are > assuming that you will usually use a qualified import. The > following are wonderful names, even though they conflict with the > prelude: null > filter > map > lookup > import Prelude as P > The following are terrible names: > T > C > Not to mention that this usage is hideously confusing while looking at the haddock docs. While I don't mind Haskore having them, they should just be different names for a type that has a clear name. It also appears to generate an excessive amount of modules. -- (c) this sig last receiving data processing entity. Inspect headers for past copyright information. All rights reserved. Unauthorised copying, hiring, renting, public performance and/or broadcasting of this signature prohibited. From lemming at henning-thielemann.de Fri Jun 6 12:54:29 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri Jun 6 12:42:59 2008 Subject: [Haskell-cafe] Re: Design your modules for qualified import In-Reply-To: <20080606165707.43133d30@solaris> References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <200806061412.23585.g9ks157k@acme.softbase.org> <20080606165707.43133d30@solaris> Message-ID: On Fri, 6 Jun 2008, Achim Schneider wrote: > Jan-Willem Maessen wrote: > > > There's one caveat: Always choose descriptive names, even if you are > > assuming that you will usually use a qualified import. The > > following are wonderful names, even though they conflict with the > > prelude: null > > filter > > map > > lookup > > > import Prelude as P > > > The following are terrible names: > > T > > C > > Not to mention that this usage is hideously confusing while looking at > the haddock docs. But that will be resolved when Haddock can show identifiers with qualifications. > While I don't mind Haskore having them, they should just be different > names for a type that has a clear name. It also appears to generate an > excessive amount of modules. It's good to have fine grained modules, because you can more easily exchange the parts you want different from the standard way. For reducing import lists for simple songs I think we could provide wrapper modules. From duncan.coutts at worc.ox.ac.uk Fri Jun 6 14:15:32 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Fri Jun 6 14:04:30 2008 Subject: [Haskell-cafe] ANNOUNCE: Cabal-1.4 release candidate Message-ID: <1212776132.15010.383.camel@localhost> Hi everyone, == Cabal-1.4 release candidate == The second release candidate of Cabal-1.4 is out: http://haskell.org/cabal/download.html Please test and report bugs: http://hackage.haskell.org/trac/hackage/ The aim for the Cabal-1.4 release is to get various fixes and improvements into the hands of developers and to support a release of cabal-install. == cabal-install == A snapshot of cabal-install is also available: http://haskell.org/cabal/download.html It requires the zlib and HTTP packages (both are available from hackage). Bug reports should go in the same trac as above. cabal-install is intended to be the standard command line interface to the whole Cabal/Hackage system. It replaces the "runhaskell Setup.hs" interface and a few other tools you may or may not have heard of (cabal-setup, cabal-upload, cabal-get). cabal-install is usable now and we will be making a proper release some time after the Cabal-1.4 release. == Testing == We are particularly interested in finding regressions from Cabal-1.2.x or any important fixes that will require API changes since once we release 1.4 we have to maintain API compatibility for the rest of the 1.4.x series. This is also an excellent opportunity to make sure your favourite bug or feature request is properly described in our bug tracker: http://hackage.haskell.org/trac/hackage/ To help us guide development priorities please add yourself to the ticket's cc list and describe why that bug or feature is important to you. == Compatibility == We have tried to preserve compatibility with all packages that worked with the Cabal-1.2.x series. That is, packages that can be built using Cabal (including custom Setup.hs scripts) but not packages that directly import and use the Cabal API. Packages that directly import and use the Cabal api will need updating. This affects packages that build distro packages for example, rpm debs etc. Currently we know of only one package on hackage which has a Setup.hs script that compiles with 1.2 but fail to compile with 1.4. Takusen, will require an update to be able to work with both Cabal-1.2.x and 1.4.x. A patch has been sent to the maintainers of Takusen. == Credits == On behalf of the Cabal hackers and the community generally I'd like to thank the large number of people who have contributed patches during this development series. Previously I was rather worried that we were not getting enough contributors to fix bugs and do new feature development, but now I'm very pleased. :-) == Get involved == Of course there's still a lot to do! We have big plans for Cabal-2.0, cabal-install and the Hackage website. So if you're interested in helping out with this core infrastructure project then: * subscribe to the cabal-devel mailing list: http://www.haskell.org/mailman/listinfo/cabal-devel * grab the source: http://haskell.org/cabal/code.html * read the guide to the source code: http://hackage.haskell.org/trac/hackage/wiki/SourceGuide * take a look at our list of bugs and feature requests: http://hackage.haskell.org/trac/hackage/report/12 especially the easy tickets: http://hackage.haskell.org/trac/hackage/report/13 Duncan (wearing his Cabal release manager hat) From patperry at stanford.edu Fri Jun 6 14:56:00 2008 From: patperry at stanford.edu (Patrick Perry) Date: Fri Jun 6 14:48:43 2008 Subject: [Haskell-cafe] Re: Patrick Perry's BLAS package In-Reply-To: <48492F38.3070107@um.es> References: <48492F38.3070107@um.es> Message-ID: Wow, thanks for noticing, Alberto! For anyone interested, I put up a formal announcement describing the bindings a little bit here: http://quantile95.com/ I just registered the domain yesterday, so it may take a few days to resolve the DNS magic. Here's the text of the announcement: I?m really happy that people seem to be interested in the library. Alberto, in particular, is the primary author of hmatrix, another haskell linear algebra library (which I stole a few ideas from), so if he endorses it, that means a lot to me. So, Yet Another Linear Algebra Library? I?ve already mentioned hmatrix. There?s also another one called HBlas. Why would anyone want a third? Here are my reasons: * Support for both immutable and mutable types. Haskell tries to make you use immutable types as much as possible, and indeed there is a very good reason for this, but sometimes you have a 100MB matrix, and it just isn?t very practical to make a copy of it every time you modify it. hmatrix only supports immutable types, and HBlas only supports mutable ones. I wanted both. * Access control via phantom types. When you have immutable and mutable types, it?s very annoying to have separate functions for each type. Do I want to have to call ?numCols? for immutable matrices and ?getNumCols? for mutable ones, even though both functions are pure, and both do exactly the same thing? No. If I want to add an immutable matrix to a mutable one, to I want to first call ?unsafeThaw? on the immutable one to cast it to be mutable? No. With the phantom type trick, you can get around this insanity. Jane Street Capital has a very good description of how this works. * Phantom types for matrix and vector shapes. This is a trick I learned from darcs. It means that the compiler can catch many dimension-mismatch mistakes. So, for instance, a function like foo :: (BLAS1 e) => Matrix (m,n) e -> Matrix (n,k) e -> Int -> Vector m e foo a b i = let x = row b i in a <*> x will not type-check. (?<*>? is the function to multiply a matrix by a vector. Everything is ok if you replace ?row? by ?col?.) This feature has caught a few bugs in my code. * Taking the conjugate transpose (?herm?) of a matrix is an O(1) operation. This is similar to hmatrix, where taking the transpose is O(1). As BLAS and LAPACK (mostly) support this, it makes no sense to copy a matrix just to work with the conjugate transpose. Why conjugate transpose instead of just transpose? Because the former is a far more common operation. This is why the ??? operator in MATLAB is conjugate transpose. The drawback for this feature is that BLAS and LAPACK do not support it everywhere. In particular, QR decomposition with pivoting is going to be a huge pain in the ass to support for herm-ed matrices. * Support for triangular and hermitian views of matrices. This is a feature of BLAS that no one seems to support (not even MATLAB). In addition to the ?Matrix? type, there are ?Tri Matrix? and ?Herm Matrix? types that only refer to the upper- or lower-triangular part of the matrix. Hopefully the features above are compelling enough to make people want to use the library. These bindings have been a lot of work. For me to come up with the feature list above, I?ve already gone through a few iterations of dramatic re-writes (hence the version number). Of course, I always welcome suggestions for how to make it better. What?s next? In the immediate future, I plan to add banded matrices. I?ve already written a good chunk of code for this, but it isn?t very well tested, so I decided to leave it out of the release. I?m also going to add permutation matrices. I don?t have plans to add support for packed triangular matrices, but if someone else wanted to do that, I would be happy to include it. The same goes for symmetric complex matrices. LAPACK support is on the horizon, but that may take awhile. Also, I probably won?t do more than SVD, QR, and Cholesky, since those are all I need. Expect a preliminary announcement by the end of the summer. This work would not have been possible without looking at the other excellent linear algebra libraries out there. In particular the GNU Scientific Library was the basis for much of the design. I also drew inspiration from hmatrix and the haskell array libraries. Please let me know if you have any success in using the library, and if you have any suggestions for how to make it better. Patrick On Jun 6, 2008, at 5:36 AM, Alberto Ruiz wrote: > Hello all, > > I have just noticed that yesterday this fantastic package has been > uploaded to hackage: > > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/blas-0.4 > > We finally have a high quality library for numeric linear algebra. > This is very good news for the Haskell community. > > Patrick, many thanks for your excellent work. Do you have similar > plans for LAPACK? > > Alberto From xj2106 at columbia.edu Fri Jun 6 16:22:31 2008 From: xj2106 at columbia.edu (Xiao-Yong Jin) Date: Fri Jun 6 16:19:02 2008 Subject: [Haskell-cafe] Re: Patrick Perry's BLAS package In-Reply-To: (Patrick Perry's message of "Fri, 6 Jun 2008 11:56:00 -0700") References: <48492F38.3070107@um.es> Message-ID: <87prquxqig.fsf@columbia.edu> (Sorry, Patrick. I forgot to CC haskell-cafe.) Salute! Excellent! Patrick Perry writes: > Wow, thanks for noticing, Alberto! For anyone interested, I put up a > formal announcement describing the bindings a little bit here: > > http://quantile95.com/ > > I just registered the domain yesterday, so it may take a few days to > resolve the DNS magic. Here's the text of the announcement: > The magic is working, now. > > I?m really happy that people seem to be interested in the > library. Alberto, in particular, is the primary author of hmatrix, > another haskell linear algebra library (which I stole a few ideas > from), so if he endorses it, that means a lot to me. > > So, Yet Another Linear Algebra Library? I?ve already mentioned > hmatrix. There?s also another one called HBlas. Why would anyone want > a third? Here are my reasons: > > * Support for both immutable and mutable types. Haskell tries > to make you use immutable types as much as possible, and indeed there > is a very good reason for this, but sometimes you have a 100MB > matrix, and it just isn?t very practical to make a copy of it every > time you modify it. hmatrix only supports immutable types, and HBlas > only supports mutable ones. I wanted both. I didn't use hmatrix a lot, because I wrote some STUArray things and I wasn't sure what to do with that. However, I just noticed that there is a bunch of ST growing under Data.Packed in hmatrix. Guess things is going to change, soon. And perhaps with your work, Alberto doesn't need to reinvent the wheel anymore. > > * Access control via phantom types. When you have > immutable and mutable types, it?s very annoying to have > separate functions for each type. Do I want to have to > call ?numCols? for immutable matrices and ?getNumCols? for > mutable ones, even though both functions are pure, and > both do exactly the same thing? No. If I want to add an > immutable matrix to a mutable one, to I want to first call > ?unsafeThaw? on the immutable one to cast it to be > mutable? No. With the phantom type trick, you can get > around this insanity. Jane Street Capital has a very good > description of how this works. Lovely! > * Phantom types for matrix and vector shapes. This is a > trick I learned from darcs. It means that the compiler can > catch many dimension-mismatch mistakes. So, for instance, > a function like foo :: (BLAS1 e) => Matrix (m,n) e -> > Matrix (n,k) e -> Int -> Vector m e foo a b i = let x = > row b i in a <*> x will not type-check. (?<*>? is the > function to multiply a matrix by a vector. Everything is > ok if you replace ?row? by ?col?.) This feature has caught > a few bugs in my code. If I understand this correctly, the compiler can catch dimension mismatches so that using `col' will result in a compilation error when m and k are different, is it so? > > LAPACK support is on the horizon, but that may take awhile. Also, I > probably won?t do more than SVD, QR, and Cholesky, since those are all > I need. Expect a preliminary announcement by the end of the summer. > > This work would not have been possible without looking at the other > excellent linear algebra libraries out there. In particular the GNU > Scientific Library was the basis for much of the design. I also drew > inspiration from hmatrix and the haskell array libraries. > > Please let me know if you have any success in using the library, and > if you have any suggestions for how to make it better. I haven't look through the code, yet. But it looks like there are certain levels of similarities between blas and hmatrix. Is it possible for these two libraries to cooperate well with each other? (I didn't look at HBlas, so can't say much about that.) Apart from some warnings, the library compiles fine in my system. But there is a minor issue about the library it links against when `./Setup test'. I need to use `-lcblas' instead of `-lblas' to get it to link to correct libraries. I don't know other people's system. But in my system, Gentoo Linux, I use blas library provided by atlas, and libblas.so is a fortran library and libcblas.so is for C. All in all, good job. Thanks. Xiao-Yong -- c/* __o/* <\ * (__ */\ < From jmaessen at alum.mit.edu Fri Jun 6 16:35:16 2008 From: jmaessen at alum.mit.edu (Jan-Willem Maessen) Date: Fri Jun 6 16:27:49 2008 Subject: [Haskell-cafe] Re: Design your modules for qualified import In-Reply-To: References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <200806061412.23585.g9ks157k@acme.softbase.org> <20080606165707.43133d30@solaris> Message-ID: <243AABC8-0311-4C50-BC98-563440F96DB2@alum.mit.edu> On Jun 6, 2008, at 12:54 PM, Henning Thielemann wrote: > > On Fri, 6 Jun 2008, Achim Schneider wrote: > >> Jan-Willem Maessen wrote: >> >>> There's one caveat: Always choose descriptive names, even if you are >>> assuming that you will usually use a qualified import. The >>> following are wonderful names, even though they conflict with the >>> prelude: null >>> filter >>> map >>> lookup >>> >> import Prelude as P Precisely. If I import the prelude qualified and your library unqualified, is my code readable? I should hope it is. And if the library used the overlapping names reasonably, you shouldn't be left wondering when you read my code. >>> The following are terrible names: >>> T >>> C >> >> Not to mention that this usage is hideously confusing while looking >> at >> the haddock docs. > > But that will be resolved when Haddock can show identifiers with > qualifications. I specifically *didn't* bring up the Haddock issue, because I think it's a side show. Fundamentally, these types are neither clear nor descriptive. Their treatment by one or another documentation tool is, at some level, beside the point. > It's good to have fine grained modules, because you can more easily > exchange the parts you want different from the standard way. For > reducing > import lists for simple songs I think we could provide wrapper > modules. Make your modules as small as you like; small modules are great. But keep things readable, please! -Jan > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From himself at poczta.nom.pl Fri Jun 6 17:48:29 2008 From: himself at poczta.nom.pl (Andrzej Jaworski) Date: Fri Jun 6 16:44:42 2008 Subject: [Haskell-cafe] Patrick Perry's BLAS package Message-ID: <002101c8c81f$6b3d9b00$e9d54c59@bzdryk> Hi, Indeed, this has been long awaited. Long live Patrick!!! And continue the good work:-) However, such essential work shouldn't be dependent on heroic effort of an individual. If Haskell is to remain non-commercial a disciplined community effort should be taken akin to Pythonian. Perhaps also thouse of you who teach Haskell could better use cheap labour of students, after all Haskell's module system is not all that weak;-) Cheers, -A.J. From ko at daimi.au.dk Fri Jun 6 18:41:07 2008 From: ko at daimi.au.dk (Klaus Ostermann) Date: Fri Jun 6 18:33:36 2008 Subject: [Haskell-cafe] Question about kinds Message-ID: <17701553.post@talk.nabble.com> Why does the code below not pass the type checker? If I could explictly parameterize y with the type constructor Id (as e.g. in System F), then 'y Id' should have the type Int -> Int and hence "y Id x" should be OK, but with Haskell's implicit type parameters it does not work. So, how can I make this work? Klaus ------------ type Id a = a x :: Id Int x = undefined y :: (a Int) -> (a Int) y = undefined test = y x Error: Couldn't match expected type `a Int' against inferred type `Id Int' In the first argument of `y', namely `x' In the expression: y x In the definition of `test': test = y x -- View this message in context: http://www.nabble.com/Question-about-kinds-tp17701553p17701553.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From patperry at stanford.edu Fri Jun 6 18:45:47 2008 From: patperry at stanford.edu (Patrick Perry) Date: Fri Jun 6 18:38:36 2008 Subject: [Haskell-cafe] Re: Patrick Perry's BLAS package In-Reply-To: <87prquxqig.fsf@columbia.edu> References: <48492F38.3070107@um.es> <87prquxqig.fsf@columbia.edu> Message-ID: > >> >> a function like foo :: (BLAS1 e) => Matrix (m,n) e -> >> Matrix (n,k) e -> Int -> Vector m e foo a b i = let x = >> row b i in a <*> x will not type-check. (?<*>? is the >> function to multiply a matrix by a vector. Everything is >> ok if you replace ?row? by ?col?.) This feature has caught >> a few bugs in my code. > > If I understand this correctly, the compiler can catch > dimension mismatches so that using `col' will result in a > compilation error when m and k are different, is it so? Yes, the compiler infers the