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 type of expression to be Matrix(m,n) e -> Matrix (l,m) e -> Int -> Vector n e which is different from the declared type. The error will be something like "Expected type Vector m e, but got type Vector a1 e instead". > 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.) This is more work than you might think. The data structures are different, many of the function names are different, and the module namespaces overlap. I wouldn't recommend any switch from hmatrix to blas right now unless you really need mutable types-- hmatrix has a lot more linear algebra functionality. > 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. I don't know of a good way to get around this. It seems like every system has a different convention for the location and name of the cblas libraries. So, everyone has to edit the "extra-libraries" and the "extra-lib-dirs" field in the blas.cabal file. Does anyone know of a better way of doing this? Patrick -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080606/f5c2fa83/attachment.htm From dons at galois.com Fri Jun 6 22:32:18 2008 From: dons at galois.com (Don Stewart) Date: Fri Jun 6 22:24:50 2008 Subject: [Haskell-cafe] Patrick Perry's BLAS package In-Reply-To: <002101c8c81f$6b3d9b00$e9d54c59@bzdryk> References: <002101c8c81f$6b3d9b00$e9d54c59@bzdryk> Message-ID: <20080607023218.GA11462@scytale.galois.com> himself: > 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;-) > Yes, more libraries! 500 is not enough! The best thing anyone here can do for haskell is contribute a library. Latest packages: http://hackage.haskell.org/packages/archive/recent.html How to upload a package: http://www.haskell.org/haskellwiki/How_to_write_a_Haskell_program Join in! The more areas we cover with Haskell code, the easier the path is to ongoing development, and a viable, sustainable Haskell world. -- Don From derek.a.elkins at gmail.com Fri Jun 6 22:43:25 2008 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Fri Jun 6 22:35:58 2008 Subject: [Haskell-cafe] Question about kinds In-Reply-To: <17701553.post@talk.nabble.com> References: <17701553.post@talk.nabble.com> Message-ID: <1212806605.7306.31.camel@derek-laptop> On Fri, 2008-06-06 at 15:41 -0700, Klaus Ostermann wrote: > 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 Down this path is higher-order unification which is undecidable. You can use a newtype. From oddron at gmail.com Sat Jun 7 00:05:48 2008 From: oddron at gmail.com (Ronald Guida) Date: Fri Jun 6 23:58:16 2008 Subject: [Haskell-cafe] Teaching Monads Message-ID: <62728db30806062105t455382c4h503651d8427d6da0@mail.gmail.com> Monads in Haskell are a topic that I, like most beginners, find difficult and "mind-twisting". Now that I think I understand monads, they seem to be very simple; I've read that this is a common experience. So I wonder, what would it take to help beginners catch on with a minimum of fuss or frustration? The plethora of monad tutorials out there is clear evidence that plenty of others have wondered the same thing. What made monads "click" for me is when I understood the following things: 1. When monads are being used, closures are almost always involved. 2. These closures naturally arise when desugaring do-syntax. do x1 <- m1 m1 >>= (\x1 -> x2 <- m2 m2 >>= (\x2 -> [Eq1] x3 <- m3 m3 >>= (\x3 -> return (f x1 x2 x3) return (f x1 x2 x3)))) 3. These closures are extremely similar to the closures that arise when desugaring let-syntax. let x1 = f1 in f1 -$ (\x1 -> Where: let x2 = f2 in f2 -$ (\x2 -> (-$) :: a -> (a -> b) -> b let x3 = f3 in f3 -$ (\x3 -> x -$ f = f x f x1 x2 x3 f x1 x2 x3))) 4. While I can think of a monad as a fancy container that holds an element of type "t", it might be more accurate to think of a monad as a container that merely displays the type "t" as a label for its contents. The container might hold one object of type "t", or it might hold several. It might not be holding any at all. Perhaps the container /never/ holds an object of type "t", but instead it holds a set of instructions to produce such an object. (e.g. Reader, State). Naturally, it's hard to illustrate nested closures, higher-order functions, and objects that aren't really there. It's easy to illustrate a sequential scheme where a single "thing" passes through a series of operations, while some related data travels in parallel. m1 >>= f1 >>= f2 >>= f3 [Eq2] In any case, the extreme similarity between desugared "do" and desugared "let" leads me to think of the concepts of a manual plumbing system and a monadic plumbing system. Basically, a manual plumbing system is what I have if I'm threading information down through a series of nested function calls in a certain stereotypical way. A monadic plumbing system is what I get when I introduce the appropriate monad to encapsulate my threading. In fact, if I look at Wadler [*], there are three examples of an evaluator that use what I'm calling "manual plumbing". In section 2.5, the operations required of a monad (return, bind) pretty much just drop right out. Wadler even points out the similarity between "bind" and "let". Now that I finally "get it", I feel that the Wadler paper, section 2.5 in particular, is probably a better introduction than many of the monad tutorials out there. Moreover, I feel that for /some/ of the tutorials out there, they spend too much time and too many illustrations explaining things like [Eq2], and then they quickly present do-notation and gloss over [Eq1]. For me, I found that that the concepts of "manual plumbing" and "monadic plumbing" were key to actually grasping the Wadler paper and understanding what monads are. In particular, I feel that these two concepts might be a way to help other beginners catch on as well. OK, so before I attempt to write a monad tutorial based on "manual plumbing" and "monadic plumbing", I would like to know, does anyone else think this is a good idea? [*] "Monads for Functional Programming". (http://homepages.inf.ed.ac.uk/wadler/papers/marktoberdorf/baastad.pdf) From jstrait at moonloop.net Sat Jun 7 00:15:35 2008 From: jstrait at moonloop.net (Jon Strait) Date: Sat Jun 7 00:18:53 2008 Subject: [Haskell-cafe] Vancouver Haskell users meeting In-Reply-To: <20080606043330.GA3478@cyberberry.com> References: <48444E7C.7050602@moonloop.net> <20080606043330.GA3478@cyberberry.com> Message-ID: <484A0B67.9070108@moonloop.net> I'll try to keep this going. I think it's a good idea. See you in the fall! Jon Asumu Takikawa wrote: > 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 >> > > From andrewcoppin at btinternet.com Fri Jun 6 14:35:00 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sat Jun 7 01:33:13 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> Message-ID: <48498354.5030506@btinternet.com> Johan Tibell wrote: > * Why is this practice common in Haskell > > Here are some guesses: > > 1. It's common in papers. Maybe. > 2. It's the default. > Probably not. > 3. Lack of common interfaces. > Yes. It's really quite frustrating that it is 100% impossible to write a single function that will process lists, arrays, sets, maps, byte strings, etc. You have to write several different versions. OK, so some functions really don't make sense for a set because it's unordered, and some functions don't make sense for a map, and so forth. But for example, if I write some complicated algorithm that uses a list to store data and I change that to a set instead, I now have to wade through the function changing every operation from a list-op into a set-op. It's really very annoying! The problem - as I'm sure everybody is well aware - is that it's rather hard to come up with a type system formulation that works even though lists and arrays can store everything, unboxed arrays can only store types X, Y and Z, sets and maps require ordered data, byte strings only store bytes, and so on and so forth. > 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. > 5. Writing "Hello" Prelude.++ "World" is just ugly. ;-) In addition, I feel I should point out that only *very* recently did I discover that it is in fact possible to import a module qualified and still be able to refer to it easily. What do I mean by that? Well, suppose I do import Text.ParserCombinators.Parsec I do *not* want to have to write "Text.ParserCombinators.Parsec.runParser"!! Until very recently, it was not at all clear to me that there is actually a very simple solution to this problem: import Text.ParserCombinators.Parsec as P Now I only have to write "P.runPaser", which is much shorter. This fact probably needs to be mentioned more loudly - I'm sure I'm not the only person to have overlooked it... From ajb at spamcop.net Sat Jun 7 02:45:43 2008 From: ajb at spamcop.net (ajb@spamcop.net) Date: Sat Jun 7 02:38:11 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <200806061412.23585.g9ks157k@acme.softbase.org> Message-ID: <20080607024543.52z9hkmgz4s8o4g8-nwo@webmail.spamcop.net> G'day all. Quoting Jan-Willem Maessen : > 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 On the contrary, these are terrible names _because_ they conflict with the Prelude. Especially "map", for which there's no excuse. If it does the obvious thing, it's far better to define a real Functor instance. It's okay if you highly encourage or effectively mandate qualified import, like Data.Map does. However, unlike Data.Map, if you do that then please don't define any operators. Requiring someone to type m M.! k is just wrong. Cheers, Andrew Bromage From lrpalmer at gmail.com Sat Jun 7 02:50:42 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Sat Jun 7 02:43:13 2008 Subject: [Haskell-cafe] Question about kinds In-Reply-To: <17701553.post@talk.nabble.com> References: <17701553.post@talk.nabble.com> Message-ID: <7ca3f0160806062350w2893d5f6p580cbf0d167a0c85@mail.gmail.com> On Fri, Jun 6, 2008 at 4:41 PM, Klaus Ostermann wrote: > type Id a = a > > x :: Id Int > x = undefined > > y :: (a Int) -> (a Int) > y = undefined In "a Int", "a" refers to any type constructor, not any type function. So the best you can do is: newtype Id a = Id a -- rest as before Luke From devriese at cs.tcd.ie Sat Jun 7 04:41:46 2008 From: devriese at cs.tcd.ie (Edsko de Vries) Date: Sat Jun 7 04:34:17 2008 Subject: [Haskell-cafe] Question about kinds In-Reply-To: <17701553.post@talk.nabble.com> References: <17701553.post@talk.nabble.com> Message-ID: <20080607084146.GA17111@netsoc.tcd.ie> On Fri, Jun 06, 2008 at 03:41:07PM -0700, Klaus Ostermann wrote: > > 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. The type of 'Id' is expanded to simply 'Int', and 'Int' does not unify with 'm a' for any type constructor 'm': Haskell's type level functions are always unevaluated (type synonyms don't count: they are always expanded). So, if you wanted to to this, you'd need to do newtype Id a = Id a Of course, now your values need to be tagged as well. Edsko From ryani.spam at gmail.com Sat Jun 7 04:50:37 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Sat Jun 7 04:43:06 2008 Subject: [Haskell-cafe] Question about kinds In-Reply-To: <17701553.post@talk.nabble.com> References: <17701553.post@talk.nabble.com> Message-ID: <2f9b2d30806070150s373fe21w421460aad3c6c1e0@mail.gmail.com> "type" declarations are not first-class; treat them more like macro expansions. In particular, you cannot make a function polymorphic over a type declaration. You can make this typecheck using a "data" or "newtype" declaration for Id: newtype Id x = Identity x (or) data Id x = Identity x You do need to wrap/unwrap the "Identity" constructor then. -- ryan On Fri, Jun 6, 2008 at 3:41 PM, Klaus Ostermann wrote: > > 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 From slavomir.kaslev at gmail.com Sat Jun 7 05:26:17 2008 From: slavomir.kaslev at gmail.com (Slavomir Kaslev) Date: Sat Jun 7 05:18:48 2008 Subject: [Haskell-Cafe] Quick question for a slow program Message-ID: <171dfd0a0806070226k7ad4ceaal4cdb4a0892e43519@mail.gmail.com> Hello, I was just brushing my haskell-fu skills writing a solution for Google Treasure Hunt Problem 4. Hers is what it looks like: > primes = sieve [2..] > where > sieve (p:xs) = p : sieve [x | x <- xs, x `mod` p /= 0] > > sumOf n l = sum (take n l) : sumOf n (tail l) > > find l = foldl1 aux l > where > aux (x:xs) (y:ys) | x == y = x : aux xs ys > | x < y = aux xs (y:ys) > | x > y = aux (x:xs) ys > > puzzle = find (reverse [primes, p7, p17, p41, p541]) > where > p7 = sumOf 7 primes > p17 = sumOf 17 primes > p41 = sumOf 41 primes > p541 = sumOf 541 primes > > main = do mapM (\x -> putStrLn $ show x) puzzle While the code is quite readable and straight forward it is as slow as tortoise with four legs broken. What optimizations would you suggest, while still keeping the code clear and highlevel? Thank you in advance. Cheers. -- Slavomir Kaslev From claus.reinke at talk21.com Sat Jun 7 05:38:10 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Sat Jun 7 05:30:45 2008 Subject: [Haskell-cafe] Question about kinds References: <17701553.post@talk.nabble.com> Message-ID: <007101c8c882$349ce3e0$f20a8351@cr3lt> short answer: use newtype instead of type (and check the language spec for the difference between the two). > Why does the code below not pass the type checker? because of the type error?-) seriously, though, it is useful to accompany such questions with some indication of what you're trying to do, to put a cap on the wide variety of possible answers (depending on what it is you're trying to achieve, there are many different techniques or tricks that might apply), and to have something to compare the non-working code against (also in case the intention needs to be edited before working code can be suggested). > 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. schemes that rely on implicit 'Id' tend to be doomed to failure in haskell and often suggest a need to get better acquainted with the limitations of haskell's type system (such schemes often arise from invalid generalisations of promising features, and many of us, myself included, have fallen into that trap at one point or other, often while working with type constructor classes): - type synonyms are syntactic macros, not part of the type system proper; the error message is a bit confusing by trying to be helpful (giving type synonym applications instead of their expansion: the type system has seen 'Int', not 'Id Int') - things of kind (* -> *) are type _constructors_, not arbitrary type functions - type families are a restricted kind of type function, but can only be applied forwards (F t1 ~> t2), not be inferred or abstracted over simplified, if the type system had to _infer_ 'Id' (or the composition of type constructors, a related favourite;-), it could do so anywhere, any number of times. in haskell's approach to this, programmers have to indicate where such things are meant to occur (eg, by using newtypes). hth, claus > 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. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From aruiz at um.es Sat Jun 7 06:19:28 2008 From: aruiz at um.es (Alberto Ruiz) Date: Sat Jun 7 06:12:09 2008 Subject: [Haskell-cafe] Re: Patrick Perry's BLAS package In-Reply-To: References: <48492F38.3070107@um.es> <87prquxqig.fsf@columbia.edu> Message-ID: <484A60B0.2090307@um.es> Patrick Perry wrote: > Xiao-Yong Jin wrote: >> 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. > > I don't know of a good way to get around this. It seems like every > system has a different convention for the location and name of the cblas > libraries. So, everyone has to edit the "extra-libraries" and the > "extra-lib-dirs" field in the blas.cabal file. Does anyone know of a > better way of doing this? > A possible solution is using flags in the cabal configuration file. For instance, I have this in hmatrix.cabal: if flag(mkl) if arch(x86_64) extra-libraries: gsl mkl_lapack mkl_intel_lp64 mkl_sequential mkl_core else extra-libraries: gsl mkl_lapack mkl_intel mkl_sequential mkl_core else extra-libraries: gsl blas lapack so if I want to link with Intel's MKL optimized blas/lapack instead of ATLAS I simply add the -fmkl flag: runhaskell Setup.lhs configure -fmkl etc. or even cabal install hmatrix -fmkl Other flags can be added to support different distributions. We could have something like cabal install package -ffedora or cabal install package -fcblas etc. Alberto From johan.tibell at gmail.com Sat Jun 7 06:31:46 2008 From: johan.tibell at gmail.com (Johan Tibell) Date: Sat Jun 7 06:24:14 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: <48498354.5030506@btinternet.com> References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <48498354.5030506@btinternet.com> Message-ID: <90889fe70806070331rdf4165bk440f4cf9f59084@mail.gmail.com> On Fri, Jun 6, 2008 at 8:35 PM, Andrew Coppin wrote: > import Text.ParserCombinators.Parsec as P > > Now I only have to write "P.runPaser", which is much shorter. Or maybe even > import Text.ParserCombinators.Parsec as Parser and then `Parser.run'. Having the module hierarchy be shallower so you don't have to add a `as' to every import might also help. I think Python does this better for common modules which have short and sweet name lite `system'. Cheers, Johan From dominic.steinitz at blueyonder.co.uk Sat Jun 7 06:59:20 2008 From: dominic.steinitz at blueyonder.co.uk (Dominic Steinitz) Date: Sat Jun 7 06:50:56 2008 Subject: [Haskell-cafe] Mersenne Build Problem Message-ID: <484A6A08.4020600@blueyonder.co.uk> I'm getting errors (see below) trying to build the tests in http://hackage.haskell.org/cgi-bin/hackage-scripts/package/mersenne-random-0.1.1 I built the package itself using ./Setup configure -f use_sse2 I thought I had an intel core duo (also see below). I think I may be missing a library but I'm not sure which one. Thanks, Dominic. > dom@lagrange:~/mersenne-random-0.1.1> cat /proc/cpuinfo > processor : 0 > vendor_id : GenuineIntel > cpu family : 6 > model : 15 > model name : Intel(R) Core(TM)2 Duo CPU E4500 @ 2.20GHz > stepping : 13 > cpu MHz : 1200.000 > cache size : 2048 KB > physical id : 0 > siblings : 2 > core id : 0 > cpu cores : 2 > fdiv_bug : no > hlt_bug : no > f00f_bug : no > coma_bug : no > fpu : yes > fpu_exception : yes > cpuid level : 10 > wp : yes > flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe lm constant_tsc pni monitor ds_cpl est tm2 ssse3 cx16 xtpr lahf_lm > bogomips : 4392.14 > clflush size : 64 > > processor : 1 > vendor_id : GenuineIntel > cpu family : 6 > model : 15 > model name : Intel(R) Core(TM)2 Duo CPU E4500 @ 2.20GHz > stepping : 13 > cpu MHz : 1200.000 > cache size : 2048 KB > physical id : 0 > siblings : 2 > core id : 1 > cpu cores : 2 > fdiv_bug : no > hlt_bug : no > f00f_bug : no > coma_bug : no > fpu : yes > fpu_exception : yes > cpuid level : 10 > wp : yes > flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe lm constant_tsc pni monitor ds_cpl est tm2 ssse3 cx16 xtpr lahf_lm > bogomips : 4388.99 > clflush size : 64 > dom@lagrange:~/mersenne-random-0.1.1/tests> make > ghc -O2 -ddump-simpl-stats -no-recomp Unit.hs --make > [1 of 1] Compiling Main ( Unit.hs, Unit.o ) > > ==================== FloatOut stats: ==================== > 154 Lets floated to top level; 35 Lets floated elsewhere; from 40 Lambda groups > > > > ==================== FloatOut stats: ==================== > 133 Lets floated to top level; 14 Lets floated elsewhere; from 34 Lambda groups > > > > ==================== Grand total simplifier statistics ==================== > Total ticks: 8378 > > 2022 PreInlineUnconditionally > 1760 PostInlineUnconditionally > 991 UnfoldingDone > 132 RuleFired > 1 *# > 15 +# > 25 ++ > 1 <# > 3 ==#->case > 2 SC:a0 > 1 SC:a_s2sW0 > 1 SPEC GHC.Num.- > 2 SPEC GHC.Real.$p1Integral > 2 SPEC GHC.Real.$p1Real > 2 SPEC GHC.Real.$p2Real > 3 SPEC Main.speed > 3 SPEC System.Random.random > 1 eftInt > 9 fold/build > 14 foldr/app > 1 fromIntegral/Word->Int > 1 int2Double# > 1 int2Word# > 3 map > 2 mapList > 1 minimumInt > 2 remInt# > 2 take > 2 takeList > 17 unpack > 6 unpack-append > 9 unpack-list > 212 LetFloatFromLet > 1 EtaReduction > 2874 BetaReduction > 27 CaseOfCase > 341 KnownBranch > 3 CaseElim > 2 CaseIdentity > 13 FillInCaseDefault > 22 SimplifierDone > > > Linking Unit ... > Unit.o: In function `s4Da_info': > (.text+0x1b21): undefined reference to `genrand_real2' > Unit.o: In function `s4RA_info': > (.text+0x3e75): undefined reference to `genrand_real2' > Unit.o: In function `s4S4_info': > (.text+0x3f61): undefined reference to `genrand_real2' > Unit.o: In function `s5su_info': > (.text+0x40bc): undefined reference to `genrand_real2' > /usr/local/lib/mersenne-random-0.1.1/ghc-6.9.20080517/libHSmersenne-random-0.1.1.a(Mersenne.o): In function `mersennezmrandomzm0zi1zi1_SystemziRandomziMersenne_zdwa2_info': > ghc13223_0.hc:(.text+0x1a3): undefined reference to `gen_rand64_mix' > /usr/local/lib/mersenne-random-0.1.1/ghc-6.9.20080517/libHSmersenne-random-0.1.1.a(Mersenne.o): In function `s2J1_info': > ghc13223_0.hc:(.text+0x91d): undefined reference to `gen_rand64_mix' > /usr/local/lib/mersenne-random-0.1.1/ghc-6.9.20080517/libHSmersenne-random-0.1.1.a(Mersenne.o): In function `s2JZ_info': > ghc13223_0.hc:(.text+0xb3d): undefined reference to `genrand_real2' > /usr/local/lib/mersenne-random-0.1.1/ghc-6.9.20080517/libHSmersenne-random-0.1.1.a(Mersenne.o): In function `s2LJ_info': > ghc13223_0.hc:(.text+0xf8d): undefined reference to `gen_rand64_mix' > /usr/local/lib/mersenne-random-0.1.1/ghc-6.9.20080517/libHSmersenne-random-0.1.1.a(Mersenne.o): In function `s35i_info': > ghc13223_0.hc:(.text+0x1397): undefined reference to `genrand_real2' > /usr/local/lib/mersenne-random-0.1.1/ghc-6.9.20080517/libHSmersenne-random-0.1.1.a(Mersenne.o): In function `s36A_info': > ghc13223_0.hc:(.text+0x1517): undefined reference to `gen_rand64_mix' > collect2: ld returned 1 exit status > make: *** [all] Error 1 From apfelmus at quantentunnel.de Sat Jun 7 07:00:42 2008 From: apfelmus at quantentunnel.de (apfelmus) Date: Sat Jun 7 06:53:26 2008 Subject: [Haskell-cafe] Re: appending an element to a list In-Reply-To: <62728db30806031357k4eb64655w7af1371cc6fe974d@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> <62728db30806031357k4eb64655w7af1371cc6fe974d@mail.gmail.com> Message-ID: Ronald Guida wrote: > Thank you, apfelmus. That was a wonderful explanation; the debit > method in [1] finally makes sense. A diagram says more than a thousand words :) My explanation is not entirely faithful to Okasaki, let me elaborate. In his book, Okasaki calls the process of transferring the debits from the input > xs = x1 : x2 : x3 : ... : xn : [] > 1 1 1 ... 1 1 0 > > ys = y1 : y2 : y3 : ... : ym : [] > 1 1 1 ... 1 1 0 to the output > xs ++ ys = x1 : x2 : x3 : ... : xn : y1 : y2 : y3 : ... : ym : [] > 2 2 2 ... 2 2 1 1 1 ... 1 1 0 "debit inheritance". In other words, the debits of xs and ys (here 1 at each node) are carried over to xs ++ ys (in addition to the debits created by ++ itself). In the thesis, he doesn't give it an explicit name, but discusses this phenomenon in the very last paragraphs of chapter 3.4 . The act of relocating debits from child to parent nodes as exemplified with > xs ++ reverse ys = > x1 : x2 : x3 : ... : xn : yn : y{n-1} : ... : y1 : [] > 1 1 1 ... 1 1 n 0 ... 0 0 0 > xs ++ reverse ys = > x1 : x2 : x3 : ... : xn : yn : y{n-1} : ... : y1 : [] > 2 2 2 ... 2 2 0 0 ... 0 0 0 is called "debit passing", but Okasaki doesn't use it earlier than in the chapter "Implicit recursive slowdown". But the example I gave here is useful for understand the scheduled implementation of real time queues. The trick there is to not create a "big" suspension with n debits but to really "physically" distribute them across the data structure x1 : x2 : x3 : ... : xn : yn : y{n-1} : ... : y1 : [] 2 2 2 ... 2 2 2 2 ... 2 2 2 and discharge them by forcing a node with every call to snoc . I say "physically" because this forcing performs actual work, it does not simply "mentally" discharge a debit to amortize work that will be done later. Note that the 2 debits added to each yi are an overestimation here, but the real time queue implementation pays for them nonetheless. My focus on debit passing in the original explanation might suggest that debits can only be discharged when actually evaluating the node to which the debit was assigned. This is not the case, an operation may discharge any debits, even in parts of the data structure that it doesn't touch. Of course, it must discharge debits of nodes it does touch. For instance, in the proof of theorem 3.1 (thesis) for queues, Okasaki writes "We can restore the invariant by discharging the first (two) debit(s) in the queue" without bothering to analyze which node this will be. So, the front queue might look like f1 : f2 : f3 : ... : fn : f{n+1} : f{n+2} : ... : fm : [] 0 0 1 ... 1 1 n 0 ... 0 0 0 and it's one of the nodes that carries one debit, or it could look like f2 : f3 : ... : fn : f{n+1} : f{n+2} : ... : fm : [] 0 0 ... 0 0 n-3 0 ... 0 0 0 and it's the node with the large amount of debits. In fact, it's not even immediate that these two are the only possibilities. However, with the debit passing from my previous post, it's easier to say which node will be discharged. But even then, only tail discharges exactly the debits of nodes it inspects while the snoc operation discharges debits in the untouched front list. Of course, as soon as identifying the nodes becomes tractable, chances are that you can turn it into a real-time data structure. Another good example are skew heaps from [2]: Chris Okasaki. Fun with binary heap trees. in J. Gibbons, O. de Moor. The Fun of Programming. http://www.palgrave.com/PDFs/0333992857.Pdf Here, the "good" nodes are annotated with one debit. Every join operation discharges O(log n) of them and allocates new ones while walking down the tree, but the "time" to actually walk down the tree is not counted immediately. This is just like (++) walks down the first list and allocates debits without immediately using O(n) time to do that. Regards, apfelmus PS: In a sense, discharging arbitrary debits can still be explained with debit passing: first pass those debits to the top and the discharge them because any operation has to inspect the top. From dan.doel at gmail.com Sat Jun 7 09:03:02 2008 From: dan.doel at gmail.com (Dan Doel) Date: Sat Jun 7 08:55:31 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: <48498354.5030506@btinternet.com> References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <48498354.5030506@btinternet.com> Message-ID: <200806070903.02682.dan.doel@gmail.com> On Friday 06 June 2008, Andrew Coppin wrote: > It's really quite frustrating that it is 100% impossible to write a > single function that will process lists, arrays, sets, maps, byte > strings, etc. You have to write several different versions. OK, so some > functions really don't make sense for a set because it's unordered, and > some functions don't make sense for a map, and so forth. But for > example, if I write some complicated algorithm that uses a list to store > data and I change that to a set instead, I now have to wade through the > function changing every operation from a list-op into a set-op. It's > really very annoying! It's not 100% impossible, depending on what exactly you're doing. For instance... Set a, ByteStrings, Seq a, Map k a and [a] are Monoids Set, Array i, Map k, Tree, Seq and [] are Foldable functors Array i, Map k, Tree, Seq, Tree and [] are Traversable functors Those can get you lots of operations (folds, maps, unions...) although there may be gaps that could be filled (Foldable is sufficient to define null, for instance, but it isn't in Data.Foldable). There's also the collections library (or Edison, if that's more your style) on hackage that takes such things a lot further. It seems it needs to be tweaked a bit to run on 6.8 according to the log, though. And there's also the issue of whether you can make all such generic operations perform well enough for every instance without making gigantic type classes that allow you to override every single operation (or if you can't, which way do you sacrifice). Of course, the prelude isn't a very good example of this sort of thing, so if that's the only place one looks (or in any module specific to one particular data structure), there's not much to find. -- Dan From phercek at gmail.com Sat Jun 7 09:18:03 2008 From: phercek at gmail.com (Peter Hercek) Date: Sat Jun 7 09:14:49 2008 Subject: [Haskell-cafe] Re: Design your modules for qualified import In-Reply-To: <48498354.5030506@btinternet.com> References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <48498354.5030506@btinternet.com> Message-ID: Andrew Coppin wrote: > Until very recently, it was not at all clear to me that there is > actually a very simple solution to this problem: > > import Text.ParserCombinators.Parsec as P > > Now I only have to write "P.runPaser", which is much shorter. > > This fact probably needs to be mentioned more loudly - I'm sure I'm not > the only person to have overlooked it... I have one efficient way to find all the needed language features without reading the specification from the start to the end or waiting till my questions get answered. The point is that common sense will indicate you where the required features should be logically located in the language grammar. E.g. if you want something related to imported modules it is logical to check all the alternatives available in import declaration. Then I check the grammar how the production for import declaration (impdelc) looks like (where it can be used etc.). Mostly it is enough sometimes I need to check the language specification since it is not obvious from the grammar. The result is that when I learn a new language the first thing I'm looking for is the formal grammar. Luckily most languages have it available. Some languages (like Haskell) are obsessed with shortcuts and the result is that their grammar is a bit cryptic; others (like VHDL) have it just great - production names clearly indicate what they actually do. On the other side haskell has nice online report :-) Peter. From s_zefirov at ipmce.ru Sat Jun 7 09:32:46 2008 From: s_zefirov at ipmce.ru (Serguey Zefirov) Date: Sat Jun 7 09:22:38 2008 Subject: [Haskell-cafe] Data.Map traversal. Message-ID: <484A8DFE.7030209@ipmce.ru> I found that I often need predecessor and successor of some key in Data.Map.Map. Just like that: predKey, succKey :: Ord k => Data.Map.Map k a -> k -> Maybe k predKeyElem, succKeyElem :: Ord k => Data.Map.Map k a -> k -> Maybe (k,a) Data.Map has operations like that on key indexes, but it is slightly unnatural to work with three entities (index, key and element) where two suffices. So I propose to include those operations into next version of Data.Map. If anyone could point me in the right direction I could do any necessary modifications myself (just because I need it). From miguelimo38 at yandex.ru Sat Jun 7 09:35:21 2008 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Sat Jun 7 09:28:05 2008 Subject: [Haskell-cafe] Teaching Monads In-Reply-To: <62728db30806062105t455382c4h503651d8427d6da0@mail.gmail.com> References: <62728db30806062105t455382c4h503651d8427d6da0@mail.gmail.com> Message-ID: <0A68E976-C842-4049-B17C-F3F6F33032FD@yandex.ru> On 7 Jun 2008, at 08:05, Ronald Guida wrote: > What made monads "click" for me is when I understood the following > things: Well, in case anybody's interested, I didn't know anything about monads before I tried to read the book "Toposes theory" (not sure about the exact name, I've read it in Russian) by P.T. Johnstone. It's Chapter 0 contained some facts about monads without proofs or even definitions. I've looked for some definitions in Mathematical Encyclopedia, asked one of my professors about other ones, tried to prove all results in this chapter by myself (successfully), and, suddenly, found out that I understand what monads are. Then, while reading YAHT, I've thought a bit, then realized, that Haskell monads are the same beast I already know (I didn't know about Kleisli triples before), and everything was clear. From dan.doel at gmail.com Sat Jun 7 09:49:45 2008 From: dan.doel at gmail.com (Dan Doel) Date: Sat Jun 7 09:42:21 2008 Subject: [Haskell-cafe] Teaching Monads In-Reply-To: <62728db30806062105t455382c4h503651d8427d6da0@mail.gmail.com> References: <62728db30806062105t455382c4h503651d8427d6da0@mail.gmail.com> Message-ID: <200806070949.46114.dan.doel@gmail.com> On Saturday 07 June 2008, Ronald Guida wrote: > 3. These closures are extremely similar to the closures that arise > when desugaring let-syntax. > > let x1 = f1 in f1 -$ (\x1 -> Where: > let x2 = f2 in f2 -$ (\x2 -> (-$) :: a -> (a -> b) -> b > let x3 = f3 in f3 -$ (\x3 -> x -$ f = f x > f x1 x2 x3 f x1 x2 x3))) In fact, this is the identity monad (this is not valid Haskell, but we'll let that slide): type Id a = a instance Monad Id where return a = a a >>= f = f a do x1 <- f1 f1 >>= \x1 (\x1 -> x2 <- f2 f2 >>= \x2 (\x2 -> x3 <- f3 f3 >>= \x3 (\x3 -> f x1 x2 x3) f3) return (f x1 x2 x3) return (f x1 x2 x3) f2) f1 Which is the same as the lets modulo let-polymorphism and recursive bindings. (In Haskell, you need a newtype wrapper but it's otherwise the same.) > OK, so before I attempt to write a monad tutorial based on "manual > plumbing" and "monadic plumbing", I would like to know, does anyone > else think this is a good idea? I think the general consensus is "don't write yet more monad tutorials." If you think Wadler's original paper is good, then it doesn't hurt to recommend it (you could instead write a "don't be afraid of reading academic papers" tutorial :)). But don't let me stop you, of course. :) -- Dan From xj2106 at columbia.edu Sat Jun 7 10:21:13 2008 From: xj2106 at columbia.edu (Xiao-Yong Jin) Date: Sat Jun 7 10:17:55 2008 Subject: [Haskell-cafe] Issues of the "mailto" link on the list archive page Message-ID: <873anpxr52.fsf@columbia.edu> Hi, I had private conversation with Andrzej Jaworski about the fact that his reply to Alberto Ruiz's post is off thread. What he did was clicking on the "mailto" link beside the author's name on the list archive web page [1]. [1] http://www.haskell.org/pipermail/haskell-cafe/2008-June/044023.html I am not quite sure about what this link is supposed to do. But, if it is meant for people to click and reply to the thread, it is not doing this correctly, as the "Subject" and "In-Reply-To" fields in the link are obtained from these fields in the head of current email. It would be useful if the link shows "Subject" with an added "Re: " if there is not already one, and fill in the "in-Reply-To" field with the value from the "Message-Id" field of current email head. An optional "Reference" field is informative for most of the email client, too. Sorry if this topic has the least connection to the glorious Haskell. Best, Xiao-Yong -- c/* __o/* <\ * (__ */\ < From dbueno at gmail.com Sat Jun 7 10:59:57 2008 From: dbueno at gmail.com (Denis Bueno) Date: Sat Jun 7 10:52:25 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: <48498354.5030506@btinternet.com> References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <48498354.5030506@btinternet.com> Message-ID: <6dbd4d000806070759x7355f70br5f992eeec1f363fd@mail.gmail.com> On Fri, Jun 6, 2008 at 2:35 PM, Andrew Coppin wrote: > Johan Tibell wrote: >> 3. Lack of common interfaces. >> > > Yes. > > It's really quite frustrating that it is 100% impossible to write a single > function that will process lists, arrays, sets, maps, byte strings, etc. You > have to write several different versions. OK, so some functions really don't > make sense for a set because it's unordered, and some functions don't make > sense for a map, and so forth. But for example, if I write some complicated > algorithm that uses a list to store data and I change that to a set instead, > I now have to wade through the function changing every operation from a > list-op into a set-op. It's really very annoying! I can think of at least two ways I have been able to keep generic code generic, in the way you describe: 1. Use the Data.Foldable interface. Lists, Sets, Sequences and Trees are all foldable. This doesn't help with your complaint about arrays and bytestrings, but it's something. You can do a lot with Foldable. 2. Factor out the operations *your app uses* into a typeclass. For some code I was writing I wrote the following interface -- | Represents a container of type @t@ storing elements of type @a@ that -- support membership, insertion, and deletion. class Ord a => Setlike t a where -- | The set-like object with an element removed. without :: t -> a -> t -- | The set-like object with an element included. with :: t -> a -> t -- | Whether the set-like object contains a certain element. contains :: t -> a -> Bool [Aside: This could be made H98 easily, but I didn't need it to be.] By implementing this class for various types (sets and lists, as well as a few others I used) I achieved the implementation-agnosticism you described at fairly low cost. If I needed to change out a list for an array, I only changed the code that creates the initial data structure, or the signature in the actual record containing the type --- in other words, I only changed what needed to be changed, and the rest was inferred. The reason I think it makes sense for *me* to have created and implemented this interface, instead of a library writer, is that for each task that is data-structure agnostic in some respect, you will need a *different* set of operations. I know which ones I need, so I should make only those generic. The library writer, to be generic, would have to write interfaces for all combinations of operations one might care about (too many for this not to be a waste of time) and that *still* wouldn't be good enough, because certain operations have slightly differing semantics (or signatures) that make genericity inadvisable (e.g. Set.map does not preserve the length of the input list, but List.map does. If your code relies on this rule about "map", it is bad to use an interface with a "generic" map). Perhaps there are certain, small, common interfaces --- like Setlike --- that could be agreed upon. But some people will always clamor that it doesn't fit their application, or doesn't have the right methods. Which I think is okay, if we don't ask too much of standard libs. -- Denis From loup.vaillant at gmail.com Sat Jun 7 11:31:29 2008 From: loup.vaillant at gmail.com (Loup Vaillant) Date: Sat Jun 7 11:23:57 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: <48498354.5030506@btinternet.com> References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <48498354.5030506@btinternet.com> Message-ID: <6f9f8f4a0806070831p17045ed5x8983fcabf7ed4085@mail.gmail.com> 2008/6/6 Andrew Coppin : > Until very recently, it was not at all clear to me that there is actually a > very simple solution to this problem: > > import Text.ParserCombinators.Parsec as P > > Now I only have to write "P.runPaser", which is much shorter. Err, I have a beginner question, then: Is there any difference between: import Very.Long.Module.Name as M and: import qualified Very.Long.Module.Name as M ? Loup From tphyahoo at gmail.com Sat Jun 7 12:13:18 2008 From: tphyahoo at gmail.com (Thomas Hartman) Date: Sat Jun 7 12:05:45 2008 Subject: [Haskell-cafe] installing happy 1.17 Message-ID: <910ddf450806070913x3bd5f69cia04724ad37c23eed@mail.gmail.com> I had a problem installing happy 1.17 (same result with happy head). This appears to be required for installing happs-hsp-template via cabal install. thanks for any advice! Thomas. ***** thartman@thartman-laptop:~/haskellInstalls/smallInstalls>darcs get --partial http://darcs.haskell.org/happy/ ********************** Copying patch 87 of 87... done. Applying patch 86 of 86... done. Finished getting. thartman@thartman-laptop:~/haskellInstalls/smallInstalls>cd happy thartman@thartman-laptop:~/haskellInstalls/smallInstalls/happy>runghc Setup.lhs configure Setup.lhs:30:43: Not in scope: `buildVerbose' thartman@thartman-laptop:~/haskellInstalls/smallInstalls/happy>cabal --version cabal-install version 0.4.9 using version 1.3.12 of the Cabal library thartman@thartman-laptop:~/haskellInstalls/smallInstalls/happy>ghc-pkg list | grep -i cabal Cabal-1.2.3.0, Cabal-1.3.11, Cabal-1.3.12, Cabal-1.5.2, From tphyahoo at gmail.com Sat Jun 7 12:37:57 2008 From: tphyahoo at gmail.com (Thomas Hartman) Date: Sat Jun 7 12:30:25 2008 Subject: [Haskell-cafe] ANNOUNCE: Cabal-1.4 release candidate In-Reply-To: <1212776132.15010.383.camel@localhost> References: <1212776132.15010.383.camel@localhost> Message-ID: <910ddf450806070937o4f636f24ua6f3821598037024@mail.gmail.com> as promised, sudo cabal install plugins works out of the box now. that's nice :) thomas. 2008/6/6 Duncan Coutts : > 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) > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From dokondr at gmail.com Sat Jun 7 12:44:35 2008 From: dokondr at gmail.com (Dmitri O.Kondratiev) Date: Sat Jun 7 12:37:03 2008 Subject: [Haskell-cafe] Newbie Q: Overloading and type classes Message-ID: <53396d9e0806070944r1c728f37rc2c88bd49eb69475@mail.gmail.com> {-- I try to define class Store that will group types implmenting different storage mechanisms . All types should support two functions: 1) put (key, value) pair into storage 2) get value from storage corresponding to the given key As an example I start with the following storage types: --} -- simple memory cell data OneCell k v = Cell(k, v) -- list of cells data CellList k v = CLst [(k, v)] {-- First, without grouping these types into any class, just to illustrate what these types should do, I define the following functions: --} {-- put::(k, v) -> OneCell k v -> OneCell k v put (k1, v1) (Cell(k, v)) = Cell(k1, v1) get :: Eq k => k -> OneCell k v -> Maybe v get k (Cell (_, v)) = Just v c1 ::OneCell String Int c1 = Cell("one", 1) putLst :: (k,v) -> CellList k v -> CellList k v putLst (k,v) (CLst xs) = CLst ((k,v) : xs) getLst :: Eq k => k -> CellList k v -> Maybe v getLst k (CLst xs) = lookup k xs cl1 = CLst [("one",1),("two",2),("three",3)] --} {-- These work as expected. Now I try to define Store class that should allow me to overload put & get functions: --} class Store s where put :: Eq k => (k, v) -> s -> s get :: k s -> Maybe v {-- instance Store OneCell where put (k1, v1) (Cell(k, v)) = Cell(k1, v1) get k (Cell (_, v)) = Just v --} {-- I get the following error: `OneCell' is not applied to enough type arguments Expected kind `*', but `OneCell' has kind `* -> * -> *' In the instance declaration for `Store OneCell' --} instance Store CellList where put (k,v) (CLst xs) = CLst ((k,v) : xs) get k (CLst xs) = lookup k xs {-- I get the following error: `CellList' is not applied to enough type arguments Expected kind `*', but `CellList' has kind `* -> * -> *' In the instance declaration for `Store CellList' --} What should I do to create Store class? Thanks! -- Dmitri O. Kondratiev dokondr@gmail.com http://www.geocities.com/dkondr -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080607/ddd86072/attachment.htm From derek.a.elkins at gmail.com Sat Jun 7 12:54:18 2008 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Sat Jun 7 12:46:54 2008 Subject: [Haskell-cafe] Teaching Monads In-Reply-To: <62728db30806062105t455382c4h503651d8427d6da0@mail.gmail.com> References: <62728db30806062105t455382c4h503651d8427d6da0@mail.gmail.com> Message-ID: <1212857658.7306.35.camel@derek-laptop> On Sat, 2008-06-07 at 00:05 -0400, Ronald Guida wrote: > Monads in Haskell are a topic that I, like most beginners, find > difficult and "mind-twisting". Now that I think I understand monads, > they seem to be very simple; I've read that this is a common > experience. > > So I wonder, what would it take to help beginners catch on with a > minimum of fuss or frustration? The plethora of monad tutorials out > there is clear evidence that plenty of others have wondered the same > thing. > > What made monads "click" for me is when I understood the following > things: > > 1. When monads are being used, closures are almost always involved. > > 2. These closures naturally arise when desugaring do-syntax. > > do x1 <- m1 m1 >>= (\x1 -> > x2 <- m2 m2 >>= (\x2 -> [Eq1] > x3 <- m3 m3 >>= (\x3 -> > return (f x1 x2 x3) return (f x1 x2 x3)))) > > 3. These closures are extremely similar to the closures that arise > when desugaring let-syntax. > > let x1 = f1 in f1 -$ (\x1 -> Where: > let x2 = f2 in f2 -$ (\x2 -> (-$) :: a -> (a -> b) -> b > let x3 = f3 in f3 -$ (\x3 -> x -$ f = f x > f x1 x2 x3 f x1 x2 x3))) > > 4. While I can think of a monad as a fancy container that holds an > element of type "t", it might be more accurate to think of a monad > as a container that merely displays the type "t" as a label for its > contents. The container might hold one object of type "t", or it > might hold several. It might not be holding any at all. Perhaps > the container /never/ holds an object of type "t", but instead it > holds a set of instructions to produce such an object. > (e.g. Reader, State). > > Naturally, it's hard to illustrate nested closures, higher-order > functions, and objects that aren't really there. It's easy to > illustrate a sequential scheme where a single "thing" passes through a > series of operations, while some related data travels in parallel. > > m1 >>= f1 >>= f2 >>= f3 [Eq2] > > In any case, the extreme similarity between desugared "do" and > desugared "let" leads me to think of the concepts of a manual > plumbing system and a monadic plumbing system. > > Basically, a manual plumbing system is what I have if I'm threading > information down through a series of nested function calls in a > certain stereotypical way. A monadic plumbing system is what I get > when I introduce the appropriate monad to encapsulate my threading. > > In fact, if I look at Wadler [*], there are three examples of an > evaluator that use what I'm calling "manual plumbing". In section > 2.5, the operations required of a monad (return, bind) pretty much > just drop right out. Wadler even points out the similarity between > "bind" and "let". > > Now that I finally "get it", I feel that the Wadler paper, section 2.5 > in particular, is probably a better introduction than many of the > monad tutorials out there. Moreover, I feel that for /some/ of > the tutorials out there, they spend too much time and too many > illustrations explaining things like [Eq2], and then they quickly > present do-notation and gloss over [Eq1]. > > For me, I found that that the concepts of "manual plumbing" and > "monadic plumbing" were key to actually grasping the Wadler paper and > understanding what monads are. In particular, I feel that these two > concepts might be a way to help other beginners catch on as well. > > OK, so before I attempt to write a monad tutorial based on "manual > plumbing" and "monadic plumbing", I would like to know, does anyone > else think this is a good idea? Why should I recommend a beginner to this tutorial rather than one of the dozens of others online or, better yet, to Wadler's papers directly (which is what I do)? From david.maciver at gmail.com Sat Jun 7 13:18:15 2008 From: david.maciver at gmail.com (David MacIver) Date: Sat Jun 7 13:10:45 2008 Subject: [Haskell-Cafe] Quick question for a slow program In-Reply-To: <171dfd0a0806070226k7ad4ceaal4cdb4a0892e43519@mail.gmail.com> References: <171dfd0a0806070226k7ad4ceaal4cdb4a0892e43519@mail.gmail.com> Message-ID: On Sat, Jun 7, 2008 at 10:26 AM, Slavomir Kaslev wrote: > Hello, > > I was just brushing my haskell-fu skills writing a solution for Google > Treasure Hunt Problem 4. Hers is what it looks like: > >> primes = sieve [2..] >> where >> sieve (p:xs) = p : sieve [x | x <- xs, x `mod` p /= 0] Read this: www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf This is probably the biggest culprit in your code. :-) From aruiz at um.es Sat Jun 7 13:24:54 2008 From: aruiz at um.es (Alberto Ruiz) Date: Sat Jun 7 13:17:31 2008 Subject: [Haskell-cafe] Re: Patrick Perry's BLAS package In-Reply-To: References: <48492F38.3070107@um.es> <87prquxqig.fsf@columbia.edu> Message-ID: <484AC466.7030908@um.es> Xiao-Yong Jin wrote: > Salute! Excellent! > > Patrick Perry writes: > >> >> * 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. > Sure, in the future the internal modules of hmatrix (if not all of them) can be replaced by Patrick's blas and the future lapack. And several alternative high level interfaces may coexist as thin layers on the underlying computational engine with different goals: from very simple interfaces for causal usage to advanced ones for more complex applications. >>> >>> 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 type of expression to be > > Matrix(m,n) e -> Matrix (l,m) e -> Int -> Vector n e > > which is different from the declared type. The error will be something > like "Expected type Vector m e, but got type Vector a1 e instead". And if I understand it correctly, usage is also very practical. You can define something like listVector 3 [1,2,3::Double] and the dimension type is "free". But if you give a signature you get static dimension checking: listVector 3 [1,2,3] Vector TypeDim3 Double I like this approach very much. Which types do you recommend for the dimensions? User friendly static dimension checking must be available in any serious Haskell linear algebra library. Frederik Eaton also made very interesting work on this in his index aware library. >> 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.) > > This is more work than you might think. The data structures are > different, many of the function names are different, and the module > namespaces overlap. I wouldn't recommend any switch from hmatrix to > blas right now unless you really need mutable types-- hmatrix has a lot > more linear algebra functionality. >> 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. > > I don't know of a good way to get around this. It seems like every > system has a different convention for the location and name of the cblas > libraries. So, everyone has to edit the "extra-libraries" and the > "extra-lib-dirs" field in the blas.cabal file. Does anyone know of a > better way of doing this? > (sorry if you receive this again, a previous message seems to be lost) A possible solution is using flags in the cabal configuration file. For instance, I have this in hmatrix.cabal: if flag(mkl) if arch(x86_64) extra-libraries: gsl mkl_lapack mkl_intel_lp64 mkl_sequential mkl_core else extra-libraries: gsl mkl_lapack mkl_intel mkl_sequential mkl_core else extra-libraries: gsl blas lapack so if I want to link with Intel's MKL optimized blas/lapack instead of ATLAS I simply add the -fmkl flag: runhaskell Setup.lhs configure -fmkl etc. or even cabal install hmatrix -fmkl Other flags can be added to support different distributions. We could have something like cabal install package -ffedora or cabal install package -fcblas etc. Alberto From duncan.coutts at worc.ox.ac.uk Sat Jun 7 13:44:48 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sat Jun 7 13:33:32 2008 Subject: [Haskell-cafe] Re: Fwd: installing happy 1.17 In-Reply-To: <910ddf450806070936p44837a8cu4b9d12e386349953@mail.gmail.com> References: <910ddf450806070913x3bd5f69cia04724ad37c23eed@mail.gmail.com> <910ddf450806070936p44837a8cu4b9d12e386349953@mail.gmail.com> Message-ID: <1212860688.15010.412.camel@localhost> On Sat, 2008-06-07 at 09:36 -0700, Thomas Hartman wrote: > cabal issue? Yes and no. What is happening is that there are several versions of the Cabal library installed. In particular Cabal-1.3.12 and Cabal-1.5.2. The happy package uses build-type Custom so cabal-install compiles the Setup.lhs script. The question is what version of the Cabal library should it use? The happy.cabal file specifies cabal-version: >= 1.2 so we'd better respect that. But even then we have several choices. Currently it just picks the highest one of the remaining choices. In this case that meant Cabal-1.5.2 -- the latest development version. This version turns out to have API changes that means that we get a type error when compiling Setup.lhs. As it happens, if cabal-install had picked one of the other choices then it would have compiled ok because the 1.2.x and upcoming 1.4.x series do not have those api changes. The immediate workarounds are: * unregister Cabal-1.5.2 * cabal install happy --cabal-lib-version 1.3.12 Perhaps a better solution is for cabal-install to choose the version of the Cabal library differently. Of course it has to be within the hard constraints specified in the .cabal file and on the command line. But after that perhaps it should prefer the version of the Cabal library that it itself was built with and at second preference the latest version in the same major series. The last preference would be as now, the latest version available. Sound sensible? Duncan > ---------- Forwarded message ---------- > From: Thomas Hartman > Date: 2008/6/7 > Subject: installing happy 1.17 > To: haskell > > > I had a problem installing happy 1.17 (same result with happy head). > This appears to be required for installing happs-hsp-template via > cabal install. > > thanks for any advice! > > Thomas. > > ***** > > thartman@thartman-laptop:~/haskellInstalls/smallInstalls>darcs get > --partial http://darcs.haskell.org/happy/ > ********************** > Copying patch 87 of 87... done. > Applying patch 86 of 86... done. > Finished getting. > > thartman@thartman-laptop:~/haskellInstalls/smallInstalls>cd happy > > thartman@thartman-laptop:~/haskellInstalls/smallInstalls/happy>runghc > Setup.lhs configure > > Setup.lhs:30:43: Not in scope: `buildVerbose' > thartman@thartman-laptop:~/haskellInstalls/smallInstalls/happy>cabal --version > cabal-install version 0.4.9 > using version 1.3.12 of the Cabal library > thartman@thartman-laptop:~/haskellInstalls/smallInstalls/happy>ghc-pkg > list | grep -i cabal > Cabal-1.2.3.0, Cabal-1.3.11, Cabal-1.3.12, Cabal-1.5.2, From dries at harnie.be Sat Jun 7 13:58:45 2008 From: dries at harnie.be (Dries Harnie) Date: Sat Jun 7 13:51:24 2008 Subject: [Haskell-Cafe] Quick question for a slow program In-Reply-To: <171dfd0a0806070226k7ad4ceaal4cdb4a0892e43519@mail.gmail.com> References: <171dfd0a0806070226k7ad4ceaal4cdb4a0892e43519@mail.gmail.com> Message-ID: <20080607195845.5e7ea7b2@kaabuntu.harnie> On Sat, 7 Jun 2008 12:26:17 +0300 "Slavomir Kaslev" wrote: > I was just brushing my haskell-fu skills writing a solution for Google > Treasure Hunt Problem 4. Hers is what it looks like: > > > primes = sieve [2..] > > where > > sieve (p:xs) = p : sieve [x | x <- xs, x `mod` p /= 0] > > > > sumOf n l = sum (take n l) : sumOf n (tail l) > > > > find l = foldl1 aux l > > where > > aux (x:xs) (y:ys) | x == y = x : aux xs ys > > | x < y = aux xs (y:ys) > > | x > y = aux (x:xs) ys > > > > puzzle = find (reverse [primes, p7, p17, p41, p541]) > > where > > p7 = sumOf 7 primes > > p17 = sumOf 17 primes > > p41 = sumOf 41 primes > > p541 = sumOf 541 primes > > > > main = do mapM (\x -> putStrLn $ show x) puzzle > > While the code is quite readable and straight forward it is as slow as > tortoise with four legs broken. What optimizations would you suggest, > while still keeping the code clear and highlevel? While I can't quite prove it, I surmise find is wasting a lot of time tracking down numbers which are sums of three or four of those lists before continuing. Here's mine: > sliding n = map (sum . take n) $ tails primes > > merge (x:xs) (y:ys) | x < y = x:merge xs (y:ys) > | otherwise = y:merge (x:xs) ys > > four = filter (\l -> length l == 5) $ group $ foldr1 merge $ map sliding [1,5,43,107,689] In my original implementation I used an isPrime test at the end, but I like your approach better (hence the 1 in map sliding). Does this still count as "clear and highlevel"? :) Dries Harnie -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080607/f1cb8c99/signature.bin From dons at galois.com Sat Jun 7 14:07:26 2008 From: dons at galois.com (Don Stewart) Date: Sat Jun 7 13:59:57 2008 Subject: [Haskell-cafe] Mersenne Build Problem In-Reply-To: <484A6A08.4020600@blueyonder.co.uk> References: <484A6A08.4020600@blueyonder.co.uk> Message-ID: <20080607180726.GA13289@scytale.galois.com> dominic.steinitz: > I'm getting errors (see below) trying to build the tests in > > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/mersenne-random-0.1.1 > > I built the package itself using > > ./Setup configure -f use_sse2 > > I thought I had an intel core duo (also see below). I think I may be > missing a library but I'm not sure which one. > > > Unit.o: In function `s4Da_info': > > (.text+0x1b21): undefined reference to `genrand_real2' > > Unit.o: In function `s4RA_info': > > (.text+0x3e75): undefined reference to `genrand_real2' > > Unit.o: In function `s4S4_info': > > (.text+0x3f61): undefined reference to `genrand_real2' > > Unit.o: In function `s5su_info': > > (.text+0x40bc): undefined reference to `genrand_real2' > > /usr/local/lib/mersenne-random-0.1.1/ghc-6.9.20080517/libHSmersenne-random-0.1.1.a(Mersenne.o): In function `mersennezmrandomzm0zi1zi1_SystemziRandomziMersenne_zdwa2_info': > > ghc13223_0.hc:(.text+0x1a3): undefined reference to `gen_rand64_mix' > > /usr/local/lib/mersenne-random-0.1.1/ghc-6.9.20080517/libHSmersenne-random-0.1.1.a(Mersenne.o): In function `s2J1_info': > > ghc13223_0.hc:(.text+0x91d): undefined reference to `gen_rand64_mix' > > /usr/local/lib/mersenne-random-0.1.1/ghc-6.9.20080517/libHSmersenne-random-0.1.1.a(Mersenne.o): In function `s2JZ_info': > > ghc13223_0.hc:(.text+0xb3d): undefined reference to `genrand_real2' > > /usr/local/lib/mersenne-random-0.1.1/ghc-6.9.20080517/libHSmersenne-random-0.1.1.a(Mersenne.o): In function `s2LJ_info': > > ghc13223_0.hc:(.text+0xf8d): undefined reference to `gen_rand64_mix' > > /usr/local/lib/mersenne-random-0.1.1/ghc-6.9.20080517/libHSmersenne-random-0.1.1.a(Mersenne.o): In function `s35i_info': > > ghc13223_0.hc:(.text+0x1397): undefined reference to `genrand_real2' > > /usr/local/lib/mersenne-random-0.1.1/ghc-6.9.20080517/libHSmersenne-random-0.1.1.a(Mersenne.o): In function `s36A_info': > > ghc13223_0.hc:(.text+0x1517): undefined reference to `gen_rand64_mix' > > collect2: ld returned 1 exit status > > make: *** [all] Error 1 > Lookks like the C bits didn't install properly? Possibly your cabal is very old? From himself at poczta.nom.pl Sat Jun 7 15:08:25 2008 From: himself at poczta.nom.pl (Andrzej Jaworski) Date: Sat Jun 7 14:02:06 2008 Subject: [Haskell-cafe] Patrick Perry's BLAS package References: <002101c8c81f$6b3d9b00$e9d54c59@bzdryk> <20080607023218.GA11462@scytale.galois.com> Message-ID: <003101c8c8d1$e319ad50$e9d54c59@bzdryk> On Jun 7, 11:21 am, Don Stewart wrote: > The best thing anyone here can do for haskell is contribute a library. > The more areas we cover with Haskell code, the easier the path is to > ongoing development, and a viable, sustainable Haskell world. Hi Don, I cannot agree more but: (1) I doubt that your consistant contribution and sense of responsibility can be replaced by independent volunteers. (2) More important than the number of libraries is their maintenance and accessibility by which I mean not just sufficient documentation but also reviews with pragmatic suggestions and shared experience formated into some knoledge base. (3) Haskell attracts guys that like originality [ like me;-) ] which is dengerous since building viable programming environment should be a top down affair. Regular coders are easier to cooperate. Conclusion: Some coordination effort is inevitable. Complementary librairs should be chained and updated together like toolboxes in Matlab, which might encourage writers to dedicate domain specific articles or a book around them. Cheers, -Andrzej Jaworski From bertram.felgenhauer at googlemail.com Sat Jun 7 14:22:36 2008 From: bertram.felgenhauer at googlemail.com (Bertram Felgenhauer) Date: Sat Jun 7 14:15:10 2008 Subject: [Haskell-cafe] Mersenne Build Problem In-Reply-To: <484A6A08.4020600@blueyonder.co.uk> References: <484A6A08.4020600@blueyonder.co.uk> Message-ID: <20080607182236.GB4258@zombie.inf.tu-dresden.de> Dominic Steinitz wrote: > I'm getting errors (see below) trying to build the tests in > > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/mersenne-random-0.1.1 > [snip] > > Linking Unit ... > > Unit.o: In function `s4Da_info': > > (.text+0x1b21): undefined reference to `genrand_real2' > > Unit.o: In function `s4RA_info': > > (.text+0x3e75): undefined reference to `genrand_real2' > > Unit.o: In function `s4S4_info': > > (.text+0x3f61): undefined reference to `genrand_real2' > > Unit.o: In function `s5su_info': > > (.text+0x40bc): undefined reference to `genrand_real2' > > /usr/local/lib/mersenne-random-0.1.1/ghc-6.9.20080517/[...] ^^^^^^^^^^^^^^^^ [snip] The missing symbols are inlined functions. ghc 6.9 doesn't include the header files anymore when compiling via C. (The solution is to create C wrappers around those functions. I guess I'll whip up a patch.) HTH, Bertram From daniel.is.fischer at web.de Sat Jun 7 14:27:31 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sat Jun 7 14:18:03 2008 Subject: [Haskell-Cafe] Quick question for a slow program In-Reply-To: <171dfd0a0806070226k7ad4ceaal4cdb4a0892e43519@mail.gmail.com> References: <171dfd0a0806070226k7ad4ceaal4cdb4a0892e43519@mail.gmail.com> Message-ID: <200806072027.31395.daniel.is.fischer@web.de> Am Samstag, 7. Juni 2008 11:26 schrieb Slavomir Kaslev: > Hello, > > I was just brushing my haskell-fu skills writing a solution for Google > > Treasure Hunt Problem 4. Hers is what it looks like: > > primes = sieve [2..] > > where > > sieve (p:xs) = p : sieve [x | x <- xs, x `mod` p /= 0] That alone breaks at least three of the tortoise's legs. Simple trial division: primes = 2:3:filter isPrime [5,7 .. ] isPrime n | n < 2 = False | n < 4 = True | even n = False | otherwise = go (tail primes) where r = floor $ sqrt (fromIntegral n + 0.5) go (p:ps) = (r < p) || (n `mod` p /= 0) && go ps is orders of magnitude faster. A really good prime generator wins a lot. > > > > sumOf n l = sum (take n l) : sumOf n (tail l) This is also not really good, sumOf n l = zipWith (-) (drop n sms) sms where sms = scanl (+) 0 l is a bit faster, specialising primeSums = scanl (+) 0 primes sumOfPrimes n = zipWith (-) (drop n primeSums) primeSums a bit more. I don't see more improvements directly. > > > > find l = foldl1 aux l > > where > > aux (x:xs) (y:ys) | x == y = x : aux xs ys > > > > | x < y = aux xs (y:ys) > > | x > y = aux (x:xs) ys > > > > puzzle = find (reverse [primes, p7, p17, p41, p541]) > > where > > p7 = sumOf 7 primes > > p17 = sumOf 17 primes > > p41 = sumOf 41 primes > > p541 = sumOf 541 primes > > > > main = do mapM (\x -> putStrLn $ show x) puzzle > > While the code is quite readable and straight forward it is as slow as > tortoise with four legs broken. What optimizations would you suggest, > while still keeping the code clear and highlevel? > > Thank you in advance. > > Cheers. From gsan at stillpsycho.net Sat Jun 7 14:34:57 2008 From: gsan at stillpsycho.net (=?utf-8?q?G=C3=B6khan_San?=) Date: Sat Jun 7 14:27:29 2008 Subject: [Haskell-cafe] Dynamic curiosity Message-ID: <200806072034.57585.gsan@stillpsycho.net> Hello All, I've recently modified my existing project to support dynamic data (using 'Data.Dynamic'), and despite my earlier benchmarks on 'Dynamic', the program slowed down by a factor of 10. Profiler says that 'fromDynamic' is consuming 60% of the CPU time (with -O2). Using the below function instead of 'fromDynamic' seems to make coercion 20 times faster (thereby solving my problem): > {-# OPTIONS -fglasgow-exts #-} > import GHC.Prim > data Dynamic' = Dynamic' TypeRep Any > fromDynamic' :: forall a. Typeable a => Dynamic -> Maybe a > fromDynamic' d = > let Dynamic' t v = unsafeCoerce# d > in if t == typeOf (undefined :: a) > then Just (unsafeCoerce# v) > else Nothing I was able to reproduce the same result from scratch. The only difference with the standard implementation (I put it below for reference), other than the first ugly unsafeCoerce#, seems to be existential quantification (i.e. When I replace "if t == typeOf (undefined :: a) ..." with the "case ..." below, performance goes down again.). > fromDynamic :: Typeable a => Dynamic -> Maybe a > fromDynamic (Dynamic t v) = > case unsafeCoerce v of > r | t == typeOf r -> Just r > | otherwise -> Nothing So what is causing the improvement, or am I missing something? Thanks. -- Gokhan From duncan.coutts at worc.ox.ac.uk Sat Jun 7 14:39:20 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sat Jun 7 14:28:03 2008 Subject: [Haskell-cafe] Re: Fwd: installing happy 1.17 In-Reply-To: <1212860688.15010.412.camel@localhost> References: <910ddf450806070913x3bd5f69cia04724ad37c23eed@mail.gmail.com> <910ddf450806070936p44837a8cu4b9d12e386349953@mail.gmail.com> <1212860688.15010.412.camel@localhost> Message-ID: <1212863960.15010.413.camel@localhost> On Sat, 2008-06-07 at 18:44 +0100, Duncan Coutts wrote: > Perhaps a better solution is for cabal-install to choose the version of > the Cabal library differently. Of course it has to be within the hard > constraints specified in the .cabal file and on the command line. But > after that perhaps it should prefer the version of the Cabal library > that it itself was built with and at second preference the latest > version in the same major series. The last preference would be as now, > the latest version available. > > Sound sensible? Done: Sat Jun 7 19:26:00 BST 2008 Duncan Coutts * Use a smarter preference when picking a Cabal lib to build Setup.hs Instead of just using the latest version we use the best version according to the following preferences in priority order: - the same version as cabal-install was itself built with - the same major version number as cabal-install was built with - a stable version of Cabal (even second digit of major number) - the latest version Duncan From daniel.is.fischer at web.de Sat Jun 7 14:46:34 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sat Jun 7 14:37:38 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: <6f9f8f4a0806070831p17045ed5x8983fcabf7ed4085@mail.gmail.com> References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <48498354.5030506@btinternet.com> <6f9f8f4a0806070831p17045ed5x8983fcabf7ed4085@mail.gmail.com> Message-ID: <200806072046.34715.daniel.is.fischer@web.de> Am Samstag, 7. Juni 2008 17:31 schrieb Loup Vaillant: > 2008/6/6 Andrew Coppin : > > Until very recently, it was not at all clear to me that there is actually > > a very simple solution to this problem: > > > > import Text.ParserCombinators.Parsec as P > > > > Now I only have to write "P.runPaser", which is much shorter. > > Err, I have a beginner question, then: > Is there any difference between: > > import Very.Long.Module.Name as M > > and: > > import qualified Very.Long.Module.Name as M The former lets you access functions from Very.Long.Module.Name also unqualified. > > ? > Loup From bulat.ziganshin at gmail.com Sat Jun 7 14:44:15 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sat Jun 7 14:44:34 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: <6f9f8f4a0806070831p17045ed5x8983fcabf7ed4085@mail.gmail.com> References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <48498354.5030506@btinternet.com> <6f9f8f4a0806070831p17045ed5x8983fcabf7ed4085@mail.gmail.com> Message-ID: <1565966080.20080607224415@gmail.com> Hello Loup, Saturday, June 7, 2008, 7:31:29 PM, you wrote: > Is there any difference between: > import Very.Long.Module.Name as M > and: > import qualified Very.Long.Module.Name as M with first you get *both* qualified and unqualified identifiers, with second - only qualified -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From lrpalmer at gmail.com Sat Jun 7 15:08:11 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Sat Jun 7 15:00:37 2008 Subject: [Haskell-cafe] Newbie Q: Overloading and type classes In-Reply-To: <53396d9e0806070944r1c728f37rc2c88bd49eb69475@mail.gmail.com> References: <53396d9e0806070944r1c728f37rc2c88bd49eb69475@mail.gmail.com> Message-ID: <7ca3f0160806071208y3220e9c6r399396c31e0a7ead@mail.gmail.com> 2008/6/7 Dmitri O.Kondratiev : > class Store s where > put :: Eq k => (k, v) -> s -> s > get :: k s -> Maybe v I suspect you want this to be a constructor class. That is, you want to make explicit the fact that the type s depends on k and v. class Store s where put :: Eq k => (k,v) -> s k v -> s k v get :: s k v -> Maybe v If instead you have cell types which are restricted in what they can store in different ways, you might explore fundeps or associated types: -- fundeps class Store s k v | s -> k v where put :: (k,v) -> s -> s get :: s -> Maybe v -- associated types class Store s where type Key s :: * type Value s :: * put :: (Key s, Value s) -> s -> s get :: s -> Maybe (Value s) But if you can get away with the former, I would recommend that before looking into these advanced extensions. Luke From lrpalmer at gmail.com Sat Jun 7 15:11:12 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Sat Jun 7 15:03:40 2008 Subject: [Haskell-cafe] Newbie Q: Overloading and type classes In-Reply-To: <7ca3f0160806071208y3220e9c6r399396c31e0a7ead@mail.gmail.com> References: <53396d9e0806070944r1c728f37rc2c88bd49eb69475@mail.gmail.com> <7ca3f0160806071208y3220e9c6r399396c31e0a7ead@mail.gmail.com> Message-ID: <7ca3f0160806071211u73a4e50dh4c80dd053f7e8aab@mail.gmail.com> On Sat, Jun 7, 2008 at 1:08 PM, Luke Palmer wrote: > 2008/6/7 Dmitri O.Kondratiev : >> class Store s where >> put :: Eq k => (k, v) -> s -> s >> get :: k s -> Maybe v > > I suspect you want this to be a constructor class. That is, you want > to make explicit the fact that the type s depends on k and v. > > class Store s where > put :: Eq k => (k,v) -> s k v -> s k v > get :: s k v -> Maybe v Oops. Should be: get :: k -> s k v -> Maybe v And correspondingly for the later examples. After actually using my brain thinking about your problem, and reading the word "Newbie", I would absolutely stay away from the fundeps/associated types business. :-) Try to get this working with Cell and CellList first :-) Luke > If instead you have cell types which are restricted in what they can > store in different ways, you might explore fundeps or associated > types: > > -- fundeps > class Store s k v | s -> k v where > put :: (k,v) -> s -> s > get :: s -> Maybe v > > -- associated types > class Store s where > type Key s :: * > type Value s :: * > put :: (Key s, Value s) -> s -> s > get :: s -> Maybe (Value s) > > But if you can get away with the former, I would recommend that before > looking into these advanced extensions. > > Luke > From bertram.felgenhauer at googlemail.com Sat Jun 7 15:20:45 2008 From: bertram.felgenhauer at googlemail.com (Bertram Felgenhauer) Date: Sat Jun 7 15:13:17 2008 Subject: [Haskell-cafe] Re: Fwd: installing happy 1.17 In-Reply-To: <1212860688.15010.412.camel@localhost> References: <910ddf450806070913x3bd5f69cia04724ad37c23eed@mail.gmail.com> <910ddf450806070936p44837a8cu4b9d12e386349953@mail.gmail.com> <1212860688.15010.412.camel@localhost> Message-ID: <20080607192045.GF4258@zombie.inf.tu-dresden.de> Duncan Coutts wrote: > The immediate workarounds are: > * unregister Cabal-1.5.2 Better, hide it (that's reversible) - or does that not work with cabal-install? Bertram From duncan.coutts at worc.ox.ac.uk Sat Jun 7 15:42:04 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sat Jun 7 15:33:23 2008 Subject: [Haskell-cafe] Re: Fwd: installing happy 1.17 In-Reply-To: <20080607192045.GF4258@zombie.inf.tu-dresden.de> References: <910ddf450806070913x3bd5f69cia04724ad37c23eed@mail.gmail.com> <910ddf450806070936p44837a8cu4b9d12e386349953@mail.gmail.com> <1212860688.15010.412.camel@localhost> <20080607192045.GF4258@zombie.inf.tu-dresden.de> Message-ID: <1212867724.15010.416.camel@localhost> On Sat, 2008-06-07 at 21:20 +0200, Bertram Felgenhauer wrote: > Duncan Coutts wrote: > > The immediate workarounds are: > > * unregister Cabal-1.5.2 > > Better, hide it (that's reversible) - or does that not work with > cabal-install? If Cabal ignored hidden packages then you could never install packages that depend on the ghc package since that's always hidden. Though again we could use that as a preference rather than a hard constraint. Duncan From ryani.spam at gmail.com Sat Jun 7 16:20:03 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Sat Jun 7 16:15:24 2008 Subject: [Haskell-cafe] example of FFI FunPtr In-Reply-To: <5ae4f2ba0806060206v6a1b2385vee642df8ccaa01de@mail.gmail.com> References: <5ae4f2ba0806050038k1e0aea1exe6d81b22b1151eeb@mail.gmail.com> <4847B025.8030800@goto10.org> <5ae4f2ba0806060008i659a3e16yb179e94cf32ee8ab@mail.gmail.com> <5ae4f2ba0806060206v6a1b2385vee642df8ccaa01de@mail.gmail.com> Message-ID: <2f9b2d30806071320u4fc852dne3e4f5b5784ae723@mail.gmail.com> 2008/6/6 Galchin, Vasili : > I want to do an incremental "experiment". I want just want to pass a C > function to "callback" to a Haskell function. ??? This is easy; just declare the function via the FFI; here's an example from my implementation for the 2006 ICFP contest (http://www.boundvariable.org/); this interface is used to get access to a fast C VM from the high-level haskell debugger. The C VM can call back into Haskell in order to get and fetch characters from the console, and to notify the debugger of allocations and frees. The haskell-side debugger can query the state of the VM via the "get" functions exported by the VM. In this example, get_program_size is a first class haskell IO action; it can be passed around like any other action. If you know the function call is referentially transparent (pure), you can leave the "IO" off of the return result of the function; be careful with this, it's calling into whatever C-code you are giving and so you should treat it as carefully as you treat unsafePerformIO. The "unsafe" keyword allows GHC to optimize certain calls; in order to use it you need to know that the function won't call back into Haskell code. foreign import ccall unsafe load_program :: Ptr Word32 -> Word32 -> IO () foreign import ccall execute :: Word32 {-numCycles-} -> FunPtr GetChar -> FunPtr PutChar -> FunPtr Notify {-alloc-} -> FunPtr Notify {-free-} -> IO Word32 {-returnCode 0=success, 1=failure-} foreign import ccall unsafe get_program :: IO (Ptr Word32) foreign import ccall unsafe get_program_size :: IO Word32 foreign import ccall unsafe get_registers :: Ptr Word32 foreign import ccall unsafe get_pc :: IO Word32 foreign import ccall unsafe get_prev_pc :: IO Word32 foreign import ccall unsafe set_pc :: Word32 -> IO Bool type GetChar = IO Word32 type PutChar = Word32 -> IO () type Notify = Ptr Word32 -> Word32 -> IO () foreign import ccall "wrapper" mkGetChar :: GetChar -> IO (FunPtr GetChar) foreign import ccall "wrapper" mkPutChar :: PutChar -> IO (FunPtr PutChar) foreign import ccall "wrapper" mkNotify :: Notify -> IO (FunPtr Notify) From lanny at cisco.com Sat Jun 7 17:34:37 2008 From: lanny at cisco.com (Lanny Ripple) Date: Sat Jun 7 17:27:42 2008 Subject: [Haskell-Cafe] Quick question for a slow program In-Reply-To: <171dfd0a0806070226k7ad4ceaal4cdb4a0892e43519@mail.gmail.com> References: <171dfd0a0806070226k7ad4ceaal4cdb4a0892e43519@mail.gmail.com> Message-ID: <484AFEED.908@cisco.com> The second prime generator on this page http://www.haskell.org/haskellwiki/Prime_numbers is quick and easy. I keep it nearby for all those sudden attacks of needing to solve yet another projecteuler problem. -ljr Slavomir Kaslev wrote: > Hello, > > I was just brushing my haskell-fu skills writing a solution for Google > Treasure Hunt Problem 4. Hers is what it looks like: > >> primes = sieve [2..] >> where >> sieve (p:xs) = p : sieve [x | x <- xs, x `mod` p /= 0] >> >> sumOf n l = sum (take n l) : sumOf n (tail l) >> >> find l = foldl1 aux l >> where >> aux (x:xs) (y:ys) | x == y = x : aux xs ys >> | x < y = aux xs (y:ys) >> | x > y = aux (x:xs) ys >> >> puzzle = find (reverse [primes, p7, p17, p41, p541]) >> where >> p7 = sumOf 7 primes >> p17 = sumOf 17 primes >> p41 = sumOf 41 primes >> p541 = sumOf 541 primes >> >> main = do mapM (\x -> putStrLn $ show x) puzzle > > While the code is quite readable and straight forward it is as slow as > tortoise with four legs broken. What optimizations would you suggest, > while still keeping the code clear and highlevel? > > Thank you in advance. > > Cheers. > From tphyahoo at gmail.com Sat Jun 7 17:46:23 2008 From: tphyahoo at gmail.com (Thomas Hartman) Date: Sat Jun 7 17:40:10 2008 Subject: [Haskell-cafe] Re: Fwd: installing happy 1.17 In-Reply-To: <1212867724.15010.416.camel@localhost> References: <910ddf450806070913x3bd5f69cia04724ad37c23eed@mail.gmail.com> <910ddf450806070936p44837a8cu4b9d12e386349953@mail.gmail.com> <1212860688.15010.412.camel@localhost> <20080607192045.GF4258@zombie.inf.tu-dresden.de> <1212867724.15010.416.camel@localhost> Message-ID: <910ddf450806071446i154926f4ybee2478ea38635fb@mail.gmail.com> great, sudo cabal install from inside 1.17 distribution dir now seems to do the right thing. however, after it's done installing (apparently without error) the happy version is still 1.16 and the happy executable is from 2006. This means that I still can't install other packages that rely on happy >=1.17 sudo cabal install haskell-src-exts Resolving dependencies... 'haskell-src-exts-0.3.4' is cached. Configuring haskell-src-exts-0.3.4... cabal: happy version >=1.17 is required but the version found at /usr/bin/happy is version 1.16 cabal: Error: some packages failed to install: haskell-src-exts-0.3.4 failed during the configure step. The exception was: exit: ExitFailure 1 happy-1.17>sudo cabal install Resolving dependencies... Warning: defaultUserHooks in Setup script is deprecated. Configuring happy-1.17... Warning: No 'build-type' specified. If you do not need a custom Setup.hs or ./configure script then use 'build-type: Simple'. Preprocessing executables for happy-1.17... Building happy-1.17... [ 1 of 18] Compiling Paths_happy ( dist/build/autogen/Paths_happy.hs, dist/build/happy/happy-tmp/Paths_happy.o ) Linking dist/build/happy/happy ... Installing: /home/thartman/.cabal/bin thartman@thartman-laptop:~/haskellInstalls/smallInstalls/happy-1.17>happy --version Happy Version 1.16 Copyright (c) 1993-1996 Andy Gill, Simon Marlow (c) 1997-2005 Simon Marlow Happy is a Yacc for Haskell, and comes with ABSOLUTELY NO WARRANTY. This program is free software; you can redistribute it and/or modify it under the terms given in the file 'LICENSE' distributed with the Happy sources. thartman@thartman-laptop:~/haskellInstalls/smallInstalls/happy-1.17>ls -l `which happy` -rwxr-xr-x 1 root root 941968 2006-11-23 21:34 /usr/bin/happy thartman@thartman-laptop:~/haskellInstalls/smallInstalls/happy-1.17> 2008/6/7 Duncan Coutts : > > On Sat, 2008-06-07 at 21:20 +0200, Bertram Felgenhauer wrote: >> Duncan Coutts wrote: >> > The immediate workarounds are: >> > * unregister Cabal-1.5.2 >> >> Better, hide it (that's reversible) - or does that not work with >> cabal-install? > > If Cabal ignored hidden packages then you could never install packages > that depend on the ghc package since that's always hidden. > > Though again we could use that as a preference rather than a hard > constraint. > > Duncan > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From duncan.coutts at worc.ox.ac.uk Sat Jun 7 18:07:00 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sat Jun 7 17:56:34 2008 Subject: [Haskell-cafe] Re: Fwd: installing happy 1.17 In-Reply-To: <910ddf450806071446i154926f4ybee2478ea38635fb@mail.gmail.com> References: <910ddf450806070913x3bd5f69cia04724ad37c23eed@mail.gmail.com> <910ddf450806070936p44837a8cu4b9d12e386349953@mail.gmail.com> <1212860688.15010.412.camel@localhost> <20080607192045.GF4258@zombie.inf.tu-dresden.de> <1212867724.15010.416.camel@localhost> <910ddf450806071446i154926f4ybee2478ea38635fb@mail.gmail.com> Message-ID: <1212876420.15010.421.camel@localhost> On Sat, 2008-06-07 at 14:46 -0700, Thomas Hartman wrote: > great, sudo cabal install from inside 1.17 distribution dir now seems > to do the right thing. > > however, after it's done installing (apparently without error) the > happy version is still 1.16 and the happy executable is from 2006. > > This means that I still can't install other packages that rely on happy >=1.17 > > sudo cabal install haskell-src-exts > Resolving dependencies... > 'haskell-src-exts-0.3.4' is cached. > Configuring haskell-src-exts-0.3.4... > cabal: happy version >=1.17 is required but the version found at > /usr/bin/happy is version 1.16 At the moment by default cabal-install installs binaries to ~/.cabal/bin which isn't on the $PATH unless you deliberately change your $PATH. The reason we don't put things directly into ~/bin/ is because some people worry about cabal-install "clobbering" programs that the user already had in ~/bin/. One idea for resolving this is: http://hackage.haskell.org/trac/hackage/ticket/289 We'd very much appreciate feedback on what the right thing to do is and if the above spec is ok for someone to implement it. Duncan From xj2106 at columbia.edu Sat Jun 7 18:45:01 2008 From: xj2106 at columbia.edu (Xiao-Yong Jin) Date: Sat Jun 7 18:43:40 2008 Subject: [Haskell-cafe] "sum" in hmatrix and blas? Message-ID: <87y75gx3te.fsf@columbia.edu> Hi, probably I am just being dumb, but what is the most efficient way to do a sum of every elements in a Vector of either hmatrix or blas? I know there is sum of absolute values from BLAS. So what about I want a plain "sum"? I can only think of the following two ways. 1. Using Data.List.foldl', so it is > sum' = foldl' (+) 0 . toList in hmatrix or > sum' = foldl' (+) 0 . elems in blas. 2. Using <.>, so it is > sum' v = constant 1 (dim v) <.> v in hmatrix or > sum' v = constant (dim v) 1 <.> v in blas. Which one is better? I guess it probably depends on the internal implementation of BLAS, but I am actually thinking in some thing similar to > t += *v++; Any delightful idea to convert my mind from a C shaped one to a Haskell shaped one? Best, Xiao-Yong -- c/* __o/* <\ * (__ */\ < From dokondr at gmail.com Sat Jun 7 19:07:19 2008 From: dokondr at gmail.com (Dmitri O.Kondratiev) Date: Sat Jun 7 19:00:46 2008 Subject: [Haskell-cafe] Newbie Q: Overloading and type classes In-Reply-To: <7ca3f0160806071211u73a4e50dh4c80dd053f7e8aab@mail.gmail.com> References: <53396d9e0806070944r1c728f37rc2c88bd49eb69475@mail.gmail.com> <7ca3f0160806071208y3220e9c6r399396c31e0a7ead@mail.gmail.com> <7ca3f0160806071211u73a4e50dh4c80dd053f7e8aab@mail.gmail.com> Message-ID: <53396d9e0806071607r6f7c3bbepff259a80a923584f@mail.gmail.com> {-- Thanks! Yes, you got it right - I "want to make explicit the fact that the type s depends on k and v. So I followed your advice and used the most simple way to do what I need: --} class Store s where put :: Eq k => (k, v) -> s k v -> s k v get :: Eq k => k -> s k v -> Maybe v instance Store OneCell where put (k1, v1) (Cell(k, v)) = Cell(k1, v1) get k (Cell (_, v)) = Just v instance Store CellList where put (k,v) (CLst xs) = CLst ((k,v) : xs) get k (CLst xs) = lookup k xs storePut :: (Store s, Eq k) => s k v -> k -> v -> s k v storePut store key value = put (key, value) store storeGet :: (Store s, Eq k) => k -> s k v -> Maybe v storeGet key store = get key store aCell :: OneCell String Int aCell = Cell("one", 1) lst :: CellList Int String lst = CLst [(1, "one"),(2, "two"),(3, "three")] st1 = storePut aCell "two" 2 st2 = storePut lst 4 "four" -- v1 = storeGet "one" st2 -- error v2 = storeGet "one" st1 -- ok {-- And what does the word "newbie" imply to you when answering my question? In what case using 'fundeps' and 'associated types' will make sence for this example? --} Thanks again for your great help! Dima On Sat, Jun 7, 2008 at 11:11 PM, Luke Palmer wrote: > > Oops. Should be: > > get :: k -> s k v -> Maybe v > > And correspondingly for the later examples. After actually using my > brain thinking about your problem, and reading the word "Newbie", I > would absolutely stay away from the fundeps/associated types business. > :-) Try to get this working with Cell and CellList first :-) > > Luke > > > If instead you have cell types which are restricted in what they can > > store in different ways, you might explore fundeps or associated > > types: > > > > -- fundeps > > class Store s k v | s -> k v where > > put :: (k,v) -> s -> s > > get :: s -> Maybe v > > > > -- associated types > > class Store s where > > type Key s :: * > > type Value s :: * > > put :: (Key s, Value s) -> s -> s > > get :: s -> Maybe (Value s) > > > > But if you can get away with the former, I would recommend that before > > looking into these advanced extensions. > > > > Luke > > > -- Dmitri O. Kondratiev dokondr@gmail.com http://www.geocities.com/dkondr -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080608/4215be5d/attachment.htm From thomas.dubuisson at gmail.com Sun Jun 8 01:11:49 2008 From: thomas.dubuisson at gmail.com (Thomas M. DuBuisson) Date: Sun Jun 8 00:59:33 2008 Subject: [Haskell-cafe] [ANN] Bindings to Xen Control (xenctrl.h) In-Reply-To: <1212380364.2448.39.camel@Clunker> References: <1212300682.2448.14.camel@Clunker> <20080601063140.GA1200@scytale.galois.com> <1212380364.2448.39.camel@Clunker> Message-ID: <1212901910.2430.7.camel@Clunker> Version 0.0.3 was release, which is nearly a complete (and completely trivial) xenctrl.h binding. Aside from unit tests and programs, the main things missing are grant table operations. There is now a quick and dirty home page at the wiki [1] and a darcs repo on c.h.o [2]. Comments, requests, and contributions are all encouraged. TomMD P.S. I intend to finish the bindings then move onto design/implementation of the higher level 'System.Xen' module when time permits. [1] http://haskell.org/haskellwiki/HsXenCtrl [2] http://code.haskell.org/~tommd/hsXenCtrl On Mon, 2008-06-02 at 00:19 -0400, Thomas M. DuBuisson wrote: > 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 lrpalmer at gmail.com Sun Jun 8 02:18:38 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Sun Jun 8 02:11:06 2008 Subject: [Haskell-cafe] Newbie Q: Overloading and type classes In-Reply-To: <53396d9e0806071607r6f7c3bbepff259a80a923584f@mail.gmail.com> References: <53396d9e0806070944r1c728f37rc2c88bd49eb69475@mail.gmail.com> <7ca3f0160806071208y3220e9c6r399396c31e0a7ead@mail.gmail.com> <7ca3f0160806071211u73a4e50dh4c80dd053f7e8aab@mail.gmail.com> <53396d9e0806071607r6f7c3bbepff259a80a923584f@mail.gmail.com> Message-ID: <7ca3f0160806072318t369cfc54gb9eb50d884459a74@mail.gmail.com> On Sat, Jun 7, 2008 at 5:07 PM, Dmitri O.Kondratiev wrote: > {-- > And what does the word "newbie" imply to you when answering my question? > In what case using 'fundeps' and 'associated types' will make sence for this > example? > --} Well, functional dependencies ("fundeps") and associated types are "advanced" extensions to the language (not Haskell98), and I personally would not consider it a good idea to approach them until you have a good handle on typeclasses. Actually, associated types are not that bad, save for the peculiar restrictions on what is possible to define (because of decidability issues). Fundeps are a bit stranger, IMO.. However, since you asked, I'll here try to expound a situation in which you might need associated types. Let's say you have a CellHash type that very efficiently stores key-value pairs, but only if the key is a string. So you have: data CellHash v = ... In the simple case, there is no way to make this an instance of Store, since Store requires a constructor with two parameters. And we can't really hack around it, because an instance of Store must support *any* key type by definition. Instead, we can use associated types, which associate *types* to instances in a class. These associated types will tell us about the acceptable keys and values of a particular instance: class Store s where type Key s :: * type Value s :: * put :: (Key s, Value s) -> s -> s get :: Key s -> s -> Value s The ":: *" annotates the kind of the result; for 'normal' value types it is *, for constructors with one parameter it is "* -> *", etc. It is straightforward to implement Store for your Cell and CellList. instance Store (Cell k v) where -- note that this is not "instance Store Cell" anymore type Key (Cell k v) = k type Value (Cell k v) = v -- as before But now we can make an instance for CellHash too: instance Store (CellHash v) where type Key (CellHash v) = String type Value (CellHash v) = v -- straightforward There's a situation where you would want to use associated types. But they are quite new, and can be hard to work with because of all the restrictions on their creation. For example, IIRC something like this would be illegal in the above instance: type Key (CellHash v) = HashKey String StringHashPolicy Because the right hand side is larger in terms of number of symbols than the left. This is untested, and I'm unsure of my knowledge here, so take the former with a grain of salt. Fundeps could be used to achieve the same thing, but are not without their caveats. Luke From dominic.steinitz at blueyonder.co.uk Sun Jun 8 03:51:24 2008 From: dominic.steinitz at blueyonder.co.uk (Dominic Steinitz) Date: Sun Jun 8 03:44:02 2008 Subject: [Haskell-cafe] Re: Mersenne Build Problem References: <484A6A08.4020600@blueyonder.co.uk> <20080607182236.GB4258@zombie.inf.tu-dresden.de> Message-ID: Bertram Felgenhauer googlemail.com> writes: > > The missing symbols are inlined functions. ghc 6.9 doesn't include the > header files anymore when compiling via C. (The solution is to create > C wrappers around those functions. I guess I'll whip up a patch.) > Bertram, Thanks. That's done the trick. I tried 0.1.1 and it works with 6.8 and 0.1.2 works with 6.9. It certainly is a lot faster than system.random. Dominic. From johan.tibell at gmail.com Sun Jun 8 04:55:36 2008 From: johan.tibell at gmail.com (Johan Tibell) Date: Sun Jun 8 04:48:01 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: <200806070903.02682.dan.doel@gmail.com> References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <48498354.5030506@btinternet.com> <200806070903.02682.dan.doel@gmail.com> Message-ID: <90889fe70806080155r62ce1fc2v300d6667ef45c70f@mail.gmail.com> On Sat, Jun 7, 2008 at 3:03 PM, Dan Doel wrote: > On Friday 06 June 2008, Andrew Coppin wrote: >> It's really quite frustrating that it is 100% impossible to write a >> single function that will process lists, arrays, sets, maps, byte >> strings, etc. You have to write several different versions. OK, so some >> functions really don't make sense for a set because it's unordered, and >> some functions don't make sense for a map, and so forth. But for >> example, if I write some complicated algorithm that uses a list to store >> data and I change that to a set instead, I now have to wade through the >> function changing every operation from a list-op into a set-op. It's >> really very annoying! > > It's not 100% impossible, depending on what exactly you're doing. For > instance... > > Set a, ByteStrings, Seq a, Map k a and [a] are Monoids > Set, Array i, Map k, Tree, Seq and [] are Foldable functors > Array i, Map k, Tree, Seq, Tree and [] are Traversable functors > > Those can get you lots of operations (folds, maps, unions...) although there > may be gaps that could be filled (Foldable is sufficient to define null, for > instance, but it isn't in Data.Foldable). These do help in the case you want to traverse data structures that share a set of properties (e.g. are Functors). However, it doesn't address the problem of sharing an interface among Set, IntSet, ByteSet, etc. In other words there's a need for a Set type class. Hopefully type families will help us write such an interface and keep it efficient. Cheers, Johan From toman144 at student.liu.se Sun Jun 8 08:54:17 2008 From: toman144 at student.liu.se (Tomas Andersson) Date: Sun Jun 8 08:46:51 2008 Subject: [Haskell-cafe] "sum" in hmatrix and blas? In-Reply-To: <87y75gx3te.fsf@columbia.edu> References: <87y75gx3te.fsf@columbia.edu> Message-ID: <200806081454.18467.toman144@student.liu.se> Den Sunday 08 June 2008 00.45.01 skrev Xiao-Yong Jin: > Any delightful idea to convert my mind from a C shaped one > to a Haskell shaped one? > You can never go wrong with a good old fashioned hand written tail recursion when you're in doubt, they are pretty much the closest thing to for-loops there is in haskell and should be easy to grok for Imperative programmers and usually produce really fast code. sum vect = let d = dim vect in sum' (d - 1) 0 where sum' 0 s = s + (vect @> 0) sum' index s = sum' (index - 1) (s + (vect @> index)) I don't know the hmatrix api very well, but if there is a function for computing the inner product between two vectors you could always do something like the following meta code: sum v = innerProduct v <1,1,1,1,1,1> > Best, > Xiao-Yong From igloo at earth.li Sun Jun 8 09:38:11 2008 From: igloo at earth.li (Ian Lynagh) Date: Sun Jun 8 09:30:37 2008 Subject: [Haskell-cafe] Data.Map traversal. In-Reply-To: <484A8DFE.7030209@ipmce.ru> References: <484A8DFE.7030209@ipmce.ru> Message-ID: <20080608133811.GA8068@matrix.chaos.earth.li> Hi Serguey, On Sat, Jun 07, 2008 at 05:32:46PM +0400, Serguey Zefirov wrote: > > So I propose to include those operations into next version of Data.Map. > > If anyone could point me in the right direction I could do any necessary > modifications myself (just because I need it). Please see http://www.haskell.org/haskellwiki/Library_submissions for how to propose changes to the libraries. Thanks Ian From igloo at earth.li Sun Jun 8 09:41:38 2008 From: igloo at earth.li (Ian Lynagh) Date: Sun Jun 8 09:34:01 2008 Subject: [Haskell-cafe] Issues of the "mailto" link on the list archive page In-Reply-To: <873anpxr52.fsf@columbia.edu> References: <873anpxr52.fsf@columbia.edu> Message-ID: <20080608134138.GB8068@matrix.chaos.earth.li> On Sat, Jun 07, 2008 at 10:21:13AM -0400, Xiao-Yong Jin wrote: > > I had private conversation with Andrzej Jaworski about the > fact that his reply to Alberto Ruiz's post is off thread. > What he did was clicking on the "mailto" link beside the > author's name on the list archive web page [1]. > > [1] http://www.haskell.org/pipermail/haskell-cafe/2008-June/044023.html > > I am not quite sure about what this link is supposed to do. > But, if it is meant for people to click and reply to the > thread, it is not doing this correctly, as the "Subject" and > "In-Reply-To" fields in the link are obtained from these > fields in the head of current email. It would be useful if > the link shows "Subject" with an added "Re: " if there is > not already one, and fill in the "in-Reply-To" field with > the value from the "Message-Id" field of current email > head. An optional "Reference" field is informative for most > of the email client, too. If anyone knows how we can make mailman do this better, please let us know. Thanks Ian From apfelmus at quantentunnel.de Sun Jun 8 09:44:58 2008 From: apfelmus at quantentunnel.de (apfelmus) Date: Sun Jun 8 09:37:40 2008 Subject: [Haskell-cafe] Re: Quick question for a slow program In-Reply-To: <484AFEED.908@cisco.com> References: <171dfd0a0806070226k7ad4ceaal4cdb4a0892e43519@mail.gmail.com> <484AFEED.908@cisco.com> Message-ID: Lanny Ripple wrote: > The second prime generator on this page > > http://www.haskell.org/haskellwiki/Prime_numbers > > is quick and easy. I keep it nearby for all those sudden attacks of > needing to solve yet another projecteuler problem. The second prime sieve did not create an implicit heap as advertised. I've fixed that and also cleaned up the page a bit, moving this sieve to the section "Implicit Heap". Regards, apfelmus From xj2106 at columbia.edu Sun Jun 8 10:15:01 2008 From: xj2106 at columbia.edu (Xiao-Yong Jin) Date: Sun Jun 8 10:11:53 2008 Subject: [Haskell-cafe] "sum" in hmatrix and blas? In-Reply-To: <200806081454.18467.toman144@student.liu.se> (Tomas Andersson's message of "Sun, 8 Jun 2008 14:54:17 +0200") References: <87y75gx3te.fsf@columbia.edu> <200806081454.18467.toman144@student.liu.se> Message-ID: <87r6b8vwre.fsf@columbia.edu> Tomas Andersson writes: > You can never go wrong with a good old fashioned hand written tail recursion > when you're in doubt, they are pretty much the closest thing to for-loops > there is in haskell and should be easy to grok for Imperative programmers and > usually produce really fast code. > > sum vect = let d = dim vect > in sum' (d - 1) 0 > where sum' 0 s = s + (vect @> 0) > sum' index s = sum' (index - 1) (s + (vect @> index)) > Do I need the strict version of sum'? Put something like sum' a b | a `seq` b `seq` False = undefined Or ghc will optimize it automatically? I always don't know when such optimization is useful. > > > I don't know the hmatrix api very well, but if there is a function for > computing the inner product between two vectors you could always do something > like the following meta code: > > sum v = innerProduct v <1,1,1,1,1,1> I just doubt the efficiency here. If v is a very large vector, I guess the allocation time of that intermediate vector [1,1..] is not small. But it is just my guess. Xiao-Yong -- c/* __o/* <\ * (__ */\ < From judah.jacobson at gmail.com Sun Jun 8 14:01:45 2008 From: judah.jacobson at gmail.com (Judah Jacobson) Date: Sun Jun 8 13:54:08 2008 Subject: [Haskell-cafe] Re: Patrick Perry's BLAS package In-Reply-To: References: <48492F38.3070107@um.es> <87prquxqig.fsf@columbia.edu> Message-ID: <6d74b0d20806081101n34e1d99l567c551f82b156ec@mail.gmail.com> 2008/6/6 Patrick Perry : > > 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. > > I don't know of a good way to get around this. It seems like every system > has a different convention for the location and name of the cblas libraries. > So, everyone has to edit the "extra-libraries" and the "extra-lib-dirs" > field in the blas.cabal file. Does anyone know of a better way of doing > this? > My preference is to use an autoconf script to solve that problem. ("build-type: Configure" in the cabal file.) For example, the editline and readline C libraries require termcap, which may be linked using one of -lcurses, -ltermcap, etc. The Haskell packages have a configure script which checks which of curses/termcap is available and outputs an editline.buildinfo file with the extra-libraries field filled in. That file is then used automatically by cabal in the build and install phases. See for example: http://code.haskell.org/editline/editline.cabal http://code.haskell.org/editline/configure.ac http://code.haskell.org/editline/editline.buildinfo.in There's also more information is in the Cabal manual: http://haskell.org/cabal/release/latest/doc/users-guide/x30.html#system-dependent Best, -Judah From dons at galois.com Sun Jun 8 14:33:35 2008 From: dons at galois.com (Don Stewart) Date: Sun Jun 8 14:25:59 2008 Subject: [Haskell-cafe] "sum" in hmatrix and blas? In-Reply-To: <87r6b8vwre.fsf@columbia.edu> References: <87y75gx3te.fsf@columbia.edu> <200806081454.18467.toman144@student.liu.se> <87r6b8vwre.fsf@columbia.edu> Message-ID: <20080608183335.GA18015@scytale.galois.com> xj2106: > Tomas Andersson writes: > > > You can never go wrong with a good old fashioned hand written tail recursion > > when you're in doubt, they are pretty much the closest thing to for-loops > > there is in haskell and should be easy to grok for Imperative programmers and > > usually produce really fast code. > > > > sum vect = let d = dim vect > > in sum' (d - 1) 0 > > where sum' 0 s = s + (vect @> 0) > > sum' index s = sum' (index - 1) (s + (vect @> index)) > > > > Do I need the strict version of sum'? Put something like > > sum' a b | a `seq` b `seq` False = undefined > > Or ghc will optimize it automatically? I always don't know > when such optimization is useful. If you give a type annotation, so GHC can tell its an atomic type, like Int or Double, 's' will be inferred as strict. But if in doubt, use bang patterns: {-# LANGUAGE BangPatterns #-} sum vect = sum' (d-1) 0 where d = dim vect go :: Int -> Double -> Double -- for example go 0 s = s + (vect @> 0) go !i !s = go (i-1) (s + (vect @> i)) See this recent post on understanding how these kind of loops are compiled, http://cgi.cse.unsw.edu.au/~dons/blog/2008/05/16 The core for your loop should look very good, assuming @> is efficient. -- Don From aruiz at um.es Sun Jun 8 15:27:11 2008 From: aruiz at um.es (Alberto Ruiz) Date: Sun Jun 8 15:19:42 2008 Subject: [Haskell-cafe] "sum" in hmatrix and blas? In-Reply-To: <87r6b8vwre.fsf@columbia.edu> References: <87y75gx3te.fsf@columbia.edu> <200806081454.18467.toman144@student.liu.se> <87r6b8vwre.fsf@columbia.edu> Message-ID: <484C328F.5080205@um.es> Xiao-Yong Jin wrote: > Tomas Andersson writes: > >> You can never go wrong with a good old fashioned hand written tail recursion >> when you're in doubt, they are pretty much the closest thing to for-loops >> there is in haskell and should be easy to grok for Imperative programmers and >> usually produce really fast code. >> >> sum vect = let d = dim vect >> in sum' (d - 1) 0 >> where sum' 0 s = s + (vect @> 0) >> sum' index s = sum' (index - 1) (s + (vect @> index)) >> > > Do I need the strict version of sum'? Put something like > > sum' a b | a `seq` b `seq` False = undefined > > Or ghc will optimize it automatically? I always don't know > when such optimization is useful. > >> >> I don't know the hmatrix api very well, but if there is a function for >> computing the inner product between two vectors you could always do something >> like the following meta code: >> >> sum v = innerProduct v <1,1,1,1,1,1> > > I just doubt the efficiency here. If v is a very large > vector, I guess the allocation time of that intermediate > vector [1,1..] is not small. But it is just my guess. My experience is that Haskell allocation time is very fast and usually negligible in most non trivial matrix computations. A good thing about sum v = constant 1 (dim v) <.> v is that a constant vector is efficiently created internally (not from an intermediate Haskell list), and the inner product will be computed by the possibly optimized blas version available in your machine. You can also write simple definitions like the next one for the average of the rows of a matrix as a simple vector-matrix product: mean m = w <> m where w = constant k r r = rows m k = 1 / fromIntegral r I prefer high level "index free" matrix operations to C-like code. Definitions are clearer, have less bugs, and are also more efficient if you use optimized numerical libs. In any case, many algorithms can be solved by the recursive approach described by Tomas. Alberto > > Xiao-Yong From lanny at cisco.com Sun Jun 8 18:21:45 2008 From: lanny at cisco.com (Lanny Ripple) Date: Sun Jun 8 18:14:03 2008 Subject: [Haskell-cafe] Re: Quick question for a slow program In-Reply-To: References: <171dfd0a0806070226k7ad4ceaal4cdb4a0892e43519@mail.gmail.com> <484AFEED.908@cisco.com> Message-ID: <484C5B79.3060405@cisco.com> At least when I teased apart why the first one worked it looked heap-like. Each step of the foldr pulled off the smallest nonprime and merged the next two lists guaranteeing that the next smallest nonprime would be at the head of the next step. Can't argue with results though. The version you have up is about twice as fast as the old one (if a bit harder to read). -ljr apfelmus wrote: > Lanny Ripple wrote: >> The second prime generator on this page >> >> http://www.haskell.org/haskellwiki/Prime_numbers >> >> is quick and easy. I keep it nearby for all those sudden attacks of >> needing to solve yet another projecteuler problem. > > The second prime sieve did not create an implicit heap as advertised. > I've fixed that and also cleaned up the page a bit, moving this sieve to > the section "Implicit Heap". > > > Regards, > apfelmus > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From catanzar at EECS.Berkeley.EDU Sun Jun 8 19:28:49 2008 From: catanzar at EECS.Berkeley.EDU (Bryan Catanzaro) Date: Sun Jun 8 19:21:21 2008 Subject: [Haskell-cafe] Printing a random list Message-ID: <4D711340-1377-433C-8E1C-122003B979EF@EECS.Berkeley.EDU> I'm just starting out with Haskell, and I could use some help. I'm trying to create a random list and print it out, which seems simple enough, but has been giving me problems. Here's what I have: module Main where import IO import Random randomList :: Random a => a -> a-> [IO a] randomList lbound ubound = randomRIO(lbound, ubound) : randomList lbound ubound main = do myRandomList <- sequence(randomList(0::Int 255)) putStrLn(show(take(10 myRandomList))) ----- So, I have tried to make a randomList action which defines an infinite random list, bounded by lbound and ubound. It seems that to print this, I need to convert between randomList, which is of type [IO a] to something like IO [a], which is what sequence should do for me. Then I just want to print out the first 10 elements. I'm currently getting the error "Only unit numeric type pattern is valid", pointing to 0::Int 255 in the code. I'm not sure what this means. I'm sure I'm looking at this the wrong way, since I'm new to Haskell and haven't quite wrapped my head around it yet. Maybe you can fix the problem by showing me a more Haskell approach to creating a random list and printing it... =) Thanks! - bryan catanzaro From dons at galois.com Sun Jun 8 19:33:11 2008 From: dons at galois.com (Don Stewart) Date: Sun Jun 8 19:25:34 2008 Subject: [Haskell-cafe] Printing a random list In-Reply-To: <4D711340-1377-433C-8E1C-122003B979EF@EECS.Berkeley.EDU> References: <4D711340-1377-433C-8E1C-122003B979EF@EECS.Berkeley.EDU> Message-ID: <20080608233311.GB18376@scytale.galois.com> catanzar: > I'm just starting out with Haskell, and I could use some help. I'm > trying to create a random list and print it out, which seems simple > enough, but has been giving me problems. Here's what I have: > > module Main > where > import IO > import Random > > randomList :: Random a => a -> a-> [IO a] > randomList lbound ubound = randomRIO(lbound, ubound) : > randomList lbound ubound > > > main = do > myRandomList <- sequence(randomList(0::Int 255)) > putStrLn(show(take(10 myRandomList))) > > > > ----- > > So, I have tried to make a randomList action which defines an infinite > random list, bounded by lbound and ubound. It seems that to print > this, I need to convert between randomList, which is of type [IO a] to > something like IO [a], which is what sequence should do for me. Then > I just want to print out the first 10 elements. > > I'm currently getting the error "Only unit numeric type pattern is > valid", pointing to 0::Int 255 in the code. I'm not sure what this > means. Missing parenthesis around the (0 :: Int) type annotation. > I'm sure I'm looking at this the wrong way, since I'm new to Haskell > and haven't quite wrapped my head around it yet. Maybe you can fix > the problem by showing me a more Haskell approach to creating a random > list and printing it... =) > For lists, best to use the randomRs function, import System.Random main = do g <- newStdGen print (take 10 (randomRs (0,255) g :: [Int])) Running it: $ runhaskell A.hs [11,90,187,119,240,57,241,52,143,86] Cheers, Don From xj2106 at columbia.edu Sun Jun 8 19:40:55 2008 From: xj2106 at columbia.edu (Xiao-Yong Jin) Date: Sun Jun 8 19:37:50 2008 Subject: [Haskell-cafe] "sum" in hmatrix and blas? In-Reply-To: <484C328F.5080205@um.es> (Alberto Ruiz's message of "Sun, 08 Jun 2008 21:27:11 +0200") References: <87y75gx3te.fsf@columbia.edu> <200806081454.18467.toman144@student.liu.se> <87r6b8vwre.fsf@columbia.edu> <484C328F.5080205@um.es> Message-ID: <877iczwl4o.fsf@columbia.edu> Alberto Ruiz writes: > My experience is that Haskell allocation time is very fast and usually > negligible in most non trivial matrix computations. > > A good thing about > > sum v = constant 1 (dim v) <.> v > > is that a constant vector is efficiently created internally (not from > an intermediate Haskell list), and the inner product will be computed > by the possibly optimized blas version available in your machine. > > You can also write simple definitions like the next one for the > average of the rows of a matrix as a simple vector-matrix product: > > mean m = w <> m > where w = constant k r > r = rows m > k = 1 / fromIntegral r > > I prefer high level "index free" matrix operations to C-like > code. Definitions are clearer, have less bugs, and are also more > efficient if you use optimized numerical libs. > > In any case, many algorithms can be solved by the recursive approach > described by Tomas. After reading don's blog, I tried to make a test with both methods. The code is very simple, as following module Main where import System import Numeric.LinearAlgebra vsum1 :: Vector Double -> Double vsum1 v = constant 1 (dim v) <.> v vsum2 :: Vector Double -> Double vsum2 v = go (d - 1) 0 where d = dim v go :: Int -> Double -> Double go 0 s = s + (v @> 0) go !j !s = go (j - 1) (s + (v @> j)) mean :: Vector Double -> Double mean v = vsum v / fromIntegral (dim v) where vsum = vsum1 main :: IO () main = do fn:nrow:ncol:_ <- getArgs print . mean . flatten =<< fromFile fn (read nrow, read ncol) Compile it with "-O2 -optc-O2", and run with a data set of length 5000000. The results are with "vsum1": 80,077,984 bytes allocated in the heap 2,208 bytes copied during GC (scavenged) 64 bytes copied during GC (not scavenged) 40,894,464 bytes maximum residency (2 sample(s)) %GC time 0.0% (0.0% elapsed) Alloc rate 35,235,448 bytes per MUT second ./vsum1 huge 5000000 1 2.25s user 0.09s system 99% cpu 2.348 total This is reasonable, exactly two copies of vector with size of 40MB. with "vsum2": 560,743,120 bytes allocated in the heap 19,160 bytes copied during GC (scavenged) 15,920 bytes copied during GC (not scavenged) 40,919,040 bytes maximum residency (2 sample(s)) %GC time 0.3% (0.3% elapsed) Alloc rate 222,110,261 bytes per MUT second ./mean2 huge 5000000 1 2.53s user 0.06s system 99% cpu 2.598 total This is strange. A lot of extra usage of heap? Probably because '@>' is not efficient? So it looks like the inner-product approach wins with a fairly margin. -- c/* __o/* <\ * (__ */\ < From catanzar at EECS.Berkeley.EDU Sun Jun 8 19:46:51 2008 From: catanzar at EECS.Berkeley.EDU (Bryan Catanzaro) Date: Sun Jun 8 19:39:16 2008 Subject: [Haskell-cafe] Printing a random list In-Reply-To: <20080608233311.GB18376@scytale.galois.com> References: <4D711340-1377-433C-8E1C-122003B979EF@EECS.Berkeley.EDU> <20080608233311.GB18376@scytale.galois.com> Message-ID: <9DDAB370-CE8F-4EA8-B287-0995F3CD7055@EECS.Berkeley.EDU> Thanks for the response, it does compile after I juggled some parentheses around. And also I appreciate the pointer to the better way of making a random list. So that problem is solved. However, when I ran my random list generator, the interpreter had a stack overflow. Here's my code again: --- module Main where import IO import Random randomList :: Random a => a -> a-> [IO a] randomList lbound ubound = randomRIO(lbound, ubound) : randomList lbound ubound main = do myRandomList <- sequence(randomList (0::Int) 255) putStrLn(show(take 10 myRandomList)) --- It seems that this code somehow tries to evaluate every element of the infinite list defined by randomList. Can you tell me why it is not lazily evaluating this list? I can get around this by changing main to do this instead: --- main = do myRandomList <- sequence(take 10 (randomList (0::Int) 255)) putStrLn(show(myRandomList)) --- But I don't understand why sequence(randomList (0::Int) 255) actually tries to evaluate the entire infinite list, instead of just lazily defining a list with the proper types, that I evaluate later when I take elements from it. Thanks for your help! - bryan On Jun 8, 2008, at 4:33 PM, Don Stewart wrote: > catanzar: >> I'm just starting out with Haskell, and I could use some help. I'm >> trying to create a random list and print it out, which seems simple >> enough, but has been giving me problems. Here's what I have: >> >> module Main >> where >> import IO >> import Random >> >> randomList :: Random a => a -> a-> [IO a] >> randomList lbound ubound = randomRIO(lbound, ubound) : >> randomList lbound ubound >> >> >> main = do >> myRandomList <- sequence(randomList(0::Int 255)) >> putStrLn(show(take(10 myRandomList))) >> >> >> >> ----- >> >> So, I have tried to make a randomList action which defines an >> infinite >> random list, bounded by lbound and ubound. It seems that to print >> this, I need to convert between randomList, which is of type [IO a] >> to >> something like IO [a], which is what sequence should do for me. Then >> I just want to print out the first 10 elements. >> >> I'm currently getting the error "Only unit numeric type pattern is >> valid", pointing to 0::Int 255 in the code. I'm not sure what this >> means. > > Missing parenthesis around the (0 :: Int) type annotation. > >> I'm sure I'm looking at this the wrong way, since I'm new to Haskell >> and haven't quite wrapped my head around it yet. Maybe you can fix >> the problem by showing me a more Haskell approach to creating a >> random >> list and printing it... =) >> > > For lists, best to use the randomRs function, > > import System.Random > > main = do > g <- newStdGen > print (take 10 (randomRs (0,255) g :: [Int])) > > Running it: > > $ runhaskell A.hs > [11,90,187,119,240,57,241,52,143,86] > > Cheers, > Don From bos at serpentine.com Sun Jun 8 20:01:48 2008 From: bos at serpentine.com (Bryan O'Sullivan) Date: Sun Jun 8 19:54:54 2008 Subject: [Haskell-cafe] Re: Patrick Perry's BLAS package In-Reply-To: <6d74b0d20806081101n34e1d99l567c551f82b156ec@mail.gmail.com> References: <48492F38.3070107@um.es> <87prquxqig.fsf@columbia.edu> <6d74b0d20806081101n34e1d99l567c551f82b156ec@mail.gmail.com> Message-ID: <484C72EC.2010003@serpentine.com> Judah Jacobson wrote: > My preference is to use an autoconf script to solve that problem. > ("build-type: Configure" in the cabal file.) That approach would not work well for BLAS. The various BLAS libraries have profoundly different performance characteristics, and you wouldn't want to get the wrong one for your system, if you had both installed. References: <87y75gx3te.fsf@columbia.edu> <200806081454.18467.toman144@student.liu.se> <87r6b8vwre.fsf@columbia.edu> <484C328F.5080205@um.es> <877iczwl4o.fsf@columbia.edu> Message-ID: <20080609001622.GC18376@scytale.galois.com> Below are some notes on this for Simon PJ and Alberto. In general, GHC is doing very well here, with only one small wibble preventing the recursive version running as fast as the C version. xj2106: > Alberto Ruiz writes: > > > My experience is that Haskell allocation time is very fast and usually > > negligible in most non trivial matrix computations. > > > > A good thing about > > > > sum v = constant 1 (dim v) <.> v > > > > is that a constant vector is efficiently created internally (not from > > an intermediate Haskell list), and the inner product will be computed > > by the possibly optimized blas version available in your machine. > > > > You can also write simple definitions like the next one for the > > average of the rows of a matrix as a simple vector-matrix product: > > > > mean m = w <> m > > where w = constant k r > > r = rows m > > k = 1 / fromIntegral r > > > > I prefer high level "index free" matrix operations to C-like > > code. Definitions are clearer, have less bugs, and are also more > > efficient if you use optimized numerical libs. > > > > In any case, many algorithms can be solved by the recursive approach > > described by Tomas. > > After reading don's blog, I tried to make a test with both > methods. The code is very simple, as following > > module Main where > import System > import Numeric.LinearAlgebra > > vsum1 :: Vector Double -> Double > vsum1 v = constant 1 (dim v) <.> v > > vsum2 :: Vector Double -> Double > vsum2 v = go (d - 1) 0 > where > d = dim v > go :: Int -> Double -> Double > go 0 s = s + (v @> 0) > go !j !s = go (j - 1) (s + (v @> j)) > > > mean :: Vector Double -> Double > mean v = vsum v / fromIntegral (dim v) > where vsum = vsum1 > > main :: IO () > main = do > fn:nrow:ncol:_ <- getArgs > print . mean . flatten =<< fromFile fn (read nrow, read ncol) > > Compile it with "-O2 -optc-O2", and run with a data set of > length 5000000. The results are > > with "vsum1": > 80,077,984 bytes allocated in the heap > 2,208 bytes copied during GC (scavenged) > 64 bytes copied during GC (not scavenged) > 40,894,464 bytes maximum residency (2 sample(s)) > %GC time 0.0% (0.0% elapsed) > Alloc rate 35,235,448 bytes per MUT second > ./vsum1 huge 5000000 1 2.25s user 0.09s system 99% cpu 2.348 total > > This is reasonable, exactly two copies of vector with size > of 40MB. > > with "vsum2": > 560,743,120 bytes allocated in the heap > 19,160 bytes copied during GC (scavenged) > 15,920 bytes copied during GC (not scavenged) > 40,919,040 bytes maximum residency (2 sample(s)) > %GC time 0.3% (0.3% elapsed) > Alloc rate 222,110,261 bytes per MUT second > ./mean2 huge 5000000 1 2.53s user 0.06s system 99% cpu 2.598 total > > This is strange. A lot of extra usage of heap? Probably > because '@>' is not efficient? So it looks like the > inner-product approach wins with a fairly margin. Yes, I'd suspect that @> isn't fully unlifted, so you get some heap allocation on each index, each time around the loop? We'd have to look at how @> was defined to spot why. I began with: $ cabal install hmatrix which failed, due to missing linking against gfortran and glscblas Added those to the cabal file, and hmatrix was installed. Looking at the core we get from vsum2, we see: vsum2 compiles quite well $wgo_s1Nn :: Int# -> Double# -> Double# $wgo_s1Nn = \ (ww3_s1Mc :: Int#) (ww4_s1Mg :: Double#) -> case ww3_s1Mc of ds_X17R { __DEFAULT -> case Data.Packed.Internal.Vector.$wat @ Double Foreign.Storable.$f9 ww_s1Ms ww1_s1Mu (I# ds_X17R) of { D# y_a1KQ -> $wgo_s1Nn (-# ds_X17R 1) (+## ww4_s1Mg y_a1KQ) }; 0 -> +## ww4_s1Mg ww2_s1M7 }; } in $wgo_s1Nn (-# ww_s1Ms 1) 0.0 But note the return value from $wat is boxed, only to be immediately unboxed. That looks to be the source of the heap allocations. Let's see if we can help that. Vector is defined as: data Vector t = V { dim :: Int -- ^ number of elements , fptr :: ForeignPtr t -- ^ foreign pointer to the memory block } While a much better definition would be: data Vector t = V { dim :: {-# UNPACK #-} !Int -- ^ number of elements , fptr :: {-# UNPACK #-} !(ForeignPtr t) -- ^ foreign pointer to the memory block } And we can add some inlining to at' and at. That might be enough for GHC to see through to the D# boxing. Now they're fully unfolded and specialised into our source program, True -> case unsafeDupablePerformIO @ Double ((\ (eta1_a1KA :: State# RealWorld) -> case noDuplicate# eta1_a1KA of s'_a1KB { __DEFAULT -> case readDoubleOffAddr# @ RealWorld ww1_s1NB ds_X184 s'_a1KB of wild2_a1Lc { (# s2_a1Le, x_a1Lf #) -> case touch# @ ForeignPtrContents ww2_s1NC s2_a1Le of s_a1KS { __DEFAULT -> BAD -----> (# s_a1KS, D# x_a1Lf #) } } }) `cast` (sym ((:CoIO) Double) :: State# RealWorld -> (# State# RealWorld, Double #) ~ IO Double)) of wild11_a1LC { D# y_a1LE -> $wgo_s1Oz (-# ds_X184 1) (+## ww4_s1Nq y_a1LE) But still the readDoubleOffAddr# result is boxed into D#, and then unboxed in the loop. A GHC optimiser flaw? Possibly the same as: http://hackage.haskell.org/trac/ghc/ticket/2289 Simon PJ, does that seem right? While vsum1 is pretty much unoptimised calls into C; vsum1 :: Data.Packed.Internal.Vector.Vector Double -> Double vsum1 = \ (v_anC :: Data.Packed.Internal.Vector.Vector Double) -> Numeric.LinearAlgebra.Linear.dot @ Double Data.Packed.Internal.Matrix.$f2 (Data.Packed.Internal.Matrix.$sconstantAux Data.Packed.Internal.Matrix.cconstantR lit (case v_anC of tpl_B2 { Data.Packed.Internal.Vector.V ipv_B3 ipv1_B4 -> ipv_B3 })) v_anC Alberto, I would modify the other types in hmatrix similary, data Matrix t = MC { rows :: {-# UNPACK #-} !Int, ... cols :: !Int, cdat :: !(Vector t) } | MF { rows :: {-# UNPACK #-} !Int, ...cols :: !Int, fdat :: !(Vector t) } ensuring we can keep these things in registers. But it would be wise to have some benchmarking too. Alberto, what do you think? Do you have some test data we could play with to see if unboxing the haskell skin over the underlying C calls helps with Haskell-side loops and iterative calls? In general, though, hmatrix looks *very* well written. I'd have good confidence in this library for performance work. -- Don From xj2106 at columbia.edu Sun Jun 8 20:15:55 2008 From: xj2106 at columbia.edu (Xiao-Yong Jin) Date: Sun Jun 8 20:12:50 2008 Subject: [Haskell-cafe] Re: Patrick Perry's BLAS package In-Reply-To: <484C72EC.2010003@serpentine.com> (Bryan O'Sullivan's message of "Sun, 08 Jun 2008 17:01:48 -0700") References: <48492F38.3070107@um.es> <87prquxqig.fsf@columbia.edu> <6d74b0d20806081101n34e1d99l567c551f82b156ec@mail.gmail.com> <484C72EC.2010003@serpentine.com> Message-ID: <87y75fv4xw.fsf@columbia.edu> "Bryan O'Sullivan" writes: > Judah Jacobson wrote: > >> My preference is to use an autoconf script to solve that problem. >> ("build-type: Configure" in the cabal file.) > > That approach would not work well for BLAS. The various BLAS libraries > have profoundly different performance characteristics, and you wouldn't > want to get the wrong one for your system, if you had both installed. Is the blas library linked statically? It looks to me that the binary is dynamically linked. linux-vdso.so.1 => (0x00007fff003fe000) libgsl.so.0 => /usr/lib/libgsl.so.0 (0x00002af4aa8cc000) libblas.so.0 => /usr/lib/libblas.so.0 (0x00002af4aac91000) liblapack.so.0 => /usr/lib/liblapack.so.0 (0x00002af4aaeb0000) libutil.so.1 => /lib/libutil.so.1 (0x00002af4ab612000) libdl.so.2 => /lib/libdl.so.2 (0x00002af4ab815000) libm.so.6 => /lib/libm.so.6 (0x00002af4aba19000) libgmp.so.3 => /usr/lib/libgmp.so.3 (0x00002af4abc9b000) librt.so.1 => /lib/librt.so.1 (0x00002af4abedb000) libc.so.6 => /lib/libc.so.6 (0x00002af4ac0e4000) libgslcblas.so.0 => /usr/lib/libgslcblas.so.0 (0x00002af4ac424000) libgfortran.so.1 => /usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/libgfortran.so.1 (0x00002af4ac654000) libatlas.so.0 => /usr/lib/libatlas.so.0 (0x00002af4ac8eb000) libpthread.so.0 => /lib/libpthread.so.0 (0x00002af4ad123000) libcblas.so.0 => /usr/lib/libcblas.so.0 (0x00002af4ad33e000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00002af4ad55d000) /lib64/ld-linux-x86-64.so.2 (0x00002af4aa6b0000) And presumably the various BLAS implementations share identical interface. You can still change the library at run-time with LD_LIBRARY_PATH. Or am I missing something? Xiao-Yong -- c/* __o/* <\ * (__ */\ < From oddron at gmail.com Sun Jun 8 20:25:41 2008 From: oddron at gmail.com (Ronald Guida) Date: Sun Jun 8 20:18:02 2008 Subject: [Haskell-cafe] Printing a random list In-Reply-To: <9DDAB370-CE8F-4EA8-B287-0995F3CD7055@EECS.Berkeley.EDU> References: <4D711340-1377-433C-8E1C-122003B979EF@EECS.Berkeley.EDU> <20080608233311.GB18376@scytale.galois.com> <9DDAB370-CE8F-4EA8-B287-0995F3CD7055@EECS.Berkeley.EDU> Message-ID: <62728db30806081725r4b57898w859e74bb3866adb8@mail.gmail.com> Bryan Catanzaro wrote: > However, when I ran my random list generator, the interpreter had a stack > overflow. Here's my code again: > --- > module Main > where > import IO > import Random > > randomList :: Random a => a -> a-> [IO a] > randomList lbound ubound = randomRIO(lbound, ubound) : randomList > lbound ubound > > > main = do > myRandomList <- sequence(randomList (0::Int) 255) > putStrLn(show(take 10 myRandomList)) > --- > > It seems that this code somehow tries to evaluate every element of the > infinite list defined by randomList. You are correct. > Can you tell me why it is not lazily evaluating this list? Whenever you use IO, there is a baton being passed along behind the scenes. The baton is called "RealWorld#" and it represents the fact that interactions with global state and the outside world have to be serialized. In particular, whenever you use the global random number generator, a global state variable has to be updated. This has to be serialized, thus the baton has to be passed along from one action to the next. When you "sequence" a list of IO actions, you are effectively sending the baton along that list, and you don't get it back until the end of the list is reached. Your code is sending the baton into an infinite list of actions, never to be returned. > I can get around this by changing main to do this > instead: > > --- > main = do > myRandomList <- sequence(take 10 (randomList (0::Int) 255)) > putStrLn(show(myRandomList)) > --- Now you are sending the baton into a list of only 10 actions. The baton comes back, and the program goes on. If you don't know in advance how many random numbers you need, and if you are satisfied with the global random number generator, then Don Stewart's solution is a better approach. Don Stewart wrote: > main = do > g <- newStdGen > print (take 10 (randomRs (0,255) g :: [Int])) If you want to be able to reproduce the same sequence of random numbers, for example for testing and debugging purposes, then you can use mkStdGen to create your own random number generator, independent of the global one. The catch is that you will have to thread the state of the random number generator through your code. Once you learn about monads (if you haven't already), you'll recognize that you can use the State monad for your random number generator. From dons at galois.com Sun Jun 8 21:25:25 2008 From: dons at galois.com (Don Stewart) Date: Sun Jun 8 21:17:49 2008 Subject: [Haskell-cafe] "sum" in hmatrix and blas? In-Reply-To: <20080609001622.GC18376@scytale.galois.com> References: <87y75gx3te.fsf@columbia.edu> <200806081454.18467.toman144@student.liu.se> <87r6b8vwre.fsf@columbia.edu> <484C328F.5080205@um.es> <877iczwl4o.fsf@columbia.edu> <20080609001622.GC18376@scytale.galois.com> Message-ID: <20080609012525.GA18748@scytale.galois.com> Problem solved. The Haskell loop now wins. > > After reading don's blog, I tried to make a test with both > > methods. The code is very simple, as following > > > > module Main where > > import System > > import Numeric.LinearAlgebra > > > > vsum1 :: Vector Double -> Double > > vsum1 v = constant 1 (dim v) <.> v > > > > vsum2 :: Vector Double -> Double > > vsum2 v = go (d - 1) 0 > > where > > d = dim v > > go :: Int -> Double -> Double > > go 0 s = s + (v @> 0) > > go !j !s = go (j - 1) (s + (v @> j)) > > > > > > mean :: Vector Double -> Double > > mean v = vsum v / fromIntegral (dim v) > > where vsum = vsum1 > > > > main :: IO () > > main = do > > fn:nrow:ncol:_ <- getArgs > > print . mean . flatten =<< fromFile fn (read nrow, read ncol) > > > > Compile it with "-O2 -optc-O2", and run with a data set of > > length 5000000. The results are > > > > with "vsum1": > > 80,077,984 bytes allocated in the heap > > 2,208 bytes copied during GC (scavenged) > > 64 bytes copied during GC (not scavenged) > > 40,894,464 bytes maximum residency (2 sample(s)) > > %GC time 0.0% (0.0% elapsed) > > Alloc rate 35,235,448 bytes per MUT second > > ./vsum1 huge 5000000 1 2.25s user 0.09s system 99% cpu 2.348 total > > > > This is reasonable, exactly two copies of vector with size > > of 40MB. > > > > with "vsum2": > > 560,743,120 bytes allocated in the heap > > 19,160 bytes copied during GC (scavenged) > > 15,920 bytes copied during GC (not scavenged) > > 40,919,040 bytes maximum residency (2 sample(s)) > > %GC time 0.3% (0.3% elapsed) > > Alloc rate 222,110,261 bytes per MUT second > > ./mean2 huge 5000000 1 2.53s user 0.06s system 99% cpu 2.598 total > > > > This is strange. A lot of extra usage of heap? Probably > > because '@>' is not efficient? So it looks like the > > inner-product approach wins with a fairly margin. > Looking at the core we get from vsum2, we see: > > vsum2 compiles quite well > > $wgo_s1Nn :: Int# -> Double# -> Double# > > $wgo_s1Nn = > \ (ww3_s1Mc :: Int#) (ww4_s1Mg :: Double#) -> > case ww3_s1Mc of ds_X17R { > __DEFAULT -> > case Data.Packed.Internal.Vector.$wat > @ Double Foreign.Storable.$f9 ww_s1Ms ww1_s1Mu (I# ds_X17R) > of { D# y_a1KQ -> > $wgo_s1Nn (-# ds_X17R 1) (+## ww4_s1Mg y_a1KQ) > }; > 0 -> +## ww4_s1Mg ww2_s1M7 > }; > } in $wgo_s1Nn (-# ww_s1Ms 1) 0.0 > > But note the return value from $wat is boxed, only to be immediately > unboxed. That looks to be the source of the heap allocations. > > Let's see if we can help that. Ah, of course. The problem is the unsafePerformIO used to wrap up the 'peek'. This blocks the optimisations somewhat, after we unpack the Vector type.. So if we rewrite 'safeRead' to not use unsafePerformIO, but instead: safeRead v = inlinePerformIO . withForeignPtr (fptr v) inlinePerformIO (IO m) = case m realWorld# of (# _, r #) -> r Along with this change to Vector: data Vector t = V { dim :: {-# UNPACK #-} !Int , fptr :: {-# UNPACK #-} !(ForeignPtr t) } and some inlining for the bounds checks. Following bytestrings, we see the performance go from, with a 180M input file: Goal: vsum1: $ ghc-core A.hs -optc-O2 -fvia-C -fbang-patterns $ time ./A data 4000 2500 0.9999727441161678 ./A data 4000 2500 5.37s user 0.20s system 99% cpu 5.609 total 160,081,136 bytes allocated in the heap 155 Mb total memory in use Before: vsum2-old: $wgo_s1Ns = \ (ww3_s1Me :: Int#) (ww4_s1Mi :: Double#) -> case ww3_s1Me of ds_X17Y { __DEFAULT -> case Data.Packed.Internal.Vector.$wat @ Double Foreign.Storable.$f9 ww_s1Mu ww1_s1Mw (I# ds_X17Y) of wild1_a1Hg { D# y_a1Hi -> $wgo_s1Ns (-# ds_X17Y 1) (+## ww4_s1Mi y_a1Hi) }; 0 -> +## ww4_s1Mi ww2_s1M9 }; } in $wgo_s1Ns (-# ww_s1Mu 1) 0.0 ./A data 4000 2500 +RTS -sstderr 0.999972744115876 ./A data 4000 2500 +RTS -sstderr 6.04s user 0.15s system 99% cpu 6.203 total 1,121,416,400 bytes allocated in the heap 78 Mb total memory in use After: True -> case readDoubleOffAddr# @ RealWorld ww1_s1Nr ds_X180 realWorld# of wild2_a1HS { (# s2_a1HU, x_a1HV #) -> case touch# @ ForeignPtrContents ww2_s1Ns s2_a1HU of s_a1HG { __DEFAULT -> $wgo_s1Ok (-# ds_X180 1) (+## ww4_s1Ng x_a1HV) } No needless boxing. $ time ./A data 4000 2500 +RTS -sstderr ./A data 4000 2500 +RTS -sstderr 0.999972744115876 ./A data 4000 2500 +RTS -sstderr 5.41s user 0.10s system 99% cpu 5.548 total 80,071,072 bytes allocated in the heap 78 Mb total memory in use And the total runtime and allocation now is better than the fully 'C' version. Yay. Patch attached to the darcs version of hmatrix. Similar changes can likely be done to the other data types in hmatrix, for pretty much ideal code. -- Don -------------- next part -------------- Sun Jun 8 18:21:18 PDT 2008 Don Stewart * Use unpacking and inlining to ensure Vector can be stored unlifted at runtime New patches: [Use unpacking and inlining to ensure Vector can be stored unlifted at runtime Don Stewart **20080609012118] { hunk ./lib/Data/Packed/Internal/Vector.hs 24 +import GHC.Base +import GHC.IOBase + hunk ./lib/Data/Packed/Internal/Vector.hs 28 -data Vector t = V { dim :: Int -- ^ number of elements - , fptr :: ForeignPtr t -- ^ foreign pointer to the memory block +data Vector t = V { dim :: {-# UNPACK #-} !Int -- ^ number of elements + , fptr :: {-# UNPACK #-}!(ForeignPtr t) -- ^ foreign pointer to the memory block hunk ./lib/Data/Packed/Internal/Vector.hs 59 -safeRead v = unsafePerformIO . withForeignPtr (fptr v) +safeRead v = inlinePerformIO . withForeignPtr (fptr v) +{-# INLINE safeRead #-} + +inlinePerformIO :: IO a -> a +inlinePerformIO (IO m) = case m realWorld# of (# _, r #) -> r +{-# INLINE inlinePerformIO #-} hunk ./lib/Data/Packed/Internal/Vector.hs 88 +{-# INLINE at #-} } Context: [range checking and other additions to the mutable interface Alberto Ruiz **20080606154148] [safe wrappers and examples/parallel.hs Alberto Ruiz **20080606120801] [really add Data.Packed.ST.hs Alberto Ruiz **20080605123525] [added acknowledgement to Bulat Alberto Ruiz **20080605122046] [remove updateVector and updateMatrix Alberto Ruiz **20080605121008] [first version of Data.Packed.ST Alberto Ruiz **20080605120440] [Data.Packed.Convert Alberto Ruiz **20080603090037] [added updateMatrix Alberto Ruiz **20080601120950] [added updateVector Alberto Ruiz **20080601113907] [TAG 0.3.0.0 Alberto Ruiz **20080527125906] Patch bundle hash: 189a5974a11e189e967d537176cf24e388e332e3 From goalieca at gmail.com Sun Jun 8 22:15:15 2008 From: goalieca at gmail.com (Ryan Dickie) Date: Sun Jun 8 22:07:38 2008 Subject: [Haskell-cafe] Vancouver Haskell users meeting In-Reply-To: <20080606043330.GA3478@cyberberry.com> References: <48444E7C.7050602@moonloop.net> <20080606043330.GA3478@cyberberry.com> Message-ID: <4c69c1be0806081915i558f6214i6b1b90eb03a3487c@mail.gmail.com> Same deal but i'm in Ottawa for the summer. I'll be back around september. --ryan 2008/6/6 Asumu Takikawa : > 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 > > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.6 (GNU/Linux) > > iD8DBQFISL4aPVZMXBlgx7ERAv/OAJwP/1bfduqEa6bTBEaOV3420puRKACfU+Pa > sZtx9R39ZlrrjUp8/zMlNhk= > =+LbA > -----END PGP SIGNATURE----- > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From vigalchin at gmail.com Sun Jun 8 22:17:14 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Sun Jun 8 22:09:40 2008 Subject: [Haskell-cafe] FunPtr error? Message-ID: <5ae4f2ba0806081917u3cbeada0ge4968bb5183c888e@mail.gmail.com> Hello, I am getting what is to me a mysterious error in a test case that I am writing: vigalchin@ubuntu:~/FTP/Haskell/unix-2.2.0.0/tests/timer$ runhaskell Setup.lhs build Preprocessing executables for Test-1.0... Building Test-1.0... [1 of 1] Compiling Main ( ./timer.hs, dist/build/timer/timer-tmp/Main.o ) ./timer.hs:11:45: Not in scope: data constructor `FunPtr' It seems like the compiler is complaining about the lack of FunPtr in it's symbol table but System.Posix is imported: module Main where import System.Posix import Foreign import Foreign.C import Foreign.Ptr main = do let event = Sigevent{sigevFunction=(FunPtr (notifyFunc))} <<<<<< error here timerId <- timerCreate Clock_Realtime Nothing timerDelete timerId return () notifyFunc :: Sigval -> IO () notifyFunc sigval = do putStrLn "timer POP!!!!!!!" return () I am probably looking right at the answer and not seeing it. ?? Thanks, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080608/631fd843/attachment.htm From lrpalmer at gmail.com Sun Jun 8 23:01:03 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Sun Jun 8 22:53:24 2008 Subject: [Haskell-cafe] FunPtr error? In-Reply-To: <5ae4f2ba0806081917u3cbeada0ge4968bb5183c888e@mail.gmail.com> References: <5ae4f2ba0806081917u3cbeada0ge4968bb5183c888e@mail.gmail.com> Message-ID: <7ca3f0160806082001v2264fd02n69d9bf06da672227@mail.gmail.com> 2008/6/8 Galchin, Vasili : > Hello, > > I am getting what is to me a mysterious error in a test case that I am > writing: > vigalchin@ubuntu:~/FTP/Haskell/unix-2.2.0.0/tests/timer$ runhaskell > Setup.lhs build > Preprocessing executables for Test-1.0... > Building Test-1.0... > [1 of 1] Compiling Main ( ./timer.hs, > dist/build/timer/timer-tmp/Main.o ) > > ./timer.hs:11:45: Not in scope: data constructor `FunPtr' There is a *type* called FunPtr in scope, but not a data constructor as you are using it. That is, you could say: foo :: FunPtr (Int -> IO ()) That is, use the type called FunPtr, but you may not use a *function* called FunPtr, because it doesn't exist. You need to use functions like nullFunPtr, castPtrToFunPtr, etc. to construct FunPtrs. Luke From vigalchin at gmail.com Sun Jun 8 23:07:37 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Sun Jun 8 22:59:59 2008 Subject: [Haskell-cafe] FunPtr error? In-Reply-To: <7ca3f0160806082001v2264fd02n69d9bf06da672227@mail.gmail.com> References: <5ae4f2ba0806081917u3cbeada0ge4968bb5183c888e@mail.gmail.com> <7ca3f0160806082001v2264fd02n69d9bf06da672227@mail.gmail.com> Message-ID: <5ae4f2ba0806082007j7c02b68ch368c4a6aad27eeb0@mail.gmail.com> ah ..,. right ,..... my bad. Vasili On Sun, Jun 8, 2008 at 10:01 PM, Luke Palmer wrote: > 2008/6/8 Galchin, Vasili : > > Hello, > > > > I am getting what is to me a mysterious error in a test case that I > am > > writing: > > vigalchin@ubuntu:~/FTP/Haskell/unix-2.2.0.0/tests/timer$ runhaskell > > Setup.lhs build > > Preprocessing executables for Test-1.0... > > Building Test-1.0... > > [1 of 1] Compiling Main ( ./timer.hs, > > dist/build/timer/timer-tmp/Main.o ) > > > > ./timer.hs:11:45: Not in scope: data constructor `FunPtr' > > There is a *type* called FunPtr in scope, but not a data constructor > as you are using it. That is, you could say: > > foo :: FunPtr (Int -> IO ()) > > That is, use the type called FunPtr, but you may not use a *function* > called FunPtr, because it doesn't exist. You need to use functions > like nullFunPtr, castPtrToFunPtr, etc. to construct FunPtrs. > > Luke > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080608/963cfb54/attachment.htm From byorgey at gmail.com Sun Jun 8 23:43:58 2008 From: byorgey at gmail.com (Brent Yorgey) Date: Sun Jun 8 23:36:19 2008 Subject: [Haskell-cafe] Package updates on haskell.org In-Reply-To: <20080605224735.GD20317@scytale.galois.com> References: <20080605224735.GD20317@scytale.galois.com> Message-ID: <22fcbd520806082043pf032794s8cf99e1b998cf421@mail.gmail.com> On Thu, Jun 5, 2008 at 6:47 PM, Don Stewart wrote: > The HWN, which I'm sadly too busy to maintain now, Does this imply that you're looking for someone to take over the HWN? I'd be willing. -Brent -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080608/812260ce/attachment.htm From vigalchin at gmail.com Sun Jun 8 23:46:23 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Sun Jun 8 23:38:46 2008 Subject: Fwd: [Haskell-cafe] FunPtr error? In-Reply-To: <5ae4f2ba0806082012h2766337bqed0f88cb177f3b11@mail.gmail.com> References: <5ae4f2ba0806081917u3cbeada0ge4968bb5183c888e@mail.gmail.com> <7ca3f0160806082001v2264fd02n69d9bf06da672227@mail.gmail.com> <5ae4f2ba0806082012h2766337bqed0f88cb177f3b11@mail.gmail.com> Message-ID: <5ae4f2ba0806082046i7e116808l414397f040753249@mail.gmail.com> So Luke .. how do I go from (Sigval -> ()), i..e notifyFunc, to FunPtr using the suggested data constructors? On Sun, Jun 8, 2008 at 10:01 PM, Luke Palmer wrote: > 2008/6/8 Galchin, Vasili : > > Hello, > > > > I am getting what is to me a mysterious error in a test case that I > am > > writing: > > vigalchin@ubuntu:~/FTP/Haskell/unix-2.2.0.0/tests/timer$ runhaskell > > Setup.lhs build > > Preprocessing executables for Test-1.0... > > Building Test-1.0... > > [1 of 1] Compiling Main ( ./timer.hs, > > dist/build/timer/timer-tmp/Main.o ) > > > > ./timer.hs:11:45: Not in scope: data constructor `FunPtr' > > There is a *type* called FunPtr in scope, but not a data constructor > as you are using it. That is, you could say: > > foo :: FunPtr (Int -> IO ()) > > That is, use the type called FunPtr, but you may not use a *function* > called FunPtr, because it doesn't exist. You need to use functions > like nullFunPtr, castPtrToFunPtr, etc. to construct FunPtrs. > > Luke > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080608/c98b9bc5/attachment.htm From bulat.ziganshin at gmail.com Mon Jun 9 01:54:28 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Jun 9 01:46:57 2008 Subject: [Haskell-cafe] FunPtr error? In-Reply-To: <5ae4f2ba0806081917u3cbeada0ge4968bb5183c888e@mail.gmail.com> References: <5ae4f2ba0806081917u3cbeada0ge4968bb5183c888e@mail.gmail.com> Message-ID: <1097402345.20080609095428@gmail.com> Hello Vasili, Monday, June 9, 2008, 6:17:14 AM, you wrote: 1. standard place to import FunPtr from is Foreign.Ptr, not System.Posix 2. FunPtr is exported as abstract type, without constructors. you can't construct values of this type directly. instead you should use "wrapper" generators as in the example that Clause has wrote. read it carefully :) > Hello, > ???? I am getting what is to me a mysterious error in a test case that I am writing: > vigalchin@ubuntu:~/FTP/Haskell/unix-2.2.0.0/tests/timer$ runhaskell Setup.lhs build > Preprocessing executables for Test-1.0... > Building Test-1.0... > [1 of 1] Compiling Main???????????? ( ./timer.hs, > dist/build/timer/timer-tmp/Main.o ) > ./timer.hs:11:45: Not in scope: data constructor `FunPtr' > It seems like the compiler is complaining about the lack of FunPtr > in it's symbol table but System.Posix is imported: > > module Main where > import System.Posix > import Foreign > import Foreign.C > import Foreign.Ptr > main = do > ???????? let event = Sigevent{sigevFunction=(FunPtr (notifyFunc))}? <<<<<< error here > > ???????? timerId <- timerCreate Clock_Realtime Nothing > ???????? timerDelete timerId > ???????? return () > notifyFunc :: Sigval -> IO () > notifyFunc sigval = do > ?? putStrLn "timer POP!!!!!!!" > ?? return () > I am probably looking right at the answer and not seeing it. ?? > Thanks, Vasili > -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bulat.ziganshin at gmail.com Mon Jun 9 01:55:15 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Jun 9 01:47:42 2008 Subject: [Haskell-cafe] Package updates on haskell.org In-Reply-To: <22fcbd520806082043pf032794s8cf99e1b998cf421@mail.gmail.com> References: <20080605224735.GD20317@scytale.galois.com> <22fcbd520806082043pf032794s8cf99e1b998cf421@mail.gmail.com> Message-ID: <1608367796.20080609095515@gmail.com> Hello Brent, Monday, June 9, 2008, 7:43:58 AM, you wrote: > The HWN, which I'm sadly too busy to maintain now, > Does this imply that you're looking for someone to take over the HWN?? I'd be willing. it will be cool! -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From dons at galois.com Mon Jun 9 02:01:03 2008 From: dons at galois.com (Don Stewart) Date: Mon Jun 9 01:53:36 2008 Subject: [Haskell-cafe] Package updates on haskell.org In-Reply-To: <22fcbd520806082043pf032794s8cf99e1b998cf421@mail.gmail.com> References: <20080605224735.GD20317@scytale.galois.com> <22fcbd520806082043pf032794s8cf99e1b998cf421@mail.gmail.com> Message-ID: <20080609060103.GL18376@scytale.galois.com> byorgey: > On Thu, Jun 5, 2008 at 6:47 PM, Don Stewart <[1]dons@galois.com> wrote: > > The HWN, which I'm sadly too busy to maintain now, > > Does this imply that you're looking for someone to take over the HWN? I'd > be willing. Yep, I've spoken with Brent. He's just starting his PhD, so a perfect candidate to take over the weekly news. More announcements to follow. Thanks for the offer , Brent! -- Don From vigalchin at gmail.com Mon Jun 9 02:24:59 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Mon Jun 9 02:17:20 2008 Subject: [Haskell-cafe] FunPtr error? In-Reply-To: <1097402345.20080609095428@gmail.com> References: <5ae4f2ba0806081917u3cbeada0ge4968bb5183c888e@mail.gmail.com> <1097402345.20080609095428@gmail.com> Message-ID: <5ae4f2ba0806082324t53691b06se7efa48f5df7c379@mail.gmail.com> Thanks. Clause? regards, Vasili On Mon, Jun 9, 2008 at 12:54 AM, Bulat Ziganshin wrote: > Hello Vasili, > > Monday, June 9, 2008, 6:17:14 AM, you wrote: > > 1. standard place to import FunPtr from is Foreign.Ptr, not System.Posix > 2. FunPtr is exported as abstract type, without constructors. you > can't construct values of this type directly. instead you should use > "wrapper" generators as in the example that Clause has wrote. read it > carefully :) > > > > Hello, > > > I am getting what is to me a mysterious error in a test case that I > am writing: > > vigalchin@ubuntu:~/FTP/Haskell/unix-2.2.0.0/tests/timer$ runhaskell > Setup.lhs build > > Preprocessing executables for Test-1.0... > > Building Test-1.0... > > [1 of 1] Compiling Main ( ./timer.hs, > > dist/build/timer/timer-tmp/Main.o ) > > > ./timer.hs:11:45: Not in scope: data constructor `FunPtr' > > > It seems like the compiler is complaining about the lack of FunPtr > > in it's symbol table but System.Posix is imported: > > > > module Main where > > > import System.Posix > > import Foreign > > import Foreign.C > > import Foreign.Ptr > > > main = do > > > let event = Sigevent{sigevFunction=(FunPtr (notifyFunc))} > <<<<<< error here > > > > timerId <- timerCreate Clock_Realtime Nothing > > > timerDelete timerId > > > return () > > > notifyFunc :: Sigval -> IO () > > notifyFunc sigval = do > > putStrLn "timer POP!!!!!!!" > > return () > > > I am probably looking right at the answer and not seeing it. ?? > > > Thanks, Vasili > > > > > > > > -- > Best regards, > Bulat mailto:Bulat.Ziganshin@gmail.com > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080609/1f4004ce/attachment.htm From apfelmus at quantentunnel.de Mon Jun 9 05:28:48 2008 From: apfelmus at quantentunnel.de (apfelmus) Date: Mon Jun 9 05:21:19 2008 Subject: [Haskell-cafe] Re: Quick question for a slow program In-Reply-To: <484C5B79.3060405@cisco.com> References: <171dfd0a0806070226k7ad4ceaal4cdb4a0892e43519@mail.gmail.com> <484AFEED.908@cisco.com> <484C5B79.3060405@cisco.com> Message-ID: Lanny Ripple wrote: > At least when I teased apart why the first one worked it looked > heap-like. Each step of the foldr pulled off the smallest nonprime > and merged the next two lists guaranteeing that the next smallest > nonprime would be at the head of the next step. Well, there is heap and heap. It's true that the tree of calls to merge fulfills the heap property, see the following diagrams: merge before evaluation / \ 4 merge : / \ 6 9 merge : : / \ 8 12 25 merge : ... : / \ ... 30 49 ... : : ... ... 4 first element : merge / \ 6 9 : : 8 merge : / \ ... 12 25 : : ... merge / \ 30 49 : : ... merge / \ ... ... 4 first and second element : 6 : merge / \ 8 9 : : ... merge / \ 12 25 : : ... merge / \ 30 49 : : ... merge / \ ... ... and so on. But as you can see, the heap is not balanced, foldr1 merge only generates a linear chain of merge nodes. A balanced tree like merge / \ merge merge / \ / \ 4 9 25 49 : : : : ... ... ... ... would be better, except that we need a variant that with an infinite number of leaves. The function foldTree builds such a tree. There is also the complication that the heap "bites its own tail" in that the multiples of a prime, and hence the heap, are not available until the prime itself has been calculated from the heap. The People a data structure solves this. Regards, apfelmus From ko at daimi.au.dk Mon Jun 9 09:20:33 2008 From: ko at daimi.au.dk (Klaus Ostermann) Date: Mon Jun 9 09:12:55 2008 Subject: [Haskell-cafe] Moving "forall" over type constructors Message-ID: <484D2E21.7000005@daimi.au.dk> At first I'd like to thank Claus, Ryan, Edsko, Luke and Derek for their quite helpful replies to my previous thread. In the course of following their advice I encountered the problem of moving a "forall" quantifier over a wrapper type constructor. If I have > newtype Wrapper a = Wrapper a and I instantiate Wrapper with a polymorphic type, then it is possible to move the quantifier outside: > outside :: Wrapper (forall a. (t a)) -> (forall a. Wrapper (t a)) > outside(Wrapper x) = Wrapper x (surprisingly the code does not work with the implementation 'outside x = x'; I guess this is a ghc bug) However, the other way around does not work: > inside :: (forall a. Wrapper (t a))-> Wrapper (forall a. (t a)) > inside x= x results in the following error: Couldn't match expected type `forall a. t a' against inferred type `t a' Expected type: Wrapper (forall a1. t a1) Inferred type: Wrapper (t a) In the expression: x In the definition of `inside': inside x = x Any ideas on how to make this work? Klaus From devriese at cs.tcd.ie Mon Jun 9 09:40:49 2008 From: devriese at cs.tcd.ie (Edsko de Vries) Date: Mon Jun 9 09:33:11 2008 Subject: [Haskell-cafe] Moving "forall" over type constructors In-Reply-To: <484D2E21.7000005@daimi.au.dk> References: <484D2E21.7000005@daimi.au.dk> Message-ID: <20080609134049.GA19510@netsoc.tcd.ie> On Mon, Jun 09, 2008 at 03:20:33PM +0200, Klaus Ostermann wrote: > At first I'd like to thank Claus, Ryan, Edsko, Luke and Derek for their > quite helpful replies to my previous thread. > > In the course of following their advice I encountered the problem of > moving a "forall" quantifier over a wrapper type constructor. > > If I have > > > newtype Wrapper a = Wrapper a > > and I instantiate Wrapper with a polymorphic type, then it is possible > to move the quantifier outside: > > > outside :: Wrapper (forall a. (t a)) -> (forall a. Wrapper (t a)) > > outside(Wrapper x) = Wrapper x > > (surprisingly the code does not work with the implementation 'outside x > = x'; I guess this is a ghc bug) Not a bug; those two types are not the same. In the code you've given, ghc needs to find evidence that it can create a element of type (Wrapper (t a)) for any any; fortunately, it can do so because it has 'x', which can create a 't a' for any 'a'. > > > > inside :: (forall a. Wrapper (t a))-> Wrapper (forall a. (t a)) > > inside x= x > > results in the following error: But here we have an argument that can return a Wrapper (t a) for any 'a'; that does *not* mean it can return a wrapper of a polymorphic type. If you think about 'a' as an actual argument, then you could pass 'Int' to get a Wrapper (t Int), Bool to get a wrapper (t Bool), or even (forall a. a -> a) to get a Wrapper (t (forall a. a -> a)), but no argument at all could make a Wrapper (forall a. t a). Edsko From ko at daimi.au.dk Mon Jun 9 09:55:20 2008 From: ko at daimi.au.dk (Klaus Ostermann) Date: Mon Jun 9 09:47:40 2008 Subject: [Haskell-cafe] Moving "forall" over type constructors In-Reply-To: <20080609134049.GA19510@netsoc.tcd.ie> References: <484D2E21.7000005@daimi.au.dk> <20080609134049.GA19510@netsoc.tcd.ie> Message-ID: <17733353.post@talk.nabble.com> > But here we have an argument that can return a Wrapper (t a) for any > 'a'; that does *not* mean it can return a wrapper of a polymorphic type. > If you think about 'a' as an actual argument, then you could pass 'Int' > to get a Wrapper (t Int), Bool to get a wrapper (t Bool), or even > (forall a. a -> a) to get a Wrapper (t (forall a. a -> a)), but no > argument at all could make a Wrapper (forall a. t a). I just found out that it *is* possible to implement the inside function, namely as follows: > inside :: forall t. ((forall a. Wrapper (t a))-> Wrapper (forall a. (t > a))) > inside x = Wrapper f > where f :: forall a. (t a) > f = unwrap x > unwrap (Wrapper z) = z I guess this solves my problem. Sorry for bothering you with this question. I still find it a bit weird to write all these obfuscated identity functions to make the type checker happy, though. Klaus -- View this message in context: http://www.nabble.com/Moving-%22forall%22-over-type-constructors-tp17732668p17733353.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From ketil at malde.org Mon Jun 9 10:04:48 2008 From: ketil at malde.org (Ketil Malde) Date: Mon Jun 9 09:56:29 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: <20080607024543.52z9hkmgz4s8o4g8-nwo@webmail.spamcop.net> (ajb@spamcop.net's message of "Sat\, 07 Jun 2008 02\:45\:43 -0400") References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <200806061412.23585.g9ks157k@acme.softbase.org> <20080607024543.52z9hkmgz4s8o4g8-nwo@webmail.spamcop.net> Message-ID: <87ve0ibt6n.fsf@malde.org> ajb@spamcop.net writes: >> null >> filter >> map >> lookup > On the contrary, these are terrible names _because_ they conflict > with the Prelude. I agree. One solution would be to stuff these into Data.List. > It's okay if you highly encourage or effectively mandate qualified > import, like Data.Map does. I think designing modules for qualified-only use is a mistake. I also think import lists get quite ugly, with multiple instances of import qualified Data.Set as S import Data.Set (Set) for multiple - sometimes even the majority - of modules. Add to this that people will assign a variation of abbreviations for modules, we quickly lose consistency. And - is there a way to make GHCi use aliased qualification? I find my self typing detailed taxonomies all the time there. For Haskell', I would relly like to have good, generic classes/interfaces for this, so that a) code becomes readable (including import lists), and b) code can be written more generically, and c) it becomes easier to switch between e.g. different string types. -k -- If I haven't seen further, it is by standing in the footprints of giants From devriese at cs.tcd.ie Mon Jun 9 10:04:13 2008 From: devriese at cs.tcd.ie (Edsko de Vries) Date: Mon Jun 9 09:56:38 2008 Subject: [Haskell-cafe] Moving "forall" over type constructors In-Reply-To: <17733353.post@talk.nabble.com> References: <484D2E21.7000005@daimi.au.dk> <20080609134049.GA19510@netsoc.tcd.ie> <17733353.post@talk.nabble.com> Message-ID: <20080609140413.GC19510@netsoc.tcd.ie> On Mon, Jun 09, 2008 at 06:55:20AM -0700, Klaus Ostermann wrote: > > > > But here we have an argument that can return a Wrapper (t a) for any > > 'a'; that does *not* mean it can return a wrapper of a polymorphic type. > > If you think about 'a' as an actual argument, then you could pass 'Int' > > to get a Wrapper (t Int), Bool to get a wrapper (t Bool), or even > > (forall a. a -> a) to get a Wrapper (t (forall a. a -> a)), but no > > argument at all could make a Wrapper (forall a. t a). > > I just found out that it *is* possible to implement the inside function, > namely as follows: > > > inside :: forall t. ((forall a. Wrapper (t a))-> Wrapper (forall a. (t > > a))) > > inside x = Wrapper f > > where f :: forall a. (t a) > > f = unwrap x > > unwrap (Wrapper z) = z > > I guess this solves my problem. Sorry for bothering you with this question. > I still find it a bit weird to write all these obfuscated identity functions > to make the type checker happy, though. As I said, the types are not isomorphic -- it you think of type parameters as arguments you will see why. Edsko From leather at cs.uu.nl Mon Jun 9 10:59:49 2008 From: leather at cs.uu.nl (Sean Leather) Date: Mon Jun 9 10:52:09 2008 Subject: [Haskell-cafe] Moving "forall" over type constructors In-Reply-To: <3c6288ab0806090756g1ad94967v9e6f6a8c75f33e10@mail.gmail.com> References: <484D2E21.7000005@daimi.au.dk> <20080609134049.GA19510@netsoc.tcd.ie> <17733353.post@talk.nabble.com> <20080609140413.GC19510@netsoc.tcd.ie> <3c6288ab0806090756g1ad94967v9e6f6a8c75f33e10@mail.gmail.com> Message-ID: <3c6288ab0806090759q4fcbdb5bu2da7c620fa4d5f7f@mail.gmail.com> Hi, > I just found out that it *is* possible to implement the inside function, > > namely as follows: > > > > > inside :: forall t. ((forall a. Wrapper (t a))-> Wrapper (forall a. (t > > > a))) > > > inside x = Wrapper f > > > where f :: forall a. (t a) > > > f = unwrap x > > > unwrap (Wrapper z) = z > > > > I guess this solves my problem. Sorry for bothering you with this > question. > > I still find it a bit weird to write all these obfuscated identity > functions > > to make the type checker happy, though. > > As I said, the types are not isomorphic -- it you think of type > parameters as arguments you will see why. I found these examples interesting, mostly because I don't understand it very well. So, I simplified Klaus' code a bit and derived the following: ----- {-# LANGUAGE Rank2Types #-} -- Wrapper newtype W a = W { unW :: a } inside :: ((forall a. W (t a))-> W (forall a. (t a))) --inside (W x) = W x -- (a) FAILS --inside = W . unW -- (b) FAILS inside x = W (unW x) -- (c) WORKS ----- Can someone comment on the differences between the following in terms of type-checking or inference? Considering the errors I got, I'm guess the issue is the same for the pattern-matching (a) and the point-free (b) versions. Are there any pointers for developing a better understanding or intuition of this? Thanks, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080609/28cff892/attachment.htm From olivier.boudry at gmail.com Mon Jun 9 11:25:22 2008 From: olivier.boudry at gmail.com (Olivier Boudry) Date: Mon Jun 9 11:17:42 2008 Subject: [Haskell-cafe] ANNOUNCE: hfann-01 Message-ID: Hi all, I'm pleased to announce the first release of the hfann module ( http://code.haskell.org/~oboudry/hfann/). This module is an interface to the "Fast Artificial Neural Network (FANN)" library (see http://leenissen.dk/fann/). This is an early release. At the moment the hfann module does not cover all the functions found in the FANN library but it should be useable to train and use simple Neural Networks. At least is can be used to run an equivalent of the "Getting Started" example found in http://leenissen.dk/fann/html/files2/gettingstarted-txt.html. The module was developped on Windows XP with GHC-6.8.2. The README should provide you with all required information to install this module. The haddock documentation should give enough information to get started using it. == Installation == Download version 2.0 of the FANN library from: http://leenissen.dk/fann/download.php and build it according to the instruction found on: http://leenissen.dk/fann/html/files2/installation-txt.html Get the hfann module darcs get http://code.haskell.org/~oboudry/hfann/ Build it using Cabal runghc Setup.lhs configure runghc Setup.lhs build runghc Setup.lhs haddock runghc Setup.lhs install == Examples == Training an ANN to the xor function: > import HFANN > main = do > withStandardFann [2,3,1] $ \fann -> do > setActivationFunctionHidden fann fannSigmoidSymetric > setActivationFunctionOutput fann fannSigmoidSymetric > trainOnFile fann "xor.data" -- train data > 20000 -- max epochs > 100 -- epochs between reports > 0.001 -- desired error > saveFann fann "xor.ann" C:\Temp\Haskell\hfann\examples\xor>Train.exe Max epochs 20000. Desired error: 0.0010000000. Epochs 1. Current error: 0.2503675520. Bit fail 4. Epochs 100. Current error: 0.0181358512. Bit fail 0. Epochs 169. Current error: 0.0009599295. Bit fail 0. Using the trained ANN on the 4 possible input values to the xor function (-1 = False, 1 = True). > import HFANN > main = do > withSavedFann "xor.ann" $ \fann -> do > mapM_ (\x -> runFann fann x >>= print) [[-1,-1],[-1,1],[1,-1],[1,1]] C:\Temp\Haskell\hfann\examples\xor>Use.exe [-0.950566361876292] [0.9178714756661263] [0.9457588340834527] [-0.9482816646878051] The "xor.data" training data content: 4 2 1 -1 -1 -1 -1 1 1 1 -1 1 1 1 -1 The files for this example can be found in the "examples/xor" directory == Bug reports, suggestions and comments are welcome. You can send them directly to my e-mail address. Olivier. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080609/d1a52cb7/attachment.htm From aruiz at um.es Mon Jun 9 12:10:09 2008 From: aruiz at um.es (Alberto Ruiz) Date: Mon Jun 9 12:02:32 2008 Subject: [Haskell-cafe] "sum" in hmatrix and blas? In-Reply-To: <20080609012525.GA18748@scytale.galois.com> References: <87y75gx3te.fsf@columbia.edu> <200806081454.18467.toman144@student.liu.se> <87r6b8vwre.fsf@columbia.edu> <484C328F.5080205@um.es> <877iczwl4o.fsf@columbia.edu> <20080609001622.GC18376@scytale.galois.com> <20080609012525.GA18748@scytale.galois.com> Message-ID: <484D55E1.6060607@um.es> Patch applied! I will also make the recommended changes in the Matrix type and prepare some benchmarks for this kind of Haskell loops. In fact, such excellent performance will also be very useful in image processing algorithms which must read and write a large number of C array elements. I now think that some C auxiliary functions in the easyVision library for operations not available in the IPP can be replaced by much nicer Haskell versions. I'm currently working on the implementation of interest point descriptors based on histograms of local gradient directions. This may be a very good benchmark. I will prepare a first version and post here the results for discussion. Don, many thanks for your all your help! Alberto Don Stewart wrote: > Problem solved. The Haskell loop now wins. > >>> After reading don's blog, I tried to make a test with both >>> methods. The code is very simple, as following >>> >>> module Main where >>> import System >>> import Numeric.LinearAlgebra >>> >>> vsum1 :: Vector Double -> Double >>> vsum1 v = constant 1 (dim v) <.> v >>> >>> vsum2 :: Vector Double -> Double >>> vsum2 v = go (d - 1) 0 >>> where >>> d = dim v >>> go :: Int -> Double -> Double >>> go 0 s = s + (v @> 0) >>> go !j !s = go (j - 1) (s + (v @> j)) >>> >>> >>> mean :: Vector Double -> Double >>> mean v = vsum v / fromIntegral (dim v) >>> where vsum = vsum1 >>> >>> main :: IO () >>> main = do >>> fn:nrow:ncol:_ <- getArgs >>> print . mean . flatten =<< fromFile fn (read nrow, read ncol) >>> >>> Compile it with "-O2 -optc-O2", and run with a data set of >>> length 5000000. The results are >>> >>> with "vsum1": >>> 80,077,984 bytes allocated in the heap >>> 2,208 bytes copied during GC (scavenged) >>> 64 bytes copied during GC (not scavenged) >>> 40,894,464 bytes maximum residency (2 sample(s)) >>> %GC time 0.0% (0.0% elapsed) >>> Alloc rate 35,235,448 bytes per MUT second >>> ./vsum1 huge 5000000 1 2.25s user 0.09s system 99% cpu 2.348 total >>> >>> This is reasonable, exactly two copies of vector with size >>> of 40MB. >>> >>> with "vsum2": >>> 560,743,120 bytes allocated in the heap >>> 19,160 bytes copied during GC (scavenged) >>> 15,920 bytes copied during GC (not scavenged) >>> 40,919,040 bytes maximum residency (2 sample(s)) >>> %GC time 0.3% (0.3% elapsed) >>> Alloc rate 222,110,261 bytes per MUT second >>> ./mean2 huge 5000000 1 2.53s user 0.06s system 99% cpu 2.598 total >>> >>> This is strange. A lot of extra usage of heap? Probably >>> because '@>' is not efficient? So it looks like the >>> inner-product approach wins with a fairly margin. > >> Looking at the core we get from vsum2, we see: >> >> vsum2 compiles quite well >> >> $wgo_s1Nn :: Int# -> Double# -> Double# >> >> $wgo_s1Nn = >> \ (ww3_s1Mc :: Int#) (ww4_s1Mg :: Double#) -> >> case ww3_s1Mc of ds_X17R { >> __DEFAULT -> >> case Data.Packed.Internal.Vector.$wat >> @ Double Foreign.Storable.$f9 ww_s1Ms ww1_s1Mu (I# ds_X17R) >> of { D# y_a1KQ -> >> $wgo_s1Nn (-# ds_X17R 1) (+## ww4_s1Mg y_a1KQ) >> }; >> 0 -> +## ww4_s1Mg ww2_s1M7 >> }; >> } in $wgo_s1Nn (-# ww_s1Ms 1) 0.0 >> >> But note the return value from $wat is boxed, only to be immediately >> unboxed. That looks to be the source of the heap allocations. >> >> Let's see if we can help that. > > Ah, of course. The problem is the unsafePerformIO used to wrap up the > 'peek'. This blocks the optimisations somewhat, after we unpack the Vector type.. > > So if we rewrite 'safeRead' to not use unsafePerformIO, but instead: > > safeRead v = inlinePerformIO . withForeignPtr (fptr v) > > inlinePerformIO (IO m) = case m realWorld# of (# _, r #) -> r > > Along with this change to Vector: > > data Vector t = V { dim :: {-# UNPACK #-} !Int > , fptr :: {-# UNPACK #-} !(ForeignPtr t) > } > > and some inlining for the bounds checks. > Following bytestrings, we see the performance go from, with a 180M input > file: > > Goal: > vsum1: > $ ghc-core A.hs -optc-O2 -fvia-C -fbang-patterns > $ time ./A data 4000 2500 > 0.9999727441161678 > > ./A data 4000 2500 5.37s user 0.20s system 99% cpu 5.609 total > 160,081,136 bytes allocated in the heap > 155 Mb total memory in use > > Before: > vsum2-old: > > $wgo_s1Ns = > \ (ww3_s1Me :: Int#) (ww4_s1Mi :: Double#) -> > case ww3_s1Me of ds_X17Y { > __DEFAULT -> > case Data.Packed.Internal.Vector.$wat > @ Double Foreign.Storable.$f9 ww_s1Mu ww1_s1Mw (I# ds_X17Y) > of wild1_a1Hg { D# y_a1Hi -> > $wgo_s1Ns (-# ds_X17Y 1) (+## ww4_s1Mi y_a1Hi) > }; > 0 -> +## ww4_s1Mi ww2_s1M9 > }; > } in $wgo_s1Ns (-# ww_s1Mu 1) 0.0 > > ./A data 4000 2500 +RTS -sstderr > 0.999972744115876 > > ./A data 4000 2500 +RTS -sstderr 6.04s user 0.15s system 99% cpu 6.203 total > 1,121,416,400 bytes allocated in the heap > 78 Mb total memory in use > > After: > True -> > case readDoubleOffAddr# > @ RealWorld ww1_s1Nr ds_X180 realWorld# > of wild2_a1HS { (# s2_a1HU, x_a1HV #) -> > case touch# @ ForeignPtrContents ww2_s1Ns s2_a1HU > of s_a1HG { __DEFAULT -> > $wgo_s1Ok (-# ds_X180 1) (+## ww4_s1Ng x_a1HV) > } > > No needless boxing. > > $ time ./A data 4000 2500 +RTS -sstderr > ./A data 4000 2500 +RTS -sstderr > 0.999972744115876 > > ./A data 4000 2500 +RTS -sstderr 5.41s user 0.10s system 99% cpu 5.548 total > 80,071,072 bytes allocated in the heap > > 78 Mb total memory in use > > And the total runtime and allocation now is better than the fully 'C' version. > Yay. > > Patch attached to the darcs version of hmatrix. > Similar changes can likely be done to the other data types in hmatrix, > for pretty much ideal code. > > -- Don > > From Joseph.Re at MorganStanley.com Mon Jun 9 13:48:48 2008 From: Joseph.Re at MorganStanley.com (Re, Joseph (IT)) Date: Mon Jun 9 13:41:51 2008 Subject: [Haskell-cafe] Unable to hc-build ghc 6.6.1 Message-ID: <507725E31752A74CB00728FA6C17D99C09E1039D@NYWEXMB29.msad.ms.com> I'm trying to do a registered hc-build on linux2.4 x86 with ghc 6.6.1. After fixing mk/bootstrap.mk to include "-lncurses" in HC_BOOT_LIBS to get past an undefined reference to "tputs" et al, I've gotten stuck with the following undefined reference error: ------------------------------------------------------------------------ == gmake all -wr; in /tmp/ghc-6.6.1/utils/runstdtest ------------------------------------------------------------------------ gmake[1]: Nothing to be done for `all'. Finished making all in runstdtest: 0 ------------------------------------------------------------------------ == gmake all -wr; in /tmp/ghc-6.6.1/utils/genapply ------------------------------------------------------------------------ gcc -o genapply -fno-defer-pop -fomit-frame-pointer -fno-builtin -DDONT_WANT_WIN32_DLL_SUPPORT -D__GLASGOW_HASKELL__=606 -O -I/tmp/ghc-6.6.1/includes -I/tmp/ghc-6.6.1/libraries/base/include -I/tmp/ghc-6.6.1/libraries/unix/include -I/tmp/ghc-6.6.1/libraries/parsec/include -I/tmp/ghc-6.6.1/libraries/readline/include -L/tmp/ghc-6.6.1/rts -L/tmp/ghc-6.6.1/libraries/base -L/tmp/ghc-6.6.1/libraries/base/cbits -L/tmp/ghc-6.6.1/libraries/haskell98 -L/tmp/ghc-6.6.1/libraries/parsec -L/tmp/ghc-6.6.1/libraries/regex-base -L/tmp/ghc-6.6.1/libraries/regex-compat -L/tmp/ghc-6.6.1/libraries/regex-posix -L/tmp/ghc-6.6.1/libraries/Cabal -L/tmp/ghc-6.6.1/libraries/template-haskell -L/tmp/ghc-6.6.1/libraries/readline -L/tmp/ghc-6.6.1/libraries/unix -L/tmp/ghc-6.6.1/libraries/unix/cbits -u "base_GHCziBase_Izh_static_info" -u "base_GHCziBase_Czh_static_info" -u "base_GHCziFloat_Fzh_static_info" -u "base_GHCziFloat_Dzh_static_info" -u "base_GHCziPtr_Ptr_static_info" -u "base_GHCziWord_Wzh_static_info" -u "base_GHCziInt_I8zh_static_info" -u "base_GHCziInt_I16zh_static_info" -u "base_GHCziInt_I32zh_static_info" -u "base_GHCziInt_I64zh_static_info" -u "base_GHCziWord_W8zh_static_info" -u "base_GHCziWord_W16zh_static_info" -u "base_GHCziWord_W32zh_static_info" -u "base_GHCziWord_W64zh_static_info" -u "base_GHCziStable_StablePtr_static_info" -u "base_GHCziBase_Izh_con_info" -u "base_GHCziBase_Czh_con_info" -u "base_GHCziFloat_Fzh_con_info" -u "base_GHCziFloat_Dzh_con_info" -u "base_GHCziPtr_Ptr_con_info" -u "base_GHCziStable_StablePtr_con_info" -u "base_GHCziBase_False_closure" -u "base_GHCziBase_True_closure" -u "base_GHCziPack_unpackCString_closure" -u "base_GHCziIOBase_stackOverflow_closure" -u "base_GHCziIOBase_heapOverflow_closure" -u "base_GHCziIOBase_NonTermination_closure" -u "base_GHCziIOBase_BlockedOnDeadMVar_closure" -u "base_GHCziIOBase_Deadlock_closure" -u "base_GHCziWeak_runFinalizzerBatch_closure" -u "__stginit_Prelude" GenApply.o -lHSreadline -lreadline -lHStemplate-haskell -lHSunix -lHSunix_cbits -lHSCabal -lHShaskell98 -lHSregex-compat -lHSregex-posix -lHSregex-base -lHSbase -lHSbase_cbits -lHSparsec -lHSrts -lgmp -lm -lncurses -ldl -lrt GenApply.o(.text+0x13a55): In function `s5cr_info': : undefined reference to `base_DataziList_zdsintersperse_info' GenApply.o(.text+0x14c11): In function `s58p_info': : undefined reference to `base_DataziList_zdsintersperse_info' GenApply.o(.text+0x17d79): In function `s54x_info': : undefined reference to `base_DataziList_zdsintersperse_info' collect2: ld returned 1 exit status gmake[1]: *** [genapply] Error 1 Failed making all in genapply: 1 gmake: *** [all] Error 1 gmake: Leaving directory `/tmp/ghc-6.6.1/utils' Does anyone know why this might be occuring? The only reference to "base_DataziList_zdsintersperse_info" on google didn't seem to have an answer. For reference my mk/build.mk is: SRC_HC_OPTS = -H32m -O -fvia-C -Rghc-timing -keep-hc-files GhcLibHcOpts = -O GhcLibWays = SplitObjs = NO just as the example one given on http://hackage.haskell.org/trac/ghc/wiki/Building/Porting. Also- in case this is related- I moved AutoApply_thr.thr_hc to AutoApply_thr.hc (and likewise for debug, thr_debug, and thr_p). Thanks, Joseph Re -------------------------------------------------------- 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 olivier.boudry at gmail.com Mon Jun 9 13:52:26 2008 From: olivier.boudry at gmail.com (Olivier Boudry) Date: Mon Jun 9 13:44:46 2008 Subject: [Haskell-cafe] ANNOUNCE: hfann-01 In-Reply-To: <20080609152905.GD23950@scytale.galois.com> References: <20080609152905.GD23950@scytale.galois.com> Message-ID: On Mon, Jun 9, 2008 at 11:29 AM, Don Stewart wrote: > Excellent. Would you like to upload it to hackage.haskell.org, so it can > be easily installed with the 'cabal install' tool? > > Hi all, As suggested by Don, I just uploaded the hfann package to hackage.haskell.org. It's available here: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hfann Best regards, Olivier. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080609/15faec58/attachment.htm From vigalchin at gmail.com Mon Jun 9 14:18:29 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Mon Jun 9 14:11:03 2008 Subject: [Haskell-cafe] FunPtr error? In-Reply-To: <5ae4f2ba0806082324t53691b06se7efa48f5df7c379@mail.gmail.com> References: <5ae4f2ba0806081917u3cbeada0ge4968bb5183c888e@mail.gmail.com> <1097402345.20080609095428@gmail.com> <5ae4f2ba0806082324t53691b06se7efa48f5df7c379@mail.gmail.com> Message-ID: <5ae4f2ba0806091118y922e881nbcb1a945cc765bb3@mail.gmail.com> In any case, what I want to do is store FunPtr in a data type and marshall into a C struct as a C function pointer. Vasili On Mon, Jun 9, 2008 at 1:24 AM, Galchin, Vasili wrote: > Thanks. Clause? > > regards, Vasili > > > On Mon, Jun 9, 2008 at 12:54 AM, Bulat Ziganshin < > bulat.ziganshin@gmail.com> wrote: > >> Hello Vasili, >> >> Monday, June 9, 2008, 6:17:14 AM, you wrote: >> >> 1. standard place to import FunPtr from is Foreign.Ptr, not System.Posix >> 2. FunPtr is exported as abstract type, without constructors. you >> can't construct values of this type directly. instead you should use >> "wrapper" generators as in the example that Clause has wrote. read it >> carefully :) >> >> >> > Hello, >> >> > I am getting what is to me a mysterious error in a test case that I >> am writing: >> > vigalchin@ubuntu:~/FTP/Haskell/unix-2.2.0.0/tests/timer$ runhaskell >> Setup.lhs build >> > Preprocessing executables for Test-1.0... >> > Building Test-1.0... >> > [1 of 1] Compiling Main ( ./timer.hs, >> > dist/build/timer/timer-tmp/Main.o ) >> >> > ./timer.hs:11:45: Not in scope: data constructor `FunPtr' >> >> > It seems like the compiler is complaining about the lack of FunPtr >> > in it's symbol table but System.Posix is imported: >> > >> > module Main where >> >> > import System.Posix >> > import Foreign >> > import Foreign.C >> > import Foreign.Ptr >> >> > main = do >> >> > let event = Sigevent{sigevFunction=(FunPtr (notifyFunc))} >> <<<<<< error here >> > >> > timerId <- timerCreate Clock_Realtime Nothing >> >> > timerDelete timerId >> >> > return () >> >> > notifyFunc :: Sigval -> IO () >> > notifyFunc sigval = do >> > putStrLn "timer POP!!!!!!!" >> > return () >> >> > I am probably looking right at the answer and not seeing it. ?? >> >> > Thanks, Vasili >> >> >> >> > >> >> >> -- >> Best regards, >> Bulat mailto:Bulat.Ziganshin@gmail.com >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080609/2fb34a02/attachment.htm From duncan.coutts at worc.ox.ac.uk Mon Jun 9 14:41:05 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Mon Jun 9 14:29:31 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: <87ve0ibt6n.fsf@malde.org> References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <200806061412.23585.g9ks157k@acme.softbase.org> <20080607024543.52z9hkmgz4s8o4g8-nwo@webmail.spamcop.net> <87ve0ibt6n.fsf@malde.org> Message-ID: <1213036865.15010.448.camel@localhost> On Mon, 2008-06-09 at 16:04 +0200, Ketil Malde wrote: > I think designing modules for qualified-only use is a mistake. I also > think import lists get quite ugly, with multiple instances of > > import qualified Data.Set as S > import Data.Set (Set) > > for multiple - sometimes even the majority - of modules. As far as I can see that is the only downside, having to import more than once to get the type name unqualified with the rest of the module qualified. > Add to this that people will assign a variation of abbreviations for > modules, we quickly lose consistency. The obvious consistent thing to do is to use the last part of the module name, at least for short names like Set and Map. For ByteString it is more of a mouthful. import qualified Data.Set as Set import Data.Set (Set) Set.empty, Set.insert etc etc. > And - is there a way to make GHCi use aliased qualification? I find > my self typing detailed taxonomies all the time there. The ghci syntax currently is: :m Data.Set wouldn't it be much nicer as: import Data.Set then we could have the obvious: import Data.Set as Set Duncan From ryani.spam at gmail.com Mon Jun 9 15:16:25 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Mon Jun 9 15:08:54 2008 Subject: [Haskell-cafe] FunPtr error? In-Reply-To: <5ae4f2ba0806091118y922e881nbcb1a945cc765bb3@mail.gmail.com> References: <5ae4f2ba0806081917u3cbeada0ge4968bb5183c888e@mail.gmail.com> <1097402345.20080609095428@gmail.com> <5ae4f2ba0806082324t53691b06se7efa48f5df7c379@mail.gmail.com> <5ae4f2ba0806091118y922e881nbcb1a945cc765bb3@mail.gmail.com> Message-ID: <2f9b2d30806091216j137abcbbj34761d6f7861c5f4@mail.gmail.com> > type Notify = Sigval -> IO () > foreign import ccall "wrapper" mkNotify :: Notify -> IO (FunPtr Notify) then > main = do > notifyFPtr <- mkNotify notifyFunc > -- rest of code here > > -- then, when you are done and nothing is referencing the pointer any more > freeHaskellFunPtr notifyFPtr On 6/9/08, Galchin, Vasili wrote: > In any case, what I want to do is store FunPtr in a data type and marshall > into a C struct as a C function pointer. > > Vasili This will be suitable for that purpose. -- ryan From vogt.adam at gmail.com Mon Jun 9 15:45:44 2008 From: vogt.adam at gmail.com (Adam Vogt) Date: Mon Jun 9 15:38:09 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: <1213036865.15010.448.camel@localhost> References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <200806061412.23585.g9ks157k@acme.softbase.org> <20080607024543.52z9hkmgz4s8o4g8-nwo@webmail.spamcop.net> <87ve0ibt6n.fsf@malde.org> <1213036865.15010.448.camel@localhost> Message-ID: <20080609194544.GA2753@dell> * On Monday, June 09 2008, Duncan Coutts wrote: >> And - is there a way to make GHCi use aliased qualification? I find >> my self typing detailed taxonomies all the time there. > >The ghci syntax currently is: >:m Data.Set >wouldn't it be much nicer as: >import Data.Set >then we could have the obvious: >import Data.Set as Set ghci does load modules when you type "import Data.Set" already, but it doesn't parse "import Data.Set as Set" From johan.tibell at gmail.com Mon Jun 9 15:53:50 2008 From: johan.tibell at gmail.com (Johan Tibell) Date: Mon Jun 9 15:46:11 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: <87ve0ibt6n.fsf@malde.org> References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <200806061412.23585.g9ks157k@acme.softbase.org> <20080607024543.52z9hkmgz4s8o4g8-nwo@webmail.spamcop.net> <87ve0ibt6n.fsf@malde.org> Message-ID: <90889fe70806091253v925f596mc2b02c8ce3586167@mail.gmail.com> On Mon, Jun 9, 2008 at 4:04 PM, Ketil Malde wrote: > I think designing modules for qualified-only use is a mistake. I also > think import lists get quite ugly, with multiple instances of I was only suggesting avoiding namespacing prefixes/suffixes in identifiers. Other than that things would be the same. You don't have to import things as qualified. However, if you're going to try to avoid using identifiers in your exported interface because they would collide with other modules I would advice against it. I agree with you that the module imports get a bit ugly. I prefer that to the alternative though. > Add to this that people will assign a variation of abbreviations for > modules, we quickly lose consistency. It's a shame that we have such deep hierarchies otherwise we wouldn't need to always alias out module imports. I think Python get's it right: import os ... os.tmpname ... Duncan's recommendation of just taking the part after the last dot seems like a good rule of thumb. Doing import qualified Data.Map as M does gain you much in my opinion. Compare M.empty to emptyM. No difference, you still can't deduce the module by just looking at the call site. Cheers, Johan From xj2106 at columbia.edu Mon Jun 9 15:58:28 2008 From: xj2106 at columbia.edu (Xiao-Yong Jin) Date: Mon Jun 9 15:55:25 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: <90889fe70806091253v925f596mc2b02c8ce3586167@mail.gmail.com> (Johan Tibell's message of "Mon, 9 Jun 2008 21:53:50 +0200") References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <200806061412.23585.g9ks157k@acme.softbase.org> <20080607024543.52z9hkmgz4s8o4g8-nwo@webmail.spamcop.net> <87ve0ibt6n.fsf@malde.org> <90889fe70806091253v925f596mc2b02c8ce3586167@mail.gmail.com> Message-ID: <87hcc2v0rf.fsf@columbia.edu> "Johan Tibell" writes: > Duncan's recommendation of just taking the part after the last dot > seems like a good rule of thumb. Doing > > import qualified Data.Map as M > > does gain you much in my opinion. Compare M.empty to emptyM. No > difference, you still can't deduce the module by just looking at the > call site. I would prefer `M.empty' to `emptyM'. At least, by looking at `M.empty', you know that this `empty' is from `M' and you can easily check out what `M' is from the import list. I personally always found myself unproductively tracing back something like `emptyM' to its origin. > > > Cheers, > > Johan -- c/* __o/* <\ * (__ */\ < From nicolas.pouillard at gmail.com Mon Jun 9 16:05:53 2008 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Mon Jun 9 15:58:34 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: <90889fe70806091253v925f596mc2b02c8ce3586167@mail.gmail.com> References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <200806061412.23585.g9ks157k@acme.softbase.org> <20080607024543.52z9hkmgz4s8o4g8-nwo@webmail.spamcop.net> <87ve0ibt6n.fsf@malde.org> <90889fe70806091253v925f596mc2b02c8ce3586167@mail.gmail.com> Message-ID: <1213041478-sup-9212@ausone.local> Excerpts from johan.tibell's message of Mon Jun 09 21:53:50 +0200 2008: > On Mon, Jun 9, 2008 at 4:04 PM, Ketil Malde wrote: > > I think designing modules for qualified-only use is a mistake. I also > > think import lists get quite ugly, with multiple instances of > > I was only suggesting avoiding namespacing prefixes/suffixes in > identifiers. Other than that things would be the same. You don't have > to import things as qualified. However, if you're going to try to > avoid using identifiers in your exported interface because they would > collide with other modules I would advice against it. I agree with you > that the module imports get a bit ugly. I prefer that to the > alternative though. > > > Add to this that people will assign a variation of abbreviations for > > modules, we quickly lose consistency. > > It's a shame that we have such deep hierarchies otherwise we wouldn't > need to always alias out module imports. I think Python get's it > right: > > import os > > ... os.tmpname ... > > Duncan's recommendation of just taking the part after the last dot > seems like a good rule of thumb. Doing > > import qualified Data.Map as M > > does gain you much in my opinion. Compare M.empty to emptyM. No > difference, you still can't deduce the module by just looking at the > call site. Coming from a world where qualified names at call sites or full import (open) are the default rules (OCaml), I much prefer the import way (where you specify names that gets imported) and thus prefer when names don't collide (except for modules like Data.Map or ByteString where I use the "as" notation). The key point for me is to be able to trace as fast as possible what precisely use a module by looking (only) at the top of the file. Best regards, -- Nicolas Pouillard aka Ertai -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 194 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080609/9f09992c/signature.bin From sebastian.sylvan at gmail.com Mon Jun 9 16:53:28 2008 From: sebastian.sylvan at gmail.com (Sebastian Sylvan) Date: Mon Jun 9 16:45:48 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> Message-ID: <3d96ac180806091353q6fd8cyc78eb513c8a6c4c5@mail.gmail.com> On Thu, Jun 5, 2008 at 4:19 PM, Johan Tibell wrote: > > > * 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. > Another BIG reason: It's impossible to export a whole hierarchy qualified. I.e it would be neat if the user could write: import Graphics.UI.Gtk And then have Gtk re-export sub-modules qualified, so you could write "Button.new", "Window.new" etc. etc. As it stands you have two options: prefix all the "new" functions with the kind of widget they create (buttonNew, windowNew), or force the user to add a gazillion qualified imports. Ideally you would be able to add "qualified" to the module export statement, and have it automatically bring in that module qualified (it should also support an "as" so you'd write "qualified module Graphics.UI.Gtk.Button as Button" in the export list to get the above behaviour.) -- Sebastian Sylvan +44(0)7857-300802 UIN: 44640862 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080609/167e1039/attachment-0001.htm From mail at joachim-breitner.de Mon Jun 9 16:57:38 2008 From: mail at joachim-breitner.de (Joachim Breitner) Date: Mon Jun 9 16:50:07 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: <1213045058.21568.10.camel@otto.ehbuehl.net> Hi again, Am Donnerstag, den 05.06.2008, 17:22 +0200 schrieb Joachim Breitner: > 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 wrote a module that provides this API. It can be found here: http://darcs.nomeata.de/darcswatch/src/LockRestart.hs I use it for darcswatch, you can see the relevant change here: http://darcs.nomeata.de/cgi-bin/darcsweb.cgi?r=darcswatch;a=filediff;h=20080609203612-23c07-aec8c4e1f22a9c3bdd44d062ab26f7d18a880a18.gz;f=src/Main.hs Actually, since only the call to "or" in the third changed line from the bottom is special to darcswatch, this can be moved into LockRestart, so the change to the program is reduced to this: config <- read `fmap` readFile (confdir ++ "config") + + lockRestart (cOutput config) patchNew or True (do_work config) + +do_work config patchNew = do putStrLn "Reading repositories..." or even config <- read `fmap` readFile (confdir ++ "config") + + lockRestart (cOutput config) patchNew or True $ \patchNew -> do + putStrLn "Reading repositories..." if you prefer. Enjoy, Joachim Breitner -- 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: 197 bytes Desc: Dies ist ein digital signierter Nachrichtenteil Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080609/49ba5360/attachment.bin From dbueno at gmail.com Mon Jun 9 23:00:10 2008 From: dbueno at gmail.com (Denis Bueno) Date: Mon Jun 9 22:52:32 2008 Subject: [Haskell-cafe] ANN: funsat 0.5, a SAT solver written in Haskell Message-ID: <6dbd4d000806092000g131716a8v44cc45a81fae027@mail.gmail.com> Hi all, It is my pleasure to announce the first reasonable release of funsat, a modern, DPLL-style SAT solver written in Haskell. Funsat solves formulas in conjunctive normal form and produces a total variable assignment for satisfiable problems. It is available from Hackage: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/funsat http://churn.ath.cx/funsat.html As well as in a Git repo, which contains many benchmark files funsat can solve. git clone http://churn.ath.cx/funsat Funsat is intended to be reasonably efficient for practical problems and convenient to use as a constraint-solving backend in other software. The former is achieved by using several well-known techniques from the literature including two-watched literals, conflict-directed learning, non-chronological backtracking, a VSIDS-like dynamic variable ordering, and restarts. The latter is supported currently by efficient unsatisfiable core generation, which generates a minimal unsatisfiable problem for a given unsatisfiable problem. In the future, I plan to add support for converting boolean circuits into CNF, as well as support for other types of constraints. Please try it out and report bugs! (This email is the one listed on the website.) -- Denis From vigalchin at gmail.com Mon Jun 9 23:54:20 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Mon Jun 9 23:46:39 2008 Subject: [Haskell-cafe] FunPtr error? In-Reply-To: <2f9b2d30806091216j137abcbbj34761d6f7861c5f4@mail.gmail.com> References: <5ae4f2ba0806081917u3cbeada0ge4968bb5183c888e@mail.gmail.com> <1097402345.20080609095428@gmail.com> <5ae4f2ba0806082324t53691b06se7efa48f5df7c379@mail.gmail.com> <5ae4f2ba0806091118y922e881nbcb1a945cc765bb3@mail.gmail.com> <2f9b2d30806091216j137abcbbj34761d6f7861c5f4@mail.gmail.com> Message-ID: <5ae4f2ba0806092054q75176dc0h1d9da81d4eacf877@mail.gmail.com> Ryan, I tried but the compiler didn't seem to like the keyword "import": vigalchin@ubuntu:~/FTP/Haskell/unix-2.2.0.0/tests/timer$ runhaskell Setup.lhs build Preprocessing executables for Test-1.0... Building Test-1.0... [1 of 1] Compiling Main ( ./timer.hs, dist/build/timer/timer-tmp/Main.o ) ./timer.hs:29:8: parse error on input `import' .... source ...: module Main where import System.Posix import Foreign import Foreign.C import Foreign.Ptr type Notify = Sigval -> IO () main = do notifyFPtr <- mkNotify notifyFunc let event = Sigevent{sigevFunction=notifyFPtr} timerId <- timerCreate Clock_Realtime Nothing timerDelete timerId return () notifyFunc :: Sigval -> IO () notifyFunc sigval = do putStrLn "timer POP!!!!!!!" return () foreign import ccall "wrapper" mkNotify :: Notify -> IO (FunPtr Notify) ~ Everything looks ok to me. ?? Regards, Vasili On Mon, Jun 9, 2008 at 2:16 PM, Ryan Ingram wrote: > > type Notify = Sigval -> IO () > > foreign import ccall "wrapper" mkNotify :: Notify -> IO (FunPtr Notify) > > then > > main = do > > notifyFPtr <- mkNotify notifyFunc > > -- rest of code here > > > > -- then, when you are done and nothing is referencing the pointer any > more > > freeHaskellFunPtr notifyFPtr > > On 6/9/08, Galchin, Vasili wrote: > > In any case, what I want to do is store FunPtr in a data type and > marshall > > into a C struct as a C function pointer. > > > > Vasili > > This will be suitable for that purpose. > > -- ryan > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080609/a2ac483c/attachment.htm From judah.jacobson at gmail.com Tue Jun 10 00:25:39 2008 From: judah.jacobson at gmail.com (Judah Jacobson) Date: Tue Jun 10 00:17:57 2008 Subject: [Haskell-cafe] FunPtr error? In-Reply-To: <5ae4f2ba0806092054q75176dc0h1d9da81d4eacf877@mail.gmail.com> References: <5ae4f2ba0806081917u3cbeada0ge4968bb5183c888e@mail.gmail.com> <1097402345.20080609095428@gmail.com> <5ae4f2ba0806082324t53691b06se7efa48f5df7c379@mail.gmail.com> <5ae4f2ba0806091118y922e881nbcb1a945cc765bb3@mail.gmail.com> <2f9b2d30806091216j137abcbbj34761d6f7861c5f4@mail.gmail.com> <5ae4f2ba0806092054q75176dc0h1d9da81d4eacf877@mail.gmail.com> Message-ID: <6d74b0d20806092125n31df313ex483f42fc0557b06e@mail.gmail.com> 2008/6/9 Galchin, Vasili : > Ryan, > > I tried but the compiler didn't seem to like the keyword "import": > > vigalchin@ubuntu:~/FTP/Haskell/unix-2.2.0.0/tests/timer$ runhaskell > Setup.lhs build > Preprocessing executables for Test-1.0... > Building Test-1.0... > [1 of 1] Compiling Main ( ./timer.hs, > dist/build/timer/timer-tmp/Main.o ) > > ./timer.hs:29:8: parse error on input `import' > Hi Vasili, To fix that error, you probably just need to add the line "Extensions: ForeignFunctionInterface" to the .cabal file. (That is the equivalent of calling ghc by itself with the command-line arguments -fffi or -XForeignFunctionInterface.) Hope that helps, -Judah From vigalchin at gmail.com Tue Jun 10 00:32:15 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Tue Jun 10 00:24:34 2008 Subject: [Haskell-cafe] FunPtr error? In-Reply-To: <6d74b0d20806092125n31df313ex483f42fc0557b06e@mail.gmail.com> References: <5ae4f2ba0806081917u3cbeada0ge4968bb5183c888e@mail.gmail.com> <1097402345.20080609095428@gmail.com> <5ae4f2ba0806082324t53691b06se7efa48f5df7c379@mail.gmail.com> <5ae4f2ba0806091118y922e881nbcb1a945cc765bb3@mail.gmail.com> <2f9b2d30806091216j137abcbbj34761d6f7861c5f4@mail.gmail.com> <5ae4f2ba0806092054q75176dc0h1d9da81d4eacf877@mail.gmail.com> <6d74b0d20806092125n31df313ex483f42fc0557b06e@mail.gmail.com> Message-ID: <5ae4f2ba0806092132k5cb08c90tc0809dc2e0542044@mail.gmail.com> Thanks Judah ... getting closer now. Vasili On Mon, Jun 9, 2008 at 11:25 PM, Judah Jacobson wrote: > 2008/6/9 Galchin, Vasili : > > Ryan, > > > > I tried but the compiler didn't seem to like the keyword "import": > > > > vigalchin@ubuntu:~/FTP/Haskell/unix-2.2.0.0/tests/timer$ runhaskell > > Setup.lhs build > > Preprocessing executables for Test-1.0... > > Building Test-1.0... > > [1 of 1] Compiling Main ( ./timer.hs, > > dist/build/timer/timer-tmp/Main.o ) > > > > ./timer.hs:29:8: parse error on input `import' > > > > Hi Vasili, > > To fix that error, you probably just need to add the line "Extensions: > ForeignFunctionInterface" to the .cabal file. (That is the > equivalent of calling ghc by itself with the command-line arguments > -fffi or -XForeignFunctionInterface.) > > Hope that helps, > -Judah > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080609/bb409494/attachment.htm From vigalchin at gmail.com Tue Jun 10 02:01:54 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Tue Jun 10 01:54:12 2008 Subject: [Haskell-cafe] FunPtr error? In-Reply-To: <6d74b0d20806092125n31df313ex483f42fc0557b06e@mail.gmail.com> References: <5ae4f2ba0806081917u3cbeada0ge4968bb5183c888e@mail.gmail.com> <1097402345.20080609095428@gmail.com> <5ae4f2ba0806082324t53691b06se7efa48f5df7c379@mail.gmail.com> <5ae4f2ba0806091118y922e881nbcb1a945cc765bb3@mail.gmail.com> <2f9b2d30806091216j137abcbbj34761d6f7861c5f4@mail.gmail.com> <5ae4f2ba0806092054q75176dc0h1d9da81d4eacf877@mail.gmail.com> <6d74b0d20806092125n31df313ex483f42fc0557b06e@mail.gmail.com> Message-ID: <5ae4f2ba0806092301p2b5e9530r828abf6436e4d07d@mail.gmail.com> I have tried various things to no avail .... vigalchin@ubuntu:~/FTP/Haskell/unix-2.2.0.0/tests/timer$ runhaskell Setup.lhs build Preprocessing executables for Test-1.0... Building Test-1.0... [1 of 1] Compiling Main ( ./timer.hs, dist/build/timer/timer-tmp/Main.o ) ./timer.hs:22:0: Unacceptable argument type in foreign declaration: Sigval When checking declaration: foreign import ccall safe "wrapper" mkNotify :: Notify -> IO (FunPtr Notify) => here is my Sigval def data Sigval = SivalInt Int | SivalPtr (Ptr Char) I did a find/grep for "Unacceptable argument" in the ghc compiler source and assuming no typo I didn't find. ?? Thanks. Kind regards, Vasili On Mon, Jun 9, 2008 at 11:25 PM, Judah Jacobson wrote: > 2008/6/9 Galchin, Vasili : > > Ryan, > > > > I tried but the compiler didn't seem to like the keyword "import": > > > > vigalchin@ubuntu:~/FTP/Haskell/unix-2.2.0.0/tests/timer$ runhaskell > > Setup.lhs build > > Preprocessing executables for Test-1.0... > > Building Test-1.0... > > [1 of 1] Compiling Main ( ./timer.hs, > > dist/build/timer/timer-tmp/Main.o ) > > > > ./timer.hs:29:8: parse error on input `import' > > > > Hi Vasili, > > To fix that error, you probably just need to add the line "Extensions: > ForeignFunctionInterface" to the .cabal file. (That is the > equivalent of calling ghc by itself with the command-line arguments > -fffi or -XForeignFunctionInterface.) > > Hope that helps, > -Judah > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080610/bd8cc396/attachment.htm From jules at jellybean.co.uk Tue Jun 10 07:01:29 2008 From: jules at jellybean.co.uk (Jules Bean) Date: Tue Jun 10 06:53:50 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: <87ve0ibt6n.fsf@malde.org> References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <200806061412.23585.g9ks157k@acme.softbase.org> <20080607024543.52z9hkmgz4s8o4g8-nwo@webmail.spamcop.net> <87ve0ibt6n.fsf@malde.org> Message-ID: <484E5F09.2030009@jellybean.co.uk> Ketil Malde wrote: > And - is there a way to make GHCi use aliased qualification? I find > my self typing detailed taxonomies all the time there. > > For Haskell', I would relly like to have good, generic > classes/interfaces for this, so that a) code becomes readable > (including import lists), and b) code can be written more generically, > and c) it becomes easier to switch between e.g. different string > types. Class abstraction is not zero cost. Abstract far enough that GHC can't see how to resolve dictionaries at compile time (insufficient inlining) and you will not only slow things down just because of the dictionary cost, you'll also break all those nice RULES and lose your fusion. As for import syntax / readability, whilst I'm familiar with the problems (most are mentioned in this thread) I'm not aware of any concrete proposal to improve the situation. Jules From icfp.publicity at googlemail.com Tue Jun 10 08:47:31 2008 From: icfp.publicity at googlemail.com (Matthew Fluet (ICFP Publicity Chair)) Date: Tue Jun 10 08:39:48 2008 Subject: [Haskell-cafe] DEFUN08: Final Call for Talks & Tutorials (deadline: June 27) Message-ID: <53ff55480806100547h4befc974mfede15c2e21eabed@mail.gmail.com> Final Call for Talks and Tutorials ACM SIGPLAN 2008 Developer Tracks on Functional Programming http://www.deinprogramm.de/defun-2008/ Victoria, BC, Canada, 25, 27 September, 2008 The workshop will be held in conjunction with ICFP 2008. http://www.icfpconference.org/icfp2008/ Important dates Proposal Deadline: June 27, 2008, 0:00 UTC Notification: July 14, 2008 DEFUN 2008 invites functional programmers who know how to solve problems with functional progamming to give talks and lead tutorials at the The ICFP Developer Tracks. We want to know about your favorite programming techniques, powerful libraries, and engineering approaches you've used that the world should know about and apply to other projects. We want to know how to be productive using functional programming, write better code, and avoid common pitfalls. We invite proposals for presentations in the following categories: How-to talks: 45-minute "how-to" talks that provide specific information on how to solve specific problems using functional programming. These talks focus on concrete examples, but provide useful information for developers working on different projects or in different contexts. Examples: - "How I made Haskell an extension language for SAP R/3." - "How I replaced /sbin/init by a Scheme program." - "How I hooked up my home appliances to an Erlang control system." - "How I got an SML program to drive my BMW." General language tutorials: Half-day general language tutorials for specific functional languages, given by recognized experts for the respective languages. Technology tutorials: Half-day tutorials on techniques, technologies, or solving specific problems in functional programming. Examples: - how to make the best use of specific FP programming techniques - how to inject FP into a development team used to more conventional technologies - how to connect FP to existing libraries / frameworks / platforms - how to deliver high-performance systems with FP - how to deliver high-reliability systems with FP Remember that your audience will include computing professionals who are not academics and who may not already be experts on functional programming. Presenters of tutorials will receive free registration to ICFP 2008. Submission guidelines Submit a proposal of 150 words or less for either a 45-minute talk with a short Q&A session at the end, or a 300-word-or-less proposal for a 3-hour tutorial, where you present your material, but also give participants a chance to practice it on their own laptops. Some advice: - Give it a simple and straightforward title or name; avoid fancy titles or puns that would make it harder for attendees to figure out what you'll be talking about. - Clearly identify the level of the talk: What knowledge should people have when they come to the presentation or tutorial? - Explain why people will want to attend: is the language or library useful for a wide range of attendees? Is the pitfall you're identifying common enough that a wide range of attendees is likely to encounter it? - Explain what benefits attendees are expected to take home to their own projects. - For a tutorial, explain how you want to structure the time, and what you expect to have attendees to do on their laptops. List what software you'll expect attendees to have installed prior to coming. Submit your proposal in plain text electronically to defun-2008-submission-AT-deinprogramm.de by the beginning of Friday, June 27, Universal Coordinated Time. Organizers Kathleen Fisher AT&T Labs Simon Peyton Jones Microsoft Research Mike Sperber (co-chair) DeinProgramm Don Stewart (co-chair) Galois From igloo at earth.li Tue Jun 10 11:54:32 2008 From: igloo at earth.li (Ian Lynagh) Date: Tue Jun 10 11:46:49 2008 Subject: [Haskell-cafe] Unable to hc-build ghc 6.6.1 In-Reply-To: <507725E31752A74CB00728FA6C17D99C09E1039D@NYWEXMB29.msad.ms.com> References: <507725E31752A74CB00728FA6C17D99C09E1039D@NYWEXMB29.msad.ms.com> Message-ID: <20080610155432.GA30373@matrix.chaos.earth.li> On Mon, Jun 09, 2008 at 01:48:48PM -0400, Re, Joseph (IT) wrote: > I'm trying to do a registered hc-build on linux2.4 x86 with ghc 6.6.1. You're likely to find it easier to bootstrap by installing a bindist onto the machine, unless that is impossible for some reason. > GenApply.o(.text+0x13a55): In function `s5cr_info': > : undefined reference to `base_DataziList_zdsintersperse_info' Nothing comes to mind. Were the libraries rebuilt after building GenApply on the machine on which the hc files were generated? Thanks Ian From Joseph.Re at MorganStanley.com Tue Jun 10 12:08:14 2008 From: Joseph.Re at MorganStanley.com (Re, Joseph (IT)) Date: Tue Jun 10 12:01:28 2008 Subject: [Haskell-cafe] Unable to hc-build ghc 6.6.1 In-Reply-To: <20080610155432.GA30373@matrix.chaos.earth.li> References: <507725E31752A74CB00728FA6C17D99C09E1039D@NYWEXMB29.msad.ms.com> <20080610155432.GA30373@matrix.chaos.earth.li> Message-ID: <507725E31752A74CB00728FA6C17D99C09E1080D@NYWEXMB29.msad.ms.com> > From: Ian Lynagh [mailto:igloo@earth.li] > You're likely to find it easier to bootstrap by installing a > bindist onto the machine, unless that is impossible for some reason. Unfortunately it is due to policy. > > GenApply.o(.text+0x13a55): In function `s5cr_info': > > : undefined reference to `base_DataziList_zdsintersperse_info' > > Nothing comes to mind. Were the libraries rebuilt after > building GenApply on the machine on which the hc files were generated? Nope. After building the hc tarball with a new copy of ghc 6.6.1 on the host machine, I pulled it along with a new copy of the source tarball from http://www.haskell.org/ghc onto the target machine. Untarred the hc files, changed mk/build.mk and fixed mk/bootstrap.mk, and ran distrib/hc-build. -------------------------------------------------------- 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 zunino at di.unipi.it Tue Jun 10 12:12:57 2008 From: zunino at di.unipi.it (Roberto Zunino) Date: Tue Jun 10 12:05:25 2008 Subject: [Haskell-cafe] Moving "forall" over type constructors In-Reply-To: <3c6288ab0806090759q4fcbdb5bu2da7c620fa4d5f7f@mail.gmail.com> References: <484D2E21.7000005@daimi.au.dk> <20080609134049.GA19510@netsoc.tcd.ie> <17733353.post@talk.nabble.com> <20080609140413.GC19510@netsoc.tcd.ie> <3c6288ab0806090756g1ad94967v9e6f6a8c75f33e10@mail.gmail.com> <3c6288ab0806090759q4fcbdb5bu2da7c620fa4d5f7f@mail.gmail.com> Message-ID: <484EA809.8050101@di.unipi.it> Sean Leather wrote: > inside :: ((forall a. W (t a))-> W (forall a. (t a))) > --inside (W x) = W x -- (a) FAILS > --inside = W . unW -- (b) FAILS > inside x = W (unW x) -- (c) WORKS > > Are there any pointers for developing a better understanding or > intuition of this? Usually, making type arguments explicit helps: that is, assume that each polymorphic value is actually a function expecting a type (the a in forall a. ...) and returning the value related to that type. The last 'inside' definition becomes: inside x = W (\type -> unW (x type)) Note that we do not know at this time what will be the actual "type" above. But that's OK, since we can return a type-lambda. Instead, pattern matching desugars to: inside x = case x of ... But wait! x is a function (because it's polymorphic) and we can not pattern match on that! And, at this time, we do not know the type-argument for x. So we are stuck. Also, type-lambdas and type-arguments are hard to insert in W . unW . For more tricks with type-lambdas, look up "System F". Hope this helps, Zun. From derek.a.elkins at gmail.com Tue Jun 10 12:35:44 2008 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Tue Jun 10 12:28:05 2008 Subject: [Haskell-cafe] Moving "forall" over type constructors In-Reply-To: <484EA809.8050101@di.unipi.it> References: <484D2E21.7000005@daimi.au.dk> <20080609134049.GA19510@netsoc.tcd.ie> <17733353.post@talk.nabble.com> <20080609140413.GC19510@netsoc.tcd.ie> <3c6288ab0806090756g1ad94967v9e6f6a8c75f33e10@mail.gmail.com> <3c6288ab0806090759q4fcbdb5bu2da7c620fa4d5f7f@mail.gmail.com> <484EA809.8050101@di.unipi.it> Message-ID: <1213115744.7306.48.camel@derek-laptop> On Tue, 2008-06-10 at 18:12 +0200, Roberto Zunino wrote: > Sean Leather wrote: > > inside :: ((forall a. W (t a))-> W (forall a. (t a))) > > --inside (W x) = W x -- (a) FAILS > > --inside = W . unW -- (b) FAILS > > inside x = W (unW x) -- (c) WORKS > > > > Are there any pointers for developing a better understanding or > > intuition of this? > > Usually, making type arguments explicit helps: that is, assume that each > polymorphic value is actually a function expecting a type (the a in > forall a. ...) and returning the value related to that type. The last > 'inside' definition becomes: > > inside x = W (\type -> unW (x type)) > > Note that we do not know at this time what will be the actual "type" > above. But that's OK, since we can return a type-lambda. > > Instead, pattern matching desugars to: > > inside x = case x of ... > > But wait! x is a function (because it's polymorphic) and we can not > pattern match on that! And, at this time, we do not know the > type-argument for x. So we are stuck. > > Also, type-lambdas and type-arguments are hard to insert in W . unW . This is the lack of impredicativity. W :: a -> W a To get the result type W (forall a. t a), W must instantiate the a in W's type to (forall a. t a). Further we then pass it to (.) which has type (b -> c) -> (a -> b) -> a -> c and thus require instantiating both a and b to higher-rank types. A predicative type system does not allow instantiating type variables to quantified types. From ryani.spam at gmail.com Tue Jun 10 14:18:13 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue Jun 10 14:10:44 2008 Subject: [Haskell-cafe] FunPtr error? In-Reply-To: <5ae4f2ba0806092301p2b5e9530r828abf6436e4d07d@mail.gmail.com> References: <5ae4f2ba0806081917u3cbeada0ge4968bb5183c888e@mail.gmail.com> <1097402345.20080609095428@gmail.com> <5ae4f2ba0806082324t53691b06se7efa48f5df7c379@mail.gmail.com> <5ae4f2ba0806091118y922e881nbcb1a945cc765bb3@mail.gmail.com> <2f9b2d30806091216j137abcbbj34761d6f7861c5f4@mail.gmail.com> <5ae4f2ba0806092054q75176dc0h1d9da81d4eacf877@mail.gmail.com> <6d74b0d20806092125n31df313ex483f42fc0557b06e@mail.gmail.com> <5ae4f2ba0806092301p2b5e9530r828abf6436e4d07d@mail.gmail.com> Message-ID: <2f9b2d30806101118v1c261690h1f3088a1e8d553c@mail.gmail.com> I'm not super experienced with the FFI (foreign function interface); I only used C types that you can get from #include , like Word32. You might need to make Sigval an instance of Storable, or do some magic with ForeignPtrs. Good luck! :) -- ryan On 6/9/08, Galchin, Vasili wrote: > I have tried various things to no avail .... > > vigalchin@ubuntu:~/FTP/Haskell/unix-2.2.0.0/tests/timer$ > runhaskell Setup.lhs build > Preprocessing executables for Test-1.0... > Building Test-1.0... > [1 of 1] Compiling Main ( ./timer.hs, > dist/build/timer/timer-tmp/Main.o ) > > ./timer.hs:22:0: > Unacceptable argument type in foreign declaration: Sigval > When checking declaration: > foreign import ccall safe "wrapper" mkNotify > :: Notify -> IO (FunPtr Notify) > > => here is my Sigval def > > data Sigval = SivalInt Int | SivalPtr (Ptr Char) > > I did a find/grep for "Unacceptable argument" in the ghc compiler source and > assuming no typo I didn't find. ?? > > Thanks. > > Kind regards, Vasili > > > > > On Mon, Jun 9, 2008 at 11:25 PM, Judah Jacobson > wrote: > > > 2008/6/9 Galchin, Vasili : > > > > > Ryan, > > > > > > I tried but the compiler didn't seem to like the keyword "import": > > > > > > > vigalchin@ubuntu:~/FTP/Haskell/unix-2.2.0.0/tests/timer$ > runhaskell > > > Setup.lhs build > > > Preprocessing executables for Test-1.0... > > > Building Test-1.0... > > > [1 of 1] Compiling Main ( ./timer.hs, > > > dist/build/timer/timer-tmp/Main.o ) > > > > > > ./timer.hs:29:8: parse error on input `import' > > > > > > > Hi Vasili, > > > > To fix that error, you probably just need to add the line "Extensions: > > ForeignFunctionInterface" to the .cabal file. (That is the > > equivalent of calling ghc by itself with the command-line arguments > > -fffi or -XForeignFunctionInterface.) > > > > Hope that helps, > > -Judah > > > > From ryani.spam at gmail.com Tue Jun 10 14:23:36 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue Jun 10 14:15:53 2008 Subject: [Haskell-cafe] FunPtr error? In-Reply-To: <2f9b2d30806101118v1c261690h1f3088a1e8d553c@mail.gmail.com> References: <5ae4f2ba0806081917u3cbeada0ge4968bb5183c888e@mail.gmail.com> <1097402345.20080609095428@gmail.com> <5ae4f2ba0806082324t53691b06se7efa48f5df7c379@mail.gmail.com> <5ae4f2ba0806091118y922e881nbcb1a945cc765bb3@mail.gmail.com> <2f9b2d30806091216j137abcbbj34761d6f7861c5f4@mail.gmail.com> <5ae4f2ba0806092054q75176dc0h1d9da81d4eacf877@mail.gmail.com> <6d74b0d20806092125n31df313ex483f42fc0557b06e@mail.gmail.com> <5ae4f2ba0806092301p2b5e9530r828abf6436e4d07d@mail.gmail.com> <2f9b2d30806101118v1c261690h1f3088a1e8d553c@mail.gmail.com> Message-ID: <2f9b2d30806101123s169efbf1te0abcfcb79f6bc46@mail.gmail.com> Also, if you always plan to partially apply your notification function and you just want a simple callback: void (*pCallbackFn)(void); You should be able to do something like this: > type Callback = IO () > foreign import ccall "wrapper" mkCallback :: Callback -> IO (FunPtr Callback) You can then do something like > main = do > let event = Sigval { ... fill in here ... } > callback <- mkCallback (notify event) > ... > freeHaskellFunPtr callback On 6/10/08, Ryan Ingram wrote: > I'm not super experienced with the FFI (foreign function interface); I > only used C types that you can get from #include , like > Word32. > > You might need to make Sigval an instance of Storable, or do some > magic with ForeignPtrs. Good luck! :) > > -- ryan > > > On 6/9/08, Galchin, Vasili wrote: > > I have tried various things to no avail .... > > > > vigalchin@ubuntu:~/FTP/Haskell/unix-2.2.0.0/tests/timer$ > > runhaskell Setup.lhs build > > Preprocessing executables for Test-1.0... > > Building Test-1.0... > > [1 of 1] Compiling Main ( ./timer.hs, > > dist/build/timer/timer-tmp/Main.o ) > > > > ./timer.hs:22:0: > > Unacceptable argument type in foreign declaration: Sigval > > When checking declaration: > > foreign import ccall safe "wrapper" mkNotify > > :: Notify -> IO (FunPtr Notify) > > > > => here is my Sigval def > > > > data Sigval = SivalInt Int | SivalPtr (Ptr Char) > > > > I did a find/grep for "Unacceptable argument" in the ghc compiler source and > > assuming no typo I didn't find. ?? > > > > Thanks. > > > > Kind regards, Vasili > > > > > > > > > > On Mon, Jun 9, 2008 at 11:25 PM, Judah Jacobson > > wrote: > > > > > 2008/6/9 Galchin, Vasili : > > > > > > > Ryan, > > > > > > > > I tried but the compiler didn't seem to like the keyword "import": > > > > > > > > > > vigalchin@ubuntu:~/FTP/Haskell/unix-2.2.0.0/tests/timer$ > > runhaskell > > > > Setup.lhs build > > > > Preprocessing executables for Test-1.0... > > > > Building Test-1.0... > > > > [1 of 1] Compiling Main ( ./timer.hs, > > > > dist/build/timer/timer-tmp/Main.o ) > > > > > > > > ./timer.hs:29:8: parse error on input `import' > > > > > > > > > > Hi Vasili, > > > > > > To fix that error, you probably just need to add the line "Extensions: > > > ForeignFunctionInterface" to the .cabal file. (That is the > > > equivalent of calling ghc by itself with the command-line arguments > > > -fffi or -XForeignFunctionInterface.) > > > > > > Hope that helps, > > > -Judah > > > > > > > > From ryani.spam at gmail.com Tue Jun 10 14:28:34 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue Jun 10 14:20:50 2008 Subject: [Haskell-cafe] Moving "forall" over type constructors In-Reply-To: <1213115744.7306.48.camel@derek-laptop> References: <484D2E21.7000005@daimi.au.dk> <20080609134049.GA19510@netsoc.tcd.ie> <17733353.post@talk.nabble.com> <20080609140413.GC19510@netsoc.tcd.ie> <3c6288ab0806090756g1ad94967v9e6f6a8c75f33e10@mail.gmail.com> <3c6288ab0806090759q4fcbdb5bu2da7c620fa4d5f7f@mail.gmail.com> <484EA809.8050101@di.unipi.it> <1213115744.7306.48.camel@derek-laptop> Message-ID: <2f9b2d30806101128i14c0380bj70626a5f8e5a34c4@mail.gmail.com> On 6/10/08, Derek Elkins wrote: > This is the lack of impredicativity. > > W :: a -> W a > To get the result type W (forall a. t a), W must instantiate the a in > W's type to (forall a. t a). Further we then pass it to (.) which has > type (b -> c) -> (a -> b) -> a -> c and thus require instantiating both > a and b to higher-rank types. A predicative type system does not allow > instantiating type variables to quantified types. Although if I am reading the literature correctly, that definition will likely typecheck in the next GHC... http://research.microsoft.com/~simonpj/papers/boxy/ -- ryan From Joseph.Re at MorganStanley.com Tue Jun 10 15:19:37 2008 From: Joseph.Re at MorganStanley.com (Re, Joseph (IT)) Date: Tue Jun 10 15:12:28 2008 Subject: [Haskell-cafe] Unable to hc-build ghc 6.6.1 References: <507725E31752A74CB00728FA6C17D99C09E1039D@NYWEXMB29.msad.ms.com> <20080610155432.GA30373@matrix.chaos.earth.li> Message-ID: <507725E31752A74CB00728FA6C17D99C09E10993@NYWEXMB29.msad.ms.com> > -----Original Message----- > > From: Ian Lynagh [mailto:igloo@earth.li] > > Nothing comes to mind. Were the libraries rebuilt after building > > GenApply on the machine on which the hc files were generated? > > Nope. After building the hc tarball with a new copy of ghc > 6.6.1 on the host machine, I pulled it along with a new copy > of the source tarball from http://www.haskell.org/ghc onto > the target machine. Untarred the hc files, changed > mk/build.mk and fixed mk/bootstrap.mk, and ran distrib/hc-build. Just wanted to note that I get the same error with ghc 6.4.2 (after patching ghc/Makefile's ordering of the SUBDIRS line as noted in http://hackage.haskell.org/trac/ghc/ticket/841, adding "-lncurses" to mk/bootstrap.mk, and removing ghc 6.6.1 to prevent conflicts). -------------------------------------------------------- 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 stansife at caltech.edu Tue Jun 10 20:23:58 2008 From: stansife at caltech.edu (Eric Stansifer) Date: Tue Jun 10 20:16:13 2008 Subject: [Haskell-cafe] lhs syntax highlighting in vim Message-ID: <2e58fd390806101723p3e74c6cfkce28786e9325afbd@mail.gmail.com> Hello, The syntax highlighting file for literate haskell in vim says that its maintainer is haskell-cafe@haskell.org, so hopefully one of you will find this relevant. In literate haskell files, vim optionally highlights the non-code text according to TeX markup. The syntax highlighting file looks for key phrases (e.g., "\documentclass") to decide whether to use TeX markup highlighting; but it (erroneously, in my opinion, and at variance with the documentation) will use TeX markup highlighting on any lhs file that contains the '%' character anywhere in it. The bug is in line 74 of version 1.01 of the lhaskell.vim syntax highlighting file. Thanks, Eric From derek.a.elkins at gmail.com Tue Jun 10 23:28:25 2008 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Tue Jun 10 23:20:49 2008 Subject: [Haskell-cafe] Moving "forall" over type constructors In-Reply-To: <2f9b2d30806101128i14c0380bj70626a5f8e5a34c4@mail.gmail.com> References: <484D2E21.7000005@daimi.au.dk> <20080609134049.GA19510@netsoc.tcd.ie> <17733353.post@talk.nabble.com> <20080609140413.GC19510@netsoc.tcd.ie> <3c6288ab0806090756g1ad94967v9e6f6a8c75f33e10@mail.gmail.com> <3c6288ab0806090759q4fcbdb5bu2da7c620fa4d5f7f@mail.gmail.com> <484EA809.8050101@di.unipi.it> <1213115744.7306.48.camel@derek-laptop> <2f9b2d30806101128i14c0380bj70626a5f8e5a34c4@mail.gmail.com> Message-ID: <1213154905.7306.59.camel@derek-laptop> On Tue, 2008-06-10 at 11:28 -0700, Ryan Ingram wrote: > On 6/10/08, Derek Elkins wrote: > > This is the lack of impredicativity. > > > > W :: a -> W a > > To get the result type W (forall a. t a), W must instantiate the a in > > W's type to (forall a. t a). Further we then pass it to (.) which has > > type (b -> c) -> (a -> b) -> a -> c and thus require instantiating both > > a and b to higher-rank types. A predicative type system does not allow > > instantiating type variables to quantified types. > > Although if I am reading the literature correctly, that definition > will likely typecheck in the next GHC... > > http://research.microsoft.com/~simonpj/papers/boxy/ Actually some support was hacked into the current version of GHC. http://www.haskell.org/ghc/docs/latest/html/users_guide/other-type-extensions.html#impredicative-polymorphism From aeyakovenko at gmail.com Wed Jun 11 00:13:17 2008 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Wed Jun 11 00:05:33 2008 Subject: [Haskell-cafe] blas: ghc-6.8.2: unable to load package `blas-0.4' Message-ID: Patric, I am trying to use your blas package, but I am getting a missing symbol error. > import Data.Matrix.Dense.IO > mm::(IOMatrix (Int,Int) Double) <- newListMatrix (1,1) [1.0] Loading package storable-complex-0.1 ... linking ... done. Loading package ieee-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 random-1.0.0.0 ... linking ... done. Loading package QuickCheck-1.1.0.0 ... linking ... done. Loading package blas-0.4 ... linking ... : /usr/lib/blas-0.4/ghc-6.8.2/HSblas-0.4.o: unknown symbol `cblas_ddot' ghc-6.8.2: unable to load package `blas-0.4' any ideas what i am missing? Thanks, Anatoly From dons at galois.com Wed Jun 11 00:15:07 2008 From: dons at galois.com (Don Stewart) Date: Wed Jun 11 00:07:23 2008 Subject: [Haskell-cafe] blas: ghc-6.8.2: unable to load package `blas-0.4' In-Reply-To: References: Message-ID: <20080611041507.GA32117@scytale.galois.com> aeyakovenko: > Patric, > > I am trying to use your blas package, but I am getting a missing symbol error. > > > import Data.Matrix.Dense.IO > > mm::(IOMatrix (Int,Int) Double) <- newListMatrix (1,1) [1.0] > Loading package storable-complex-0.1 ... linking ... done. > Loading package ieee-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 random-1.0.0.0 ... linking ... done. > Loading package QuickCheck-1.1.0.0 ... linking ... done. > Loading package blas-0.4 ... linking ... : > /usr/lib/blas-0.4/ghc-6.8.2/HSblas-0.4.o: unknown symbol `cblas_ddot' > ghc-6.8.2: unable to load package `blas-0.4' > > any ideas what i am missing? Missing -lcblas perhaps? The C library isn't being found. -- Don From aeyakovenko at gmail.com Wed Jun 11 00:28:27 2008 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Wed Jun 11 00:20:42 2008 Subject: [Haskell-cafe] blas: ghc-6.8.2: unable to load package `blas-0.4' In-Reply-To: <20080611041507.GA32117@scytale.galois.com> References: <20080611041507.GA32117@scytale.galois.com> Message-ID: >> /usr/lib/blas-0.4/ghc-6.8.2/HSblas-0.4.o: unknown symbol `cblas_ddot' >> ghc-6.8.2: unable to load package `blas-0.4' >> >> any ideas what i am missing? > > Missing -lcblas perhaps? The C library isn't being found. $ ll /usr/lib/libcblas.* lrwxrwxrwx 1 root root 25 Jun 10 20:57 /usr/lib/libcblas.a -> blas/reference/libcblas.a lrwxrwxrwx 1 root root 26 Jun 10 20:57 /usr/lib/libcblas.so -> blas/reference/libcblas.so lrwxrwxrwx 1 root root 28 Jun 10 20:57 /usr/lib/libcblas.so.0 -> blas/reference/libcblas.so.0 I think its installed correctly, $ nm /usr/lib/libcblas.* | grep cblas_ddot cblas_ddot.o: 00000000 T cblas_ddot nm: /usr/lib/libcblas.so: no symbols nm: /usr/lib/libcblas.so.0: no symbols From aeyakovenko at gmail.com Wed Jun 11 00:38:36 2008 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Wed Jun 11 00:30:52 2008 Subject: [Haskell-cafe] blas: ghc-6.8.2: unable to load package `blas-0.4' In-Reply-To: References: <20080611041507.GA32117@scytale.galois.com> Message-ID: nevermind, i am a little slow today. ghci -lcblas From clawsie at fastmail.fm Wed Jun 11 01:51:53 2008 From: clawsie at fastmail.fm (brad clawsie) Date: Wed Jun 11 01:44:18 2008 Subject: [Haskell-cafe] wanted: Network.Curl examples Message-ID: <864p808qo6.fsf@laptop.gateway.2wire.net> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 in search of some trivial examples using Network.Curl, preferrably posted here: http://haskell.org/haskellwiki/Network.Curl some of this stuff i can figure out, but setting the curl WriteFunction, as discussed here: http://code.haskell.org/~dons/docs/curl/Network-Curl-Opts.html#t%3AWriteFunction is nonobvious. any info would be useful, curl is a great library and it would be nice if using it were more straightforward thanks brad -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (FreeBSD) iEYEARECAAYFAkhPaAAACgkQxRg3RkRK91OQrQCfTt+xzvqIAxDkqq8/P85ZZjON HWgAoK3L/1JUQjdaWHcHfutKvI3nPJUc =BfuR -----END PGP SIGNATURE----- From duncan.coutts at worc.ox.ac.uk Wed Jun 11 06:05:09 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Jun 11 05:53:28 2008 Subject: [Haskell-cafe] blas: ghc-6.8.2: unable to load package `blas-0.4' In-Reply-To: References: <20080611041507.GA32117@scytale.galois.com> Message-ID: <1213178709.15010.476.camel@localhost> On Tue, 2008-06-10 at 21:38 -0700, Anatoly Yakovenko wrote: > nevermind, i am a little slow today. ghci -lcblas You should not need to do this manually. The blas package should say that it needs this library, in which case ghc and ghci will pick it up automatically. Using "ghci -package foo" is supposed to "Just Work"tm. If it doesn't then that's generally the fault of the package. Duncan From igloo at earth.li Wed Jun 11 06:29:35 2008 From: igloo at earth.li (Ian Lynagh) Date: Wed Jun 11 06:21:49 2008 Subject: [Haskell-cafe] lhs syntax highlighting in vim In-Reply-To: <2e58fd390806101723p3e74c6cfkce28786e9325afbd@mail.gmail.com> References: <2e58fd390806101723p3e74c6cfkce28786e9325afbd@mail.gmail.com> Message-ID: <20080611102935.GA14493@matrix.chaos.earth.li> On Wed, Jun 11, 2008 at 01:23:58AM +0100, Eric Stansifer wrote: > > The syntax highlighting file for literate haskell in vim says that its > maintainer is haskell-cafe@haskell.org, so hopefully one of you will > find this relevant. > > In literate haskell files, vim optionally highlights the non-code text > according to TeX markup. The syntax highlighting file looks for key > phrases (e.g., "\documentclass") to decide whether to use TeX markup > highlighting; but it (erroneously, in my opinion, and at variance > with the documentation) will use TeX markup highlighting on any lhs > file that contains the '%' character anywhere in it. The bug is in > line 74 of version 1.01 of the lhaskell.vim syntax highlighting file. I agree that this is wrong. It used to only look at the first 20 lines, so we were covering the case where a TeX file began with some TeX comments. We'd also look for ^\s*%, rather than a % anywhere. If we are going to look at the whole file then checking for comments isn't necessary. Thanks Ian From silva.samuel at gmail.com Wed Jun 11 06:44:57 2008 From: silva.samuel at gmail.com (Samuel Silva) Date: Wed Jun 11 06:37:15 2008 Subject: [Haskell-cafe] running haddock and lhs2TeX Message-ID: <382ead9b0806110344h7a68b9cco154e8275ea9ffaa6@mail.gmail.com> Hello I'm using haddock to my Literate Haskell code, and it runs very well. I prefer Literate Haskell instead Haskell because old code remain untouched. It also is possible run latex over my code. But running lhs2TeX is even better. However lhs2TeX doesn't proccess with some haddock information. I won't change or format haddock documentation but using two tools is a valuable help at development. I would know that somebody solve thi issue and how? To solve this issue I build processor, using perl, that escapes characters like | and @. This preprocessor just escapes characters within \begin{code} ... \end{code}. ##################################################################### # This scripts process Literate Haskell Script itself to be process # by lhs2TeX with haddock comments. # use strict; use warnings; my @tag=(); while (<>) { if ($_ =~ /\\begin{(.*)}/) {push @tag => $1;} elsif ($_ =~ /\\end{(.*)}/ and $1 eq $tag[@tag-1]) {pop @tag;} if ( elem("code",@tag) and /(.*)--(.*)/) { print $1 => process($2) => "\n"; } else { print; } } sub process{ my ($input) = @_; $input =~ s/\|/\|\|/g; # escapes | $input =~ s/\@/\@\@/g; # escapes @ $input =~ s/\^//g; # drop ^ $input =~ s/\"/\'/g; # change " into ' return "--$input"; } sub elem { my ($x,@xs) = @_; my $res = 0; for (@xs) {$res=1 if $x eq $_} return $res; } ##################################################################### -- Don't hug that, Hugs ME! Samuel Silva From chris at eidhof.nl Wed Jun 11 08:11:02 2008 From: chris at eidhof.nl (Chris Eidhof) Date: Wed Jun 11 08:03:17 2008 Subject: [Haskell-cafe] wanted: Network.Curl examples In-Reply-To: <864p808qo6.fsf@laptop.gateway.2wire.net> References: <864p808qo6.fsf@laptop.gateway.2wire.net> Message-ID: Hey Brad, I wrote a blog-post with some curl-examples in there, it's a small mashup of last.fm and upcoming, check it at http://tinyurl.com/5d8jx7 Enjoy, -chris On 11 jun 2008, at 07:51, brad clawsie wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > in search of some trivial examples using Network.Curl, preferrably > posted here: > > http://haskell.org/haskellwiki/Network.Curl > > some of this stuff i can figure out, but setting the curl > WriteFunction, as discussed here: > > http://code.haskell.org/~dons/docs/curl/Network-Curl-Opts.html#t%3AWriteFunction > > is nonobvious. > > any info would be useful, curl is a great library and it would be nice > if using it were more straightforward > > thanks > brad > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v2.0.9 (FreeBSD) > > iEYEARECAAYFAkhPaAAACgkQxRg3RkRK91OQrQCfTt+xzvqIAxDkqq8/P85ZZjON > HWgAoK3L/1JUQjdaWHcHfutKvI3nPJUc > =BfuR > -----END PGP SIGNATURE----- > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From andrewcoppin at btinternet.com Wed Jun 11 14:17:03 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Wed Jun 11 14:16:19 2008 Subject: [Haskell-cafe] Simple list processing Message-ID: <4850169F.4050003@btinternet.com> OK, so this is a fairly basic question about list processing. Several times now, I have found myself wanting to process a list to produce a new list. However, the way later elements are processed depends on what the earlier elements are - in other words, this isn't a simple "map". What is the best way to handle this? According to the theory, anything that consumes a list and produces a value is some kind of fold. [Assuming it traverses the list in a sensible order!] So it looks like you could implement this as a fold. But should that be a LEFT-fold or a RIGHT-fold? (I always get confused between the two!) Actually, anything that takes a value and processes it repeatedly to produce a list is technically an unfold. [Again assuming a sensible processing order.] So it looks like this function could also be an UNfold. As in, you take a list as input, and keep unfolding until that list becomes empty. So it looks like this can be implemented as a fold or an unfold. But neither way looks especially easy. Both of these patterns seem to be more general than necessary; I only want to take 1 element of input and produce 1 element of output, but keeping track of a running state. I guess I could use some sort of state monad and make the whole thing monadic - but that again is overkill for what I'm trying to do. Any hints here? From dons at galois.com Wed Jun 11 14:25:17 2008 From: dons at galois.com (Don Stewart) Date: Wed Jun 11 14:17:47 2008 Subject: [Haskell-cafe] Simple list processing In-Reply-To: <4850169F.4050003@btinternet.com> References: <4850169F.4050003@btinternet.com> Message-ID: <20080611182517.GF25521@scytale.galois.com> andrewcoppin: > OK, so this is a fairly basic question about list processing. > > Several times now, I have found myself wanting to process a list to > produce a new list. However, the way later elements are processed > depends on what the earlier elements are - in other words, this isn't a > simple "map". > > What is the best way to handle this? > > According to the theory, anything that consumes a list and produces a > value is some kind of fold. [Assuming it traverses the list in a > sensible order!] So it looks like you could implement this as a fold. > But should that be a LEFT-fold or a RIGHT-fold? (I always get confused > between the two!) > Sounds like a mapAccum, a combination of map and fold, http://haskell.org/ghc/docs/latest/html/libraries/base/Data-List.html#v%3AmapAccumL If you gave a concrete example it would be easier to diagnose. -- Don From daniel.is.fischer at web.de Wed Jun 11 15:03:11 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Jun 11 14:53:40 2008 Subject: [Haskell-cafe] Simple list processing In-Reply-To: <4850169F.4050003@btinternet.com> References: <4850169F.4050003@btinternet.com> Message-ID: <200806112103.11835.daniel.is.fischer@web.de> Am Mittwoch, 11. Juni 2008 20:17 schrieb Andrew Coppin: > > So it looks like this can be implemented as a fold or an unfold. But > neither way looks especially easy. Both of these patterns seem to be > more general than necessary; I only want to take 1 element of input and > produce 1 element of output, but keeping track of a running state. scanl might be a sufficiently lightweight way to do that (or it might not, depending on what you actually want to do). From chris at eidhof.nl Wed Jun 11 16:35:56 2008 From: chris at eidhof.nl (Chris Eidhof) Date: Wed Jun 11 16:28:13 2008 Subject: [Haskell-cafe] Simple list processing In-Reply-To: <4850169F.4050003@btinternet.com> References: <4850169F.4050003@btinternet.com> Message-ID: <7097A73D-758B-4C7C-A982-6086DDF0C847@eidhof.nl> Hey Andrew, On 11 jun 2008, at 20:17, Andrew Coppin wrote: > According to the theory, anything that consumes a list and produces > a value is some kind of fold. [Assuming it traverses the list in a > sensible order!] So it looks like you could implement this as a > fold. But should that be a LEFT-fold or a RIGHT-fold? (I always get > confused between the two!) Check out http://foldl.com/ and http://foldr.com ;) -chris From thomas.dubuisson at gmail.com Wed Jun 11 16:46:23 2008 From: thomas.dubuisson at gmail.com (Thomas M. DuBuisson) Date: Wed Jun 11 16:40:00 2008 Subject: [Haskell-cafe] Simple list processing In-Reply-To: <20080611182517.GF25521@scytale.galois.com> References: <4850169F.4050003@btinternet.com> <20080611182517.GF25521@scytale.galois.com> Message-ID: <1213217183.3033.1.camel@localhost.localdomain> Why is there no mapAccumL' (strict)? Just a library deficiency that we can remedy or am I missing something? Don Stewart wrote: > andrewcoppin: > > OK, so this is a fairly basic question about list processing. > > > > Several times now, I have found myself wanting to process a list to > > produce a new list. However, the way later elements are processed > > depends on what the earlier elements are - in other words, this isn't a > > simple "map". > > > > What is the best way to handle this? > > > > According to the theory, anything that consumes a list and produces a > > value is some kind of fold. [Assuming it traverses the list in a > > sensible order!] So it looks like you could implement this as a fold. > > But should that be a LEFT-fold or a RIGHT-fold? (I always get confused > > between the two!) > > > > Sounds like a mapAccum, a combination of map and fold, > > http://haskell.org/ghc/docs/latest/html/libraries/base/Data-List.html#v%3AmapAccumL > > If you gave a concrete example it would be easier to diagnose. > > -- Don > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From byorgey at gmail.com Wed Jun 11 17:11:29 2008 From: byorgey at gmail.com (Brent Yorgey) Date: Wed Jun 11 17:03:45 2008 Subject: [Haskell-cafe] Haskell Weekly News: Issue 72 - June 11, 2008 Message-ID: <22fcbd520806111411s54723e70x1af8ba04c98b2622@mail.gmail.com> --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20080611 Issue 72 - June 11, 2008 --------------------------------------------------------------------------- Welcome to issue 72 of HWN, a newsletter covering developments in the [1]Haskell community. Greetings, Haskellites! As many of you have already heard, Don Stewart has passed on the editorship of the HWN to me (Brent Yorgey). I'd like to thank Don and John Goerzen for their great work putting it together in the past, and I'm excited to make the HWN once again into a reliable, useful compendium of happenings in the Haskell community. You can expect to see a few changes---for example, hackage uploads will no longer be listed in the HWN (unless they are announced on the haskell or haskell-cafe mailing lists), since you can now see a dynamically updated list on the front page of the Haskell wiki. This edition includes all the announcements going back to Issue 71, but only some of the blog posts, since I couldn't find a way to get old feed data from Planet Haskell. Hopefully next week things will settle down to something more normal(ish) and I can begin tinkering with the format. Feel free to send suggestions and/or stories for inclusion to me, byorgey at gmail dot com. Enjoy---'Putting the W back in HWN!' Announcements hfann. Olivier Boudry [2]announced the first release of the [3]hfann module, an interface to the [4]'Fast Artificial Neural Network (FANN)' library. funsat. Denis Bueno [5]announced a release of [6]funsat, a modern, DPLL-style SAT solver written in Haskell. Funsat solves formulas in conjunctive normal form and produces a total variable assignment for satisfiable problems. DEFUN08: Call for talks and tutorials. Matthew Fluet [7]announced the final call for talks and tutorials at [8]DEFUN 2008, to be held in conjunction with [9]ICFP. Cabal-1.4 Release Candidate. Duncan Coutts [10]announced the second release candidate for [11]Cabal-1.4. Programmer's Minesweeper. Bertram Felgenhauer [12]announced a Haskell implementation of [13]Programmer's Minesweeper, which allows programmers to implement minesweeper strategies and run them. hackage RSS feed. Don Stewart [14]announced a new [15]RSS feed for the most recently uploaded packages on [16]Hackage. BLAS bindings. Patrick Perry [17]announced a set of bindings for the [18]BLAS linear algebra library. Xen Control bindings. Thomas DuBuisson [19]announced the [20]hsXenCtrl package, with FFI bindings to [21]Xen. bloomfilter. Bryan O'Sullivan [22]announced the availability of a fast Bloom filter library for Haskell. A Bloom filter is a probabilistic data structure that provides a fast set membership querying capability. It does not give false negatives, but has a tunable false positive rate. HCAR. Janis Voigtlaender [23]announced the 14th edition of the [24]Haskell Community and Activities Report (HCAR). HSmugMug. Daniel Patterson [25]announced [26]HSmugMug, a Haskell wrapper to the photo hosting site [27]SmugMug's API. LIPL. Sam Lee [28]announced the release of [29]LIPL, a tiny functional language implemented as a term project to learn Haskell. Glome 0.51. Jim Snow [30]announced version 0.51 of [31]glome, a raytracer written in Haskell. ChessLibrary. Andrew Wagner [32]announced the [33]ChessLibrary project, and mentioned that he is looking for an experienced haskeller to serve as a mentor for this project. xmonad-utils. Gwern Branwen [34]announced the upload to hackage of [35]xmonad-utils, a couple of small Xlib programs which might be useful for xmonad users. Roguestar. Christopher Lane Hinson [36]announced the release of [37]Roguestar 0.2, a science fiction themed roguelike (turn-based, chessboard-tiled, role playing) game written in Haskell. Streaming Component Combinators. Mario Blazevic [38]announced the 0.1 release of [39]Streaming Component Combinators in Haskell, based on earlier work done in [40]OmniMark. Twitter client. Chris Eidhof [41]announced a simple [42]terminal-based Twitter client. Monad.Reader call for copy. Wouter Swierstra [43]issued a call for copy for [44]The Monad.Reader. The submission deadline for Issue 11 is August 1. category-extras. Edward Kmett [45]announced a new release of the [46]category-extras package, involving all sorts of new categorical goodness. Session Types for Haskell. Matthew Sackman [47]announced the availability of [48]Session Types for Haskell. Session types are a means of describing communication between multiple threads, and statically verifying that the communication being performed is safe and conforms to the specification. Haddock 2.1.0. David Waern [49]announced the release of [50]Haddock 2.1.0. ReviewBoard. Adam Smyczek [51]announced the release of [52]Haskell bindings to [53]ReviewBoard, a development tool designed to monitor code changes and analyze dependencies. diagrams. Brent Yorgey [54]announced the initial release of [55]Graphics.Rendering.Diagrams, an embedded domain-specific language for creating simple pictures and diagrams, built on top of the Cairo vector graphics library. HXT. Uwe Schmidt [56]announced a new release of the [57]Haskell XML Toolbox. GSoC. Malcolm Wallace [58]announced the seven student projects chosen to be funded by the [59]Google Summer of Code. bytestring. Don Stewart [60]announced a new major release of [61]bytestring, the efficient string library for Haskell, suitable for high-performance scenarios. HXQ. Leonidas Fegaras [62]announced the release of [63]HXQ, an [64]XQuery compiler/interpreter for Haskell. Win32-notify. Niklas Broberg [65]announced the first release of [66]Win32-notify, an inotify-alike for Windows. cpuid. Martin Grabmueller [67]announced the new [68]cpuid package, which provides functionality for accessing information about the currently running IA-32 processor. Emping. Hans van Thiel [69]announced version 0.5 of the [70]Emping package, a utility which derives the shortest rules from a table of rules. datapacker. John Goerzen [71]announced the first release of [72]datapacker, a tool to pack files into a minimum number of CDs, DVDs, or any other arbitrary bin. darcswatch. Joachim Breitner [73]announced the release of [74]darcswatch, a tool for tracking darcs patches and repositories. Generic Haskell. Thomas van Noort [75]announced the fifth release of [76]Generic Haskell, an extension of Haskell that facilitates generic programming. drawingcombinators. Luke Palmer [77]announced the release of [78]graphics-drawingcombinators, a wrapper around OpenGL with a functional interface. The Monad.Reader. Wouter Swierstra [79]announced the publication of Issue 10 of [80]The Monad.Reader, a quarterly magazine about functional programming. Well-Typed LLP. Ian Lynagh [81]announced that he, Bj?rn Bringert and Duncan Coutts have set up a Haskell consultancy company, [82]Well-Typed LLP. Their services include application development, library and tool maintenance, project advice, and training. hgdbmi. Evan Martin [83]announced the [84]hgdbmi package, which wraps the operations of attaching GDB to a process and parsing the GDB/MI output. xmonad. Don Stewart [85]announced the release of [86]xmonad version 0.7. Updates include improved integration with GNOME, more flexible "rules", various stability fixes, and of course, many new and interesting features in the extension library. Haskell Server Pages. Niklas Broberg [87]announced a new release of [88]Haskell Server Pages, a programming model for writing dynamic web pages in Haskell, both server-side and client-side. Network.MiniHTTP. Adam Langley [89]announced a release of [90]network-minihttp, a small bytestring HTTP library. Disciplined Disciple Compiler. Ben Lippmeier [91]announced the initial alpha release of the [92]Disciplined Disciple Compiler, an explicitly lazy dialect of Haskell. haskell-src-exts. Niklas Broberg [93]announced a new release for [94]haskell-src-exts, a package for handling and manipulating Haskell source code. omnicodec. Magnus Therning [95]announced the package [96]omnicodec, containing two command line utilities for encoding and decoding data. Blog noise [97]Haskell news from the [98]blogosphere. * [99]Christophe Poucet (vincenz): ICFP Contest 2008 * [100]Real-World Haskell: CUFP 2007 videos now easier to view * [101]Wrap-up: mergesort in haskell * [102]jbofihe and Haskell * [103]Writing a Regular Expression parser in Haskell: Part 3 * [104]Real World Haskell * [105]London Haskell Users Group: Next meeting: Paradise, a DSEL for derivatives pricing * [106]Christophe Poucet (vincenz): Lazy memoization * [107]Neil Mitchell: GSoC Hoogle: Week 2 * [108]Magnus Therning: Google Treasure Hunt primes question * [109]Roman Cheplyaka: Status report: week 2 * [110]Andy Gill: The unknown cost of dictionaries * [111]Edward Kmett: Zapping Adjunctions * [112]Edward Kmett: Representing Adjunctions * [113]Andy Gill: Performance problems with functional representation of derivatives * [114]Conal Elliott: Functional linear maps Quotes of the Week * roconnor: if you click your heels and say ``there is no binding like gtk2hs'' then dcoutts will appear and answer your question. * mauke: the first rule of fix club is "the first rule of fix club is "the first rule of fix club is... * oerjan: so does this mean that a comonad is like a wildlife preserve on an island in a sea of nuclear waste? * quicksilver: head-explosion is the solution, not the problem. * Botje: [on googling for polyvariadic typeclasses] OH GOD THE FIRST HIT IS OLEGS SITE! / *ahum* / I meant, "yay, reading material" * Baughn: From my point of view, anyone who understands everything ghc can do is /scary/. I'm sure that will change once I reach that level myself, but then again, there's also the possibility that I'll be in a permanent state of autophobia. * newsham: I think the problem with people asking homework questions in this channel is that the people in this channel don't have enough homework questions of their own to do. * quicksilver: *** quicksilver beats Deewiant with the i-will-not-use-fail-stick [Deewiant] quicksilver: I'm willing to accept a good alternative. [quicksilver] no. all you are permitted to accept is a beating. * mar77a: MONAD ARGHH GHGRHGH HGHRGHR RUN * Cale: Types are a bit like the nubs on lego bricks which provide structural integrity while suggesting how the bricks should fit together. * quicksilver: zip`ap`tail the aztec god of consecutive numbers About the Haskell Weekly News New editions are posted to [115]the Haskell mailing list as well as to [116]the Haskell Sequence and [117]Planet Haskell. [118]RSS is also available, and headlines appear on [119]haskell.org. Headlines are available as [120]PDF. To help create new editions of this newsletter, please see the [121]contributing information. Send stories to byorgey at gmail dot com. The darcs repository is available at darcs get [122]http://code.haskell.org/~byorgey/code/hwn/ References 1. http://haskell.org/ 2. http://article.gmane.org/gmane.comp.lang.haskell.cafe/41154 3. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hfann 4. http://leenissen.dk/fann/ 5. http://article.gmane.org/gmane.comp.lang.haskell.cafe/41167 6. http://churn.ath.cx/funsat.html 7. http://article.gmane.org/gmane.comp.lang.haskell.cafe/38392 8. http://www.deinprogramm.de/defun-2008/ 9. http://www.icfpconference.org/icfp2008/ 10. http://article.gmane.org/gmane.comp.lang.haskell.cafe/41059 11. http://www.haskell.org/cabal/ 12. http://article.gmane.org/gmane.comp.lang.haskell.cafe/40950 13. http://www.ccs.neu.edu/home/ramsdell/pgms/index.html 14. http://article.gmane.org/gmane.comp.lang.haskell.cafe/41045 15. http://hackage.haskell.org/packages/archive/recent.rss 16. http://hackage.haskell.org/ 17. http://quantile95.com/?p=5 18. http://www.netlib.org/blas/ 19. http://article.gmane.org/gmane.comp.lang.haskell.cafe/40790 20. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hsXenCtrl 21. http://xen.org/ 22. http://article.gmane.org/gmane.comp.lang.haskell.cafe/40745 23. http://article.gmane.org/gmane.comp.lang.haskell.cafe/40703 24. http://www.haskell.org/communities/ 25. http://article.gmane.org/gmane.comp.lang.haskell.cafe/40546 26. http://dbpatterson.com/articles/10 27. http://www.smugmug.com/ 28. http://article.gmane.org/gmane.comp.lang.haskell.cafe/40500 29. http://www.lipl.googlepages.com/index.html#source 30. http://article.gmane.org/gmane.comp.lang.haskell.cafe/40479 31. http://syn.cs.pdx.edu/~jsnow/glome/ 32. http://article.gmane.org/gmane.comp.lang.haskell.cafe/40052 33. http://code.haskell.org/ChessLibrary/ 34. http://article.gmane.org/gmane.comp.lang.haskell.cafe/39773 35. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/xmonad-utils 36. http://article.gmane.org/gmane.comp.lang.haskell.cafe/39710 37. http://roguestar.downstairspeople.org/ 38. http://article.gmane.org/gmane.comp.lang.haskell.cafe/39654 39. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/scc-0.1 40. http://www.idealliance.org/papers/extreme/proceedings/html/2006/Blazevic01/EML2006Blazevic01.html 41. http://article.gmane.org/gmane.comp.lang.haskell.cafe/39648 42. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/twitter 43. http://article.gmane.org/gmane.comp.lang.haskell.cafe/39522 44. http://www.haskell.org/haskellwiki/The_Monad.Reader 45. http://article.gmane.org/gmane.comp.lang.haskell.cafe/39492 46. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/category-extras 47. http://article.gmane.org/gmane.comp.lang.haskell.cafe/39482 48. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/sessions 49. http://article.gmane.org/gmane.comp.lang.haskell.cafe/39352 50. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/haddock-2.1.0 51. http://article.gmane.org/gmane.comp.lang.haskell.cafe/39347 52. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/ 53. http://code.google.com/p/reviewboard/ 54. http://article.gmane.org/gmane.comp.lang.haskell.cafe/39342 55. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/diagrams-0.1 56. http://article.gmane.org/gmane.comp.lang.haskell.cafe/39271 57. http://www.fh-wedel.de/~si/HXmlToolbox/index.html 58. http://article.gmane.org/gmane.comp.lang.haskell.cafe/39040 59. http://code.google.com/soc/2008/haskell/about.html 60. http://article.gmane.org/gmane.comp.lang.haskell.cafe/38992 61. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/bytestring 62. http://article.gmane.org/gmane.comp.lang.haskell.cafe/38991 63. http://lambda.uta.edu/HXQ/ 64. http://www.w3.org/TR/xquery/ 65. http://article.gmane.org/gmane.comp.lang.haskell.cafe/38965 66. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Win32-notify-0.1 67. http://article.gmane.org/gmane.comp.lang.haskell.cafe/38922 68. http://uebb.cs.tu-berlin.de/~magr/projects/cpuid/doc/ 69. http://article.gmane.org/gmane.comp.lang.haskell.cafe/38870 70. http://home.telfort.nl/sp969709/emp/empug.html 71. http://article.gmane.org/gmane.comp.lang.haskell.cafe/38773 72. http://software.complete.org/datapacker 73. http://article.gmane.org/gmane.comp.lang.haskell.cafe/38736 74. http://darcswatch.nomeata.de/ 75. http://article.gmane.org/gmane.comp.lang.haskell.cafe/38676 76. http://www.generic-haskell.org/ 77. http://article.gmane.org/gmane.comp.lang.haskell.cafe/38542 78. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/graphics-drawingcombinators-0.1 79. http://article.gmane.org/gmane.comp.lang.haskell.cafe/38505 80. http://www.haskell.org/haskellwiki/The_Monad.Reader 81. http://article.gmane.org/gmane.comp.lang.haskell.cafe/38419 82. http://www.well-typed.com/ 83. http://article.gmane.org/gmane.comp.lang.haskell.cafe/38173 84. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hgdbmi 85. http://article.gmane.org/gmane.comp.lang.haskell.cafe/38167 86. http://xmonad.org/ 87. http://article.gmane.org/gmane.comp.lang.haskell.cafe/37996 88. http://code.google.com/p/hsp 89. http://article.gmane.org/gmane.comp.lang.haskell.cafe/37853 90. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/network-minihttp-0.2 91. http://article.gmane.org/gmane.comp.lang.haskell.cafe/37831 92. http://www.haskell.org/haskellwiki/DDC 93. http://article.gmane.org/gmane.comp.lang.haskell.cafe/37703 94. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/haskell-src-exts-0.3.2 95. http://article.gmane.org/gmane.comp.lang.haskell.cafe/37688 96. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/omnicodec 97. http://planet.haskell.org/ 98. http://haskell.org/haskellwiki/Blog_articles 99. http://cpoucet.wordpress.com/2008/06/11/icfp-contest-2008/ 100. http://www.realworldhaskell.org/blog/2008/06/10/cufp-2007-videos-now-easier-to-view/ 101. http://muharem.wordpress.com/2008/06/10/wrap-up-mergesort-in-haskell/ 102. http://chrisdone.com/blog/2008/06/10/jbofihe-and-haskell/ 103. http://blogs.msdn.com/matt/archive/2008/06/09/writing-a-regular-expression-parser-in-haskell-part-3.aspx 104. http://tapestryjava.blogspot.com/2008/06/real-world-haskell.html 105. http://www.londonhug.net/2008/06/09/next-meeting-paradise-a-dsel-for-derivatives-pricing/ 106. http://cpoucet.wordpress.com/2008/04/25/lazy-memoization/ 107. http://neilmitchell.blogspot.com/2008/06/gsoc-hoogle-week-2.html 108. http://therning.org/magnus/archives/353 109. http://physics-dph.blogspot.com/2008/06/status-report-week-2.html 110. http://blog.unsafeperformio.com/?p=24 111. http://comonad.com/reader/2008/zapping-strong-adjunctions/ 112. http://comonad.com/reader/2008/representing-adjunctions/ 113. http://blog.unsafeperformio.com/?p=23 114. http://feeds.feedburner.com/~r/conal/~3/304291460/ 115. http://www.haskell.org/mailman/listinfo/haskell 116. http://sequence.complete.org/ 117. http://planet.haskell.org/ 118. http://sequence.complete.org/node/feed 119. http://haskell.org/ 120. http://code.haskell.org/~byorgey/code/hwn/archives/20080611.pdf 121. http://haskell.org/haskellwiki/HWN 122. http://code.haskell.org/~byorgey/code/hwn/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080611/b603afd9/attachment.htm From patperry at stanford.edu Wed Jun 11 20:13:45 2008 From: patperry at stanford.edu (Patrick Perry) Date: Wed Jun 11 20:06:04 2008 Subject: [Haskell-cafe] ANN: blas-0.4.1 Message-ID: <5E451F8D-AE36-4FBE-A1B4-DBA25F0022CD@stanford.edu> There were a few hiccups in the release of 0.4, so this version is to make installation go a little smoother for people. There are now installation instructions (the INSTALL file) and configuration settings for some common CBLAS (ATLAS, MKL, vecLib, GSL). The default is now to assume that ATLAS is installed, so hopefully most people won't have to fuss too much with this. Alberto Ruiz reported two small issues with precision in the unit tests, and those have now been fixed. Patrick -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080611/2b4cfdc7/attachment.htm From qdunkan at gmail.com Wed Jun 11 20:18:02 2008 From: qdunkan at gmail.com (Evan Laforge) Date: Wed Jun 11 20:10:27 2008 Subject: [Haskell-cafe] appending an element to a list In-Reply-To: <48405717.20206@daimi.au.dk> References: <483EE208.2010601@inf.fu-berlin.de> <483EF36B.5040100@daimi.au.dk> <48404039.6030605@cisco.com> <48405717.20206@daimi.au.dk> Message-ID: <2518b95d0806111718u59c26afasf27638125db14215@mail.gmail.com> > Lets look at the actual reductions going on. To make the example easier, > I would like to use last instead of your complicated until. It shouldn't > make a difference. [ winds up doing twice as much work ] This was also my intuition. I had a function that built up a large output list by generating chunks and ++ them onto the output (e.g. basically concatMap). My intuition was that this would get gradually slower because each (++) implied a copy of the previous part of the list. So if I have another function consuming the eventual output it will get slower and slower because demanding an element will reduce the (++)s for each chunk, and copy the element 1000 times if I have appended 1000 chunks by now. So I switched to using DList, which has O(1) append. Then I ran timing on a list that wound up adding up a million or so chunks... and both versions were exactly the same speed (and -O2 gave both an equally big speed boost). In fact, when I try with a toy example, the DList using one is much slower than the concatMap using one, which I don't quite understand. Shouldn't concatMap be quite inefficient? The program below gives me this output: 15000000 45.7416 15000000 110.2112 -O2 brings both implementations to 45. Interestingly, if I call 't1' from ghci, it sucks up 1gb of memory and slows the system to a crawl until I kill it.. this is *after* it's computed a result and given me my prompt back... even if its somehow keeping the whole list around in some ghci variable (where?), isn't 1gb+ a lot even for 15m boxed Integers? And why does it continue to grow after the function has completed? The compiled version doesn't have this problem. import System.CPUTime import qualified Data.DList as DList dconcat_map f xs = DList.toList (DList.concat (map (DList.fromList . f) xs)) mkchunk n = [n, n*2, n*3] main = do t1 t2 t1 = do let a = concatMap mkchunk [0..5000000] t <- getCPUTime print (last a) t2 <- getCPUTime print (fromIntegral (t2 - t) / fromIntegral cpuTimePrecision) t2 = do let a = dconcat_map mkchunk [0..5000000] t <- getCPUTime print (last a) t2 <- getCPUTime print (fromIntegral (t2 - t) / fromIntegral cpuTimePrecision) From patperry at stanford.edu Wed Jun 11 20:52:29 2008 From: patperry at stanford.edu (Patrick Perry) Date: Wed Jun 11 20:44:43 2008 Subject: [Haskell-cafe] ANN: ieee-0.2 Message-ID: <0EF1EF82-7B8A-4AC5-B8CB-BA15EB127108@stanford.edu> ieee is a library that provides approximate comparison of floating point numbers based, NaN-aware minimum and maximum, and a type class for approximate comparisons. This version fixes a bug in the comparison implementation for Maybe. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/ieee From isaacdupree at charter.net Wed Jun 11 20:56:17 2008 From: isaacdupree at charter.net (Isaac Dupree) Date: Wed Jun 11 20:48:21 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: random-access-list-0.1 In-Reply-To: <48505344.4010809@web.de> References: <48505344.4010809@web.de> Message-ID: <48507431.2080908@charter.net> Stephan Friedrichs wrote: > Hello, > > I've implemented Chris Okasaki's random-access list[1] which provides > typical list operations (cons, head, tail) in O(1) and yet offers > indexed random-access in O(log n). It's uploaded on hackage[2]. > > It's still an early version which I'll extend, but especially at this > eary stage I'd appreciate your feedback concerning what's still missing > / to be fixed / to be improved. Great to see it, it deserved implementing, IIRC! I don't remember enough about it.. (and don't have Okasaki anywhere handy). Can it be lazy or infinitely long? (Data.Sequence can't, but it's fast on both ends and has fast concatenation.) Anyway, document that. If it can't be lazy/infinite, does it have any advantage over using Data.Sequence?(constant factor of speed?, possible operations?, something I'm forgetting?) Is "RandomAccessList" the best name for something that's not O(1), just O(log n)? Or just that "RandomAccessList" is just much longer than "[]"? don't use those unorthodox infix function names.. `cons` is hardly worse than .:. , `append` or `mappend` than .+. , and .!. than, hmm.. . Export a ++ and ! (!! ?) if you're really dedicated. But I'd prefer an `at` that's the same partial indexing operation, rather than the name .!. (I think this "at" was a new name being put somewhere else? partly because "!" is trying to be gradually used only to refer to strictness?) "extractHead" is an ugly name for a nevertheless standardish-meaning function... what is it usually called? uncons? headTail? (Data.Sequence, which is meant to be left-right symmetric, calls it "viewr"... except your version doesn't have the Maybe, it's partial instead, fails on empty lists) For "index", don't use Monad, use Maybe (I think that's what the recent libraries@haskell.org discussion concluded, in the context of switching Data.Map back to Maybe). Also, Data.List has genericLength etc, to support. Isn't "index" (like Data.List.genericIndex) supposed to be a name for a partial operation, not one that returns a Maybe? Shouldn't "size" be named "length" (or exported as both names, since e.g. Data.Map.size, .List.length) (why is it O(1) not O(log n)? Is it possible for these RandomAccessLists to be longer than maxBound::Int?)? for e.g. toList, is the O(n) cost spread over traversing/demanding the items of the generated list, or all up-front, or somewhere in between? Why is zip slow with unbalanced lists? Obviously, it could be implemented O(min(m,n)*(log m + log n)) just indexing each one, which would be faster for really unbalanced-size lists... Obviously, I don't understand the implementation. BTW, looking at the file, data RandomAccessList a = RandomAccessList {-# UNPACK #-} !Int ![(Int, CBTree a)] Marking a list strict like that doesn't have much effect because it only makes the first (:) or [] strict. Did you mean for an element-strict or spine-strict(which would necessarily be non-infinite) list? -Isaac > > Regards, > Stephan > > [1] Chris Okasaki: "Purely Functional Data Structures" > [2] > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/random-access-list > > > From derek.a.elkins at gmail.com Wed Jun 11 21:09:52 2008 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Wed Jun 11 21:02:07 2008 Subject: [Haskell-cafe] appending an element to a list In-Reply-To: <2518b95d0806111718u59c26afasf27638125db14215@mail.gmail.com> References: <483EE208.2010601@inf.fu-berlin.de> <483EF36B.5040100@daimi.au.dk> <48404039.6030605@cisco.com> <48405717.20206@daimi.au.dk> <2518b95d0806111718u59c26afasf27638125db14215@mail.gmail.com> Message-ID: <1213232992.7306.62.camel@derek-laptop> On Wed, 2008-06-11 at 17:18 -0700, Evan Laforge wrote: > > Lets look at the actual reductions going on. To make the example easier, > > I would like to use last instead of your complicated until. It shouldn't > > make a difference. > > [ winds up doing twice as much work ] > > This was also my intuition. I had a function that built up a large > output list by generating chunks and ++ them onto the output (e.g. > basically concatMap). My intuition was that this would get gradually > slower because each (++) implied a copy of the previous part of the > list. So if I have another function consuming the eventual output it > will get slower and slower because demanding an element will reduce > the (++)s for each chunk, and copy the element 1000 times if I have > appended 1000 chunks by now. > > So I switched to using DList, which has O(1) append. Then I ran > timing on a list that wound up adding up a million or so chunks... and > both versions were exactly the same speed (and -O2 gave both an > equally big speed boost). > > In fact, when I try with a toy example, the DList using one is much > slower than the concatMap using one, which I don't quite understand. > Shouldn't concatMap be quite inefficient? concatMap is very efficient. (++) isn't slow. Left associative uses of (++) are slow. concatMap = foldr ((++) . f) [] > > The program below gives me this output: > > 15000000 > 45.7416 > 15000000 > 110.2112 > > -O2 brings both implementations to 45. > > Interestingly, if I call 't1' from ghci, it sucks up 1gb of memory and > slows the system to a crawl until I kill it.. this is *after* it's > computed a result and given me my prompt back... even if its somehow > keeping the whole list around in some ghci variable (where?), isn't > 1gb+ a lot even for 15m boxed Integers? And why does it continue to > grow after the function has completed? The compiled version doesn't > have this problem. > > > import System.CPUTime > import qualified Data.DList as DList > > dconcat_map f xs = DList.toList (DList.concat (map (DList.fromList . f) xs)) > > mkchunk n = [n, n*2, n*3] > > main = do > t1 > t2 > > t1 = do > let a = concatMap mkchunk [0..5000000] > t <- getCPUTime > print (last a) > t2 <- getCPUTime > print (fromIntegral (t2 - t) / fromIntegral cpuTimePrecision) > > t2 = do > let a = dconcat_map mkchunk [0..5000000] > t <- getCPUTime > print (last a) > t2 <- getCPUTime > print (fromIntegral (t2 - t) / fromIntegral cpuTimePrecision) > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From page at ou.edu Wed Jun 11 23:17:40 2008 From: page at ou.edu (Rex Page) Date: Wed Jun 11 23:10:00 2008 Subject: [Haskell-cafe] monomorphism restriction Message-ID: Definition of f: f = foldr (+) 0 Types: 0 :: (Num t) => t foldr (+) 0 :: Num a => [a] -> a f :: [Integer] -> Integer Please remind me, again, of the advantages of f being something different from the formula defining it. - Rex Page From dons at galois.com Wed Jun 11 23:24:02 2008 From: dons at galois.com (Don Stewart) Date: Wed Jun 11 23:16:20 2008 Subject: [Haskell-cafe] monomorphism restriction In-Reply-To: References: Message-ID: <20080612032402.GA25431@scytale.galois.com> page: > Definition of f: > f = foldr (+) 0 > Types: > 0 :: (Num t) => t > foldr (+) 0 :: Num a => [a] -> a > f :: [Integer] -> Integer > > Please remind me, again, of the advantages of f being something different > from the formula defining it. Overloaded 'constants' take a dictionary as an argument, so while you think the value might be computed only once, it make actually be recomputed each time. This can be a killer performance penalty for overloaded numeric constants. Of course, disabling this is pretty simple. -- Don From aeyakovenko at gmail.com Thu Jun 12 02:50:09 2008 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Thu Jun 12 02:42:23 2008 Subject: [Haskell-cafe] -fvia-C error Message-ID: any idea what could be causing this error when i add the -fvia-C option /tmp/ghc32300_0/ghc32300_0.hc:6:23: error: SFMT_wrap.h: No such file or directory make: *** [release] Error 1 I am also passing these options: -O2 -fexcess-precision -funbox-strict-fields -fglasgow-exts -fbang-patterns -lcblas Thanks, Anatoly From dons at galois.com Thu Jun 12 03:07:33 2008 From: dons at galois.com (Don Stewart) Date: Thu Jun 12 02:59:49 2008 Subject: [Haskell-cafe] -fvia-C error In-Reply-To: References: Message-ID: <20080612070733.GB26022@scytale.galois.com> aeyakovenko: > any idea what could be causing this error when i add the -fvia-C option > > /tmp/ghc32300_0/ghc32300_0.hc:6:23: > error: SFMT_wrap.h: No such file or directory > make: *** [release] Error 1 > > I am also passing these options: > > -O2 -fexcess-precision -funbox-strict-fields -fglasgow-exts > -fbang-patterns -lcblas When compiling something linked against the mersenne random package? -- Don From aeyakovenko at gmail.com Thu Jun 12 03:30:51 2008 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Thu Jun 12 03:23:02 2008 Subject: [Haskell-cafe] -fvia-C error In-Reply-To: <20080612070733.GB26022@scytale.galois.com> References: <20080612070733.GB26022@scytale.galois.com> Message-ID: > When compiling something linked against the mersenne random package? yes, does it not work with fvia-C? From duncan.coutts at worc.ox.ac.uk Thu Jun 12 03:43:38 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Jun 12 03:31:42 2008 Subject: [Haskell-cafe] -fvia-C error In-Reply-To: References: Message-ID: <1213256618.15010.499.camel@localhost> On Wed, 2008-06-11 at 23:50 -0700, Anatoly Yakovenko wrote: > any idea what could be causing this error when i add the -fvia-C option > > /tmp/ghc32300_0/ghc32300_0.hc:6:23: > error: SFMT_wrap.h: No such file or directory > make: *** [release] Error 1 Some package you're using is a FFI binding that uses that C header file (SFMT_wrap.h). When you compile via C and crank up the optimisation it's quite possible for C calls to be inlined from the package in which they're defined into your code and hence you code ends up needing the headers too. You can get the above problem if a package uses a private header file and does not install it. Do you recognise SFMT_wrap.h? What package do you think it is that uses it? Duncan From duncan.coutts at worc.ox.ac.uk Thu Jun 12 03:52:49 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Jun 12 03:40:53 2008 Subject: [Haskell-cafe] -fvia-C error In-Reply-To: <20080612070733.GB26022@scytale.galois.com> References: <20080612070733.GB26022@scytale.galois.com> Message-ID: <1213257169.15010.506.camel@localhost> On Thu, 2008-06-12 at 00:07 -0700, Don Stewart wrote: > aeyakovenko: > > any idea what could be causing this error when i add the -fvia-C option > > > > /tmp/ghc32300_0/ghc32300_0.hc:6:23: > > error: SFMT_wrap.h: No such file or directory > > make: *** [release] Error 1 > > > > I am also passing these options: > > > > -O2 -fexcess-precision -funbox-strict-fields -fglasgow-exts > > -fbang-patterns -lcblas > > When compiling something linked against the mersenne random package? Don, this does not work: includes: SFMT.h SFMT_wrap.h install-includes: SFMT.h You cannot limit the scope of the SFMT_wrap.h to be just this package. You can limit .h scope to one file or global -- nothing in between. You can limit it to just that file by specifying the .h file in the foreign import declaration: > foreign import ccall "private.h foo" foo :: IO () Alternatively you can also install SFMT_wrap.h. Duncan From lemming at henning-thielemann.de Thu Jun 12 05:09:03 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Jun 12 05:01:15 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: random-access-list-0.1 In-Reply-To: <48507431.2080908@charter.net> References: <48505344.4010809@web.de> <48507431.2080908@charter.net> Message-ID: On Wed, 11 Jun 2008, Isaac Dupree wrote: > "extractHead" is an ugly name for a nevertheless standardish-meaning > function... what is it usually called? uncons? headTail? (Data.Sequence, > which is meant to be left-right symmetric, calls it "viewr"... except your > version doesn't have the Maybe, it's partial instead, fails on empty lists) I like the 'viewL' and 'viewR' kind of functions, they are safer than 'head' and 'tail', 'init' and 'last'. But since in most cases I used 'viewL' in connection with 'maybe', the continuation style functions switchL :: b -> (a -> Seq a -> b) -> Seq a -> b switchR :: b -> (Seq a -> a -> b) -> Seq a -> b are even more convenient. They replace 'case' on those structures where you do not have access to the constructors. From lemming at henning-thielemann.de Thu Jun 12 05:20:06 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Jun 12 05:12:45 2008 Subject: [Haskell-cafe] Simple list processing In-Reply-To: <1213217183.3033.1.camel@localhost.localdomain> References: <4850169F.4050003@btinternet.com> <20080611182517.GF25521@scytale.galois.com> <1213217183.3033.1.camel@localhost.localdomain> Message-ID: On Wed, 11 Jun 2008, Thomas M. DuBuisson wrote: > Why is there no mapAccumL' (strict)? Just a library deficiency that we > can remedy or am I missing something? The strictness in foldl' is needed to avoid that unevaluated computations accumulate until the end of the list. In mapAccumL and scanl this danger is smaller. If you process the elements of the output list in order then the intermediate states are also computed step by step. However, if you evaluate only the last element of the output list you have the same problem like with foldl. From silva.samuel at gmail.com Thu Jun 12 06:08:18 2008 From: silva.samuel at gmail.com (Samuel Silva) Date: Thu Jun 12 06:00:32 2008 Subject: [Haskell-cafe] Problems with Validate from HaXML Message-ID: <382ead9b0806120308l15d0f2ffg976c98f70d2c9fe7@mail.gmail.com> Hello I'm working with large DTDs from http://www.recordare.com/dtds/, particulary partwise.dtd and timewise.dtd. I check these DTDs with some tools, like Altova XML Spy and Microsoft Visual Studio, and DTDs are valid. However Validate tool from HaXML doesn't validate same DTDs. Result from Validate is: $ Validate partwise.dtd Validate: In a sequence: in content spec of ELEMENT decl: note When looking for a non-empty sequence with separators: Expected % but found | in file note.mod at line 51 col 45 used by file partwise.dtd at line 120 col 1 when looking for a content particle when looking for a content particle Problematic definition is in "note.mod" file, presented below: I'm trying using DtdToHaskell tool from HaXML to build parser from MusicXML to Haskell types. There are other ways to build XML parser using HaXML? I'm already using HaXML, with HaXML combinators, to write MusicXML. Thanks. -- Don't hug that, Hugs ME! Samuel Silva From ross at soi.city.ac.uk Thu Jun 12 06:59:35 2008 From: ross at soi.city.ac.uk (Ross Paterson) Date: Thu Jun 12 06:51:48 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: random-access-list-0.1 In-Reply-To: <48507431.2080908@charter.net> References: <48505344.4010809@web.de> <48507431.2080908@charter.net> Message-ID: <20080612105935.GA2933@soi.city.ac.uk> On Wed, Jun 11, 2008 at 08:56:17PM -0400, Isaac Dupree wrote: > Stephan Friedrichs wrote: >> I've implemented Chris Okasaki's random-access list[1] which provides >> typical list operations (cons, head, tail) in O(1) and yet offers >> indexed random-access in O(log n). It's uploaded on hackage[2]. >> >> It's still an early version which I'll extend, but especially at this >> eary stage I'd appreciate your feedback concerning what's still missing >> / to be fixed / to be improved. > > Great to see it, it deserved implementing, IIRC! I don't remember > enough about it.. (and don't have Okasaki anywhere handy). Can it be > lazy or infinitely long? (Data.Sequence can't, but it's fast on both > ends and has fast concatenation.) Anyway, document that. If it can't > be lazy/infinite, does it have any advantage over using > Data.Sequence?(constant factor of speed?, possible operations?, > something I'm forgetting?) The O(1) size function settles the finiteness question. In tests we did for the finger tree paper, we found that skew binary random access lists are 1.6-1.7 times faster than Data.Sequence for stack operations and indexing, but not much faster for updates. foldr is defined using foldr' on lists, introducing strictness without the user asking for it. In any case, it would be better to define the Foldable instance directly over the internal structure. Then you wouldn't need toList. A similar Traversable instance would also be a good idea. > Why is zip slow with unbalanced lists? Obviously, it could be > implemented O(min(m,n)*(log m + log n)) just indexing each one, which > would be faster for really unbalanced-size lists... It could be made O(min(m,n)) by toListing the longer one and traversing the shorter one adding corresponding elements from the list. I agree about using Maybe instead of Monad, and would generally prefer view functions to null/head/tail combinations. From peteg42 at gmail.com Thu Jun 12 08:29:14 2008 From: peteg42 at gmail.com (Peter Gammie) Date: Thu Jun 12 08:21:32 2008 Subject: [Haskell-cafe] Problems with Validate from HaXML In-Reply-To: <382ead9b0806120308l15d0f2ffg976c98f70d2c9fe7@mail.gmail.com> References: <382ead9b0806120308l15d0f2ffg976c98f70d2c9fe7@mail.gmail.com> Message-ID: <717927700806120529j65049b7ejfc93840671b58ea0@mail.gmail.com> Hello, I have the same problems. I believe I sent Malcolm some patches. If not, look here: http://peteg.org/haskell/HaXml/ I am away from my laptop right now so I cannot readily tell you whether a "darcs get" will do the job. In any case, there is a bug in the DTD parser that is easily fixed. (Try downloading the Parser.hs file if the darcs get fails.) Hope that helps. cheers peter On 6/12/08, Samuel Silva wrote: > Hello > > I'm working with large DTDs from http://www.recordare.com/dtds/, > particulary partwise.dtd and timewise.dtd. > I check these DTDs with some tools, like Altova XML Spy and Microsoft > Visual Studio, and DTDs are valid. > However Validate tool from HaXML doesn't validate same DTDs. > Result from Validate is: > $ Validate partwise.dtd > Validate: In a sequence: > in content spec of ELEMENT decl: note > When looking for a non-empty sequence with separators: > Expected % but found | > in file note.mod at line 51 col 45 > used by file partwise.dtd at line 120 col 1 > when looking for a content particle > when looking for a content particle > > Problematic definition is in "note.mod" file, presented below: > (((grace, %full-note;, (tie, tie?)?) | > (cue, %full-note;, duration) | > (%full-note;, duration, (tie, tie?)?)), > instrument?, %editorial-voice;, type?, dot*, > accidental?, time-modification?, stem?, notehead?, > staff?, beam*, notations*, lyric*)> > > I'm trying using DtdToHaskell tool from HaXML to build parser from > MusicXML to Haskell types. > There are other ways to build XML parser using HaXML? > I'm already using HaXML, with HaXML combinators, to write MusicXML. > > Thanks. > > -- > Don't hug that, Hugs ME! > Samuel Silva > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From bertram.felgenhauer at googlemail.com Thu Jun 12 08:56:23 2008 From: bertram.felgenhauer at googlemail.com (Bertram Felgenhauer) Date: Thu Jun 12 08:48:39 2008 Subject: [Haskell-cafe] -fvia-C error In-Reply-To: <1213257169.15010.506.camel@localhost> References: <20080612070733.GB26022@scytale.galois.com> <1213257169.15010.506.camel@localhost> Message-ID: <20080612125623.GA4186@zombie.inf.tu-dresden.de> Duncan Coutts wrote: > Don, this does not work: > > includes: SFMT.h SFMT_wrap.h > install-includes: SFMT.h Sorry, that was my fault. (It does work with ghc 6.9, but that's not much of an excuse) Bertram From isaacdupree at charter.net Thu Jun 12 09:47:50 2008 From: isaacdupree at charter.net (Isaac Dupree) Date: Thu Jun 12 09:40:00 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: random-access-list-0.1 In-Reply-To: References: <48505344.4010809@web.de> <48507431.2080908@charter.net> Message-ID: <48512906.8020103@charter.net> Henning Thielemann wrote: > > On Wed, 11 Jun 2008, Isaac Dupree wrote: > >> "extractHead" is an ugly name for a nevertheless standardish-meaning >> function... what is it usually called? uncons? headTail? >> (Data.Sequence, which is meant to be left-right symmetric, calls it >> "viewr"... except your version doesn't have the Maybe, it's partial >> instead, fails on empty lists) > > I like the 'viewL' and 'viewR' kind of functions, they are safer than > 'head' and 'tail', 'init' and 'last'. But since in most cases I used > 'viewL' in connection with 'maybe', the continuation style functions > > switchL :: b -> (a -> Seq a -> b) -> Seq a -> b > switchR :: b -> (Seq a -> a -> b) -> Seq a -> b I think you got L and R backwards? it's a little confusing to me, but following Data.Sequence I think they're meant to match whether repeated L or R makes a foldl or a foldr. > are even more convenient. They replace 'case' on those structures where > you do not have access to the constructors. on the other hand, they look harder to use with the upcoming (in GHC 6.9/6.10) "view patterns", a simple example being foo (viewr -> Nothing) = ... foo (viewr -> Just (a, as)) = ... equivalent to foo s = case viewr s of Nothing -> ... Just (a, as) -> ... (for view patterns, it's also proposed but not implemented to have special syntax for Maybe and/or tuples to make it even more convenient for these purposes... I'm not sure if it'd be a good idea either) I also mentioned the continuation style functions for Data.Map's maybe-returning in the discussion... they're most convenient if you want to destruct them right away, but harder to apply combinators to (e.g. Maybe monad. which doesn't work for Data.Sequence because they use their own custom view datatype -- was that a bad choice for them? "Maybe" of a tuple has an extra laziness-spot that shouldn't really be there, though) Anyway, people didn't seem to respond to that idea of continuation-style returning, not sure why. On the other hand, also, the only thing defending the function from using the arguments in a way it shouldn't, is parametricity... less obvious than with algrebraic data returns -Isaac From lemming at henning-thielemann.de Thu Jun 12 10:07:27 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Jun 12 09:59:39 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: random-access-list-0.1 In-Reply-To: <48512906.8020103@charter.net> References: <48505344.4010809@web.de> <48507431.2080908@charter.net> <48512906.8020103@charter.net> Message-ID: On Thu, 12 Jun 2008, Isaac Dupree wrote: > Henning Thielemann wrote: >> >> On Wed, 11 Jun 2008, Isaac Dupree wrote: >> >>> "extractHead" is an ugly name for a nevertheless standardish-meaning >>> function... what is it usually called? uncons? headTail? (Data.Sequence, >>> which is meant to be left-right symmetric, calls it "viewr"... except your >>> version doesn't have the Maybe, it's partial instead, fails on empty >>> lists) >> >> I like the 'viewL' and 'viewR' kind of functions, they are safer than >> 'head' and 'tail', 'init' and 'last'. But since in most cases I used >> 'viewL' in connection with 'maybe', the continuation style functions >> >> switchL :: b -> (a -> Seq a -> b) -> Seq a -> b >> switchR :: b -> (Seq a -> a -> b) -> Seq a -> b > > I think you got L and R backwards? Why do you think so? http://cvs.haskell.org/Hugs/pages/libraries/base/Data-Sequence.html#v%3Aviewl > it's a little confusing to me, but following Data.Sequence I think > they're meant to match whether repeated L or R makes a foldl or a foldr. viewl is like a 'case' for distinction of [] and (:) and thus can be used to implement both foldl and foldr. From isaacdupree at charter.net Thu Jun 12 10:10:56 2008 From: isaacdupree at charter.net (Isaac Dupree) Date: Thu Jun 12 10:03:05 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: random-access-list-0.1 In-Reply-To: References: <48505344.4010809@web.de> <48507431.2080908@charter.net> <48512906.8020103@charter.net> Message-ID: <48512E70.1030807@charter.net> Henning Thielemann wrote: > > On Thu, 12 Jun 2008, Isaac Dupree wrote: > >> Henning Thielemann wrote: >>> >>> On Wed, 11 Jun 2008, Isaac Dupree wrote: >>> >>>> "extractHead" is an ugly name for a nevertheless standardish-meaning >>>> function... what is it usually called? uncons? headTail? >>>> (Data.Sequence, which is meant to be left-right symmetric, calls it >>>> "viewr"... except your version doesn't have the Maybe, it's partial >>>> instead, fails on empty lists) >>> >>> I like the 'viewL' and 'viewR' kind of functions, they are safer than >>> 'head' and 'tail', 'init' and 'last'. But since in most cases I used >>> 'viewL' in connection with 'maybe', the continuation style functions >>> >>> switchL :: b -> (a -> Seq a -> b) -> Seq a -> b >>> switchR :: b -> (Seq a -> a -> b) -> Seq a -> b >> >> I think you got L and R backwards? > > Why do you think so? > > http://cvs.haskell.org/Hugs/pages/libraries/base/Data-Sequence.html#v%3Aviewl Because I was confused. Looking again, you seem to be right... >> it's a little confusing to me, but following Data.Sequence I think >> they're meant to match whether repeated L or R makes a foldl or a foldr. > > viewl is like a 'case' for distinction of [] and (:) and thus can be > used to implement both foldl and foldr. yes, but in the sense that foldr is more "natural" for lists than foldl, requiring just replacing the constructors "directly" From deduktionstheorem at web.de Thu Jun 12 14:47:12 2008 From: deduktionstheorem at web.de (Stephan Friedrichs) Date: Thu Jun 12 14:39:27 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: random-access-list-0.1 In-Reply-To: <48507431.2080908@charter.net> References: <48505344.4010809@web.de> <48507431.2080908@charter.net> Message-ID: <48516F30.4050604@web.de> Isaac Dupree wrote: > [...] > > Great to see it, it deserved implementing, IIRC! I don't remember enough about it.. (and don't have Okasaki anywhere handy). Can it be lazy or infinitely long? No, it has to be finite as it's actually a list of complete binary trees whose size depend on the skew binary representation of the list's size. I'll document this. > [...] > > Is "RandomAccessList" the best name for something that's not O(1), just O(log n)? Or just that "RandomAccessList" is just much longer than "[]"? Well Chris Okasaki called them "Skew Binary Random-Access Lists", which is even longer :) > > don't use those unorthodox infix function names.. `cons` is hardly worse than .:. , `append` or `mappend` than .+. , and .!. than, hmm.. . Export a ++ and ! (!! ?) if you're really dedicated. But I'd prefer an `at` that's the same partial indexing operation, rather than the name .!. (I think this "at" was a new name being put somewhere else? partly because "!" is trying to be gradually used only to refer to strictness?) Good point! > > "extractHead" is an ugly name for a nevertheless standardish-meaning function... what is it usually called? uncons? headTail? (Data.Sequence, which is meant to be left-right symmetric, calls it "viewr"... except your version doesn't have the Maybe, it's partial instead, fails on empty lists) Yes, I wasn't happy with that one either. The view-concept of Data.Sequence is a good idea. > > For "index", don't use Monad, use Maybe (I think that's what the recent libraries@haskell.org discussion concluded, in the context of switching Data.Map back to Maybe). I was just copying the idea from Data.Map and it's usually a good thing to have functions as general as possible, or why is it not? > Also, Data.List has genericLength etc, to At the moment, I'm using the Int type for size and indexing only for one reason: I haven't found a proper way to generalize it. I'd really like to use the Ix class, but it doesn't provide enough functionality, it only works on fixed-size intervals (i. e. for arrays, which don't change their size, but a list does). Maybe someone has an idea of how to realize lists with a variable starting index and size? > support. Isn't "index" (like Data.List.genericIndex) supposed to be a name for a partial operation, not one that returns a Maybe? Shouldn't "size" be named "length" (or exported as both names, since e.g. Data.Map.size, .List.length) (why is it O(1) not O(log n)? Is it possible for these RandomAccessLists to be longer than maxBound::Int?)? The size function is in O(1) because I cache it, otherwise it would be size (RandomAccessList xs) = sum (map fst xs) which is O(log n). I consider the caching useful, as most applications will check 0 <= i < size quite often. > > for e.g. toList, is the O(n) cost spread over traversing/demanding the items of the generated list, or all up-front, or somewhere in between? > > Why is zip slow with unbalanced lists? Obviously, it could be implemented O(min(m,n)*(log m + log n)) just indexing each one, which would be faster for really unbalanced-size lists... Obviously, I don't If two lists have exactly the same size, all the complete binary trees holding the data have the same size as well. This can be zipped directly and is a bit (~5% in my tests) faster. > understand the implementation. BTW, looking at the file, > data RandomAccessList a > = RandomAccessList {-# UNPACK #-} !Int ![(Int, CBTree a)] > Marking a list strict like that doesn't have much effect because it only makes the first (:) or [] strict. Did you mean for an element-strict or spine-strict(which would necessarily be non-infinite) list? Oh, you're right, I just meant to mark the Int strict. It obviously was too late yesterday! Thanks for this feedback! //Stephan -- Fr?her hie? es ja: Ich denke, also bin ich. Heute wei? man: Es geht auch so. - Dieter Nuhr From chaddai.fouche at gmail.com Thu Jun 12 15:43:32 2008 From: chaddai.fouche at gmail.com (=?ISO-8859-1?Q?Chadda=EF_Fouch=E9?=) Date: Thu Jun 12 15:35:50 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: random-access-list-0.1 In-Reply-To: <48516F30.4050604@web.de> References: <48505344.4010809@web.de> <48507431.2080908@charter.net> <48516F30.4050604@web.de> Message-ID: 2008/6/12 Stephan Friedrichs : >> For "index", don't use Monad, use Maybe (I think that's what the recent >> libraries@haskell.org discussion concluded, in the context of switching >> Data.Map back to Maybe). > > I was just copying the idea from Data.Map and it's usually a good thing to > have functions as general as possible, or why is it not? > Mainly because it's too easy to use them in a Monad that does not have a meaningful fail(), like IO, many beginners do this error and are surprised when their program is less robust that it should be. On the other hand it's pretty easy to get an error out of a Maybe (for example you can use fromMaybe with error() to get a meaningful error output). >> Also, Data.List has genericLength etc, to > > At the moment, I'm using the Int type for size and indexing only for one > reason: I haven't found a proper way to generalize it. I'd really like to > use the Ix class, but it doesn't provide enough functionality, it only works > on fixed-size intervals (i. e. for arrays, which don't change their size, > but a list does). Maybe someone has an idea of how to realize lists with a > variable starting index and size? Given that this structure isn't lazy enough, I really don't see a problem with using Int (any random access list with a size that needs an Integer would blow the memory anyway...). -- Jeda? From aditya_siram at hotmail.com Thu Jun 12 17:07:12 2008 From: aditya_siram at hotmail.com (Aditya Siram) Date: Thu Jun 12 16:59:23 2008 Subject: [Haskell-cafe] Cabal-Install Fails To Compile Message-ID: Hi all, I downloaded cabal-install and the cabal-1.4 branch from darcs. The following error occurs when building: > runhaskell Setup.hs build Building cabal-install-0.4.9... [19 of 27] Compiling Hackage.SrcDist ( Hackage/SrcDist.hs, dist/build/cabal/cabal-tmp/Hackage/SrcDist.o ) Hackage/SrcDist.hs:58:59: Couldn't match expected type `Char' against inferred type `Distribution.Simple.PreProcess.PPSuffixHandler' Expected type: FilePath Inferred type: [Distribution.Simple.PreProcess.PPSuffixHandler] In the fifth argument of `prepareSnapshotTree', namely `knownSuffixHandlers' In the second argument of `(>>=)', namely `prepareSnapshotTree verbosity pkg mb_lbi tmpDir knownSuffixHandlers' According to ghc-pkg compiling and installing the cabal-1.4 branch added cabal-1.3.12. Is this the problem? -Deech _________________________________________________________________ It?s easy to add contacts from Facebook and other social sites through Windows Live? Messenger. Learn how. https://www.invite2messenger.net/im/?source=TXT_EML_WLH_LearnHow From dons at galois.com Thu Jun 12 17:12:48 2008 From: dons at galois.com (Don Stewart) Date: Thu Jun 12 17:05:01 2008 Subject: [Haskell-cafe] Cabal-Install Fails To Compile In-Reply-To: References: Message-ID: <20080612211248.GA28501@scytale.galois.com> Could you try the cabal-1.4 package just put up on hackage.haskell.org? aditya_siram: > > Hi all, > I downloaded cabal-install and the cabal-1.4 branch from darcs. The following error occurs when building: > > runhaskell Setup.hs build > > Building cabal-install-0.4.9... > [19 of 27] Compiling Hackage.SrcDist ( Hackage/SrcDist.hs, dist/build/cabal/cabal-tmp/Hackage/SrcDist.o ) > > Hackage/SrcDist.hs:58:59: > Couldn't match expected type `Char' > against inferred type `Distribution.Simple.PreProcess.PPSuffixHandler' > Expected type: FilePath > Inferred type: [Distribution.Simple.PreProcess.PPSuffixHandler] > In the fifth argument of `prepareSnapshotTree', namely > `knownSuffixHandlers' > In the second argument of `(>>=)', namely > `prepareSnapshotTree > verbosity pkg mb_lbi tmpDir knownSuffixHandlers' > > > According to ghc-pkg compiling and installing the cabal-1.4 branch added cabal-1.3.12. Is this the problem? > > -Deech > _________________________________________________________________ > It?s easy to add contacts from Facebook and other social sites through Windows Live? Messenger. Learn how. > https://www.invite2messenger.net/im/?source=TXT_EML_WLH_LearnHow_______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From cdsmith at gmail.com Thu Jun 12 15:50:05 2008 From: cdsmith at gmail.com (Chris Smith) Date: Thu Jun 12 17:37:11 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: random-access-list-0.1 References: <48505344.4010809@web.de> <48507431.2080908@charter.net> <48516F30.4050604@web.de> Message-ID: Chadda? Fouch? wrote: > Given that this structure isn't lazy enough, I really don't see a > problem with using Int (any random access list with a size that needs an > Integer would blow the memory anyway...). Bad way to think about things. The implications of using Int as the result type of a function extend far beyond just storing the result type. They also include doing other computations that depend on the result type, and with enough type inference, the broken Int type propogates throughout the program. -- Chris From deduktionstheorem at web.de Thu Jun 12 18:25:57 2008 From: deduktionstheorem at web.de (Stephan Friedrichs) Date: Thu Jun 12 18:18:08 2008 Subject: [Haskell-cafe] ANN: random-access-list-0.1 In-Reply-To: References: <48505344.4010809@web.de> <48507431.2080908@charter.net> <48516F30.4050604@web.de> Message-ID: <4851A275.6050804@web.de> Chris Smith wrote: > Chadda? Fouch? wrote: >> Given that this structure isn't lazy enough, I really don't see a >> problem with using Int (any random access list with a size that needs an >> Integer would blow the memory anyway...). > > Bad way to think about things. The implications of using Int as the > result type of a function extend far beyond just storing the result > type. They also include doing other computations that depend on the > result type, and with enough type inference, the broken Int type > propogates throughout the program. > I'd like not to be restricted to Int, but what's the proper way to do so? Just adding "genericFun = fromInteger . toInteger . fun" functions is just as bad as using Ints directly. What I need is something like a more general Ix class that is not limited to a fixed interval: class Ix2 i where -- convert starting index and given index to an Int for internal -- representation toIndex :: i -> i -> Int -- given an internal Int index and a starting index, return the -- representing index fromIndex :: Int -> i -> i -- translate a starting index and a number of elements into a -- size size :: i -> Int -> i This is meant to work with a starting-index and a given index, so that a list does not have to start at index 0. Is there something like this? Or is it somehow possible to use the existing Ix class to do that? //Stephan -- Fr?her hie? es ja: Ich denke, also bin ich. Heute wei? man: Es geht auch so. - Dieter Nuhr From duncan.coutts at worc.ox.ac.uk Thu Jun 12 22:58:59 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Jun 12 22:46:57 2008 Subject: [Haskell-cafe] Cabal-Install Fails To Compile In-Reply-To: References: Message-ID: <1213325939.15010.508.camel@localhost> On Thu, 2008-06-12 at 16:07 -0500, Aditya Siram wrote: > Hi all, > I downloaded cabal-install and the cabal-1.4 branch from darcs. The following error occurs when building: > > runhaskell Setup.hs build > > Building cabal-install-0.4.9... > [19 of 27] Compiling Hackage.SrcDist ( Hackage/SrcDist.hs, dist/build/cabal/cabal-tmp/Hackage/SrcDist.o ) > > Hackage/SrcDist.hs:58:59: > Couldn't match expected type `Char' > against inferred type `Distribution.Simple.PreProcess.PPSuffixHandler' > Expected type: FilePath > Inferred type: [Distribution.Simple.PreProcess.PPSuffixHandler] > In the fifth argument of `prepareSnapshotTree', namely > `knownSuffixHandlers' > In the second argument of `(>>=)', namely > `prepareSnapshotTree > verbosity pkg mb_lbi tmpDir knownSuffixHandlers' Yeah, sorry that was my fault. You caught it in the few hours when the two darcs versions were not compatible. They work now, or as Don says, get the actual releases from hackage. Duncan From thomas.dubuisson at gmail.com Fri Jun 13 00:47:44 2008 From: thomas.dubuisson at gmail.com (Thomas M. DuBuisson) Date: Fri Jun 13 00:41:24 2008 Subject: [Haskell-cafe] [WARN] Bug fix release of pureMD5 (Was: pureMD5) In-Reply-To: <2bfa72fa0806121914w6a8a4ff6k34b7ea39f9ef9ce2@mail.gmail.com> References: <2bfa72fa0806121914w6a8a4ff6k34b7ea39f9ef9ce2@mail.gmail.com> Message-ID: <1213332464.3124.14.camel@localhost.localdomain> Cafe, Daniel Larsson noticed a correctness issue with the pureMD5 package. This issue would affect you if you built the value incrementally via the 'updateMD5' function (vs just using 'md5') and didn't provide 512 bit long bytestrings (an MD5 block of operation). As you can probably tell, I didn't invest enough into the non-performance aspects of pureMD5. Faced with actual users ;-), I have released version 0.2.0 which has the bug fix, a new API (type prevention from re-finalizing a digest), and a reasonable set of quickchecks (covering Show / Binary instances, known answer and incremented hashing). Oh, also the module name has changed to place it inline with 'Crypto' package naming while not colliding. Sorry if this causes anyone headaches. Daniel, Good catch, I hope this didn't consume much of your time. Thanks a bunch! TomMD On Fri, 2008-06-13 at 04:14 +0200, Daniel Larsson wrote: > Hi Thomas, > > > I was fiddling around with your pureMD5 package, and encountered some > problems with using the md5Update/md5Finalize sequence. I tried to > calculate the md5 of some scattered data, but it kept returning the > wrong values. It seems that each md5Update must supply an exact > blockSize number of bits, since the mdLeftOver part isn't taken into > account in subsequent calls to md5Update. > > > I wrote a small patch, and a simple QuickCheck property, to support > calculating md5 of scattered data, attached to this mail. Hopefully I > didn't mess up something... > > > -- > Daniel -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080613/0daad4e2/attachment.bin From dcespin at fastmail.fm Fri Jun 13 05:15:25 2008 From: dcespin at fastmail.fm (Dominic Espinosa) Date: Fri Jun 13 05:10:18 2008 Subject: [Haskell-cafe] Difficulty installing hscurses Message-ID: <20080613091525.GC3105@argivia.columbus.rr.com> Hello, I'm trying to install hscurses on debian-testing. I have ghc6 installed, which I've written some toy programs with, but I haven't tried to install any Hackage packages until now. hscurses depends on old-time and old-locale (those names make me raise my eyebrows a bit). In turn, old-time seems to depend on old-locale. So, I tried installing old-locale first. In installed fine. Now I'm trying to install old-time: $ runhaskell Setup.hs configure Warning: defaultUserHooks in Setup script is deprecated. Configuring old-time-1.0.0.0... Warning: The 'build-type' is 'Configure' but there is no 'configure' script. (given these warnings, I don't really expect the next command to succeed, but what the hell:) $ runhaskell Setup.hs build Preprocessing library old-time-1.0.0.0... Building old-time-1.0.0.0... System/Time.hsc:118:7: Could not find module `System.Locale': it was found in multiple packages: old-locale-1.0.0.0 base No idea what to do here. Is old-time conflicting with whatever "time" package superseded it, or what? I'm new to Haskell, and understanding the guts of its packaging system is a bit beyond me right now. Sorry if this is a FAQ or something, but I tried some Google searches and found nothing useful. Any help or tips appreciated. From isaacdupree at charter.net Fri Jun 13 07:15:18 2008 From: isaacdupree at charter.net (Isaac Dupree) Date: Fri Jun 13 07:07:25 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: random-access-list-0.1 In-Reply-To: <48516EEA.6020203@web.de> References: <48505344.4010809@web.de> <48507431.2080908@charter.net> <48516EEA.6020203@web.de> Message-ID: <485256C6.2010204@charter.net> Stephan Friedrichs wrote: > Isaac Dupree wrote: >> [...] >> >> Great to see it, it deserved implementing, IIRC! I don't remember >> enough about it.. (and don't have Okasaki anywhere handy). Can it be >> lazy or infinitely long? > > No, it has to be finite as it's actually a list of complete binary trees > whose size depend on the skew binary representation of the list's size. > I'll document this. okay then >> [...] >> >> Is "RandomAccessList" the best name for something that's not O(1), >> just O(log n)? Or just that "RandomAccessList" is just much longer >> than "[]"? > > Well Chris Okasaki called them "Skew Binary Random-Access Lists", which > is even longer :) :) hmm.. IndexableList? (just a thought, not sure whether I like it any better) >> >> don't use those unorthodox infix function names.. `cons` is hardly >> worse than .:. , `append` or `mappend` than .+. , and .!. than, hmm.. >> . Export a ++ and ! (!! ?) if you're really dedicated. But I'd prefer >> an `at` that's the same partial indexing operation, rather than the >> name .!. (I think this "at" was a new name being put somewhere else? >> partly because "!" is trying to be gradually used only to refer to >> strictness?) > > Good point! > >> >> "extractHead" is an ugly name for a nevertheless standardish-meaning >> function... what is it usually called? uncons? headTail? >> (Data.Sequence, which is meant to be left-right symmetric, calls it >> "viewr"... except your version doesn't have the Maybe, it's partial >> instead, fails on empty lists) > > Yes, I wasn't happy with that one either. The view-concept of > Data.Sequence is a good idea. yeah, it's a good idea, although I'm not sure how much I like the particular syntax of how it's done in Data.Sequence (the view-types' constructor names, mostly) >> >> For "index", don't use Monad, use Maybe (I think that's what the >> recent libraries@haskell.org discussion concluded, in the context of >> switching Data.Map back to Maybe). > > I was just copying the idea from Data.Map and it's usually a good thing > to have functions as general as possible, or why is it not? To summarize: Monad isn't the proper abstraction for failable/Maybe. Maybe is an algebraic data type that *exactly* represents the spirit of what you're trying to do: e.g. Conor McBride said: "Maybe is the most general abstraction. Requiring (>>=), or even (<*>) seems excessive. What we need is "any f with zero and return", so why not pick the canonical, initial, inductively defined such thing?" In this case the typeclass adds no generality to the function's behaviour (Maybe can be trivially converted to any other type, with a combinator even). And the confusion that results, when the function is almost always used at type Maybe anyway. If you want to read the whole discussion... if you haven't been subscribed to libraries@haskell.org , it's archived: http://thread.gmane.org/gmane.comp.lang.haskell.libraries/9082 >> Also, Data.List has genericLength etc, to > > At the moment, I'm using the Int type for size and indexing only for one > reason: I haven't found a proper way to generalize it. I'd really like > to use the Ix class, but it doesn't provide enough functionality, it > only works on fixed-size intervals (i. e. for arrays, which don't change > their size, but a list does). Maybe someone has an idea of how to > realize lists with a variable starting index and size? fair enough. If your implementation only supports sizes up to that of Int (which is reasonable for a strict finite type... whereas something like ([1..2^34] `genericIndex` (2^33)) can probably complete in a small amount of memory and only a moderate amount of time on a modern machine, even a 32-bit one, due to laziness and garbage collection) >> support. Isn't "index" (like Data.List.genericIndex) supposed to be a >> name for a partial operation, not one that returns a Maybe? Shouldn't >> "size" be named "length" (or exported as both names, since e.g. >> Data.Map.size, .List.length) (why is it O(1) not O(log n)? Is it >> possible for these RandomAccessLists to be longer than maxBound::Int?)? > > The size function is in O(1) because I cache it, otherwise it would be > > size (RandomAccessList xs) = sum (map fst xs) > > which is O(log n). I consider the caching useful, as most applications > will check 0 <= i < size quite often. sounds good > >> >> for e.g. toList, is the O(n) cost spread over traversing/demanding the >> items of the generated list, or all up-front, or somewhere in between? >> >> Why is zip slow with unbalanced lists? Obviously, it could be >> implemented O(min(m,n)*(log m + log n)) just indexing each one, which >> would be faster for really unbalanced-size lists... Obviously, I don't > > If two lists have exactly the same size, all the complete binary trees > holding the data have the same size as well. This can be zipped directly > and is a bit (~5% in my tests) faster. okay, that sounds like a fair optimization, since zipping same-size lists is a nice thing to do anyway. But the asymptotic speed ideally should still be O(min(m,n)), if possible? >> understand the implementation. BTW, looking at the file, >> data RandomAccessList a >> = RandomAccessList {-# UNPACK #-} !Int ![(Int, CBTree a)] >> Marking a list strict like that doesn't have much effect because it >> only makes the first (:) or [] strict. Did you mean for an >> element-strict or spine-strict(which would necessarily be >> non-infinite) list? > > Oh, you're right, I just meant to mark the Int strict. It obviously was > too late yesterday! > > Thanks for this feedback! > //Stephan > From claus.reinke at talk21.com Fri Jun 13 08:28:55 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Fri Jun 13 08:21:12 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: random-access-list-0.1 References: <48505344.4010809@web.de> <48507431.2080908@charter.net><48516EEA.6020203@web.de> <485256C6.2010204@charter.net> Message-ID: <005201c8cd51$0d775ab0$213c7ad5@cr3lt> > To summarize: Monad isn't the proper abstraction for failable/Maybe. > Maybe is an algebraic data type that *exactly* represents the spirit of > what you're trying to do: e.g. Conor McBride said: "Maybe is the most > general abstraction. Requiring (>>=), or even (<*>) seems excessive. > What we need is "any f with zero and return", so why not pick the > canonical, initial, inductively defined such thing?" In this case the > typeclass adds no generality to the function's behaviour (Maybe can be > trivially converted to any other type, with a combinator even). And the > confusion that results, when the function is almost always used at type > Maybe anyway. If you want to read the whole discussion... if you > haven't been subscribed to libraries@haskell.org , it's archived: > http://thread.gmane.org/gmane.comp.lang.haskell.libraries/9082 Thanks for the summary. I had been wondering about this change of mood, and I disagree with the suggestion that Maybe Nothing is the right replacement for Monad fail. Whether fail should be in Monad, or whether we really want MonadZero, MonadPlus, MonadError, or something else entirely has been open for discussion, but it is easily shown that Maybe is not the most general abstraction - it loses information wrt to (Either String), for instance: Prelude> let {f [] = fail "empty"; f [_] = fail "singleton"; f l = return l } Prelude> f [] :: Maybe [Bool] Nothing Prelude> f [True] :: Maybe [Bool] Nothing Prelude> f [True,False] :: Maybe [Bool] Just [True,False] Prelude> Prelude> :m +Control.Monad.Error Prelude Control.Monad.Error> f [] :: Either String [Bool] Left "empty" Prelude Control.Monad.Error> f [True] :: Either String [Bool] Left "singleton" Prelude Control.Monad.Error> f [True,False] :: Either String [Bool] Right [True,False] You can specialise Monad to Maybe, but you can't get back to the general handling of failure without losing the failure messages! Choosing Maybe over (Either String) means: "I don't care about the failure messages" (not that String is necessarily the best way to represent failure conditions, but that is another story again). As anyone who has ever tried to use a Parser based on that choice can attest, that choice should not be taken lightly ("Compilation failed. There were errors."). Claus From isaacdupree at charter.net Fri Jun 13 08:59:34 2008 From: isaacdupree at charter.net (Isaac Dupree) Date: Fri Jun 13 08:51:41 2008 Subject: Maybe-summary was: Re: [Haskell-cafe] Re: [Haskell] ANN: random-access-list-0.1 In-Reply-To: <005201c8cd51$0d775ab0$213c7ad5@cr3lt> References: <48505344.4010809@web.de> <48507431.2080908@charter.net><48516EEA.6020203@web.de> <485256C6.2010204@charter.net> <005201c8cd51$0d775ab0$213c7ad5@cr3lt> Message-ID: <48526F36.3020202@charter.net> Claus Reinke wrote: >> To summarize: Monad isn't the proper abstraction for failable/Maybe. >> Maybe is an algebraic data type that *exactly* represents the spirit >> of what you're trying to do: e.g. Conor McBride said: "Maybe is the >> most general abstraction. Requiring (>>=), or even (<*>) seems >> excessive. What we need is "any f with zero and return", so why not >> pick the canonical, initial, inductively defined such thing?" In this >> case the typeclass adds no generality to the function's behaviour >> (Maybe can be trivially converted to any other type, with a combinator >> even). And the confusion that results, when the function is almost >> always used at type Maybe anyway. If you want to read the whole >> discussion... if you haven't been subscribed to libraries@haskell.org >> , it's archived: >> http://thread.gmane.org/gmane.comp.lang.haskell.libraries/9082 > > Thanks for the summary. I had been wondering about this > change of mood, and I disagree with the suggestion that > Maybe Nothing is the right replacement for Monad fail. > Whether fail should be in Monad, or whether we really want MonadZero, > MonadPlus, MonadError, or something else entirely has been open for > discussion, but it is easily shown > that Maybe is not the most general abstraction - it loses information > wrt to (Either String), for instance: > > Prelude> let {f [] = fail "empty"; f [_] = fail "singleton"; f l = > return l } okay, I see, it's just that most partial functions in Data.* / container libraries don't really have multiple failure modes that need distinguishing. You could say, in a type/information-theoretic mindset, that even your "f [_]" above loses information because it doesn't vary based on the _ (and so it isn't reversible) (and this is very common and normal especially for error messages, but there's a large design space for places where they're needed, depending on whether a machine needs to understand the message, etc.) I think we didn't conclude much about e.g. parser-library return types, because we (thankfully) weren't trying to. -Isaac From duncan.coutts at worc.ox.ac.uk Fri Jun 13 09:17:47 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Fri Jun 13 09:06:50 2008 Subject: [Haskell-cafe] Difficulty installing hscurses In-Reply-To: <20080613091525.GC3105@argivia.columbus.rr.com> References: <20080613091525.GC3105@argivia.columbus.rr.com> Message-ID: <1213363067.15010.513.camel@localhost> On Fri, 2008-06-13 at 05:15 -0400, Dominic Espinosa wrote: > Hello, > > I'm trying to install hscurses on debian-testing. I have ghc6 installed, > which I've written some toy programs with, but I haven't tried to > install any Hackage packages until now. > > hscurses depends on old-time and old-locale (those names make me raise > my eyebrows a bit). In turn, old-time seems to depend on old-locale. So, > I tried installing old-locale first. In installed fine. Now I'm trying > to install old-time: I think you must be using ghc-6.6.x in which case you do not need old-time and indeed you cannot install it. The modules in old-time were included in the base package in ghc-6.6.x and split out into the old-time package in ghc-6.8.x. So the problem is that hscurses is not buildable out-of-the-box with ghc-6.6.x. You can probably hack it by editing the hscurses.cabal file and removing old-locale and old-time from the build-depends field. On the hackage page for hscurses http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hscurses it says: Built on ghc-6.8 what this doesn't say clearly is that this means it did not build on ghc-6.6. Duncan From jules at jellybean.co.uk Fri Jun 13 09:33:00 2008 From: jules at jellybean.co.uk (Jules Bean) Date: Fri Jun 13 09:25:10 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: random-access-list-0.1 In-Reply-To: <005201c8cd51$0d775ab0$213c7ad5@cr3lt> References: <48505344.4010809@web.de> <48507431.2080908@charter.net><48516EEA.6020203@web.de> <485256C6.2010204@charter.net> <005201c8cd51$0d775ab0$213c7ad5@cr3lt> Message-ID: <4852770C.2020907@jellybean.co.uk> > Whether fail should be in Monad, or whether we really want MonadZero, > MonadPlus, MonadError, or something else entirely has been open for > discussion, but it is easily shown > that Maybe is not the most general abstraction - it loses information > wrt to (Either String), for instance: > > Prelude> let {f [] = fail "empty"; f [_] = fail "singleton"; f l = Yes. But that's not what we're talking about. We're talking about lookup and index which both have one and exactly one failure mode : not found. For these functions, Maybe a is both the most general and the most precise type. It is trivial to upgrade Maybe a by decorating it with an error should you choose to do so: maybe (throwError "better error message here") return which I sometimes define as 'withError' or similar. d <- M.lookup "foo" `withError` "Variable foo not in symbol table" Jules From cetin.sert at gmail.com Fri Jun 13 09:41:29 2008 From: cetin.sert at gmail.com (Cetin Sert) Date: Fri Jun 13 09:33:38 2008 Subject: [Haskell-cafe] cgi liftM liftIO Message-ID: <1ff5dedc0806130641u461a22c7n7d5b23e4956a39d2@mail.gmail.com> Hi, Could someone please care to explain what I am doing wrong below in cgiMain2 and how can I fix it? ./Main.hs:25:15: No instance for (MonadCGI IO) arising from a use of `output' at ./Main.hs:25:15-20 Possible fix: add an instance declaration for (MonadCGI IO) In the first argument of `($)', namely `output' In the expression: output $ renderHtml $ page "import" fileForm In the definition of `upload': upload = output $ renderHtml $ page "import" fileForm ./Main.hs:57:29: Couldn't match expected type `CGI CGIResult' against inferred type `IO CGIResult' In the first argument of `handleErrors', namely `cgiMain2' In the second argument of `($)', namely `handleErrors cgiMain2' In the expression: runCGI $ handleErrors cgiMain2 import IO import Network.CGI import Text.XHtml import qualified Data.ByteString.Lazy as BS import Control.Monad (liftM) import Data.Maybe (fromJust) import Interact fileForm = form ! [method "post", enctype "multipart/form-data"] << [afile "file", submit "" "Upload"] page t b = header << thetitle << t +++ body << b cgiMain1 = do getInputFPS "file" ? ?ms ? maybe upload contents ms ? return where upload = output $ renderHtml $ page "import" fileForm contents = outputFPS cgiMain2 = do getInputFPS "file" ? ?ms ? maybe upload contents ms ? return where upload = output $ renderHtml $ page "import" fileForm contents = ?s ? do (i,o,h,_) ? runUnzip BS.hPutStr i s c ? BS.hGetContents o outputFPS c {- (i,o,h,_) ? runUnzip BS.hPutStr i s BS.hGetContents o ? outputFPS -} {- liftM :: (Monad m) => (a1 -> r) -> m a1 -> m r liftIO :: (MonadIO m) => IO a -> m a saveFile n = do cont <- liftM fromJust $ getInputFPS "file" let f = uploadDir ++ "/" ++ basename n liftIO $ BS.writeFile f cont return $ paragraph << ("Saved as " +++ anchor ! [href f] << f +++ ".") -} runUnzip = runInteractiveCommand "unzip -l /dev/stdin" main = runCGI $ handleErrors cgiMain2 Best Regards, Cetin Sert P/s: what are lifts o_O? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080613/3ab681c2/attachment.htm From jeff.polakow at db.com Fri Jun 13 10:15:35 2008 From: jeff.polakow at db.com (Jeff Polakow) Date: Fri Jun 13 10:07:49 2008 Subject: [Haskell-cafe] Announce: Fortress talk in New York City Message-ID: Hello, There will be a talk on Fortress ( a new OO/Functional language from Sun) on Wednesday June 25 at 6:30pm in Manhattan. Abstract: The Java Programming Language revolutionized programming with two simple concepts: "Write once run anywhere", and Garbage Collection. This led to a big step up in programmer productivity. Project Fortress does it again. This time we give you multiprocessor performance without having to code threads, locks, or load balancing. Can you say "Implicit Parallelism" and "Transactional Memory"? We also give you a growable language (small fixed core), strong static typing (more errors caught at compile time), and mathematical notation. This talk will focus on the strengths of Fortress as a programming language, as well as a deep dive into implementation issues. More information is available at http://lisp.meetup.com/59 -Jeff --- This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080613/4afa7796/attachment.htm From darrinth at gmail.com Fri Jun 13 10:19:52 2008 From: darrinth at gmail.com (Darrin Thompson) Date: Fri Jun 13 10:11:59 2008 Subject: [Haskell-cafe] Announce: Fortress talk in New York City In-Reply-To: References: Message-ID: 2008/6/13 Jeff Polakow : > There will be a talk on Fortress ( a new OO/Functional language from Sun) on > Wednesday June 25 at 6:30pm in Manhattan. > Sounds interesting. Any plans to post video? -- Darrin From lemming at henning-thielemann.de Fri Jun 13 10:28:10 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri Jun 13 10:20:28 2008 Subject: [Haskell-cafe] Announce: Fortress talk in New York City In-Reply-To: References: Message-ID: On Fri, 13 Jun 2008, Jeff Polakow wrote: > Hello, > > There will be a talk on Fortress ( a new OO/Functional language from Sun) > on Wednesday June 25 at 6:30pm in Manhattan. > > Abstract: > > The Java Programming Language revolutionized programming with two simple > concepts: "Write once run anywhere", and Garbage Collection. This led > to a big step up in programmer productivity. Project Fortress does it > again. This time we give you multiprocessor performance without > having to code threads, locks, or load balancing. Can you say "Implicit > Parallelism" and "Transactional Memory"? We also give you a growable > language (small fixed core), strong static typing (more errors caught at > compile time), and mathematical notation. This talk will focus on the > strengths of Fortress as a programming language, as well as a deep dive > into implementation issues. > > More information is available at http://lisp.meetup.com/59 > > -Jeff > > > --- > > This e-mail may contain confidential and/or privileged information. You send potentially confidential information to a public mailing list? Is this new language secret? :-) From si at fh-wedel.de Fri Jun 13 10:31:19 2008 From: si at fh-wedel.de (Uwe Schmidt) Date: Fri Jun 13 10:23:29 2008 Subject: [Haskell-cafe] [WARN] Bug fix release of pureMD5 (Was: pureMD5) In-Reply-To: <1213332464.3124.14.camel@localhost.localdomain> References: <2bfa72fa0806121914w6a8a4ff6k34b7ea39f9ef9ce2@mail.gmail.com> <1213332464.3124.14.camel@localhost.localdomain> Message-ID: <200806131631.19734.si@fh-wedel.de> Thomas M. DuBuisson wrote: > As you can probably tell, I didn't invest enough into the > non-performance aspects of pureMD5. Faced with actual users ;-), I have > released version 0.2.0 which has the bug fix, a new API (type prevention > from re-finalizing a digest), and a reasonable set of quickchecks > (covering Show / Binary instances, known answer and incremented > hashing). Oh, also the module name has changed to place it inline with > 'Crypto' package naming while not colliding. there is a small bug in pureMD5.cabal the line hs-source-dirs: Data,Test should be hs-source-dirs: . otherwise the sources are not found (at least on my linux box) Cheers, Uwe From claus.reinke at talk21.com Fri Jun 13 10:43:19 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Fri Jun 13 10:35:36 2008 Subject: Maybe-summary was: Re: [Haskell-cafe] Re: [Haskell] ANN:random-access-list-0.1 References: <48505344.4010809@web.de><48507431.2080908@charter.net><48516EEA.6020203@web.de><485256C6.2010204@charter.net><005201c8cd51$0d775ab0$213c7ad5@cr3lt> <48526F36.3020202@charter.net> Message-ID: <006e01c8cd63$d48d8540$213c7ad5@cr3lt> >>> http://thread.gmane.org/gmane.comp.lang.haskell.libraries/9082 .. >> that Maybe is not the most general abstraction - it loses information >> wrt to (Either String), for instance: >> >> Prelude> let {f [] = fail "empty"; f [_] = fail "singleton"; f l = >> return l } > > okay, I see, it's just that most partial functions in Data.* / container > libraries don't really have multiple failure modes that need > distinguishing. Yes, I noticed that Ross was careful to note that in the message that started that thread. I was more concerned with that specific case being generalized to an argument against not-just-Maybe (I think that was the title on the old wiki?). And single failure mode in the components doesn't imply single failure mode in combinations, either. Consider import Control.Monad import Control.Monad.Error f 1 = return 1 f _ = fail "f" g 2 = return 2 g _ = fail "g" If I call 'f', and it fails, I know that it was 'f' that failed, and it could only fail in a single way, so there's really no point in not replacing 'fail "f"' with 'Nothing', right (and the same goes for 'g')? Wrong (or Left;-)! Combining functions with single failure modes gives combinations with multiple failure modes (think of different branches in a parser/ type system/.., or of different phases in a compiler). Compare the two outputs of 'test' below: forg n = f n `mplus` g n gorf n = g n `mplus` f n fandg n = f n >>= g gandf n = g n >>= f test = do print ([forg 3, gorf 3, fandg 1, fandg 2]::[Maybe Int]) print ([forg 3, gorf 3, fandg 1, fandg 2]::[Either String Int]) I don't know whether that is an immediate concern for the particular functions under discussion from the 'containers' package, apart from all the extra lifting (and re-adding of sensible failure messages) when wanting to use those functions in a non-Maybe Monad? But it is a concern in general monadic programming (and it often requires extra work to ensure that failure paths combine as well as success paths). Claus PS: There was also the argument that there are cases where local failure handling is just not sensible (what the Erlangers call "don't program defensively", or "let it crash"), and where trying to return and handle those 'Nothing's would only make the code less readable as the problem gets passed from Pontius to Pilatus. The "let someone else clean up" approach is also supported by the not-just-Maybe pattern, although not as well in Haskell as in Erlang (with its supervisor trees and heart-beat monitoring). From Alistair.Bayley at invesco.com Fri Jun 13 10:43:13 2008 From: Alistair.Bayley at invesco.com (Bayley, Alistair) Date: Fri Jun 13 10:44:20 2008 Subject: [Haskell-cafe] Announce: Fortress talk in New York City In-Reply-To: References: Message-ID: <125EACD0CAE4D24ABDB4D148C4593DA9049E940D@GBLONXMB02.corp.amvescap.net> > From: haskell-cafe-bounces@haskell.org > [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of > Henning Thielemann > > > There will be a talk on Fortress... > > > > --- > > > > This e-mail may contain confidential and/or privileged information. > > You send potentially confidential information to a public > mailing list? I realise this is tongue-in-cheek... > Is this new language secret? :-) .. but I'm not so sure about this. If this is a serious question, here are some links: http://research.sun.com/projects/plrg/ http://research.sun.com/projects/plrg/Publications/index.html http://projectfortress.sun.com/Projects/Community BTW, check out the crappy auto-appended disclaimer (over which I have no control) on this message. Makes Jeff's look positively appealing. Alistair ***************************************************************** Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. ***************************************************************** From jmaessen at alum.mit.edu Fri Jun 13 11:14:22 2008 From: jmaessen at alum.mit.edu (Jan-Willem Maessen) Date: Fri Jun 13 11:06:35 2008 Subject: [Haskell-cafe] Announce: Fortress talk in New York City In-Reply-To: <125EACD0CAE4D24ABDB4D148C4593DA9049E940D@GBLONXMB02.corp.amvescap.net> References: <125EACD0CAE4D24ABDB4D148C4593DA9049E940D@GBLONXMB02.corp.amvescap.net> Message-ID: <0D52D25D-CA3E-4C45-B4D2-753EDCB0D856@alum.mit.edu> On Jun 13, 2008, at 10:43 AM, Bayley, Alistair wrote: >> From: haskell-cafe-bounces@haskell.org >> [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of >> Henning Thielemann >> >>> There will be a talk on Fortress... >>> >>> --- >>> >>> This e-mail may contain confidential and/or privileged information. >> >> You send potentially confidential information to a public >> mailing list? > > I realise this is tongue-in-cheek... > > >> Is this new language secret? :-) > > .. but I'm not so sure about this. If this is a serious question, here > are some links: > > http://research.sun.com/projects/plrg/ > http://research.sun.com/projects/plrg/Publications/index.html > http://projectfortress.sun.com/Projects/Community Let me assure the readers there's nothing confidential or privileged about Christine's talk! :-) It is, after all, an open source project. -Jan-Willem Maessen Project Fortress, Sun Microsystems Laboratories [who will be off teaching Fortress in Prague at the time] From darrinth at gmail.com Fri Jun 13 11:19:33 2008 From: darrinth at gmail.com (Darrin Thompson) Date: Fri Jun 13 11:11:40 2008 Subject: [Haskell-cafe] cabal-install failure Message-ID: Cabal-install is looking good. It now, for the record, has only two deps outside of Cabal-1.4. I installed cabal-install-0.5 on ubuntu with the haskell.org linux binary for ghc 6.8.2. I then tried cabal-install yi Got this output: ... many successful installs ... Registering vty-3.0.1... Reading package info from "dist/installed-pkg-config" ... done. Saving old package config file... done. Writing new package config file... done. Downloading yi-0.3... [1 of 1] Compiling Main ( Setup.hs, dist/setup/Main.o ) Setup.hs:9:0: Warning: Deprecated use of `showPackageId' (imported from Distribution.Simple, but defined in Distribution.Package): use the Text class instead Linking dist/setup/setup ... Warning: defaultUserHooks in Setup script is deprecated. Configuring yi-0.3... Warning: Instead of 'ghc-options: -DDYNAMIC -DFRONTEND_VTY' use 'cpp-options: -DDYNAMIC -DFRONTEND_VTY' setup: alex version >=2.0.1 && <3 is required but it could not be found. cabal: Error: some packages failed to install: yi-0.3 failed during the configure step. The exception was: exit: ExitFailure 1 Is this a cabal problem of package problem? I would have expected it to fail immediately instead of discover this problem so far into process. Thanks. -- Darrin From deduktionstheorem at web.de Fri Jun 13 11:38:48 2008 From: deduktionstheorem at web.de (Stephan Friedrichs) Date: Fri Jun 13 11:31:00 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: random-access-list-0.1 In-Reply-To: <485256C6.2010204@charter.net> References: <48505344.4010809@web.de> <48507431.2080908@charter.net> <48516EEA.6020203@web.de> <485256C6.2010204@charter.net> Message-ID: <48529488.6090107@web.de> Isaac Dupree wrote: > [...] >> >> Well Chris Okasaki called them "Skew Binary Random-Access Lists", >> which is even longer :) > > :) > > hmm.. IndexableList? (just a thought, not sure whether I like it any > better) RAList? IList? <- (will I be sued by a large computer company for that?) > [...] >> Yes, I wasn't happy with that one either. The view-concept of >> Data.Sequence is a good idea. > > yeah, it's a good idea, although I'm not sure how much I like the > particular syntax of how it's done in Data.Sequence (the view-types' > constructor names, mostly) I now have data View a = Empty | Cons a (RandomAccessList a) and view :: RandomAccessList a -> a additionally, I renamed "extractHead" to "uncons" (which is OK, because I also have "cons") but still left "head" and "tail" with the typical list-like behaviour (causing an error on empty lists). > [Monad vs. Maybe] That's quite convincing, most of all that "fail" has rather strange definitions for many Monads (because it originally does not belong to monads, does it?). > [...] >> >> The size function is in O(1) because I cache it, otherwise it would be >> >> size (RandomAccessList xs) = sum (map fst xs) >> >> which is O(log n). I consider the caching useful, as most applications >> will check 0 <= i < size quite often. > > sounds good > > [...] > >> If two lists have exactly the same size, all the complete binary trees >> holding the data have the same size as well. This can be zipped >> directly and is a bit (~5% in my tests) faster. > > okay, that sounds like a fair optimization, since zipping same-size > lists is a nice thing to do anyway. But the asymptotic speed ideally > should still be O(min(m,n)), if possible? Well... I guess that's possible converting the shorter one into a list and using fold for zipping. I'll have a close look at this! -- Fr?her hie? es ja: Ich denke, also bin ich. Heute wei? man: Es geht auch so. - Dieter Nuhr From stephen at enterity.com Fri Jun 13 12:38:25 2008 From: stephen at enterity.com (Stephen Howard) Date: Fri Jun 13 12:29:56 2008 Subject: [Haskell-cafe] working with Random.randoms Message-ID: <4852A281.8000508@enterity.com> Hi List, I am a newcomer doing my obligatory struggling with Haskell's type system, and I've got a nut I've not been able to crack. Given: import Random random_test :: Int -> String random_test n = do g <- getStdGen take n (randoms g)::String I'm expecting that I ought to be able to pass this action an integer and get back a random string that long (given, not all characters may be printable). But GHCI tells me: RandomTest.hs:7:4: Couldn't match `[]' against `IO' Expected type: [] Inferred type: IO In a 'do' expression: g <- getStdGen In the definition of `random_test': random_test n = do g <- getStdGen take n (randoms g) :: String And yet, when I run these lines in GHCI by hand, things seem to work (though the string is the same set of random characters each time, another bit that I need to solve): Prelude> :module Random Prelude Random> g <- getStdGen Prelude Random> take 5 (randoms g)::String "\1025049\315531\882767\1032009\334825" I'm guessing that randoms is returning an IO type but I'm not sure how to go about extracting the String to return to the calling action. Changing the type signature to Int -> IO String only gives me a different error. Where am I going wrong? thanks, Stephen From daniel.is.fischer at web.de Fri Jun 13 13:05:21 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Fri Jun 13 12:55:32 2008 Subject: [Haskell-cafe] working with Random.randoms In-Reply-To: <4852A281.8000508@enterity.com> References: <4852A281.8000508@enterity.com> Message-ID: <200806131905.21945.daniel.is.fischer@web.de> Am Freitag, 13. Juni 2008 18:38 schrieb Stephen Howard: > Hi List, > > I am a newcomer doing my obligatory struggling with Haskell's type > system, and I've got a nut I've not been able to crack. Given: > > import Random > > random_test :: Int -> String > random_test n = do > g <- getStdGen > take n (randoms g)::String > > I'm expecting that I ought to be able to pass this action an integer and > get back a random string that long (given, not all characters may be > printable). > > But GHCI tells me: > > RandomTest.hs:7:4: > Couldn't match `[]' against `IO' > Expected type: [] > Inferred type: IO > In a 'do' expression: g <- getStdGen > In the definition of `random_test': > random_test n = do > g <- getStdGen > take n (randoms g) :: String > > And yet, when I run these lines in GHCI by hand, things seem to work > (though the string is the same set of random characters each time, > another bit that I need to solve): > > Prelude> :module Random > Prelude Random> g <- getStdGen > Prelude Random> take 5 (randoms g)::String > "\1025049\315531\882767\1032009\334825" > > > I'm guessing that randoms is returning an IO type but I'm not sure how No, getStdGen is what's in IO, it has type IO StdGen. Since you can't get rid of IO safely, the type of random_test must be Int -> IO String. Best practice is to separate into a pure part: pure_random_test :: Int -> StdGen -> String pure_random_test n g = take n (randoms g) and the IO bound part: random_test :: Int -> IO String random_test n = do g <- getStdGen return $ pure_random_test n g or, if we like it better: random_test n = fmap (pure_random_test n) getStdGen > to go about extracting the String to return to the calling action. > Changing the type signature to Int -> IO String only gives me a > different error. > > Where am I going wrong? You must put the String (take n (randoms g)) into the IO monad. The way it works in ghci is due to the fact, that in ghci, you are basically in an IO loop/do-block. When you type g <- getStdGen the action is performed, and the result is bound to the identifier g. When you then type take 5 (randoms g), it's transformed into do ..... let it = take 5 (randoms g) print it return it Within one session, all calls to getStdGen return the same StdGen, that's why you always get the same sequence of random Chars. > > thanks, > Stephen HTH, Daniel From aditya_siram at hotmail.com Fri Jun 13 15:01:10 2008 From: aditya_siram at hotmail.com (Aditya Siram) Date: Fri Jun 13 14:53:18 2008 Subject: [Haskell-cafe] Cabal-Install Fails To Compile In-Reply-To: <1213325939.15010.508.camel@localhost> References: <1213325939.15010.508.camel@localhost> Message-ID: Thanks so much for your help. Actually Don got it fixed within twenty minutes but I mistakenly didn't cc the group. But it works perfectly now. -Deech ---------------------------------------- > Subject: Re: [Haskell-cafe] Cabal-Install Fails To Compile > From: duncan.coutts@worc.ox.ac.uk > To: aditya_siram@hotmail.com > CC: haskell-cafe@haskell.org > Date: Fri, 13 Jun 2008 03:58:59 +0100 > > > On Thu, 2008-06-12 at 16:07 -0500, Aditya Siram wrote: >> Hi all, >> I downloaded cabal-install and the cabal-1.4 branch from darcs. The following error occurs when building: >>> runhaskell Setup.hs build >> >> Building cabal-install-0.4.9... >> [19 of 27] Compiling Hackage.SrcDist ( Hackage/SrcDist.hs, dist/build/cabal/cabal-tmp/Hackage/SrcDist.o ) >> >> Hackage/SrcDist.hs:58:59: >> Couldn't match expected type `Char' >> against inferred type `Distribution.Simple.PreProcess.PPSuffixHandler' >> Expected type: FilePath >> Inferred type: [Distribution.Simple.PreProcess.PPSuffixHandler] >> In the fifth argument of `prepareSnapshotTree', namely >> `knownSuffixHandlers' >> In the second argument of `(>>=)', namely >> `prepareSnapshotTree >> verbosity pkg mb_lbi tmpDir knownSuffixHandlers' > > Yeah, sorry that was my fault. You caught it in the few hours when the > two darcs versions were not compatible. They work now, or as Don says, > get the actual releases from hackage. > > Duncan > _________________________________________________________________ Search that pays you back! Introducing Live Search cashback. http://search.live.com/cashback/?&pkw=form=MIJAAF/publ=HMTGL/crea=srchpaysyouback From wren at freegeek.org Fri Jun 13 16:29:07 2008 From: wren at freegeek.org (wren ng thornton) Date: Fri Jun 13 16:21:41 2008 Subject: [Haskell-cafe] Re: [Haskell] ANN: random-access-list-0.1 In-Reply-To: <48507431.2080908@charter.net> References: <48505344.4010809@web.de> <48507431.2080908@charter.net> Message-ID: <4852D893.7050107@freegeek.org> Isaac Dupree wrote: > "extractHead" is an ugly name for a nevertheless standardish-meaning > function... what is it usually called? uncons? headTail? (Data.Sequence, > which is meant to be left-right symmetric, calls it "viewr"... except > your version doesn't have the Maybe, it's partial instead, fails on > empty lists) Views are nice, but these other functions are needed too. As for "extractHead", what about "split"? (cf. Control.Monad.Logic.msplit[1]) [1] http://tinyurl.com/37f4ga http://hackage.haskell.org/packages/archive/logict/0.2.3/doc/html/Control-Monad-Logic-Class.html -- Live well, ~wren From duncan.coutts at worc.ox.ac.uk Fri Jun 13 17:22:06 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Fri Jun 13 17:10:33 2008 Subject: [Haskell-cafe] cabal-install failure In-Reply-To: References: Message-ID: <1213392126.15010.547.camel@localhost> On Fri, 2008-06-13 at 11:19 -0400, Darrin Thompson wrote: > Cabal-install is looking good. It now, for the record, has only two > deps outside of Cabal-1.4. > > I installed cabal-install-0.5 on ubuntu with the haskell.org linux > binary for ghc 6.8.2. > > I then tried cabal-install yi > > Got this output: > ... many successful installs ... > Registering vty-3.0.1... > Reading package info from "dist/installed-pkg-config" ... done. > Saving old package config file... done. > Writing new package config file... done. > Downloading yi-0.3... > [1 of 1] Compiling Main ( Setup.hs, dist/setup/Main.o ) > > Setup.hs:9:0: > Warning: Deprecated use of `showPackageId' > (imported from Distribution.Simple, but defined in > Distribution.Package): > use the Text class instead > Linking dist/setup/setup ... > Warning: defaultUserHooks in Setup script is deprecated. > Configuring yi-0.3... > Warning: Instead of 'ghc-options: -DDYNAMIC -DFRONTEND_VTY' use 'cpp-options: > -DDYNAMIC -DFRONTEND_VTY' > setup: alex version >=2.0.1 && <3 is required but it could not be found. > cabal: Error: some packages failed to install: > yi-0.3 failed during the configure step. The exception was: > exit: ExitFailure 1 > > Is this a cabal problem of package problem? I would have expected it > to fail immediately instead of discover this problem so far into > process. So it's failing when configuring yi because alex is not installed. So the question is when should this get checked? I think it's not unreasonable to have the check where it is now though perhaps we could do better by bringing it forward. The point is, cabal-install only checks that haskell packages are available before beginning to install stuff. It leaves all the other checks (build tools, C libs, custom checks in Setup.hs script etc) to be done at the configure phase of each package. In theory it's not impossible to imagine doing the configure phase of every package before doing the build phase of any package but it's not clear that it gains us that much and it's a bit more complex to do it that way. Duncan From david.waern at gmail.com Fri Jun 13 18:07:13 2008 From: david.waern at gmail.com (David Waern) Date: Fri Jun 13 17:59:21 2008 Subject: [Haskell-cafe] ANN: Haddock Trac Message-ID: Hi everyone, there's now a Haddock bug-tracker and wiki at http://trac.haskell.org/haddock. Please use it to submit bug reports and feature requests! David From jason.dusek at gmail.com Fri Jun 13 19:39:35 2008 From: jason.dusek at gmail.com (Jason Dusek) Date: Fri Jun 13 19:31:41 2008 Subject: [Haskell-cafe] LDAP 0.6.3 build failure Message-ID: <42784f260806131639w7e1b9169y9d1ed738c035f8ec@mail.gmail.com> I'm trying to build the LDAP libs, version 0.6.3, on a recent MacBook Air with OpenLDAP 2.3.27 (the version of OpenLDAP shipped by Apple). The "atom sorting error" I get from `ld` is outside my range of knowledge -- if some could advise me on how to get around it, I'd be much obliged. I'm using the Apple toolchain to do do the build. -- _jsn :; Setup configure && Setup build Configuring LDAP-0.6.3... Preprocessing library LDAP-0.6.3... Building LDAP-0.6.3... ar: creating archive dist/build/libHSLDAP-0.6.3.a ld: atom sorting error for _LDAPzm0zi6zi3_LDAPziTypesLL_Berval_closure_tbl and _LDAPzm0zi6zi3_LDAPziTypesLL_CLDAP_closure_tbl in dist/build/LDAP/TypesLL.o ld: atom sorting error for _LDAPzm0zi6zi3_LDAPziTypesLL_Berval_closure_tbl and _LDAPzm0zi6zi3_LDAPziTypesLL_CLDAP_closure_tbl From judah.jacobson at gmail.com Fri Jun 13 20:21:31 2008 From: judah.jacobson at gmail.com (Judah Jacobson) Date: Fri Jun 13 20:13:37 2008 Subject: [Haskell-cafe] LDAP 0.6.3 build failure In-Reply-To: <42784f260806131639w7e1b9169y9d1ed738c035f8ec@mail.gmail.com> References: <42784f260806131639w7e1b9169y9d1ed738c035f8ec@mail.gmail.com> Message-ID: <6d74b0d20806131721s52f3857etace97e204011f27@mail.gmail.com> On Fri, Jun 13, 2008 at 4:39 PM, Jason Dusek wrote: > I'm trying to build the LDAP libs, version 0.6.3, on a recent > MacBook Air with OpenLDAP 2.3.27 (the version of OpenLDAP > shipped by Apple). > > The "atom sorting error" I get from `ld` is outside my range > of knowledge -- if some could advise me on how to get around > it, I'd be much obliged. I'm using the Apple toolchain to do > do the build. > That "error" is actually a harmless warning; in my experience it can be safely ignored. More information at: http://www.nabble.com/Re%3A--Fwd%3A-Re%3A-Problem-building-hdbc-sqlite3-with-ghc-6.8.2--p14602140.html -Judah From ryani.spam at gmail.com Fri Jun 13 20:27:01 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Fri Jun 13 20:19:07 2008 Subject: [Haskell-cafe] monomorphism restriction In-Reply-To: References: Message-ID: <2f9b2d30806131727s624ee38dja867b926bbde0cc1@mail.gmail.com> On 6/11/08, Rex Page wrote: > Please remind me, again, of the advantages of f being something different > from the formula defining it. fibs !a !b = a : fibs b (a+b) -- fibs :: Num a => a -> a -> [a] n = head $ drop 1000000 $ fibs 1 1 -- n :: Integer (due to monomorphism restriction.) sumns 0 = 0 sumns x = sumns (x-1) + n Without the monomorphism restriction, computing n is a function call; it is evaluated each time it is asked for. With the monomorphism restriction, n is a CAF and it is updated in place after it's been evaluated for the first time. Evaluating "sumns 1000" could take 1000 times as long without the monomorphism restriction, which definitely seems surprising as a user until you understand whatis going on behind the scenes with dictionary passing. If you do not want the MR, you have these options: 1) turn off explicitly (in GHC you can use -fno-monomorphism restriction) 2) add a type signature yourself (f :: Num a => [a] -> a) 3) eta-expand (f xs = foldr (+) 0 xs) -- ryan From jonathanccast at fastmail.fm Wed Jun 11 23:48:56 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Fri Jun 13 21:05:46 2008 Subject: [Haskell-cafe] monomorphism restriction In-Reply-To: <20080612032402.GA25431@scytale.galois.com> References: <20080612032402.GA25431@scytale.galois.com> Message-ID: <1213242536.6353.6.camel@jonathans-macbook> On Wed, 2008-06-11 at 20:24 -0700, Don Stewart wrote: > page: > > Definition of f: > > f = foldr (+) 0 > > Types: > > 0 :: (Num t) => t > > foldr (+) 0 :: Num a => [a] -> a > > f :: [Integer] -> Integer > > > > Please remind me, again, of the advantages of f being something different > > from the formula defining it. > > Overloaded 'constants' take a dictionary as an argument, so while you > think the value might be computed only once, it make actually be > recomputed each time. This can be a killer performance penalty for > overloaded numeric constants. > > Of course, disabling this is pretty simple. This doesn't apply to f, though --- it has a function type, so the user presumably already knows it won't be subject to updating, no? Distinguishing functions from variables by the form of declaration, rather than the type, seems somewhat questionable to me. jcc From gwern0 at gmail.com Fri Jun 13 22:10:52 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Fri Jun 13 22:04:09 2008 Subject: [Haskell-cafe] cabal-install failure In-Reply-To: <1213392126.15010.547.camel@localhost> References: <1213392126.15010.547.camel@localhost> Message-ID: <20080614021052.GA8862@craft> On 2008.06.13 22:22:06 +0100, Duncan Coutts scribbled 2.1K characters: > > On Fri, 2008-06-13 at 11:19 -0400, Darrin Thompson wrote: > > Cabal-install is looking good. It now, for the record, has only two > > deps outside of Cabal-1.4. > > > > I installed cabal-install-0.5 on ubuntu with the haskell.org linux > > binary for ghc 6.8.2. > > > > I then tried cabal-install yi > > > > Got this output: > > ... many successful installs ... > > Registering vty-3.0.1... > > Reading package info from "dist/installed-pkg-config" ... done. > > Saving old package config file... done. > > Writing new package config file... done. > > Downloading yi-0.3... > > [1 of 1] Compiling Main ( Setup.hs, dist/setup/Main.o ) > > > > Setup.hs:9:0: > > Warning: Deprecated use of `showPackageId' > > (imported from Distribution.Simple, but defined in > > Distribution.Package): > > use the Text class instead > > Linking dist/setup/setup ... > > Warning: defaultUserHooks in Setup script is deprecated. > > Configuring yi-0.3... > > Warning: Instead of 'ghc-options: -DDYNAMIC -DFRONTEND_VTY' use 'cpp-options: > > -DDYNAMIC -DFRONTEND_VTY' > > setup: alex version >=2.0.1 && <3 is required but it could not be found. > > cabal: Error: some packages failed to install: > > yi-0.3 failed during the configure step. The exception was: > > exit: ExitFailure 1 > > > > Is this a cabal problem of package problem? I would have expected it > > to fail immediately instead of discover this problem so far into > > process. > > So it's failing when configuring yi because alex is not installed. > > So the question is when should this get checked? I think it's not > unreasonable to have the check where it is now though perhaps we could > do better by bringing it forward. > > The point is, cabal-install only checks that haskell packages are > available before beginning to install stuff. It leaves all the other > checks (build tools, C libs, custom checks in Setup.hs script etc) to be > done at the configure phase of each package. > > In theory it's not impossible to imagine doing the configure phase of > every package before doing the build phase of any package but it's not > clear that it gains us that much and it's a bit more complex to do it > that way. > > Duncan I think this may be Cabal's fault anyway. The yi.cabal includes the line: build-tools: alex >= 2.0.1 && < 3 in the 'executable yi' section, right after the build-depends, so Yi is being straightforward and upfront about its needs. Now, Cabal is obviously checking that the build-depends is satisfied first, but why isn't it checking that alex is available when it has the information it needs to check, presumably anything in build-tools is *required*, and the field name suggests that it would be checked? -- gwern watchers 5.0i Fax UXO NORAD Consulting meta Gatt of data -------------- 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/20080613/b4cc70b5/attachment.bin From vigalchin at gmail.com Sat Jun 14 01:59:31 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Sat Jun 14 01:51:38 2008 Subject: [Haskell-cafe] FunPtr error? In-Reply-To: <5ae4f2ba0806092301p2b5e9530r828abf6436e4d07d@mail.gmail.com> References: <5ae4f2ba0806081917u3cbeada0ge4968bb5183c888e@mail.gmail.com> <1097402345.20080609095428@gmail.com> <5ae4f2ba0806082324t53691b06se7efa48f5df7c379@mail.gmail.com> <5ae4f2ba0806091118y922e881nbcb1a945cc765bb3@mail.gmail.com> <2f9b2d30806091216j137abcbbj34761d6f7861c5f4@mail.gmail.com> <5ae4f2ba0806092054q75176dc0h1d9da81d4eacf877@mail.gmail.com> <6d74b0d20806092125n31df313ex483f42fc0557b06e@mail.gmail.com> <5ae4f2ba0806092301p2b5e9530r828abf6436e4d07d@mail.gmail.com> Message-ID: <5ae4f2ba0806132259o26632f1bsa159839029529fc@mail.gmail.com> If I change data Sigval = SivalInt Int | SivalPtr (Ptr Char) to ... newtype Sigval = Sivalint Int | SivalPtr (Ptr Char) then my test case builds and links. ?? Regards, Vasili On Mon, Jun 9, 2008 at 11:01 PM, Galchin, Vasili wrote: > I have tried various things to no avail .... > > vigalchin@ubuntu:~/FTP/Haskell/unix-2.2.0.0/tests/timer$ runhaskell > Setup.lhs build > Preprocessing executables for Test-1.0... > Building Test-1.0... > [1 of 1] Compiling Main ( ./timer.hs, > dist/build/timer/timer-tmp/Main.o ) > > ./timer.hs:22:0: > Unacceptable argument type in foreign declaration: Sigval > When checking declaration: > foreign import ccall safe "wrapper" mkNotify > :: Notify -> IO (FunPtr Notify) > > => here is my Sigval def > > data Sigval = SivalInt Int | SivalPtr (Ptr Char) > > I did a find/grep for "Unacceptable argument" in the ghc compiler source > and assuming no typo I didn't find. ?? > > Thanks. > > Kind regards, Vasili > > > > > On Mon, Jun 9, 2008 at 11:25 PM, Judah Jacobson > wrote: > >> 2008/6/9 Galchin, Vasili : >> > Ryan, >> > >> > I tried but the compiler didn't seem to like the keyword "import": >> > >> > vigalchin@ubuntu:~/FTP/Haskell/unix-2.2.0.0/tests/timer$ runhaskell >> > Setup.lhs build >> > Preprocessing executables for Test-1.0... >> > Building Test-1.0... >> > [1 of 1] Compiling Main ( ./timer.hs, >> > dist/build/timer/timer-tmp/Main.o ) >> > >> > ./timer.hs:29:8: parse error on input `import' >> > >> >> Hi Vasili, >> >> To fix that error, you probably just need to add the line "Extensions: >> ForeignFunctionInterface" to the .cabal file. (That is the >> equivalent of calling ghc by itself with the command-line arguments >> -fffi or -XForeignFunctionInterface.) >> >> Hope that helps, >> -Judah >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080613/c5638bda/attachment.htm From aneumann at inf.fu-berlin.de Sat Jun 14 02:05:48 2008 From: aneumann at inf.fu-berlin.de (Adrian Neumann) Date: Sat Jun 14 01:58:09 2008 Subject: [Haskell-cafe] cgi liftM liftIO In-Reply-To: <1ff5dedc0806130641u461a22c7n7d5b23e4956a39d2@mail.gmail.com> References: <1ff5dedc0806130641u461a22c7n7d5b23e4956a39d2@mail.gmail.com> Message-ID: I think you need to put liftIO in front of the IO actions you want to do inside the CGI Monad. Like in this example > http://www.haskell.org/haskellwiki/ Practical_web_programming_in_Haskell#File_uploads (Why did I need to use google to find that? The wiki search in awful. Searching for CGI returns nothing, whereas with google the above is the first hit.) Am 13.06.2008 um 15:41 schrieb Cetin Sert: > Hi, > > Could someone please care to explain what I am doing wrong below in > cgiMain2 and how can I fix it? > > > ./Main.hs:25:15: > No instance for (MonadCGI IO) > arising from a use of `output' at ./Main.hs:25:15-20 > Possible fix: add an instance declaration for (MonadCGI IO) > In the first argument of `($)', namely `output' > In the expression: output $ renderHtml $ page "import" fileForm > In the definition of `upload': > upload = output $ renderHtml $ page "import" fileForm > > ./Main.hs:57:29: > Couldn't match expected type `CGI CGIResult' > against inferred type `IO CGIResult' > In the first argument of `handleErrors', namely `cgiMain2' > In the second argument of `($)', namely `handleErrors cgiMain2' > In the expression: runCGI $ handleErrors cgiMain2 > > > import IO > import Network.CGI > import Text.XHtml > > import qualified Data.ByteString.Lazy as BS > > import Control.Monad (liftM) > import Data.Maybe (fromJust) > > import Interact > > fileForm = form ! [method "post", enctype "multipart/form-data"] << > [afile "file", submit "" "Upload"] > > page t b = header << thetitle << t +++ body << b > > cgiMain1 = do > getInputFPS "file" ? ?ms ? maybe upload contents ms ? return > where > upload = output $ renderHtml $ page "import" fileForm > contents = outputFPS > > cgiMain2 = do > getInputFPS "file" ? ?ms ? maybe upload contents ms ? return > where > upload = output $ renderHtml $ page "import" fileForm > contents = ?s ? do > (i,o,h,_) ? runUnzip > BS.hPutStr i s > c ? BS.hGetContents o > outputFPS c > > > {- > (i,o,h,_) ? runUnzip > BS.hPutStr i s > BS.hGetContents o ? outputFPS > -} > > > > {- > liftM :: (Monad m) => (a1 -> r) -> m a1 -> m r > liftIO :: (MonadIO m) => IO a -> m a > > saveFile n = > do cont <- liftM fromJust $ getInputFPS "file" > let f = uploadDir ++ "/" ++ basename n > liftIO $ BS.writeFile f cont > return $ paragraph << ("Saved as " +++ anchor ! [href f] << > f +++ ".") > -} > > runUnzip = runInteractiveCommand "unzip -l /dev/stdin" > > main = runCGI $ handleErrors cgiMain2 > > Best Regards, > Cetin Sert > > P/s: what are lifts o_O? > _______________________________________________ > 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: PGP.sig Type: application/pgp-signature Size: 194 bytes Desc: Signierter Teil der Nachricht Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080614/555be2b5/PGP-0001.bin From gwern0 at gmail.com Sat Jun 14 02:12:04 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Sat Jun 14 02:04:55 2008 Subject: [Haskell-cafe] cgi liftM liftIO In-Reply-To: References: <1ff5dedc0806130641u461a22c7n7d5b23e4956a39d2@mail.gmail.com> Message-ID: <20080614061204.GA7160@craft> On 2008.06.14 08:05:48 +0200, Adrian Neumann scribbled 4.0K characters: > I think you need to put liftIO in front of the IO actions you want to do > inside the CGI Monad. Like in this example > > > http://www.haskell.org/haskellwiki/ > Practical_web_programming_in_Haskell#File_uploads > > (Why did I need to use google to find that? The wiki search in awful. > Searching for CGI returns nothing, whereas with google the above is the > first hit.) IIRC, MediaWiki search will not search for anything shorter than 4 characters (as an optimization, I think). This is admittedly annoying when you are searching not for 'the' but 'IRC' or 'CGI'... -- gwern William Gap subversives Lexis-Nexis SADMS Blowpipe GRU Posse ISCS mailbomb -------------- 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/20080614/c2215f65/attachment.bin From vigalchin at gmail.com Sat Jun 14 02:40:42 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Sat Jun 14 02:32:47 2008 Subject: [Haskell-cafe] FunPtr error? In-Reply-To: <5ae4f2ba0806132259o26632f1bsa159839029529fc@mail.gmail.com> References: <5ae4f2ba0806081917u3cbeada0ge4968bb5183c888e@mail.gmail.com> <1097402345.20080609095428@gmail.com> <5ae4f2ba0806082324t53691b06se7efa48f5df7c379@mail.gmail.com> <5ae4f2ba0806091118y922e881nbcb1a945cc765bb3@mail.gmail.com> <2f9b2d30806091216j137abcbbj34761d6f7861c5f4@mail.gmail.com> <5ae4f2ba0806092054q75176dc0h1d9da81d4eacf877@mail.gmail.com> <6d74b0d20806092125n31df313ex483f42fc0557b06e@mail.gmail.com> <5ae4f2ba0806092301p2b5e9530r828abf6436e4d07d@mail.gmail.com> <5ae4f2ba0806132259o26632f1bsa159839029529fc@mail.gmail.com> Message-ID: <5ae4f2ba0806132340w39031820q3e1e86723760469@mail.gmail.com> oops .. my bad ... If I change data Sigval = SivalInt Int to newtype Sigval = SivalInt Int OR data Sigval = SivalPtr (Ptr Char) to newtype Sigval = SivalPtr (Ptr Char). Why should "newtype" instead of a data type allow my test case to build? Vasili On Fri, Jun 13, 2008 at 10:59 PM, Galchin, Vasili wrote: > If I change > > data Sigval = SivalInt Int | SivalPtr (Ptr Char) > to ... > > newtype Sigval = Sivalint Int | SivalPtr (Ptr Char) > > then my test case builds and links. ?? > > > Regards, Vasili > > > > > On Mon, Jun 9, 2008 at 11:01 PM, Galchin, Vasili > wrote: > >> I have tried various things to no avail .... >> >> vigalchin@ubuntu:~/FTP/Haskell/unix-2.2.0.0/tests/timer$ runhaskell >> Setup.lhs build >> Preprocessing executables for Test-1.0... >> Building Test-1.0... >> [1 of 1] Compiling Main ( ./timer.hs, >> dist/build/timer/timer-tmp/Main.o ) >> >> ./timer.hs:22:0: >> Unacceptable argument type in foreign declaration: Sigval >> When checking declaration: >> foreign import ccall safe "wrapper" mkNotify >> :: Notify -> IO (FunPtr Notify) >> >> => here is my Sigval def >> >> data Sigval = SivalInt Int | SivalPtr (Ptr Char) >> >> I did a find/grep for "Unacceptable argument" in the ghc compiler source >> and assuming no typo I didn't find. ?? >> >> Thanks. >> >> Kind regards, Vasili >> >> >> >> >> On Mon, Jun 9, 2008 at 11:25 PM, Judah Jacobson < >> judah.jacobson@gmail.com> wrote: >> >>> 2008/6/9 Galchin, Vasili : >>> > Ryan, >>> > >>> > I tried but the compiler didn't seem to like the keyword "import": >>> > >>> > vigalchin@ubuntu:~/FTP/Haskell/unix-2.2.0.0/tests/timer$ runhaskell >>> > Setup.lhs build >>> > Preprocessing executables for Test-1.0... >>> > Building Test-1.0... >>> > [1 of 1] Compiling Main ( ./timer.hs, >>> > dist/build/timer/timer-tmp/Main.o ) >>> > >>> > ./timer.hs:29:8: parse error on input `import' >>> > >>> >>> Hi Vasili, >>> >>> To fix that error, you probably just need to add the line "Extensions: >>> ForeignFunctionInterface" to the .cabal file. (That is the >>> equivalent of calling ghc by itself with the command-line arguments >>> -fffi or -XForeignFunctionInterface.) >>> >>> Hope that helps, >>> -Judah >>> >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080613/28014839/attachment.htm From xs at xaph.net Sat Jun 14 03:19:19 2008 From: xs at xaph.net (Rafal Kolanski) Date: Sat Jun 14 03:11:29 2008 Subject: [Haskell-cafe] monomorphism restriction In-Reply-To: <2f9b2d30806131727s624ee38dja867b926bbde0cc1@mail.gmail.com> References: <2f9b2d30806131727s624ee38dja867b926bbde0cc1@mail.gmail.com> Message-ID: <485370F7.20308@xaph.net> Ryan Ingram wrote: > sumns 0 = 0 > sumns x = sumns (x-1) + n > > Without the monomorphism restriction, computing n is a function call; > it is evaluated each time it is asked for. I'm relatively new to Haskell, and since this topic already came up, I was wondering if anyone could explain to me how this ties into implicit parameters which "escape" from their respective functions? For instance, if I just state: maxLength = maxLengthParameter ?config without providing a type signature and then use it, I get warned that ?config "escapes" from maxLength and that I should provide a type signature or turn off the monomorphism restriction. I find implicit parameters are a really nice way to pass a configuration to a whole tree of functions (in this case an LZSS compressor) without having to explicitly add it as a parameter to every single one of the functions. What are the performance implications of turning off the restriction and allowing implicit parameters to "escape"? Are there general performance implications of implicit parameters I am not aware of? Yours Sincerely, Rafal Kolanski. From duncan.coutts at worc.ox.ac.uk Sat Jun 14 03:56:34 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sat Jun 14 03:44:23 2008 Subject: [Haskell-cafe] cabal-install failure In-Reply-To: <20080614021052.GA8862@craft> References: <1213392126.15010.547.camel@localhost> <20080614021052.GA8862@craft> Message-ID: <1213430194.15010.556.camel@localhost> On Fri, 2008-06-13 at 22:10 -0400, Gwern Branwen wrote: > I think this may be Cabal's fault anyway. The yi.cabal includes the line: > build-tools: alex >= 2.0.1 && < 3 > > in the 'executable yi' section, right after the build-depends, so Yi > is being straightforward and upfront about its needs. Now, Cabal is > obviously checking that the build-depends is satisfied first, but why > isn't it checking that alex is available when it has the information > it needs to check, presumably anything in build-tools is *required*, > and the field name suggests that it would be checked? Yes, you're right. This is the ticket you filed last time: http://hackage.haskell.org/trac/hackage/ticket/227 and my comment: One problem is that not all build-tools correspond to haskell packages. Some do some don't. We have a hard coded list of them at the moment (which can be extended in Setup.hs files) so we could extend that with what haskell package if any the tools correspond to. Any better suggestions to make it a tad more generic? If anyone has a godd suggestion I'm happy to hear it. Otherwise we can just add a Maybe Dependency to the Program type to indicate that some build tools have a corresponding haskell package. Duncan From claus.reinke at talk21.com Sat Jun 14 06:03:38 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Sat Jun 14 05:55:56 2008 Subject: [Haskell-cafe] cabal-install failure References: <1213392126.15010.547.camel@localhost> <20080614021052.GA8862@craft> <1213430194.15010.556.camel@localhost> Message-ID: <008501c8ce05$ec0ef260$f82b8351@cr3lt> > http://hackage.haskell.org/trac/hackage/ticket/227 > > One problem is that not all build-tools correspond to haskell > packages. Some do some don't. We have a hard coded list of them > at the moment (which can be extended in Setup.hs files) so we > could extend that with what haskell package if any the tools > correspond to. Any better suggestions to make it a tad more > generic? That list seems to be in Distribution/Simple/Program.hs, in case anyone else is looking for it. Encoded information includes: dependency name, program name (if different from dependency), option to get version info and code to extract it (with one apparently very special case being hsc2hs). Btw, most of the version extraction code looks like a regular expression match - wouldn't that make the specification easier (and turn the comments into part of the spec)? > If anyone has a godd suggestion I'm happy to hear it. Otherwise we can > just add a Maybe Dependency to the Program type to indicate that some > build tools have a corresponding haskell package. I'm not sure what you're suggesting there (currently even those tools that can be built with Cabal do not register with Cabal), but here are my suggestions: 1. Haskell tools should register with Cabal, whether built with it (such as Alex, Happy, ..) or not (such as GHC, ..). That registration should include any build-relevant information (versions/variants, ..). 2. When checking a build-tools dependency, Cabal checks (a) whether the tool is registered with Cabal (b) whether the tool is registered with the system installation manager (c) whether the tool can be found by other means (configure, built-in rules, ..) In other words, make tools look like packages (lifetime dependency management, not just build support), and make system packages look like Cabal packages (Cabal as the interface to native managers), using special treatment only if absolutely necessary. I thought those suggestions were clear from my earlier messages?-) Claus http://www.haskell.org/pipermail/haskell-cafe/2008-May/043368.html http://www.haskell.org/pipermail/haskell-cafe/2008-June/043977.html http://www.haskell.org/pipermail/haskell-cafe/2008-June/043910.html From jon.fairbairn at cl.cam.ac.uk Sat Jun 14 06:30:38 2008 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Sat Jun 14 06:22:55 2008 Subject: [Haskell-cafe] Re: working with Random.randoms References: <4852A281.8000508@enterity.com> Message-ID: Stephen Howard writes: > I am a newcomer doing my obligatory struggling with > Haskell's type system, That's your mistake. Don't struggle with the type system, the type system is your friend; when it tells you you are doing something wrong, it's usually right. > and I've got a nut I've not been able to crack. Given: > > import Random > > random_test :: Int -> String > random_test n = do > g <- getStdGen > take n (randoms g)::String My immediate reaction on seeing this is that "do" is for manipulating monads, but the only monad you've indicated in the type is [] (from String = [Char]), and that's probably an accident. In GHCi: Prelude> :t Random.getStdGen Random.getStdGen :: IO System.Random.StdGen What this says is that getStdGen isn't a function, which is to say it doesn't always return the same value (ie it isn't pure -- it wouldn't be much use if it were!). In effect it uses the real world to get a new value, and such things are kept safely in the IO monad. In C, everything is in the IO monad; there's no way of telling from the type whether something is pure or not?. In Haskell (apart from some ugliness that's supposed to stay hidden) you have to distinguish between pure and impure, and the type checker keeps track of all this for you. > And yet, when I run these lines in GHCI by hand, The top level of GHCi is IO (which shouldn't come as a surprise!) > things seem to work (though the string is the same set of > random characters each time, another bit that I need to > solve That's a somewhat obscure aspect of GHCi, I think, to do with "not reverting top-level expressions". If you do this: Prelude> :set +r Prelude> g <- Random.getStdGen -- what's the type? 1954047482 7573 Prelude> g <- Random.getStdGen -- what's the type? 1626678354 7697 Prelude> you see that you get a different StdGen each time. > I'm guessing that randoms is returning an IO type but I'm > not sure how to go about extracting the String to return to > the calling action. Changing the type signature to Int -> > IO String only gives me a different error. If you do any IO, you've done some IO! So you need to lift out the StdGen and pass that to the functions that you want to use it. main :: IO() do gen <- getStdGen the_list <- real_programme gen print the_list You should be able to deduce from the fact that the first argument of real_programme here is of type StdGen (not IO anything) and its result type is [something] that real_programme is pure, and gen has only one value throughout. So if you want more than one random list out of it, you either need to use Random.split or pass more than one gen in. [1] Were you truly perverse, you could define your own libraries in Haskell so that YourInt = IO Int; YourDouble = IO Double etc, and make appropriate classes in place of Num &c (hiding the proper ones), so that + :: YourInt -> YourInt -> YourInt and so on (you'd have to define your own Bool and if, too, but Haskell can do that). Then the type checker would overlook all sorts of mistakes that it could otherwise have caught. -- J?n Fairbairn Jon.Fairbairn@cl.cam.ac.uk http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html (updated 2008-04-26) From c-bauer-olsbruecken at t-online.de Sat Jun 14 06:45:58 2008 From: c-bauer-olsbruecken at t-online.de (Christoph Bauer) Date: Sat Jun 14 06:38:16 2008 Subject: [Haskell-cafe] ANN: Topkata Message-ID: <87zlpoguqh.fsf@elefant.olsbruecken.local> Hi All, Topkata is a simple OpenGL Game written in Haskell. It's not very advanced. Goal so far is to guide a ball trough an labyrinth to the opposite corner. The web page shows an screenshot. It's only tested under Linux. http://home.arcor.de/chr_bauer/topkata.html Feedback&Patches are welcome. BTW, I had a lot of support in #haskell! Christoph Bauer From ndmitchell at gmail.com Sat Jun 14 06:50:07 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Sat Jun 14 06:42:11 2008 Subject: [Haskell-cafe] ANN: Topkata In-Reply-To: <87zlpoguqh.fsf@elefant.olsbruecken.local> References: <87zlpoguqh.fsf@elefant.olsbruecken.local> Message-ID: <404396ef0806140350w2eb18cf4n68b7d2f08ece7025@mail.gmail.com> Hi Christoph, > opposite corner. The web page shows an screenshot. It's only tested > under Linux. Looks cool! Could you upload it to hackage? http://hackage.haskell.org/ Once its on hackage, using cabal install, it should be possible to get your game going with as little as: cabal install topkata && topkata That would be awsome for trying it out! Thanks Neil From gwern0 at gmail.com Sat Jun 14 08:30:12 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Sat Jun 14 08:22:57 2008 Subject: [Haskell-cafe] ANN: Mueval 0.21 Message-ID: <20080614123012.GA29554@craft> Hiya everyone. I'd like to announce the release of a little CLI program I whipped up. It's called mueval . WHAT: Mueval grew out of my discontent with Lambdabot: it's really neat to be able to run expressions like this: 07:53 < ivanm> > filter (\ x -> isLetter x || x == '\t') "asdf$#$ dfs" 07:55 < lambdabot> "asdfdfs" But lambdabot is crufty and very difficult to install or run. IMO, we need a replacement or rewrite, but one of the things that make this difficult is that lambdabot uses hs-plugins to get that sort of evaluation functionality, and hs-plugins is half the problem. We want some sort of standalone executable which provides that functionality. Now, 'ghc -e' is obviously unsuited because there is no sandboxing, so what I've done is basically marry the GHC API (as rendered less sharp-edged by Hint) with a bunch of resource limits and sandboxing (as largely stolen from lambdabot). EXAMPLES: The end result is an adorable little program, which you can use like this: bash-3.2$ mueval --expression '1*100+1' Expression type: (Num t) => t result: "101" bash-3.2$ mueval --expression "filter (\`notElem\` ['A'..'Z']) \"abcXsdzWEE\"" Expression type: [Char] result: "\"abcsdz\"" Note that mueval will avoid all the attacks I've been able to test on it: bash-3.2$ mueval --expression 'let x = x in x' Expression type: t result: "mueval: Time limit exceeded bash-3.2$ mueval --expression "let foo = readFile \"/etc/passwd\" >>= print in foo" Expression type: IO () result: "" bash-3.2$ mueval --module System.IO.Unsafe --expression "let foo = unsafePerformIO readFile \"/etc/passwd\" in foo" mueval: Unknown or untrusted module supplied! Aborting. SUMMARY: Anyway, it's my hope that this will be useful as an example or useful in itself for people endeavouring to fix the lambdabot situation or just in safely running code period. GETTING: You can download mueval at the usual place: . (There will probably be a darcs repository at some point.) ----- TODO: Mueval isn't feature-complete yet. The last thing I want to add is an ability to change the current user to 'mubot', which presumably the user will have set up to have access to next to nothing much like is already often done with daemons, but I haven't been able to figure out how to do this - the only suitable function I've found is 'setUID', and that requires one to be root... -- gwern SHA Fetish Ceridian Eurosat munitions MCI spies 26 M.P.R.I. ISN -------------- 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/20080614/883cac24/attachment.bin From mycatownz at foxbox.lurkingfox.co.uk Sat Jun 14 09:10:05 2008 From: mycatownz at foxbox.lurkingfox.co.uk (Richard) Date: Sat Jun 14 09:02:09 2008 Subject: [Haskell-cafe] Hoogle totally broken? Message-ID: <20080614131005.GA22204@foxbox.lurkingfox.co.uk> It'd seem that (at least the online version of) Hoogle is totally broken and useless. See, for example, the output when looking for: Monad m => m a -> (a -> m b) -> m b (i.e. (>>=)'s type) over at: http://haskell.org/hoogle/?q=Monad+m+%3D>+m+a+->+(a+->+m+b)+->+m+b Data.Generics.Sche... everywhere :: (a -> a) -> a -> a Data.Generics.Sche... everywhere' :: (a -> a) -> a -> a Prelude. ($) :: (a -> b) -> a -> b Prelude. ($!) :: (a -> b) -> a -> b Data.Function. ($) :: (a -> b) -> a -> b Prelude. maybe :: b -> (a -> b) -> Maybe a -> b Data.Maybe. maybe :: b -> (a -> b) -> Maybe a -> b ... and so on. (>>=) isn't there at all!? From byorgey at gmail.com Sat Jun 14 09:14:55 2008 From: byorgey at gmail.com (Brent Yorgey) Date: Sat Jun 14 09:06:59 2008 Subject: [Haskell-cafe] Hoogle totally broken? In-Reply-To: <20080614131005.GA22204@foxbox.lurkingfox.co.uk> References: <20080614131005.GA22204@foxbox.lurkingfox.co.uk> Message-ID: <22fcbd520806140614p53dc3054ib329b53fa58ad1b@mail.gmail.com> On Sat, Jun 14, 2008 at 9:10 AM, Richard wrote: > It'd seem that (at least the online version of) Hoogle is totally broken > and useless. See, for example, the output when looking for: > Monad m => m a -> (a -> m b) -> m b (i.e. (>>=)'s type) > over at: > http://haskell.org/hoogle/?q=Monad+m+%3D>+m+a+->+(a+->+m+b)+->+m+b > > Data.Generics.Sche... everywhere :: (a -> a) -> a -> a > Data.Generics.Sche... everywhere' :: (a -> a) -> a -> a > Prelude. ($) :: (a -> b) -> a -> b > Prelude. ($!) :: (a -> b) -> a -> b > Data.Function. ($) :: (a -> b) -> a -> b > Prelude. maybe :: b -> (a -> b) -> Maybe a -> b > Data.Maybe. maybe :: b -> (a -> b) -> Maybe a -> b > > ... and so on. (>>=) isn't there at all!? > It's well-known that the current version of Hoogle doesn't deal well with type constructors, like the 'm' in your type above. However, you're (we're all) in luck, since Neil Mitchell is working on a new version of Hoogle for GSoC as we speak! =) -Brent -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080614/51d2faf7/attachment.htm From lemming at henning-thielemann.de Sat Jun 14 09:23:28 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sat Jun 14 09:15:36 2008 Subject: [Haskell-cafe] working with Random.randoms In-Reply-To: <4852A281.8000508@enterity.com> References: <4852A281.8000508@enterity.com> Message-ID: On Fri, 13 Jun 2008, Stephen Howard wrote: > Hi List, > > I am a newcomer doing my obligatory struggling with Haskell's type system, > and I've got a nut I've not been able to crack. Given: > > import Random > > random_test :: Int -> String > random_test n = do > g <- getStdGen > take n (randoms g)::String > > I'm expecting that I ought to be able to pass this action an integer and get > back a random string that long (given, not all characters may be printable). If you only need an arbitrary sequence and it is ok for you to get always the same one, you can construct a random generator using mkStdGen. From tom.davie at gmail.com Sat Jun 14 09:23:03 2008 From: tom.davie at gmail.com (Thomas Davie) Date: Sat Jun 14 09:15:46 2008 Subject: [Haskell-cafe] ANN: Topkata In-Reply-To: <87zlpoguqh.fsf@elefant.olsbruecken.local> References: <87zlpoguqh.fsf@elefant.olsbruecken.local> Message-ID: <4B3E7353-F7F2-4D2D-A335-30D2D3883A4A@gmail.com> On 14 Jun 2008, at 12:45, Christoph Bauer wrote: > Hi All, > > Topkata is a simple OpenGL Game written in Haskell. It's not very > advanced. Goal so far is to guide a ball trough an labyrinth to the > opposite corner. The web page shows an screenshot. It's only tested > under Linux. > > http://home.arcor.de/chr_bauer/topkata.html > > Feedback&Patches are welcome. BTW, I had a lot of support in #haskell! Looks awesome, and I completely agree with Niel -- hackage it up! In the mean time -- who knows enough to make ghc target ARM, and get this to link against the iPhone libraries? This would be quite a coup if it could be made to run there! Bob From daniel.is.fischer at web.de Sat Jun 14 09:27:09 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sat Jun 14 09:17:17 2008 Subject: [Haskell-cafe] Hoogle totally broken? In-Reply-To: <20080614131005.GA22204@foxbox.lurkingfox.co.uk> References: <20080614131005.GA22204@foxbox.lurkingfox.co.uk> Message-ID: <200806141527.09196.daniel.is.fischer@web.de> Am Samstag, 14. Juni 2008 15:10 schrieb Richard: > It'd seem that (at least the online version of) Hoogle is totally broken > and useless. See, for example, the output when looking for: > Monad m => m a -> (a -> m b) -> m b (i.e. (>>=)'s type) > over at: > http://haskell.org/hoogle/?q=Monad+m+%3D>+m+a+->+(a+->+m+b)+->+m+b > > Data.Generics.Sche... everywhere :: (a -> a) -> a -> a > Data.Generics.Sche... everywhere' :: (a -> a) -> a -> a > Prelude. ($) :: (a -> b) -> a -> b > Prelude. ($!) :: (a -> b) -> a -> b > Data.Function. ($) :: (a -> b) -> a -> b > Prelude. maybe :: b -> (a -> b) -> Maybe a -> b > Data.Maybe. maybe :: b -> (a -> b) -> Maybe a -> b > > ... and so on. (>>=) isn't there at all!? It's near the bottom of page 4 of the results. hoogle doesn't do an exact search, it reports all "close enough matches", which sometimes is less useful than other times. One great thing about hoogle's notion of 'close enough' is that it includes permutations of parameters, one less good thing is that it's not particularly faithful to type constructors. I think Neil's in the process of writing hoogle 4, which supposedly will be better with such things. However, in spite of hoogle's quirks and shortcomings, if you get used to them, it's a very useful tool already. Cheers, Daniel From ndmitchell at gmail.com Sat Jun 14 09:44:02 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Sat Jun 14 09:36:06 2008 Subject: [Haskell-cafe] Hoogle totally broken? In-Reply-To: <20080614131005.GA22204@foxbox.lurkingfox.co.uk> References: <20080614131005.GA22204@foxbox.lurkingfox.co.uk> Message-ID: <404396ef0806140644i373ced85pd86ce9b16796d650@mail.gmail.com> Hi Richard, > It'd seem that (at least the online version of) Hoogle is totally broken > and useless. To finish your sentance: "when searching for types with higher-kinded type classes". In practice, this usually means Monad and occasionally Functor. > ... and so on. (>>=) isn't there at all!? It is, but its on page 4. That's clearly a bug, and a well known one. I am currently writing Hoogle 4, details can be found here: http://neilmitchell.blogspot.com/2008/04/summer-of-code-2008.html To quote from that page: # Removal of all bugs Hoogle 3 has a number of embarrassing bugs, some of which are not easily fixed. The nastiest of these is to do with monads, which are horribly mistreated. Since I now know the underlying issues which have caused a problem with Hoogle 3, things like higher-kinded type classes can be solved in a more principled manner. So try again in 3 months, and the issue will be gone :-) Thanks Neil From lemming at henning-thielemann.de Sat Jun 14 09:48:26 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sat Jun 14 09:40:30 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: <3d96ac180806091353q6fd8cyc78eb513c8a6c4c5@mail.gmail.com> References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <3d96ac180806091353q6fd8cyc78eb513c8a6c4c5@mail.gmail.com> Message-ID: On Mon, 9 Jun 2008, Sebastian Sylvan wrote: > Another BIG reason: It's impossible to export a whole hierarchy qualified. > I.e it would be neat if the user could write: > > import Graphics.UI.Gtk > > And then have Gtk re-export sub-modules qualified, so you could write > "Button.new", "Window.new" etc. etc. As it stands you have two options: > prefix all the "new" functions with the kind of widget they create > (buttonNew, windowNew), or force the user to add a gazillion qualified > imports. The problem would be again that no one knows, where "Window" comes from. Better would be import Graphics.UI.Gtk (Window, Button, ) Don't know if this extension would be worth the trouble. From lemming at henning-thielemann.de Sat Jun 14 09:48:36 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sat Jun 14 09:40:42 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: <1213036865.15010.448.camel@localhost> References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <200806061412.23585.g9ks157k@acme.softbase.org> <20080607024543.52z9hkmgz4s8o4g8-nwo@webmail.spamcop.net> <87ve0ibt6n.fsf@malde.org> <1213036865.15010.448.camel@localhost> Message-ID: On Mon, 9 Jun 2008, Duncan Coutts wrote: > On Mon, 2008-06-09 at 16:04 +0200, Ketil Malde wrote: > >> And - is there a way to make GHCi use aliased qualification? I find >> my self typing detailed taxonomies all the time there. > > The ghci syntax currently is: > :m Data.Set > wouldn't it be much nicer as: > import Data.Set > then we could have the obvious: > import Data.Set as Set This would be nice! Feature request? From golubovsky at gmail.com Sat Jun 14 10:26:47 2008 From: golubovsky at gmail.com (Dimitry Golubovsky) Date: Sat Jun 14 10:18:50 2008 Subject: [Haskell-cafe] External query interface to HackageDB? Message-ID: Hi, Is there any way to query the latest version of a particular package stored on Hackage, that was successfully built? I mean, not _how_ to do that (I have some ideas that I have to download directory listings, looking for failure logs, etc.), but is there any tool or interface already available that does similar things? Unfortunately, tarfiles provided on Hackage (like 00-index.tar.gz) do not help, e. g. BerkeleyDB failed to build in all three versions, yet its all cabal files are included in the tarball: tar tvf 00-index.tar.gz ... -rw-r--r-- www-data/www-data 1055 2007-04-06 13:03 ./BerkeleyDB/0.1/BerkeleyDB.cabal -rw-r--r-- www-data/www-data 1061 2007-04-06 16:59 ./BerkeleyDB/0.2/BerkeleyDB.cabal -rw-rw-r-- www-data/www-data 1236 2008-01-11 14:42 ./BerkeleyDB/0.3/BerkeleyDB.cabal I remember, in the past, HackageDB was expected to become a database of some sort: is there any database-like backend that would accept queries, other than just parsing Apache dir listings? My final goal, given some master-list of package names, to be able to retrieve latest succesfully built (not just uploaded) releases from Hackage Thanks. -- Dimitry Golubovsky Anywhere on the Web From sebastian.sylvan at gmail.com Sat Jun 14 10:28:21 2008 From: sebastian.sylvan at gmail.com (Sebastian Sylvan) Date: Sat Jun 14 10:20:26 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <3d96ac180806091353q6fd8cyc78eb513c8a6c4c5@mail.gmail.com> Message-ID: <3d96ac180806140728m1061e1bdr43f3a4759554b0b2@mail.gmail.com> On 6/14/08, Henning Thielemann wrote: > > > On Mon, 9 Jun 2008, Sebastian Sylvan wrote: > > Another BIG reason: It's impossible to export a whole hierarchy qualified. >> I.e it would be neat if the user could write: >> >> import Graphics.UI.Gtk >> >> And then have Gtk re-export sub-modules qualified, so you could write >> "Button.new", "Window.new" etc. etc. As it stands you have two options: >> prefix all the "new" functions with the kind of widget they create >> (buttonNew, windowNew), or force the user to add a gazillion qualified >> imports. >> > > The problem would be again that no one knows, where "Window" comes from. > Better would be > I really don't see how this is a big problem. Lots of languages do hierarchical import (e.g. .Net languages) and I don't think I've ever heard anyone complain about this particular aspect of it. The worst case scenario is that you need a little bit of tool support to help you sort it out. Plus, it's not like you can't just qualify the import to make it easier to see where it comes from if you really think it's a problem: import qualified Graphics.UI.GTK as GTK and then use GTK.Button.new etc. -- Sebastian Sylvan +44(0)7857-300802 UIN: 44640862 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080614/67d473e5/attachment.htm From lemming at henning-thielemann.de Sat Jun 14 10:38:33 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sat Jun 14 10:30:39 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: <3d96ac180806140728m1061e1bdr43f3a4759554b0b2@mail.gmail.com> References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <3d96ac180806091353q6fd8cyc78eb513c8a6c4c5@mail.gmail.com> <3d96ac180806140728m1061e1bdr43f3a4759554b0b2@mail.gmail.com> Message-ID: On Sat, 14 Jun 2008, Sebastian Sylvan wrote: > On 6/14/08, Henning Thielemann wrote: >> >> The problem would be again that no one knows, where "Window" comes from. >> Better would be >> > I really don't see how this is a big problem. Lots of languages do > hierarchical import (e.g. .Net languages) and I don't think I've ever heard > anyone complain about this particular aspect of it. It's not a problem for you and thus you do not pay attention to these complaints, I suspect. Maybe the people who would complain about the importing style, simply don't use the mentioned languages. > The worst case scenario is that you need a little bit of tool support to > help you sort it out. Plus, it's not like you can't just qualify the > import to make it easier to see where it comes from if you really think > it's a problem: Cf. http://www.haskell.org/haskellwiki/Import_modules_properly Haskell can re-export modules, which makes tracing identifiers more difficult. I want to be able to read modules without using a tool. From c-bauer-olsbruecken at t-online.de Sat Jun 14 10:53:50 2008 From: c-bauer-olsbruecken at t-online.de (Christoph Bauer) Date: Sat Jun 14 10:45:57 2008 Subject: [Haskell-cafe] ANN: Topkata In-Reply-To: <404396ef0806140350w2eb18cf4n68b7d2f08ece7025@mail.gmail.com> (Neil Mitchell's message of "Sat, 14 Jun 2008 11:50:07 +0100") References: <87zlpoguqh.fsf@elefant.olsbruecken.local> <404396ef0806140350w2eb18cf4n68b7d2f08ece7025@mail.gmail.com> Message-ID: <87ve0cvzi9.fsf@elefant.olsbruecken.local> Hello Neil, > Looks cool! Could you upload it to hackage? Thank you. Ok, I uploaded the current version. At the moment you have to run topkata in the topkata-0.0 directory with ./dist/build/topkata/topkata, because it has to find its texture/sound files. Furthermore I encounter problems (i.e. segmentation faults) on Gentoo with the openal package. But openal-soft-1.4.272 works fine. Christoph Bauer From byorgey at gmail.com Sat Jun 14 11:06:38 2008 From: byorgey at gmail.com (Brent Yorgey) Date: Sat Jun 14 10:58:42 2008 Subject: [Haskell-cafe] ANN: Topkata In-Reply-To: <22fcbd520806140806w33fb2060y9f00b3e6ff0d3daa@mail.gmail.com> References: <87zlpoguqh.fsf@elefant.olsbruecken.local> <404396ef0806140350w2eb18cf4n68b7d2f08ece7025@mail.gmail.com> <87ve0cvzi9.fsf@elefant.olsbruecken.local> <22fcbd520806140806w33fb2060y9f00b3e6ff0d3daa@mail.gmail.com> Message-ID: <22fcbd520806140806y311f4f9ax8aaa42763bb7dc8f@mail.gmail.com> On Sat, Jun 14, 2008 at 10:53 AM, Christoph Bauer < c-bauer-olsbruecken@t-online.de> wrote: > Hello Neil, > > > Looks cool! Could you upload it to hackage? > > Thank you. Ok, I uploaded the current version. At the moment you have > to run topkata in the topkata-0.0 directory with > ./dist/build/topkata/topkata, because it has to find its texture/sound > files. There's a way to put something in the .cabal file about extra data files, and have it install them in a certain location that you can then find programmatically. I forget the details, but I think it's pretty easy to set up. Maybe take a look through the Cabal documentation. Or maybe Duncan will jump in and explain. =) -Brent -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080614/f63e910b/attachment.htm From ndmitchell at gmail.com Sat Jun 14 11:09:13 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Sat Jun 14 11:01:17 2008 Subject: [Haskell-cafe] ANN: Topkata In-Reply-To: <22fcbd520806140806y311f4f9ax8aaa42763bb7dc8f@mail.gmail.com> References: <87zlpoguqh.fsf@elefant.olsbruecken.local> <404396ef0806140350w2eb18cf4n68b7d2f08ece7025@mail.gmail.com> <87ve0cvzi9.fsf@elefant.olsbruecken.local> <22fcbd520806140806w33fb2060y9f00b3e6ff0d3daa@mail.gmail.com> <22fcbd520806140806y311f4f9ax8aaa42763bb7dc8f@mail.gmail.com> Message-ID: <404396ef0806140809x52f28124t4eea5dc78a02ac@mail.gmail.com> Hi > > > Looks cool! Could you upload it to hackage? > > > > Thank you. Ok, I uploaded the current version. At the moment you have > > to run topkata in the topkata-0.0 directory with > > ./dist/build/topkata/topkata, because it has to find its texture/sound > > files. > > There's a way to put something in the .cabal file about extra data files, > and have it install them in a certain location that you can then find > programmatically. I forget the details, but I think it's pretty easy to set http://neilmitchell.blogspot.com/2008/02/adding-data-files-using-cabal.html Thanks Neil From odtaa48 at verizon.net Sat Jun 14 12:14:55 2008 From: odtaa48 at verizon.net (odtaa48) Date: Sat Jun 14 12:07:24 2008 Subject: [Haskell-cafe] const is question Message-ID: <000a01c8ce39$c8e1ad30$0201a8c0@Linus> hello could someone explain the following differing results const id 0 5 -> 5 -- ie. 'takes' the 'last' one const (id 0) 5 -> 0 -- ie. 'takes' the 'first' one Thanks From sfvisser at cs.uu.nl Sat Jun 14 12:18:48 2008 From: sfvisser at cs.uu.nl (Sebastiaan Visser) Date: Sat Jun 14 12:10:55 2008 Subject: [Haskell-cafe] Lazy IO. Message-ID: Hi, I've got a question about lazy IO in Haskell. The most well known function to do lazy IO is the `hGetContents', which lazily reads all the contents from a handle and returns this as a regular [Char]. The thing with hGetContents is that is puts the Handle in a semi-closed state, no one can use the handle anymore. This behaviour is understandable from the point of safety; it is not yet determined when the result of hGetContents will actually be computed, using the handle in the meantime is undesirable. The point is, I think I really have a situation in which I want to use the handle again `after' a call to hGetContents. I think I can best explain this using a code example. readHttpMessage :: IO (Headers, Data.ByteString.Lazy.ByteString) readHttpMessage = do myStream <- request <- hGetContents myStream header <- parseHttpHeader request bs <- Data.ByteString.Lazy.hGetContents myStream return (header, body) The Data.ByteString.Lazy.hGetContents in the example above obviously fails because the handle is semi-closed. So, what I am trying to do here is apply a parser (on that consumes Char's) to the input stream until it has succeeded. After this I want to collect the remainings of the stream in a lazy ByteString, or maybe even something else. I tried to open the handler again using some internal handle hackery, but this failed (luckily). In the module GHC.IO there is a function `lazyRead' that more or less seems to do what I want. But I'll guess there is a good reason for not exporting it. Does anyone know a pattern in which I can do this easily? Thanks, -- Sebastiaan From jake.mcarthur at gmail.com Sat Jun 14 12:22:28 2008 From: jake.mcarthur at gmail.com (Jake Mcarthur) Date: Sat Jun 14 12:14:35 2008 Subject: [Haskell-cafe] const is question In-Reply-To: <000a01c8ce39$c8e1ad30$0201a8c0@Linus> References: <000a01c8ce39$c8e1ad30$0201a8c0@Linus> Message-ID: <9156AEFC-D4ED-4BF8-BB52-C8531B3FA8CB@gmail.com> On Jun 14, 2008, at 11:14 AM, odtaa48 wrote: > const id 0 5 -> 5 -- ie. 'takes' the 'last' one The type of const is a -> b -> a. The first argument to const here is id and the second is 0, so the evaluation of const id 0 is going to result in id. Then we apply id to 5, yielding 5. Perhaps it would be more clear to write the expression is (const id 0) 5. > const (id 0) 5 -> 0 -- ie. 'takes' the 'first' one Here the two arguments to const are (id 0) and 5. Since the effect of const is to toss out the second argument, this evaluates to id 0, which evaluates to simply 0. Does that help? - Jake McArthur From sfvisser at cs.uu.nl Sat Jun 14 12:23:52 2008 From: sfvisser at cs.uu.nl (Sebastiaan Visser) Date: Sat Jun 14 12:15:59 2008 Subject: [Haskell-cafe] const is question In-Reply-To: <000a01c8ce39$c8e1ad30$0201a8c0@Linus> References: <000a01c8ce39$c8e1ad30$0201a8c0@Linus> Message-ID: On Jun 14, 2008, at 6:14 PM, odtaa48 wrote: > hello > could someone explain the following differing results const id 0 > 5 -> 5 -- ie. 'takes' the 'last' one > const (id 0) 5 -> 0 -- ie. 'takes' the 'first' one > > Thanks You can easily see what is happening by rewriting the equations step by step. Remember that the const function is (\x y -> x) and the id function is (\x -> x). Example 1: const id 0 5 == (const id 0) 5 == id 5 == 5 Example 2: const (id 0) 5 == const 0 5 == 0 So, in both cases const takes the first. -- Sebastiaan. From felipe.lessa at gmail.com Sat Jun 14 12:45:23 2008 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sat Jun 14 12:37:32 2008 Subject: [Haskell-cafe] Lazy IO. In-Reply-To: References: Message-ID: (Sorry, Sebastiaan, I hit send accidentally) On Sat, Jun 14, 2008 at 1:18 PM, Sebastiaan Visser wrote: > readHttpMessage :: IO (Headers, Data.ByteString.Lazy.ByteString) > readHttpMessage = do > myStream <- > request <- hGetContents myStream > header <- parseHttpHeader request > bs <- Data.ByteString.Lazy.hGetContents myStream > return (header, body) Why not readHttpMessage = do myStream <- data <- Data.ByteString.Lazy.hGetContents myStream (header, rest) <- parseHttpHeader data return (header, rest) i.e. make parseHttpHeader return the rest of the string it didn't parse? In fact, may I ask why parseHttpHeader is not a pure function? HTH, -- Felipe. From isaacdupree at charter.net Sat Jun 14 12:49:38 2008 From: isaacdupree at charter.net (Isaac Dupree) Date: Sat Jun 14 12:41:40 2008 Subject: [Haskell-cafe] Lazy IO. In-Reply-To: References: Message-ID: <4853F6A2.50103@charter.net> Sebastiaan Visser wrote: > Hi, > > I've got a question about lazy IO in Haskell. The most well known > function to do lazy IO is the `hGetContents', which lazily reads all the > contents from a handle and returns this as a regular [Char]. > > The thing with hGetContents is that is puts the Handle in a semi-closed > state, no one can use the handle anymore. This behaviour is > understandable from the point of safety; it is not yet determined when > the result of hGetContents will actually be computed, using the handle > in the meantime is undesirable. > > The point is, I think I really have a situation in which I want to use > the handle again `after' a call to hGetContents. I think I can best > explain this using a code example. > > readHttpMessage :: IO (Headers, Data.ByteString.Lazy.ByteString) > readHttpMessage = do > myStream <- > request <- hGetContents myStream > header <- parseHttpHeader request > bs <- Data.ByteString.Lazy.hGetContents myStream > return (header, body) that's impure because parseHttpHeader doesn't return anything telling you how much of the stream it's looked at. Maybe it looked ahead more than it needed to, thus deleting part of the body. I was going to suggest, if you can't change parseHttpHeader to use ByteStrings, > bs <- Data.ByteString.Lazy.hGetContents myStream > header <- parseHttpHeader (Data.ByteString.Lazy.unpack bs) but you still have to get parseHttpHeader (or perhaps if it has similar friends) to tell you how much of the string it consumed! I don't know what parsing functions you have available to work with, so I can't tell you whether it's possible. -Isaac From sfvisser at cs.uu.nl Sat Jun 14 12:50:50 2008 From: sfvisser at cs.uu.nl (Sebastiaan Visser) Date: Sat Jun 14 12:42:58 2008 Subject: [Haskell-cafe] Lazy IO. In-Reply-To: References: Message-ID: <679EFD47-4040-4A36-AA7A-78C3CEE41E3D@cs.uu.nl> On Jun 14, 2008, at 6:45 PM, Felipe Lessa wrote: > (Sorry, Sebastiaan, I hit send accidentally) > > On Sat, Jun 14, 2008 at 1:18 PM, Sebastiaan Visser > wrote: >> readHttpMessage :: IO (Headers, Data.ByteString.Lazy.ByteString) >> readHttpMessage = do >> myStream <- >> request <- hGetContents myStream >> header <- parseHttpHeader request >> bs <- Data.ByteString.Lazy.hGetContents myStream >> return (header, body) > > Why not > > readHttpMessage = do > myStream <- > data <- Data.ByteString.Lazy.hGetContents myStream > (header, rest) <- parseHttpHeader data > return (header, rest) > > i.e. make parseHttpHeader return the rest of the string it didn't > parse? Doesn't this imply that the parseHttpHeader must work on ByteStrings instead of regular Strings? Maybe this works for HTTP headers, but sometimes ByteStrings are not appropriate. Especially when you are not using the regular `System.IO.hGetContents' but the `System.IO.UTF8.hGetContents'. > In fact, may I ask why parseHttpHeader is not a pure function? This is not a real-life example. It might as well be a pure function. > HTH, > > -- Felipe. -- Sebastiaan From sfvisser at cs.uu.nl Sat Jun 14 12:59:38 2008 From: sfvisser at cs.uu.nl (Sebastiaan Visser) Date: Sat Jun 14 12:51:46 2008 Subject: [Haskell-cafe] Lazy IO. In-Reply-To: <4853F6A2.50103@charter.net> References: <4853F6A2.50103@charter.net> Message-ID: On Jun 14, 2008, at 6:49 PM, Isaac Dupree wrote: > Sebastiaan Visser wrote: >> Hi, >> I've got a question about lazy IO in Haskell. The most well known >> function to do lazy IO is the `hGetContents', which lazily reads >> all the >> contents from a handle and returns this as a regular [Char]. >> The thing with hGetContents is that is puts the Handle in a semi- >> closed >> state, no one can use the handle anymore. This behaviour is >> understandable from the point of safety; it is not yet determined >> when >> the result of hGetContents will actually be computed, using the >> handle >> in the meantime is undesirable. >> The point is, I think I really have a situation in which I want to >> use >> the handle again `after' a call to hGetContents. I think I can best >> explain this using a code example. >> readHttpMessage :: IO (Headers, Data.ByteString.Lazy.ByteString) >> readHttpMessage = do >> myStream <- >> request <- hGetContents myStream >> header <- parseHttpHeader request >> bs <- Data.ByteString.Lazy.hGetContents myStream >> return (header, body) > > that's impure because parseHttpHeader doesn't return anything > telling you how much of the stream it's looked at. Maybe it looked > ahead more than it needed to, thus deleting part of the body. I > was going to suggest, if you can't change parseHttpHeader to use > ByteStrings, > > > bs <- Data.ByteString.Lazy.hGetContents myStream > > header <- parseHttpHeader (Data.ByteString.Lazy.unpack bs) > > but you still have to get parseHttpHeader (or perhaps if it has > similar friends) to tell you how much of the string it consumed! I > don't know what parsing functions you have available to work with, > so I can't tell you whether it's possible. It is a regular Parsec parser and I am pretty sure it does not consume anything other than the header itself. Maybe I could rewrite my parser to work on Word8's instead of Char's, I don't think HTTP even allows Unicode characters within HTTP headers. Thanks. I think I'll try this. But I'm still curious about how to lazily parse messages with arbitrary size Unicode headers and plain (possibly) binary bodies. > -Isaac -- Sebastiaan. From felipe.lessa at gmail.com Sat Jun 14 13:16:56 2008 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sat Jun 14 13:09:00 2008 Subject: [Haskell-cafe] Lazy IO. In-Reply-To: <679EFD47-4040-4A36-AA7A-78C3CEE41E3D@cs.uu.nl> References: <679EFD47-4040-4A36-AA7A-78C3CEE41E3D@cs.uu.nl> Message-ID: On Sat, Jun 14, 2008 at 1:50 PM, Sebastiaan Visser wrote: > Doesn't this imply that the parseHttpHeader must work on ByteStrings instead > of regular Strings? I made the change because it's easier and faster to go from ByteString to String than the converse. > Maybe this works for HTTP headers, but sometimes > ByteStrings are not appropriate. Especially when you are not using the > regular `System.IO.hGetContents' but the `System.IO.UTF8.hGetContents'. You may use the package encoding instead, take a look at [1]. It will decode a lazy ByteString into a String. In your HTTP parsing example, you could break the ByteString on "\r\n\r\n" and then decodeLazy only the first part, while returning the second without modifying it. [1] http://hackage.haskell.org/packages/archive/encoding/0.4.1/doc/html/Data-Encoding.html#v%3AdecodeLazy -- Felipe. From allbery at ece.cmu.edu Sat Jun 14 13:19:39 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sat Jun 14 13:11:44 2008 Subject: [Haskell-cafe] Lazy IO. In-Reply-To: References: <4853F6A2.50103@charter.net> Message-ID: <02813790-FD5F-4422-8EF7-CBB5C3121136@ece.cmu.edu> On 2008 Jun 14, at 12:59, Sebastiaan Visser wrote: > But I'm still curious about how to lazily parse messages with > arbitrary size Unicode headers and plain (possibly) binary bodies. Sounds like Data.Binary (see hackage) to me. -- 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 sfvisser at cs.uu.nl Sat Jun 14 13:27:58 2008 From: sfvisser at cs.uu.nl (Sebastiaan Visser) Date: Sat Jun 14 13:20:07 2008 Subject: [Haskell-cafe] Lazy IO. In-Reply-To: References: <679EFD47-4040-4A36-AA7A-78C3CEE41E3D@cs.uu.nl> Message-ID: <9C183730-3244-49BA-BAE0-49D49716C976@cs.uu.nl> On Jun 14, 2008, at 7:16 PM, Felipe Lessa wrote: > On Sat, Jun 14, 2008 at 1:50 PM, Sebastiaan Visser > wrote: >> Doesn't this imply that the parseHttpHeader must work on >> ByteStrings instead >> of regular Strings? > > I made the change because it's easier and faster to go from ByteString > to String than the converse. > >> Maybe this works for HTTP headers, but sometimes >> ByteStrings are not appropriate. Especially when you are not using >> the >> regular `System.IO.hGetContents' but the >> `System.IO.UTF8.hGetContents'. > > You may use the package encoding instead, take a look at [1]. It will > decode a lazy ByteString into a String. In your HTTP parsing example, > you could break the ByteString on "\r\n\r\n" and then decodeLazy only > the first part, while returning the second without modifying it. Sounds interesting. This could indeed solve (a part of) my problem. The thing is, when decoding the header - in my web server architecture - it is not yet clear what should be done be the body. Some `handlers' may want to have it as a String, UTF8 String, ByteString or may not even need it at all. > [1] http://hackage.haskell.org/packages/archive/encoding/0.4.1/doc/ > html/Data-Encoding.html#v%3AdecodeLazy Because HTTP headers are line based and the parser does not need any look ahead - the first "\r\n\r\n" is the header delimiter - it might be possible to use the hGetLine for the headers. After this I am still `free' to decide what to do for the body: System.IO.hGetContents, System.IO.UTF8.hGetContents, Data.ByteString.Lazy.hGetContents, hClose, etc... > -- Felipe. Thanks, Sebastiaan. From sebastian.sylvan at gmail.com Sat Jun 14 13:38:27 2008 From: sebastian.sylvan at gmail.com (Sebastian Sylvan) Date: Sat Jun 14 13:30:33 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <3d96ac180806091353q6fd8cyc78eb513c8a6c4c5@mail.gmail.com> <3d96ac180806140728m1061e1bdr43f3a4759554b0b2@mail.gmail.com> Message-ID: <3d96ac180806141038k46ea8058v60f8d78f59bc6a81@mail.gmail.com> On 6/14/08, Henning Thielemann wrote: > > > On Sat, 14 Jun 2008, Sebastian Sylvan wrote: > > On 6/14/08, Henning Thielemann wrote: >> >>> >>> The problem would be again that no one knows, where "Window" comes from. >>> Better would be >>> >>> I really don't see how this is a big problem. Lots of languages do >> hierarchical import (e.g. .Net languages) and I don't think I've ever >> heard >> anyone complain about this particular aspect of it. >> > > It's not a problem for you and thus you do not pay attention to these > complaints, I suspect. Maybe the people who would complain about the > importing style, simply don't use the mentioned languages. > >> The worst case scenario is that you need a little bit of tool support to >> help you sort it out. Plus, it's not like you can't just qualify the import >> to make it easier to see where it comes from if you really think it's a >> problem: >> > > Cf. > http://www.haskell.org/haskellwiki/Import_modules_properly > > Haskell can re-export modules, which makes tracing identifiers more > difficult. I want to be able to read modules without using a tool. > I'm not sure I understand you point. You're so opposed to the *option* of allowing hierarchical exports (even though you can still import it qualified if you personally like having to specify at each callsite exactly where some identifier is coming from), that you'd rather any library making use of a module hierarchy is forced to either make the user add dozens of boilerplate import statements (with "qualified" and "as") or the more common strategy of prefixing each function call with the module name (buttonNew)? To me a module system that requires the latter in practice is horribly broken, and I'm suggesting a low-impact way of fixing it. It may not be the best system available, but it's a tiny extension of the current. I really don't see why adding this option hurts you, when it clearly helps enable doing what this thread advocates (use qualified modules to distinguish between functions of the same name, rather than adding a bunch of prefixes/suffixes to the functions). -- Sebastian Sylvan +44(0)7857-300802 UIN: 44640862 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080614/cd36a38b/attachment.htm From lemming at henning-thielemann.de Sat Jun 14 13:53:48 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sat Jun 14 13:45:53 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: <3d96ac180806141038k46ea8058v60f8d78f59bc6a81@mail.gmail.com> References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <3d96ac180806091353q6fd8cyc78eb513c8a6c4c5@mail.gmail.com> <3d96ac180806140728m1061e1bdr43f3a4759554b0b2@mail.gmail.com> <3d96ac180806141038k46ea8058v60f8d78f59bc6a81@mail.gmail.com> Message-ID: On Sat, 14 Jun 2008, Sebastian Sylvan wrote: > On 6/14/08, Henning Thielemann wrote: >> >> >> On Sat, 14 Jun 2008, Sebastian Sylvan wrote: >> >> On 6/14/08, Henning Thielemann wrote: >>> >>>> >>>> The problem would be again that no one knows, where "Window" comes from. >>>> Better would be >>>> >>>> I really don't see how this is a big problem. Lots of languages do >>> hierarchical import (e.g. .Net languages) and I don't think I've ever >>> heard >>> anyone complain about this particular aspect of it. >>> >> >> It's not a problem for you and thus you do not pay attention to these >> complaints, I suspect. Maybe the people who would complain about the >> importing style, simply don't use the mentioned languages. >> >>> The worst case scenario is that you need a little bit of tool support to >>> help you sort it out. Plus, it's not like you can't just qualify the import >>> to make it easier to see where it comes from if you really think it's a >>> problem: >>> >> >> Cf. >> http://www.haskell.org/haskellwiki/Import_modules_properly >> >> Haskell can re-export modules, which makes tracing identifiers more >> difficult. I want to be able to read modules without using a tool. >> > > I'm not sure I understand you point. You're so opposed to the *option* of > allowing hierarchical exports (even though you can still import it qualified > if you personally like having to specify at each callsite exactly where some > identifier is coming from), I was concerned with the _import_ part of your proposal. (I haven't thought about the export part so far.) > that you'd rather any library making use of a module hierarchy is forced > to either make the user add dozens of boilerplate import statements > (with "qualified" and "as") or the more common strategy of prefixing > each function call with the module name (buttonNew)? To me a module > system that requires the latter in practice is horribly broken, and I'm > suggesting a low-impact way of fixing it. It may not be the best system > available, but it's a tiny extension of the current. > > I really don't see why adding this option hurts you, when it clearly helps > enable doing what this thread advocates (use qualified modules to > distinguish between functions of the same name, rather than adding a bunch > of prefixes/suffixes to the functions). Button.new is my favorite, because with current import variants I can easily lookup, what Button and Button.new refer to. I understand your proposal in that way that import Graphics.UI.Gtk brings module qualifications Window and Button into scope although they are not explicitly mentioned. Thus I could no longer find out easily what Butten.new means. From marco-oweber at gmx.de Sat Jun 14 14:08:28 2008 From: marco-oweber at gmx.de (Marc Weber) Date: Sat Jun 14 14:00:33 2008 Subject: [Haskell-cafe] ANN: Printf-TH Message-ID: <20080614180828.GA27701@gmx.de> Igloo (Ian Lynagh) allowed me kindly taking over maintainance on his printf library using template haskell written in 2003. I've updated it so that it compiles with ghc-6.8.2. You can get it from hackage: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Printf-TH usage looks like this: {-# OPTIONS_GHC -XTemplateHaskell #-} ... import Language.Haskell.TH.Syntax import Text.Printf.TH (printf) ... putStrLn $ $(printf "Foo %H bar") (Just 5) putStrLn $ $(printf "%6d") 1 putStrLn $ $(printf "%6d") (-1) Short Explanation: $(printf "%d") will be replaced by a auto generated function taking an int etc Benefit: Wrong arg types or wrong printf arg count will result in compile time errors. Enjoy Marc Weber From sebastian.sylvan at gmail.com Sat Jun 14 14:21:40 2008 From: sebastian.sylvan at gmail.com (Sebastian Sylvan) Date: Sat Jun 14 14:13:44 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <3d96ac180806091353q6fd8cyc78eb513c8a6c4c5@mail.gmail.com> <3d96ac180806140728m1061e1bdr43f3a4759554b0b2@mail.gmail.com> <3d96ac180806141038k46ea8058v60f8d78f59bc6a81@mail.gmail.com> Message-ID: <3d96ac180806141121k2c388ed4pd9f960bda540d45f@mail.gmail.com> On 6/14/08, Henning Thielemann wrote: > > > On Sat, 14 Jun 2008, Sebastian Sylvan wrote: > > On 6/14/08, Henning Thielemann wrote: >> >>> >>> >>> On Sat, 14 Jun 2008, Sebastian Sylvan wrote: >>> >>> On 6/14/08, Henning Thielemann wrote: >>> >>>> >>>> >>>>> The problem would be again that no one knows, where "Window" comes >>>>> from. >>>>> Better would be >>>>> >>>>> I really don't see how this is a big problem. Lots of languages do >>>>> >>>> hierarchical import (e.g. .Net languages) and I don't think I've ever >>>> heard >>>> anyone complain about this particular aspect of it. >>>> >>>> >>> It's not a problem for you and thus you do not pay attention to these >>> complaints, I suspect. Maybe the people who would complain about the >>> importing style, simply don't use the mentioned languages. >>> >>> The worst case scenario is that you need a little bit of tool support to >>>> help you sort it out. Plus, it's not like you can't just qualify the >>>> import >>>> to make it easier to see where it comes from if you really think it's a >>>> problem: >>>> >>>> >>> Cf. >>> http://www.haskell.org/haskellwiki/Import_modules_properly >>> >>> Haskell can re-export modules, which makes tracing identifiers more >>> difficult. I want to be able to read modules without using a tool. >>> >>> >> I'm not sure I understand you point. You're so opposed to the *option* of >> allowing hierarchical exports (even though you can still import it >> qualified >> if you personally like having to specify at each callsite exactly where >> some >> identifier is coming from), >> > > I was concerned with the _import_ part of your proposal. (I haven't thought > about the export part so far.) > > that you'd rather any library making use of a module hierarchy is forced >> to either make the user add dozens of boilerplate import statements (with >> "qualified" and "as") or the more common strategy of prefixing each function >> call with the module name (buttonNew)? To me a module system that requires >> the latter in practice is horribly broken, and I'm suggesting a low-impact >> way of fixing it. It may not be the best system available, but it's a tiny >> extension of the current. >> >> I really don't see why adding this option hurts you, when it clearly helps >> enable doing what this thread advocates (use qualified modules to >> distinguish between functions of the same name, rather than adding a bunch >> of prefixes/suffixes to the functions). >> > > Button.new is my favorite, because with current import variants I can > easily lookup, what Button and Button.new refer to. I understand your > proposal in that way that > > import Graphics.UI.Gtk > > brings module qualifications Window and Button into scope although they are > not explicitly mentioned. Thus I could no longer find out easily what > Butten.new means. > I don't see why this is so bad when it's exactly what we have for other identifiers? E.g. if you import Control.Monad you get mapM, but you can't really say for sure where this identifier comes from, which is no better than not knowing where "Button.new" comes from. In both cases you have the option to qualify the module import so you have to say "Monad.mapM" or "GTK.Button.new" which makes it more apparent. I suppose you would make the "hiding" clause and the "import list" thing work with modules too for consistency, so if you really wanted to you could list the modules/identifiers that you bring in. Are you saying that you prefer the situation where to use GTK the user would have to explicitly import every single sub-module in the hierarchy ("import qualified Graphics.UI.GTK.X as X" where X = {Button,Window, ... etc})? I don't think that's very nice at all, and I certainly don't like having to add the module name to the functions... I think lots of libraries are like that, and we need some mechanism of importing lots of related modules together so that they come in qualified, without forcing the user to write a gazillion lines of boilerplate import statements.. I think that if GTK did use this system (rather than append the module name to the function and export them "flatly") a lot of people would resort to ugly hacks like putting the import statements in a file somewhere and using the C preprocessor to include it, yuck! (OTOH this may be just what's required to convince everyone that we need to improve the module system)... -- Sebastian Sylvan +44(0)7857-300802 UIN: 44640862 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080614/60df56e6/attachment.htm From andrewcoppin at btinternet.com Sat Jun 14 14:58:07 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sat Jun 14 15:25:25 2008 Subject: [Haskell-cafe] Documenting the impossible Message-ID: <485414BF.30307@btinternet.com> I have a small idea. I'm curios if anybody else thinks it's a good idea... How about a {-# IMPOSSIBLE #-} pragma that documents the fact that a particular point in the program *should* be unreachable? For example, you look up a key in a Map. You know the key is there, because you just put it there yourself two seconds ago. But, theoretically, lookup returns a Maybe x so - theoretically - it's possible it might return Nothing. No matter what you do, GHC will insert code to check whether we have Just x or Nothing, and in the Nothing case throw an exception. Obviously there is no way in hell this code path can ever be executed. At least, assuming your code isn't broken... This is where the pragma comes in. The idea is that you write something like case lookup k m of Just v -> process v Nothing -> {-# IMPOSSIBLE "lookup in step 3" #-} When compiled without optimisations, the pragma just causes an exception to be thrown, rather like "error" does. When compiled with optimisations, the whole case alternative is removed, and no code is generated for it. (And if the impossible somehow happens... behaviour is undefined.) So you test your program with your code compiled unoptimised, and when you're "sure" the impossible can't happen, you tell the compiler to remove the check for it. (Actually, it would possibly be a good idea to have a switch to turn this on and off seperately if needed...) Does anybody think this is a useful idea? If so I'll add a feature request ticket to the GHC Trac. But I want to see if folks like the idea first... (I was thinking the message in the pragma would be what gets displayed on screen, along with some auto-generated location info. Just a module name and line number ought to be sufficient...) From derek.a.elkins at gmail.com Sat Jun 14 15:47:00 2008 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Sat Jun 14 15:39:10 2008 Subject: [Haskell-cafe] Documenting the impossible In-Reply-To: <485414BF.30307@btinternet.com> References: <485414BF.30307@btinternet.com> Message-ID: <1213472820.5557.1.camel@derek-laptop> On Sat, 2008-06-14 at 19:58 +0100, Andrew Coppin wrote: > I have a small idea. I'm curios if anybody else thinks it's a good idea... > > How about a {-# IMPOSSIBLE #-} pragma that documents the fact that a > particular point in the program *should* be unreachable? > > For example, you look up a key in a Map. You know the key is there, > because you just put it there yourself two seconds ago. But, > theoretically, lookup returns a Maybe x so - theoretically - it's > possible it might return Nothing. No matter what you do, GHC will insert > code to check whether we have Just x or Nothing, and in the Nothing case > throw an exception. > > Obviously there is no way in hell this code path can ever be executed. > At least, assuming your code isn't broken... This is where the pragma > comes in. The idea is that you write something like > > case lookup k m of > Just v -> process v > Nothing -> {-# IMPOSSIBLE "lookup in step 3" #-} > > When compiled without optimisations, the pragma just causes an exception > to be thrown, rather like "error" does. When compiled with > optimisations, the whole case alternative is removed, and no code is > generated for it. (And if the impossible somehow happens... behaviour is > undefined.) So you test your program with your code compiled > unoptimised, and when you're "sure" the impossible can't happen, you > tell the compiler to remove the check for it. (Actually, it would > possibly be a good idea to have a switch to turn this on and off > seperately if needed...) > > Does anybody think this is a useful idea? If so I'll add a feature > request ticket to the GHC Trac. But I want to see if folks like the idea > first... > I think it's a horrible idea. From lemming at henning-thielemann.de Sat Jun 14 15:52:25 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sat Jun 14 15:44:29 2008 Subject: [Haskell-cafe] Documenting the impossible In-Reply-To: <485414BF.30307@btinternet.com> References: <485414BF.30307@btinternet.com> Message-ID: On Sat, 14 Jun 2008, Andrew Coppin wrote: > How about a {-# IMPOSSIBLE #-} pragma that documents the fact that a > particular point in the program *should* be unreachable? > ... > When compiled without optimisations, the pragma just causes an exception to > be thrown, rather like "error" does. When compiled with optimisations, the > whole case alternative is removed, and no code is generated for it. (And if > the impossible somehow happens... behaviour is undefined.) So you test your > program with your code compiled unoptimised, and when you're "sure" the > impossible can't happen, you tell the compiler to remove the check for it. > (Actually, it would possibly be a good idea to have a switch to turn this on > and off seperately if needed...) I think it is another instance of mixing up errors and exceptions (you know the haskellwiki pages ...) Since an 'error' marks a programming error (which should never occur) it would not hurt the program if all 'error's are replaced by 'undefined', an illegal memory access or any other misbehaviour. So 'error' is exactly what you propose as IMPOSSIBLE pragma. A compiler option for replacing all 'error's by nops would do want you want. From thomas.dubuisson at gmail.com Sat Jun 14 15:53:13 2008 From: thomas.dubuisson at gmail.com (Thomas M. DuBuisson) Date: Sat Jun 14 15:46:40 2008 Subject: [Haskell-cafe] Documenting the impossible In-Reply-To: <485414BF.30307@btinternet.com> References: <485414BF.30307@btinternet.com> Message-ID: <1213473193.3124.20.camel@localhost.localdomain> I think when Andy made HPC he added a way to mark code unreachable so it wouldn't "harm" your test coverage report. On Sat, 2008-06-14 at 19:58 +0100, Andrew Coppin wrote: > I have a small idea. I'm curios if anybody else thinks it's a good idea... > > How about a {-# IMPOSSIBLE #-} pragma that documents the fact that a > particular point in the program *should* be unreachable? > > For example, you look up a key in a Map. You know the key is there, > because you just put it there yourself two seconds ago. But, > theoretically, lookup returns a Maybe x so - theoretically - it's > possible it might return Nothing. No matter what you do, GHC will insert > code to check whether we have Just x or Nothing, and in the Nothing case > throw an exception. > > Obviously there is no way in hell this code path can ever be executed. > At least, assuming your code isn't broken... This is where the pragma > comes in. The idea is that you write something like > > case lookup k m of > Just v -> process v > Nothing -> {-# IMPOSSIBLE "lookup in step 3" #-} > > When compiled without optimisations, the pragma just causes an exception > to be thrown, rather like "error" does. When compiled with > optimisations, the whole case alternative is removed, and no code is > generated for it. (And if the impossible somehow happens... behaviour is > undefined.) So you test your program with your code compiled > unoptimised, and when you're "sure" the impossible can't happen, you > tell the compiler to remove the check for it. (Actually, it would > possibly be a good idea to have a switch to turn this on and off > seperately if needed...) > > Does anybody think this is a useful idea? If so I'll add a feature > request ticket to the GHC Trac. But I want to see if folks like the idea > first... > > (I was thinking the message in the pragma would be what gets displayed > on screen, along with some auto-generated location info. Just a module > name and line number ought to be sufficient...) > > _______________________________________________ > 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: 197 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080614/3ff4acbd/attachment.bin From dons at galois.com Sat Jun 14 15:56:11 2008 From: dons at galois.com (Don Stewart) Date: Sat Jun 14 15:48:23 2008 Subject: [Haskell-cafe] Documenting the impossible In-Reply-To: <485414BF.30307@btinternet.com> References: <485414BF.30307@btinternet.com> Message-ID: <20080614195611.GA30515@scytale.galois.com> andrewcoppin: > I have a small idea. I'm curios if anybody else thinks it's a good idea... > > How about a {-# IMPOSSIBLE #-} pragma that documents the fact that a > particular point in the program *should* be unreachable? > > For example, you look up a key in a Map. You know the key is there, > because you just put it there yourself two seconds ago. But, > theoretically, lookup returns a Maybe x so - theoretically - it's > possible it might return Nothing. No matter what you do, GHC will insert > code to check whether we have Just x or Nothing, and in the Nothing case > throw an exception. > > Obviously there is no way in hell this code path can ever be executed. > At least, assuming your code isn't broken... This is where the pragma > comes in. The idea is that you write something like > > case lookup k m of > Just v -> process v > Nothing -> {-# IMPOSSIBLE "lookup in step 3" #-} You could try using an 'assert' , which has the property of being compiled out at higher optimisation levels. And you can use 'error' or 'undefined' for undefined behaviour. http://www.haskell.org/ghc/docs/latest/html/users_guide/assertions.html Not very Haskelly though. -- Don From dons at galois.com Sat Jun 14 16:06:05 2008 From: dons at galois.com (Don Stewart) Date: Sat Jun 14 15:58:12 2008 Subject: [Haskell-cafe] ANN: Topkata In-Reply-To: <4B3E7353-F7F2-4D2D-A335-30D2D3883A4A@gmail.com> References: <87zlpoguqh.fsf@elefant.olsbruecken.local> <4B3E7353-F7F2-4D2D-A335-30D2D3883A4A@gmail.com> Message-ID: <20080614200605.GB30515@scytale.galois.com> tom.davie: > On 14 Jun 2008, at 12:45, Christoph Bauer wrote: > > >Hi All, > > > >Topkata is a simple OpenGL Game written in Haskell. It's not very > >advanced. Goal so far is to guide a ball trough an labyrinth to the > >opposite corner. The web page shows an screenshot. It's only tested > >under Linux. > > > >http://home.arcor.de/chr_bauer/topkata.html > > > >Feedback&Patches are welcome. BTW, I had a lot of support in #haskell! > > Looks awesome, and I completely agree with Niel -- hackage it up! > > In the mean time -- who knows enough to make ghc target ARM, and get > this to link against the iPhone libraries? This would be quite a coup > if it could be made to run there! I'd be interested. We should start a wiki page for Haskell on the iphone.. -- Don From ndmitchell at gmail.com Sat Jun 14 16:29:09 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Sat Jun 14 16:21:12 2008 Subject: [Haskell-cafe] Documenting the impossible In-Reply-To: <485414BF.30307@btinternet.com> References: <485414BF.30307@btinternet.com> Message-ID: <404396ef0806141329w36c54982r1e3c38820894f47d@mail.gmail.com> Hi > How about a {-# IMPOSSIBLE #-} pragma that documents the fact that a > particular point in the program *should* be unreachable? Why not make it a function taking a string and returning a value of any type. Then we can keep our language and not break various parsing/type checking properties and rules on pragmas. We can even define it: impossible = error Now you can use tools like Catch and Reach to ensure it is impossible. I think it would be nice to distinguish between: * error - inserted by the compiler * impossible - the programmer knows this can't occur * abort - deliberate aborting because the user made some mistake. The safe library provides abort already. Thanks Neil From marco-oweber at gmx.de Sat Jun 14 16:58:32 2008 From: marco-oweber at gmx.de (Marc Weber) Date: Sat Jun 14 16:50:40 2008 Subject: [Haskell-cafe] Documenting the impossible In-Reply-To: <485414BF.30307@btinternet.com> References: <485414BF.30307@btinternet.com> Message-ID: <20080614205832.GB25415@gmx.de> > Does anybody think this is a useful idea? If so I'll add a feature request > ticket to the GHC Trac. But I want to see if folks like the idea first... Mmmh.. dont' know. Even Java folks don't allow this kind of creeping bug and I guess they know why. You never want undefined behaviour at least when using haskell. Because if that error occurs it's hard to debug, no I don't like that at all. May I look at your proposal from another view? Am I right that you ask for not having to run the "fromJust" code to save some cpu cycles? Very simple example : let list = [ (a,a*a) | a <- [1..10] ] in .. Now getting the square of 4 (standard) fromJust $ lookup 4 list Removing the fromJust code thingy leads to: lookupGoodFaith key ((x,v):xs) | key == x = v | otherwise = lookupGoodFaith xs lookupGoodFaith _ (_,v) = v Where is the difference? I don't even compare the key of the last list item, because it must match. So you safe some additional cpu cycles.. The same can be implemented for Data.Map etc.. Marc Weber From lemming at henning-thielemann.de Sat Jun 14 17:01:28 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sat Jun 14 16:54:17 2008 Subject: [Haskell-cafe] Documenting the impossible In-Reply-To: <404396ef0806141329w36c54982r1e3c38820894f47d@mail.gmail.com> References: <485414BF.30307@btinternet.com> <404396ef0806141329w36c54982r1e3c38820894f47d@mail.gmail.com> Message-ID: On Sat, 14 Jun 2008, Neil Mitchell wrote: > Hi > >> How about a {-# IMPOSSIBLE #-} pragma that documents the fact that a >> particular point in the program *should* be unreachable? > > Why not make it a function taking a string and returning a value of > any type. Then we can keep our language and not break various > parsing/type checking properties and rules on pragmas. We can even > define it: > > impossible = error > > Now you can use tools like Catch and Reach to ensure it is impossible. > > I think it would be nice to distinguish between: > > * error - inserted by the compiler Example? > * impossible - the programmer knows this can't occur This is an error. However the programmer adds a message because he might be wrong. > * abort - deliberate aborting because the user made some mistake. This is an exception. The signature of a function must reflect this by a Maybe, Either type etc. http://www.haskell.org/haskellwiki/Exception http://www.haskell.org/haskellwiki/Error From marco-oweber at gmx.de Sat Jun 14 17:06:26 2008 From: marco-oweber at gmx.de (Marc Weber) Date: Sat Jun 14 16:58:31 2008 Subject: [Haskell-cafe] Template Haskell sugar / spliceing in automatically ? Message-ID: <20080614210626.GC25415@gmx.de> Hi, I've been thinking about template haskell sugar lately. Some cool libraries are there such as metaHDBC or the template haskell printf library. However they all have one thing in common: $(printf "...") a b c $(runStmt "INSERT INTO ( ) VALUES ( ?, ?, ? )" ) 2 3 4 Would it make sense to automatically splice those functions? {-# auto-splice: runStmt, printf #-} So that you can just use printf "..." a b c and runStmt "INSERT INTO ( ) VALUES ( ?, ?, ? )" 2 3 4 without $() ? Would this be convinient? Marc Weber From ndmitchell at gmail.com Sat Jun 14 17:16:49 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Sat Jun 14 17:08:53 2008 Subject: [Haskell-cafe] Documenting the impossible In-Reply-To: References: <485414BF.30307@btinternet.com> <404396ef0806141329w36c54982r1e3c38820894f47d@mail.gmail.com> Message-ID: <404396ef0806141416t2d4ce383n4ee3b72a31256400@mail.gmail.com> Hi > > * error - inserted by the compiler > > Example? Pattern-match errors. > > * abort - deliberate aborting because the user made some mistake. > > This is an exception. The signature of a function must reflect this by a > Maybe, Either type etc. Disagree. I mean more like: when (Delete `elem` flags && Keep `elem` flags) $ abort "User cannot pick both keep and delete on the command line" Think "die" in Perl world. Thanks Neil From lemming at henning-thielemann.de Sat Jun 14 17:40:25 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sat Jun 14 17:32:28 2008 Subject: [Haskell-cafe] Documenting the impossible In-Reply-To: <404396ef0806141416t2d4ce383n4ee3b72a31256400@mail.gmail.com> References: <485414BF.30307@btinternet.com> <404396ef0806141329w36c54982r1e3c38820894f47d@mail.gmail.com> <404396ef0806141416t2d4ce383n4ee3b72a31256400@mail.gmail.com> Message-ID: On Sat, 14 Jun 2008, Neil Mitchell wrote: > Hi > >>> * error - inserted by the compiler >> >> Example? > > Pattern-match errors. Calling a function with patterns it cannot process is a programming error. >>> * abort - deliberate aborting because the user made some mistake. >> >> This is an exception. The signature of a function must reflect this by a >> Maybe, Either type etc. > > Disagree. I mean more like: > > when (Delete `elem` flags && Keep `elem` flags) $ > abort "User cannot pick both keep and delete on the command line" > > Think "die" in Perl world. I wouldn't use such a function, because it does not scale. E.g. I cannot code a loop which lets the user enter flags until they match the conditions. Thus instead of 'abort' I would throw an exception - which is equivalent to the use of an exceptional value like Nothing or Left in Haskell (maybe wrapped in ErrorT). From phercek at gmail.com Sat Jun 14 18:12:26 2008 From: phercek at gmail.com (Peter Hercek) Date: Sat Jun 14 18:04:40 2008 Subject: [Haskell-cafe] Re: Documenting the impossible In-Reply-To: <485414BF.30307@btinternet.com> References: <485414BF.30307@btinternet.com> Message-ID: Andrew Coppin wrote: <-- cut --> > When compiled without optimisations, the pragma just causes an exception > to be thrown, rather like "error" does. When compiled with > optimisations, the whole case alternative is removed, and no code is > generated for it. (And if the impossible somehow happens... behaviour is > undefined.) So if the compiler optimizes otherwise well you save how much? Something like: * one load from cache (since the next is the pointer which will be needed anyway later and moreover it was created just few insturctions before); almost always should be in L1; so lets say 2 or 3 ticks; moreover this applies only when you do not tag pointers (which can be done for Maybe) * run test instruction on it; 1 tick * conditional jump; should be doable so that it is predicted correctly by default - so you get 1 tick here probably too So you want to save somewhere about 2 to 5 ticks (which with a bit of luck can be shared with other instructions) but you get unsafe execution. Does not sound right to me. There should be other optimizations which can be done and which save more. If it is ever done I hope it will be possible to switch it off. Or the compiler must prove that what I think is impossible is really impossible and then it can do it :-D Peter. From derek.a.elkins at gmail.com Sat Jun 14 19:24:26 2008 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Sat Jun 14 19:16:44 2008 Subject: [Haskell-cafe] Template Haskell sugar / spliceing in automatically ? In-Reply-To: <20080614210626.GC25415@gmx.de> References: <20080614210626.GC25415@gmx.de> Message-ID: <1213485866.5557.8.camel@derek-laptop> On Sat, 2008-06-14 at 23:06 +0200, Marc Weber wrote: > Hi, I've been thinking about template haskell sugar lately. > > Some cool libraries are there such as metaHDBC or the template haskell > printf library. > > However they all have one thing in common: > > $(printf "...") a b c > > $(runStmt "INSERT INTO ( ) VALUES ( ?, ?, ? )" ) 2 3 4 > > > Would it make sense to automatically splice those functions? > > {-# auto-splice: runStmt, printf #-} > > So that you can just use > printf "..." a b c > and > runStmt "INSERT INTO ( ) VALUES ( ?, ?, ? )" 2 3 4 > without $() ? > > Would this be convinient? I've been iffy about this since TH was first created. It would certainly be more convenient, but it starts running into some unpleasant issues. Admittedly, most of these issues are issues of expectations, but still. One example from the CL/Scheme world, is that these macros wouldn't be proper functions, so e.g. 'map printf' wouldn't work or wouldn't mean the same thing, 'let formatString = "%s" in printf formatString' wouldn't work or wouldn't mean the same thing (thus being a violation of referential transparency, at least at a superficial level). Let's say we have a function 'mydo' that turns an applicative expression into one using monadic style. Then something like foo = runState (mydo (inc + inc)) 0 brings back some of the issues of programming in an impure language. Currently, I'm still leaning toward the more explicit syntax. From isaacdupree at charter.net Sat Jun 14 19:29:43 2008 From: isaacdupree at charter.net (Isaac Dupree) Date: Sat Jun 14 19:21:59 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: <3d96ac180806141121k2c388ed4pd9f960bda540d45f@mail.gmail.com> References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <3d96ac180806091353q6fd8cyc78eb513c8a6c4c5@mail.gmail.com> <3d96ac180806140728m1061e1bdr43f3a4759554b0b2@mail.gmail.com> <3d96ac180806141038k46ea8058v60f8d78f59bc6a81@mail.gmail.com> <3d96ac180806141121k2c388ed4pd9f960bda540d45f@mail.gmail.com> Message-ID: <48545467.7080209@charter.net> Sebastian Sylvan wrote: > On 6/14/08, Henning Thielemann wrote: >> >> On Sat, 14 Jun 2008, Sebastian Sylvan wrote: >> >> On 6/14/08, Henning Thielemann wrote: >>>> >>>> On Sat, 14 Jun 2008, Sebastian Sylvan wrote: >>>> >>>> On 6/14/08, Henning Thielemann wrote: >>>> >>>>> >>>>>> The problem would be again that no one knows, where "Window" comes >>>>>> from. >>>>>> Better would be >>>>>> >>>>>> I really don't see how this is a big problem. Lots of languages do >>>>>> >>>>> hierarchical import (e.g. .Net languages) and I don't think I've ever >>>>> heard >>>>> anyone complain about this particular aspect of it. >>>>> >>>>> >>>> It's not a problem for you and thus you do not pay attention to these >>>> complaints, I suspect. Maybe the people who would complain about the >>>> importing style, simply don't use the mentioned languages. >>>> >>>> The worst case scenario is that you need a little bit of tool support to >>>>> help you sort it out. Plus, it's not like you can't just qualify the >>>>> import >>>>> to make it easier to see where it comes from if you really think it's a >>>>> problem: >>>>> >>>>> >>>> Cf. >>>> http://www.haskell.org/haskellwiki/Import_modules_properly >>>> >>>> Haskell can re-export modules, which makes tracing identifiers more >>>> difficult. I want to be able to read modules without using a tool. >>>> >>>> >>> I'm not sure I understand you point. You're so opposed to the *option* of >>> allowing hierarchical exports (even though you can still import it >>> qualified >>> if you personally like having to specify at each callsite exactly where >>> some >>> identifier is coming from), >>> >> I was concerned with the _import_ part of your proposal. (I haven't thought >> about the export part so far.) >> >> that you'd rather any library making use of a module hierarchy is forced >>> to either make the user add dozens of boilerplate import statements (with >>> "qualified" and "as") or the more common strategy of prefixing each function >>> call with the module name (buttonNew)? To me a module system that requires >>> the latter in practice is horribly broken, and I'm suggesting a low-impact >>> way of fixing it. It may not be the best system available, but it's a tiny >>> extension of the current. >>> >>> I really don't see why adding this option hurts you, when it clearly helps >>> enable doing what this thread advocates (use qualified modules to >>> distinguish between functions of the same name, rather than adding a bunch >>> of prefixes/suffixes to the functions). >>> >> Button.new is my favorite, because with current import variants I can >> easily lookup, what Button and Button.new refer to. I understand your >> proposal in that way that >> >> import Graphics.UI.Gtk >> >> brings module qualifications Window and Button into scope although they are >> not explicitly mentioned. Thus I could no longer find out easily what >> Butten.new means. >> > I don't see why this is so bad when it's exactly what we have for other > identifiers? E.g. if you import Control.Monad you get mapM, but you can't > really say for sure where this identifier comes from, which is no better > than not knowing where "Button.new" comes from. In both cases you have the > option to qualify the module import so you have to say "Monad.mapM" or > "GTK.Button.new" which makes it more apparent. > > I suppose you would make the "hiding" clause and the "import list" thing > work with modules too for consistency, so if you really wanted to you could > list the modules/identifiers that you bring in. yeah, we could come up with a syntax. one that gives privileged meaning to hierarchy. If used according to "design your modules for qualified import", it would still allow fairly easy use and looking up function uses. import Graphics.UI.GTK (import qualified Button, import qualified Window) then you get Button.f (because Graphics.UI.GTK wasn't imported qualified), Graphics.UI.GTK.Button.f, (not f or Graphics.UI.GTK.f because of qualified Button) ... they're normal import statements inside. What it saves is the duplication of Graphics.UI.GTK and "....Button as Button". Not sure I like how long "import qualified" is, repeated there, but it seemed much less confusing than anything shorter. import Data (import qualified Map, Map.Map) or import Data (import qualified Map, import Map(Map)) or a shortcut for that common pattern of importing a few things unqualified import Data (import qualified Map and (Map)) aka. import qualified Data.Map as Map and (Map) aka. import qualified Data.Map as Map (empty,singleton,...) and (Map) or perhaps "unqualifying" rather than "and" personally I would like it if we could also import (f as g) if we wanted to rename an "f" we were importing, to "g" in the module and re-exports, without having to be concerned about (for lowercase) monomorphism restriction, (for types) whether a synonym will work properly everywhere (not without extensions!), (for constructor, record fields, and classes) simple *impossibility*. That wish is only related in that it's a related generalization, though. hmm. -Isaac > Are you saying that you prefer the situation where to use GTK the user would > have to explicitly import every single sub-module in the hierarchy ("import > qualified Graphics.UI.GTK.X as X" where X = {Button,Window, ... etc})? I > don't think that's very nice at all, and I certainly don't like having to > add the module name to the functions... I think lots of libraries are like > that, and we need some mechanism of importing lots of related modules > together so that they come in qualified, without forcing the user to write a > gazillion lines of boilerplate import statements.. > > I think that if GTK did use this system (rather than append the module name > to the function and export them "flatly") a lot of people would resort to > ugly hacks like putting the import statements in a file somewhere and using > the C preprocessor to include it, yuck! (OTOH this may be just what's > required to convince everyone that we need to improve the module system)... > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From isaacdupree at charter.net Sat Jun 14 19:41:59 2008 From: isaacdupree at charter.net (Isaac Dupree) Date: Sat Jun 14 19:34:27 2008 Subject: [Haskell-cafe] Documenting the impossible In-Reply-To: <404396ef0806141416t2d4ce383n4ee3b72a31256400@mail.gmail.com> References: <485414BF.30307@btinternet.com> <404396ef0806141329w36c54982r1e3c38820894f47d@mail.gmail.com> <404396ef0806141416t2d4ce383n4ee3b72a31256400@mail.gmail.com> Message-ID: <48545747.3010607@charter.net> Neil Mitchell wrote: >>> * abort - deliberate aborting because the user made some mistake. >> This is an exception. The signature of a function must reflect this by a >> Maybe, Either type etc. > > Disagree. I mean more like: > > when (Delete `elem` flags && Keep `elem` flags) $ > abort "User cannot pick both keep and delete on the command line" > > Think "die" in Perl world. in that case should use abort :: String -> IO a, not abort :: String -> a. "abort" as "pure function" is just for messy scripting convenience a-la Perl. (Which is not to say that's never useful, of course -- I would just try my hardest to avoid it in my code, probably.) On the other hand, Control.Exception.throw, if it's ever useful, obviously isn't meant to indicate a programmer error, but to throw an exception (that will probably be caught somewhere in the program's IO). So there's a reason for _|_ besides programmer error (well, there's also user-driven nontermination such as when an interpreter is told to execute an infinite loop :-) -Isaac From jonathanccast at fastmail.fm Sat Jun 14 22:25:14 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Sat Jun 14 22:17:06 2008 Subject: [Haskell-cafe] monomorphism restriction In-Reply-To: <485370F7.20308@xaph.net> References: <2f9b2d30806131727s624ee38dja867b926bbde0cc1@mail.gmail.com> <485370F7.20308@xaph.net> Message-ID: <1213496714.6353.16.camel@jonathans-macbook> On Sat, 2008-06-14 at 17:19 +1000, Rafal Kolanski wrote: > Ryan Ingram wrote: > > sumns 0 = 0 > > sumns x = sumns (x-1) + n > > > > Without the monomorphism restriction, computing n is a function call; > > it is evaluated each time it is asked for. > > I'm relatively new to Haskell, and since this topic already came up, I > was wondering if anyone could explain to me how this ties into implicit > parameters which "escape" from their respective functions? > > For instance, if I just state: > maxLength = maxLengthParameter ?config > without providing a type signature and then use it, I get warned that > ?config "escapes" from maxLength and that I should provide a type > signature or turn off the monomorphism restriction. Which means you have to declare ?config at top level and then maxLength has that value baked into it. > I find implicit parameters are a really nice way to pass a configuration > to a whole tree of functions (in this case an LZSS compressor) without > having to explicitly add it as a parameter to every single one of the > functions. > > What are the performance implications of turning off the restriction and > allowing implicit parameters to "escape"? Are there general performance > implications of implicit parameters I am not aware of? Implicit parameters get turned into real parameters under the hood. Turning off the monomorphism restriction (e.g., giving a type signature) just leaves the implicit parameter in place, so maxLength is a function, not a value. You probably /want/ maxLength to be computed from whatever ?config happens to be in scope, so you won't mind in this case. But Haskell wants to be sure you know that it is a function, and laziness's automatic memoization doesn't work for it, before it will proceed. That's all that's going on here. jcc From dgoldsmith at mac.com Sun Jun 15 01:41:20 2008 From: dgoldsmith at mac.com (Deborah Goldsmith) Date: Sun Jun 15 01:33:24 2008 Subject: [Haskell-cafe] ANN: Topkata In-Reply-To: <20080614200605.GB30515@scytale.galois.com> References: <87zlpoguqh.fsf@elefant.olsbruecken.local> <4B3E7353-F7F2-4D2D-A335-30D2D3883A4A@gmail.com> <20080614200605.GB30515@scytale.galois.com> Message-ID: <9F19B056-4F87-469D-8A3B-7688BC1E2131@mac.com> On Jun 14, 2008, at 1:06 PM, Don Stewart wrote: > tom.davie: >> In the mean time -- who knows enough to make ghc target ARM, and get >> this to link against the iPhone libraries? This would be quite a >> coup >> if it could be made to run there! > > I'd be interested. We should start a wiki page for Haskell on the > iphone.. It's an interesting idea, but I think it would need to be a cross- compiler. Does ghc support cross-compilation? Deborah From magnus at therning.org Sun Jun 15 02:52:49 2008 From: magnus at therning.org (Magnus Therning) Date: Sun Jun 15 02:45:01 2008 Subject: [Haskell-cafe] OT: Paper on increasing entropy in software systems Message-ID: <4854BC41.6080602@therning.org> This is wildly off topic, but since the Haskell community is a rather academic one I thought there might be a good chance to find someone who can point me in the right direction. I was just listening to Brooks' talk at OOPSLA 2007 and in the Q&A part at the end he mentions a paper on increasing entropy in software systems. He mentions the authors' names but I can't quite make it out and Google hasn't been very helpful either. He says the paper ?must be 30 years old? and it sounds like he says it's by Les Bellati and Manny Leimann (Lehmann?). As I said, I can't quite make out the names, and the names ring no bells for me. Does anyone on the list know what paper he's referring to? /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?gmail?com http://therning.org/magnus What if I don't want to obey the laws? Do they throw me in jail with the other bad monads? -- Daveman -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 197 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080615/f81c15db/signature.bin From c-bauer-olsbruecken at t-online.de Sun Jun 15 03:57:17 2008 From: c-bauer-olsbruecken at t-online.de (Christoph Bauer) Date: Sun Jun 15 03:49:34 2008 Subject: [Haskell-cafe] ANN: Topkata In-Reply-To: <404396ef0806140809x52f28124t4eea5dc78a02ac@mail.gmail.com> (Neil Mitchell's message of "Sat, 14 Jun 2008 16:09:13 +0100") References: <87zlpoguqh.fsf@elefant.olsbruecken.local> <404396ef0806140350w2eb18cf4n68b7d2f08ece7025@mail.gmail.com> <87ve0cvzi9.fsf@elefant.olsbruecken.local> <22fcbd520806140806w33fb2060y9f00b3e6ff0d3daa@mail.gmail.com> <22fcbd520806140806y311f4f9ax8aaa42763bb7dc8f@mail.gmail.com> <404396ef0806140809x52f28124t4eea5dc78a02ac@mail.gmail.com> Message-ID: <87od635dwi.fsf@elefant.olsbruecken.local> Hi, >> There's a way to put something in the .cabal file about extra data files, >> and have it install them in a certain location that you can then find >> programmatically. I forget the details, but I think it's pretty easy to set > > http://neilmitchell.blogspot.com/2008/02/adding-data-files-using-cabal.html With this summary it was easy. I pushed an patch to http://home.arcor.de/chr_bauer/topkata. Christoph From rvollmert-lists at gmx.net Sun Jun 15 04:03:03 2008 From: rvollmert-lists at gmx.net (Robert Vollmert) Date: Sun Jun 15 03:55:11 2008 Subject: [Haskell-cafe] Re: working with Random.randoms In-Reply-To: References: <4852A281.8000508@enterity.com> Message-ID: Great reply! One minor point: If real_programme is to be pure, you should use let: On Jun 14, 2008, at 12:30, Jon Fairbairn wrote: > main :: IO() > do gen <- getStdGen > the_list <- real_programme gen let the_list = real_programme gen > print the_list > > You should be able to deduce from the fact that the first > argument of real_programme here is of type StdGen (not IO > anything) and its result type is [something] that > real_programme is pure, and gen has only one value > throughout. Cheers Robert From jon.fairbairn at cl.cam.ac.uk Sun Jun 15 04:43:19 2008 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Sun Jun 15 04:35:40 2008 Subject: [Haskell-cafe] Re: working with Random.randoms References: <4852A281.8000508@enterity.com> Message-ID: Robert Vollmert writes: > Great reply! Thanks. > One minor point: If real_programme is to be pure, you should use let: Whoops! I was thinking "let" but wrote the wrong thing. If my email had been through a type-checker, it would have spotted the mistake. -- J?n Fairbairn Jon.Fairbairn@cl.cam.ac.uk http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html (updated 2008-04-26) From tom.davie at gmail.com Sun Jun 15 04:46:52 2008 From: tom.davie at gmail.com (Thomas Davie) Date: Sun Jun 15 04:38:58 2008 Subject: [Haskell-cafe] ANN: Topkata In-Reply-To: <9F19B056-4F87-469D-8A3B-7688BC1E2131@mac.com> References: <87zlpoguqh.fsf@elefant.olsbruecken.local> <4B3E7353-F7F2-4D2D-A335-30D2D3883A4A@gmail.com> <20080614200605.GB30515@scytale.galois.com> <9F19B056-4F87-469D-8A3B-7688BC1E2131@mac.com> Message-ID: On 15 Jun 2008, at 07:41, Deborah Goldsmith wrote: > On Jun 14, 2008, at 1:06 PM, Don Stewart wrote: >> tom.davie: >>> In the mean time -- who knows enough to make ghc target ARM, and get >>> this to link against the iPhone libraries? This would be quite a >>> coup >>> if it could be made to run there! >> >> I'd be interested. We should start a wiki page for Haskell on the >> iphone.. > > It's an interesting idea, but I think it would need to be a cross- > compiler. Does ghc support cross-compilation? The most obvious place to start I guess would be using -fvia-C and the C cross compiler that apple supply. I'll certainly be looking into this as soon as I get an iPhone (which unfortunately I need to wait for 3G one in Belgium). Bob From ketil at malde.org Sun Jun 15 05:13:20 2008 From: ketil at malde.org (Ketil Malde) Date: Sun Jun 15 05:04:59 2008 Subject: [Haskell-cafe] OT: Paper on increasing entropy in software systems In-Reply-To: <4854BC41.6080602@therning.org> (Magnus Therning's message of "Sun\, 15 Jun 2008 07\:52\:49 +0100") References: <4854BC41.6080602@therning.org> Message-ID: <871w2z2h8v.fsf@malde.org> Magnus Therning writes: > I was just listening to Brooks' talk at OOPSLA 2007 and in the Q&A part > at the end he mentions a paper on increasing entropy in software > systems. He mentions the authors' names but I can't quite make it out > and Google hasn't been very helpful either. He says the paper ?must be > 30 years old? and it sounds like he says it's by Les Bellati and Manny > Leimann (Lehmann?). Wikipedia's entry for "Software entropy" lists this: Lehman M.M. and Belady L. (1985). Program Evolution. Process of Software Change. No link, though. -k -- If I haven't seen further, it is by standing in the footprints of giants From haskell at brecknell.org Sun Jun 15 06:30:09 2008 From: haskell at brecknell.org (Matthew Brecknell) Date: Sun Jun 15 06:22:10 2008 Subject: [Haskell-cafe] OT: Paper on increasing entropy in software systems In-Reply-To: <871w2z2h8v.fsf@malde.org> References: <4854BC41.6080602@therning.org> <871w2z2h8v.fsf@malde.org> Message-ID: <1213525809.5777.1258527019@webmail.messagingengine.com> > > I was just listening to Brooks' talk at OOPSLA 2007 and in the Q&A part > > at the end he mentions a paper on increasing entropy in software > > systems. He mentions the authors' names but I can't quite make it out > > and Google hasn't been very helpful either. He says the paper “must be > > 30 years old” and it sounds like he says it's by Les Bellati and Manny > > Leimann (Lehmann?). > > Wikipedia's entry for "Software entropy" lists this: > > Lehman M.M. and Belady L. (1985). Program Evolution. Process of > Software Change. > > No link, though. http://www.amazon.com/exec/obidos/ASIN/0124424406 Using the author names provided by Ketil, scholar.google.com also finds this: http://www.research.ibm.com/journal/sj/153/ibmsj1503E.pdf From r.kelsall at millstream.com Sun Jun 15 09:25:00 2008 From: r.kelsall at millstream.com (Richard Kelsall) Date: Sun Jun 15 09:17:04 2008 Subject: [Haskell-cafe] Documenting the impossible In-Reply-To: <485414BF.30307@btinternet.com> References: <485414BF.30307@btinternet.com> Message-ID: <4855182C.2030203@millstream.com> Andrew Coppin wrote: > Obviously there is no way in hell this code path can ever be executed. Ah, the number of times I've thought that and been wrong :) From a simplistic perspective what I think you're asking for is to have obscure occasions when your program goes wrong with random consequences and doesn't give you an error message. This a programmer's worst nightmare. I can think of several dimensions of bug difficulty When the bug exhibits: Hard : Infrequent at run-time. Medium : Frequent at run-time. Easy : Compile-time. Reproducible: Hard : No obvious pattern or way to induce the error. Medium : A reasonably strong correlation with some precursor. Easy : Happens every time you do a particular thing. Error message: Hard : No error message. Medium : Non-specific error message. Easy : Error message that relates to an identifiable point in your program with relevant state information. Error message location: Medium : Appears on the screen. Easy : Shown on screen and recorded in a log file. Where it happens: Hard : Only on your user's machine or with their configuration. Easy : On all machines. By classifying error messages, for bugs which you have stated are infrequent and difficult to reproduce, as not needing to be displayed or logged you have pushed all these bugs into the seriously hard category. By adding 'undefined' subsequent behaviour you have made these bugs even more difficult. What we should be doing is pushing every bug in the opposite direction - towards the easy end of all the above dimensions. Richard. From aneumann at inf.fu-berlin.de Sun Jun 15 10:27:55 2008 From: aneumann at inf.fu-berlin.de (Adrian Neumann) Date: Sun Jun 15 10:20:06 2008 Subject: [Haskell-cafe] (no subject) Message-ID: {- I downloaded the source and put my file in the same directory You may need to adjust the imports -} module Main where import Picture import Draw -- change xWin to 1000 and yWin to 700 for this to work import EnableGUI -- I use a Mac import SOE hiding (Region) import qualified SOE as G (Region) import Data.List import Random -- lines are not Shapes unfortunately linie = ((Shape $ Polygon [(-0.1,-0.01),(-0.1,0.01),(0.1,0.01), (0.1,-0.01)]), (-0.1,0), (0.1,0)) main = enableGUI >> do w <- openWindow "Lindenmayer System" (xWin, yWin) newStdGen g <- getStdGen drawPic w (aufgabe2 g) k <- getKey w if (k=='q') then do closeWindow w return () else do clearWindow w main -- one big ugly line of code, not that interesting though aufgabe2 g= dasBild where r = rotateRegion (pi/2) $ Translate (-2.5,0) $ renderLSystem linie (lSystem 20 g) dasBild = Region White r `Over` Region Black ( Translate (0,-1.8) $ Scale (1,0.3)$ Translate (0,-2.6) $ rotateRegion (pi/2+pi/ 3) $ Translate (0,2.6) $ r) `Over` Region Green (Shape $ Polygon [(-5,-3.5),(-5,-1.5),(5,-1.5),(5,-3.5)]) `Over` Region Yellow (Translate (4,1.5) (Shape $ circle (0.5))) `Over` Region Blue (Shape $ Rectangle 14 7) -- start of the interesting part: -- A - Axiom, the base shape we use for rendering later --F - Forward --Branch - what it says data LSys = A LSys | F LSys | Branch StdGen [LSys] LSys | Done deriving Show -- a Axiom is a region with two connector points type Axiom = (Region, Vertex, Vertex) -- this seems not to be used anymore? scaleAxiom :: Float -> Axiom -> Axiom scaleAxiom f (r,u,v) = (Scale (f,f) r, f .*. u, f .*. v) -- just for testing purposes testLSys = A (Branch (mkStdGen 5) [A (F ((Branch (mkStdGen 5) [A (Branch (mkStdGen 5) [A (F ((Branch (mkStdGen 5) [A (F Done), A (F Done)] Done))), A (F Done)] Done), A (F Done)] Done))), A (F Done)] Done) -- a 2D rotation matrix drehM :: Float -> (Float, Float, Float, Float) drehM w = (cos w, -sin w, sin w, cos w) -- matrix vector multiplication (.**.) :: (Float, Float, Float, Float) -> Vertex -> Vertex (.**.) (a,b,c,d) (px,py) = (a*px+b*py, c* px+d*py) -- other vector stuff (.-.) (a,b) (c,d) = (a-c,b-d) (.+.) (a,b) (c,d) = (a+c,b+d) (.*.) l (c,d) = (c*l,d*l) abs' (a,b) = (abs a, abs b) betr (a,b) = sqrt (a*a+b*b) -- SOE doesn't come with a way to rotate Regions, so I wrote my own rotateRegion :: Float -> Region -> Region rotateRegion f (Shape s) = Shape (rotateS f s) rotateRegion f (Translate v r) = Translate ((drehM f).**.v) (rotateRegion f r) -- the scaling part is not right I think. Everything seems to break if I try to incorporate scaling -- into the rendering rotateRegion f (Scale v r) = Scale ((betr v/ betr nv) .*. nv) (rotateRegion f r) where x = ((drehM f).**. (fst v,0)) y = ((drehM f) .**. (0,snd v)) nv = (abs' x) .+. (abs' y) rotateRegion f (Complement r) =Complement (rotateRegion f r) rotateRegion f (Union r1 r2) = Union (rotateRegion f r1) (rotateRegion f r2) rotateRegion f (Intersect r1 r2) = Intersect (rotateRegion f r1) (rotateRegion f r2) rotateRegion f (Xor r1 r2) = Xor (rotateRegion f r1) (rotateRegion f r2) rotateRegion _ s=s rotateS f (Polygon pts) = Polygon (map ((drehM f) .**.) pts) rotateS f x = x -- nondeterministically generate a word in our LSys language -- lots of copy&paste here, any way to do this better? lSystem :: Int -> StdGen -> LSys lSystem n g = f n g (A undefined) where f :: Int -> StdGen -> LSys -> LSys f 0 _ _ = Done f (n+1) g (A _) | choose >= 1 = A (f n ng (F undefined)) | choose == 0 = A (f n ng (Branch ng [f n ng' (A undefined), f n ng'' (A undefined)] undefined)) where (choose, ng) = randomR (0::Int,3::Int) g (ng', ng'') = split ng f (n+1) g (F _) | choose >= 1 = F (f n ng (F undefined)) | choose == 0 = F (f n ng (Branch ng [f n ng' (A undefined), f n ng'' (A undefined)] undefined)) where (choose, ng) = randomR (0::Int,3::Int) g (ng', ng'') = split ng f (n+1) g (Branch h lSys _) | choose >= 1 = Branch h lSys (f n ng (F undefined)) | choose == 0 = Branch h lSys (f n ng (Branch ng [f n ng' (A undefined), f n ng'' (A undefined)] undefined)) where (choose, ng) = randomR (0::Int,5::Int) g (ng', ng'') = split ng -- recursivly render a LSys renderLSystem :: Axiom -> LSys -> Region renderLSystem _ Done = Empty renderLSystem (r,u,v) (A lSys) = r `Union` renderLSystem (r,u,v) lSys renderLSystem (r,u,v) (F lSys) = r'' `Union` renderLSystem (r'', u . +. o , v .+.o) lSys where r'' = Translate o $ r o = (v .-. u) renderLSystem (r,u,v) (Branch g lSys rest) = theBranches `Union` renderLSystem (r,u,v) rest where theBranches = Translate o $ foldr Union Empty $ -- we need to rotate around the u-Connector, not around (0,0) -- thus translation map (Translate u) $ zipWith ($) rotations (map ((Translate ((0,0).-.u)).(renderLSystem (r,u,v))) lSys) rotations = map rotateRegion (randomRs (-pi/4,pi/3) g) -- branches are rotated randomly o = (v .-. u) -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 194 bytes Desc: Signierter Teil der Nachricht Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080615/e4c3e999/PGP.bin From aneumann at inf.fu-berlin.de Sun Jun 15 10:50:28 2008 From: aneumann at inf.fu-berlin.de (Adrian Neumann) Date: Sun Jun 15 10:42:43 2008 Subject: [Haskell-cafe] Lindenmayer Systems, WAS: (no subject) In-Reply-To: References: Message-ID: I screwed up the email, sorry about that. What I wanted to say was: Hello, as homework I was assigned to "design and draw an image" using the SOE Graphics library [1]. In order to impress my classmates I decided to draw a bush-like thingy using a Lindenmayer-System. It turns out quite nice [2], and so I thought I might share my code with you. Of course criticism is very welcome. Ok, here we go: > {- I downloaded the source and put my file in the same directory > You may need to adjust the imports -} > module Main where > import Picture > import Draw -- change xWin to 1000 and yWin to 700 for this to work > import EnableGUI -- I use a Mac > import SOE hiding (Region) > import qualified SOE as G (Region) > import Data.List > import Random > > -- lines are not Shapes unfortunately > linie = ((Shape $ Polygon [(-0.1,-0.01),(-0.1,0.01),(0.1,0.01), > (0.1,-0.01)]), (-0.1,0), (0.1,0)) > > main = enableGUI >> do > w <- openWindow "Lindenmayer System" (xWin, yWin) > newStdGen > g <- getStdGen > drawPic w (aufgabe2 g) > k <- getKey w > if (k=='q') then do > closeWindow w > return () else do > clearWindow w > main > > -- one big ugly line of code, not that interesting though > aufgabe2 g= dasBild where > r = rotateRegion (pi/2) $ Translate (-2.5,0) $ renderLSystem > linie (lSystem 20 g) > dasBild = Region White r `Over` Region Black ( Translate > (0,-1.8) $ Scale (1,0.3)$ Translate (0,-2.6) $ rotateRegion (pi/2 > +pi/3) $ Translate (0,2.6) $ r) `Over` Region Green (Shape $ > Polygon [(-5,-3.5),(-5,-1.5),(5,-1.5),(5,-3.5)]) `Over` Region > Yellow (Translate (4,1.5) (Shape $ circle (0.5))) `Over` > Region Blue (Shape $ Rectangle 14 7) > > -- start of the interesting part: > -- A - Axiom, the base shape we use for rendering later > --F - Forward > --Branch - what it says > > data LSys = A LSys | F LSys | Branch StdGen [LSys] LSys | Done > deriving Show > > -- a Axiom is a region with two connector points > type Axiom = (Region, Vertex, Vertex) > > -- this seems not to be used anymore? > > scaleAxiom :: Float -> Axiom -> Axiom > scaleAxiom f (r,u,v) = (Scale (f,f) r, f .*. u, f .*. v) > > -- just for testing purposes > testLSys = A (Branch (mkStdGen 5) [A (F ((Branch (mkStdGen 5) [A > (Branch (mkStdGen 5) [A (F ((Branch (mkStdGen 5) [A (F Done), A (F > Done)] Done))), A (F Done)] Done), A (F Done)] Done))), A (F Done)] > Done) > > -- a 2D rotation matrix > drehM :: Float -> (Float, Float, Float, Float) > drehM w = (cos w, -sin w, sin w, cos w) > > -- matrix vector multiplication > (.**.) :: (Float, Float, Float, Float) -> Vertex -> Vertex > (.**.) (a,b,c,d) (px,py) = (a*px+b*py, c* px+d*py) > > -- other vector stuff > (.-.) (a,b) (c,d) = (a-c,b-d) > (.+.) (a,b) (c,d) = (a+c,b+d) > (.*.) l (c,d) = (c*l,d*l) > abs' (a,b) = (abs a, abs b) > betr (a,b) = sqrt (a*a+b*b) > > -- SOE doesn't come with a way to rotate Regions, so I wrote my own > rotateRegion :: Float -> Region -> Region > rotateRegion f (Shape s) = Shape (rotateS f s) > rotateRegion f (Translate v r) = Translate ((drehM f).**.v) > (rotateRegion f r) > > -- the scaling part is not right I think. Everything seems to break > if I try to incorporate scaling > -- into the rendering > > rotateRegion f (Scale v r) = Scale ((betr v/ betr nv) .*. nv) > (rotateRegion f r) where > x = ((drehM f).**. (fst v,0)) > y = ((drehM f) .**. (0,snd v)) > nv = (abs' x) .+. (abs' y) > rotateRegion f (Complement r) =Complement (rotateRegion f r) > rotateRegion f (Union r1 r2) = Union (rotateRegion f r1) > (rotateRegion f r2) > rotateRegion f (Intersect r1 r2) = Intersect (rotateRegion f r1) > (rotateRegion f r2) > rotateRegion f (Xor r1 r2) = Xor (rotateRegion f r1) (rotateRegion > f r2) > rotateRegion _ s=s > > rotateS f (Polygon pts) = Polygon (map ((drehM f) .**.) pts) > rotateS f x = x > > -- nondeterministically generate a word in our LSys language > -- lots of copy&paste here, any way to do this better? > > lSystem :: Int -> StdGen -> LSys > lSystem n g = f n g (A undefined) where > f :: Int -> StdGen -> LSys -> LSys > f 0 _ _ = Done > f (n+1) g (A _) > | choose >= 1 = A (f n ng (F undefined)) > | choose == 0 = A (f n ng (Branch ng [f n ng' (A > undefined), f n ng'' (A undefined)] undefined)) where > (choose, ng) = randomR (0::Int,3::Int) g > (ng', ng'') = split ng > f (n+1) g (F _) > | choose >= 1 = F (f n ng (F undefined)) > | choose == 0 = F (f n ng (Branch ng [f n ng' (A > undefined), f n ng'' (A undefined)] undefined)) where > (choose, ng) = randomR (0::Int,3::Int) g > (ng', ng'') = split ng > f (n+1) g (Branch h lSys _) > | choose >= 1 = Branch h lSys (f n ng (F undefined)) > | choose == 0 = Branch h lSys (f n ng (Branch ng [f n > ng' (A undefined), f n ng'' (A undefined)] undefined)) where > (choose, ng) = randomR (0::Int,5::Int) g > (ng', ng'') = split ng > > -- recursivly render a LSys > renderLSystem :: Axiom -> LSys -> Region > renderLSystem _ Done = Empty > renderLSystem (r,u,v) (A lSys) = r `Union` renderLSystem (r,u,v) lSys > renderLSystem (r,u,v) (F lSys) = r'' `Union` renderLSystem (r'', u . > +. o , v .+.o) lSys where > r'' = Translate o $ r > o = (v .-. u) > renderLSystem (r,u,v) (Branch g lSys rest) = > theBranches `Union` renderLSystem (r,u,v) rest where > theBranches = Translate o $ foldr Union Empty $ > -- we need to rotate around the u-Connector, not around (0,0) > -- thus translation > map (Translate u) $ zipWith ($) rotations (map > ((Translate ((0,0).-.u)).(renderLSystem (r,u,v))) lSys) > rotations = map rotateRegion (randomRs (-pi/4,pi/3) g) -- > branches are rotated randomly > o = (v .-. u) What do you think? Adrian [1] http://www.haskell.org/soe/graphics.htm [2] http://img149.imageshack.us/my.php?image=bild1tf4.png -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 194 bytes Desc: Signierter Teil der Nachricht Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080615/febb4538/PGP.bin From gwern0 at gmail.com Sun Jun 15 12:01:48 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Sun Jun 15 11:54:25 2008 Subject: [Haskell-cafe] Lindenmayer Systems, WAS: (no subject) In-Reply-To: References: Message-ID: <20080615160147.GA8943@craft> On 2008.06.15 16:50:28 +0200, Adrian Neumann scribbled 6.9K characters: > I screwed up the email, sorry about that. What I wanted to say was: > > Hello, > > as homework I was assigned to "design and draw an image" using the SOE > Graphics library [1]. In order to impress my classmates I decided to draw > a bush-like thingy using a Lindenmayer-System. It turns out quite nice > [2], and so I thought I might share my code with you. Of course criticism > is very welcome. > > Ok, here we go: > >> {- I downloaded the source and put my file in the same directory >> You may need to adjust the imports -} >> module Main where >> import Picture >> import Draw -- change xWin to 1000 and yWin to 700 for this to work >> import EnableGUI -- I use a Mac >> import SOE hiding (Region) >> import qualified SOE as G (Region) >> import Data.List >> import Random >> >> -- lines are not Shapes unfortunately >> linie = ((Shape $ Polygon [(-0.1,-0.01),(-0.1,0.01),(0.1,0.01), >> (0.1,-0.01)]), (-0.1,0), (0.1,0)) >> >> main = enableGUI >> do >> w <- openWindow "Lindenmayer System" (xWin, yWin) >> newStdGen >> g <- getStdGen >> drawPic w (aufgabe2 g) >> k <- getKey w >> if (k=='q') then do >> closeWindow w >> return () else do >> clearWindow w >> main >> >> -- one big ugly line of code, not that interesting though >> aufgabe2 g= dasBild where >> r = rotateRegion (pi/2) $ Translate (-2.5,0) $ renderLSystem linie >> (lSystem 20 g) >> dasBild = Region White r `Over` Region Black ( Translate (0,-1.8) $ >> Scale (1,0.3)$ Translate (0,-2.6) $ rotateRegion (pi/2+pi/3) $ >> Translate (0,2.6) $ r) `Over` Region Green (Shape $ Polygon >> [(-5,-3.5),(-5,-1.5),(5,-1.5),(5,-3.5)]) `Over` Region Yellow >> (Translate (4,1.5) (Shape $ circle (0.5))) `Over` >> Region Blue (Shape $ Rectangle 14 7) >> >> -- start of the interesting part: >> -- A - Axiom, the base shape we use for rendering later >> --F - Forward >> --Branch - what it says >> >> data LSys = A LSys | F LSys | Branch StdGen [LSys] LSys | Done >> deriving Show >> >> -- a Axiom is a region with two connector points >> type Axiom = (Region, Vertex, Vertex) >> >> -- this seems not to be used anymore? >> >> scaleAxiom :: Float -> Axiom -> Axiom >> scaleAxiom f (r,u,v) = (Scale (f,f) r, f .*. u, f .*. v) >> >> -- just for testing purposes >> testLSys = A (Branch (mkStdGen 5) [A (F ((Branch (mkStdGen 5) [A >> (Branch (mkStdGen 5) [A (F ((Branch (mkStdGen 5) [A (F Done), A (F >> Done)] Done))), A (F Done)] Done), A (F Done)] Done))), A (F Done)] >> Done) >> >> -- a 2D rotation matrix >> drehM :: Float -> (Float, Float, Float, Float) >> drehM w = (cos w, -sin w, sin w, cos w) >> >> -- matrix vector multiplication >> (.**.) :: (Float, Float, Float, Float) -> Vertex -> Vertex >> (.**.) (a,b,c,d) (px,py) = (a*px+b*py, c* px+d*py) >> >> -- other vector stuff >> (.-.) (a,b) (c,d) = (a-c,b-d) >> (.+.) (a,b) (c,d) = (a+c,b+d) >> (.*.) l (c,d) = (c*l,d*l) >> abs' (a,b) = (abs a, abs b) >> betr (a,b) = sqrt (a*a+b*b) >> >> -- SOE doesn't come with a way to rotate Regions, so I wrote my own >> rotateRegion :: Float -> Region -> Region >> rotateRegion f (Shape s) = Shape (rotateS f s) >> rotateRegion f (Translate v r) = Translate ((drehM f).**.v) >> (rotateRegion f r) >> >> -- the scaling part is not right I think. Everything seems to break if >> I try to incorporate scaling >> -- into the rendering >> >> rotateRegion f (Scale v r) = Scale ((betr v/ betr nv) .*. nv) >> (rotateRegion f r) where >> x = ((drehM f).**. (fst v,0)) >> y = ((drehM f) .**. (0,snd v)) >> nv = (abs' x) .+. (abs' y) >> rotateRegion f (Complement r) =Complement (rotateRegion f r) >> rotateRegion f (Union r1 r2) = Union (rotateRegion f r1) (rotateRegion >> f r2) >> rotateRegion f (Intersect r1 r2) = Intersect (rotateRegion f r1) >> (rotateRegion f r2) >> rotateRegion f (Xor r1 r2) = Xor (rotateRegion f r1) (rotateRegion f >> r2) >> rotateRegion _ s=s >> >> rotateS f (Polygon pts) = Polygon (map ((drehM f) .**.) pts) >> rotateS f x = x >> >> -- nondeterministically generate a word in our LSys language >> -- lots of copy&paste here, any way to do this better? >> >> lSystem :: Int -> StdGen -> LSys >> lSystem n g = f n g (A undefined) where >> f :: Int -> StdGen -> LSys -> LSys >> f 0 _ _ = Done >> f (n+1) g (A _) >> | choose >= 1 = A (f n ng (F undefined)) >> | choose == 0 = A (f n ng (Branch ng [f n ng' (A undefined), f >> n ng'' (A undefined)] undefined)) where >> (choose, ng) = randomR (0::Int,3::Int) g >> (ng', ng'') = split ng >> f (n+1) g (F _) >> | choose >= 1 = F (f n ng (F undefined)) >> | choose == 0 = F (f n ng (Branch ng [f n ng' (A undefined), f >> n ng'' (A undefined)] undefined)) where >> (choose, ng) = randomR (0::Int,3::Int) g >> (ng', ng'') = split ng >> f (n+1) g (Branch h lSys _) >> | choose >= 1 = Branch h lSys (f n ng (F undefined)) >> | choose == 0 = Branch h lSys (f n ng (Branch ng [f n ng' (A >> undefined), f n ng'' (A undefined)] undefined)) where >> (choose, ng) = randomR (0::Int,5::Int) g >> (ng', ng'') = split ng >> >> -- recursivly render a LSys >> renderLSystem :: Axiom -> LSys -> Region >> renderLSystem _ Done = Empty >> renderLSystem (r,u,v) (A lSys) = r `Union` renderLSystem (r,u,v) lSys >> renderLSystem (r,u,v) (F lSys) = r'' `Union` renderLSystem (r'', u .+. >> o , v .+.o) lSys where >> r'' = Translate o $ r >> o = (v .-. u) >> renderLSystem (r,u,v) (Branch g lSys rest) = >> theBranches `Union` renderLSystem (r,u,v) rest where >> theBranches = Translate o $ foldr Union Empty $ >> -- we need to rotate around the u-Connector, not around (0,0) >> -- thus translation >> map (Translate u) $ zipWith ($) rotations (map ((Translate >> ((0,0).-.u)).(renderLSystem (r,u,v))) lSys) >> rotations = map rotateRegion (randomRs (-pi/4,pi/3) g) -- >> branches are rotated randomly >> o = (v .-. u) > > What do you think? > > Adrian > > [1] http://www.haskell.org/soe/graphics.htm > [2] http://img149.imageshack.us/my.php?image=bild1tf4.png That's interesting, nice and short. The output actually reminds me a lot of Nymphaea ; have you seen't? -- gwern Maple 82 Visa/BCC noise noise FCA Blacknet TELINT WISDIM S/Key -------------- 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/20080615/863a98da/attachment.bin From andrewcoppin at btinternet.com Sun Jun 15 04:15:49 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sun Jun 15 15:05:16 2008 Subject: [Haskell-cafe] Documenting the impossible In-Reply-To: References: <485414BF.30307@btinternet.com> Message-ID: <4854CFB5.6010009@btinternet.com> Henning Thielemann wrote: > I think it is another instance of mixing up errors and exceptions (you > know the haskellwiki pages ...) > > Since an 'error' marks a programming error (which should never occur) > it would not hurt the program if all 'error's are replaced by > 'undefined', an illegal memory access or any other misbehaviour. So > 'error' is exactly what you propose as IMPOSSIBLE pragma. A compiler > option for replacing all 'error's by nops would do want you want. OK, so suppose I write a module that contains a function that accepts a number parameter, and that parameter must be greater than 2. I have no control over what value users of the library pass to my function. Suppose some client calls my function with 1 as an argument - is that an error, or an exception? On the other hand, suppose I write the same function, but now it's not exported. So the only code that can possibly call this function is my own code. So I can [theoretically] guarantee it will never be called with the "wrong" argument [assuming the code I write isn't defective]. As far as I can tell, there's no way of making this distinction in Haskell code. You'd use "error" in both cases - or if you're feeling brave, remove it in the second case and hope you're right. I'm just saying it would be nice to be able to keep it in the code for maintainability's sake, but not have the runtime penalty for it once you're "sure" your code is safe. It looks like Don's "assert" thing might be able to do this. [I had no idea this existed by the way...] Hmm, this gives me a new idea for a feature request - how about a function that evaluates to the source code line number it was called from? ;-) From lemming at henning-thielemann.de Sun Jun 15 15:37:21 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sun Jun 15 15:29:24 2008 Subject: [Haskell-cafe] Documenting the impossible In-Reply-To: <4854CFB5.6010009@btinternet.com> References: <485414BF.30307@btinternet.com> <4854CFB5.6010009@btinternet.com> Message-ID: On Sun, 15 Jun 2008, Andrew Coppin wrote: > Henning Thielemann wrote: >> I think it is another instance of mixing up errors and exceptions (you know >> the haskellwiki pages ...) >> >> Since an 'error' marks a programming error (which should never occur) it >> would not hurt the program if all 'error's are replaced by 'undefined', an >> illegal memory access or any other misbehaviour. So 'error' is exactly what >> you propose as IMPOSSIBLE pragma. A compiler option for replacing all >> 'error's by nops would do want you want. > > OK, so suppose I write a module that contains a function that accepts a > number parameter, and that parameter must be greater than 2. I have no > control over what value users of the library pass to my function. Suppose > some client calls my function with 1 as an argument - is that an error, or an > exception? It's an error, like 'head []' is an error. You must document the condition (argument > 2), unfortunately Haskell's type system does not allow to state such conditiions conveniently, and then it's the caller's responsibility to ensure that the argument is greater than 2. I like to distinguish between two kinds of users. (Are there common names for them?) The (consumer) user communicates with your program via an interface you provide: A GUI, the command line, a network. The user may even not know, that the program is written in Haskell. Everything this user makes wrong is an exception. You cannot forbid the user to make something wrong. The other kind of users are programmers, who call functions of your library. This interface is especially fast but in order to get the efficiency you can expect some cooperation by the programmer. E.g. the programmer of your library must ensure that the argument is always greater than 2. Otherwise _he_ has done an _error_. However if he writes a program which lets the user enter the number in a GUI dialog which is then passed to your library, then he must check the number before forwarding it, because the user can do wrong things. If the user enters '1' this is an _exception_. If the programmer does not reject this input it is an error. > On the other hand, suppose I write the same function, but now it's not > exported. So the only code that can possibly call this function is my own > code. So I can [theoretically] guarantee it will never be called with the > "wrong" argument [assuming the code I write isn't defective]. > > As far as I can tell, there's no way of making this distinction in Haskell > code. You'd use "error" in both cases - or if you're feeling brave, remove it > in the second case and hope you're right. I'm just saying it would be nice to > be able to keep it in the code for maintainability's sake, but not have the > runtime penalty for it once you're "sure" your code is safe. In theory you could remove 'error' in both cases, because in theory neither you nor the library user makes mistakes. In practice you better leave the error, because both of you actually make mistakes. > It looks like Don's "assert" thing might be able to do this. [I had no idea > this existed by the way...] As far as I understand, 'assert' is a wrapper to 'error' which also determines the source code location without using the C preprocessor. Is this correct? > Hmm, this gives me a new idea for a feature request - how about a function > that evaluates to the source code line number it was called from? ;-) Would be also nice for a "single stepper", which shows at which places in the source code things are currently evaluated. From lemming at henning-thielemann.de Sun Jun 15 15:41:40 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sun Jun 15 15:33:40 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: <48545467.7080209@charter.net> References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <3d96ac180806091353q6fd8cyc78eb513c8a6c4c5@mail.gmail.com> <3d96ac180806140728m1061e1bdr43f3a4759554b0b2@mail.gmail.com> <3d96ac180806141038k46ea8058v60f8d78f59bc6a81@mail.gmail.com> <3d96ac180806141121k2c388ed4pd9f960bda540d45f@mail.gmail.com> <48545467.7080209@charter.net> Message-ID: On Sat, 14 Jun 2008, Isaac Dupree wrote: > yeah, we could come up with a syntax. one that gives privileged meaning to > hierarchy. If used according to "design your modules for qualified import", > it would still allow fairly easy use and looking up function uses. > > import Graphics.UI.GTK (import qualified Button, import qualified Window) > > then you get Button.f (because Graphics.UI.GTK wasn't imported qualified), > Graphics.UI.GTK.Button.f, (not f or Graphics.UI.GTK.f because of qualified > Button) ... they're normal import statements inside. What it saves is the > duplication of Graphics.UI.GTK and "....Button as Button". Not sure I like > how long "import qualified" is, repeated there, but it seemed much less > confusing than anything shorter. > > import Data (import qualified Map, Map.Map) > or > import Data (import qualified Map, import Map(Map)) > or a shortcut for that common pattern of importing a few things unqualified > import Data (import qualified Map and (Map)) > aka. import qualified Data.Map as Map and (Map) > aka. import qualified Data.Map as Map (empty,singleton,...) and (Map) > or perhaps "unqualifying" rather than "and" > > personally I would like it if we could also import (f as g) if we wanted to > rename an "f" we were importing, to "g" in the module and re-exports, without > having to be concerned about (for lowercase) monomorphism restriction, (for > types) whether a synonym will work properly everywhere (not without > extensions!), (for constructor, record fields, and classes) simple > *impossibility*. That wish is only related in that it's a related > generalization, though. nice From duncan.coutts at worc.ox.ac.uk Sun Jun 15 15:49:14 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sun Jun 15 15:37:42 2008 Subject: [Haskell-cafe] cabal-install failure In-Reply-To: <008501c8ce05$ec0ef260$f82b8351@cr3lt> References: <1213392126.15010.547.camel@localhost> <20080614021052.GA8862@craft> <1213430194.15010.556.camel@localhost> <008501c8ce05$ec0ef260$f82b8351@cr3lt> Message-ID: <1213559354.15010.580.camel@localhost> On Sat, 2008-06-14 at 11:03 +0100, Claus Reinke wrote: > > http://hackage.haskell.org/trac/hackage/ticket/227 > > > > One problem is that not all build-tools correspond to haskell > > packages. Some do some don't. We have a hard coded list of them > > at the moment (which can be extended in Setup.hs files) so we > > could extend that with what haskell package if any the tools > > correspond to. Any better suggestions to make it a tad more > > generic? > > That list seems to be in Distribution/Simple/Program.hs, in case > anyone else is looking for it. Encoded information includes: > dependency name, program name (if different from dependency), Right, we have the common name of the program. We don't actually track the actual name as it happens to be on any particular system except in so far as we try to find the full path to the program when we configure it. The main point of the Program abstraction is about configuring and running programs. As it happens some programs are provided by some haskell packages (but not all, eg ld, ar, etc). > option to get version info and code to extract it (with one apparently > very special case being hsc2hs). And ld.exe on windows (we find it in ghc's gcc-lib bin dir). > Btw, most of the version extraction code looks like a regular > expression match - wouldn't that make the specification easier > (and turn the comments into part of the spec)? True, in most cases finding the name of the program involves running it with some --version flag and matching some part of the output. However that's not always the case. Some programs do silly things like produce the version output on stderr instead of stdout. We figured the most general thing was just a function FilePath -> IO (Maybe Version) which is what we've got. I'm not sure what the advantage would be to make it more declarative by making it into data rather than a extraction function. Also, the Cabal lib cannot depend on any regular expression library because they are not part of the bootstrapping library set. > > If anyone has a godd suggestion I'm happy to hear it. Otherwise we can > > just add a Maybe Dependency to the Program type to indicate that some > > build tools have a corresponding haskell package. > > I'm not sure what you're suggesting there (currently even those > tools that can be built with Cabal do not register with Cabal), but > here are my suggestions: > > 1. Haskell tools should register with Cabal, whether built with it > (such as Alex, Happy, ..) or not (such as GHC, ..). That > registration should include any build-relevant information > (versions/variants, ..). > > 2. When checking a build-tools dependency, Cabal checks > (a) whether the tool is registered with Cabal I'm not sure this helps. We want to know what to install when it's missing. We can already tell if a program (not package) is available by searching for it. > (b) whether the tool is registered with the system installation manager This is hard. > (c) whether the tool can be found by other means (configure, > built-in rules, ..) > > In other words, make tools look like packages (lifetime dependency > management, not just build support), and make system packages look > like Cabal packages (Cabal as the interface to native managers), using > special treatment only if absolutely necessary. I thought those suggestions > were clear from my earlier messages?-) Sure, haskell executable tools built by haskell packages are really packages. So the problem currently is that build-tools refers to programs not packages. One can list any known program in the build-tools field and the list of programs is extensible in the Setup.hs script. As they are used so far by current packages on hackage, they always refer to haskell tools built by haskell packages (almost only used to refer to alex, happy and c2hs) so perhaps we should just quietly redefine the meaning on build-tools to be another kind of build-depends. That is it specifies a haskell package. If we have need to specify non-haskell build tools, perhaps we should do that separately? eg "some-other-kind-of-build-tools: perl >= 5.8" Duncan From barsoap at web.de Sun Jun 15 16:22:16 2008 From: barsoap at web.de (Achim Schneider) Date: Sun Jun 15 16:14:34 2008 Subject: [Haskell-cafe] Re: Documenting the impossible References: <485414BF.30307@btinternet.com> Message-ID: <20080615222216.79be4ac8@solaris> Andrew Coppin wrote: > I have a small idea. I'm curios if anybody else thinks it's a good > idea... > > How about a {-# IMPOSSIBLE #-} pragma that documents the fact that a > particular point in the program *should* be unreachable? > I might support this in some way or the other _after_ we've got errors that report source file and line number. Before that I will stay, steadfast and stubborn, utterly ignorant of anything with less importance. Just use assert s v = if debug then error s else v in the mean time. -DHAVE_CONFIG_H ;) -- (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 duncan.coutts at worc.ox.ac.uk Sun Jun 15 17:17:56 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sun Jun 15 17:05:34 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: <3d96ac180806141121k2c388ed4pd9f960bda540d45f@mail.gmail.com> References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <3d96ac180806091353q6fd8cyc78eb513c8a6c4c5@mail.gmail.com> <3d96ac180806140728m1061e1bdr43f3a4759554b0b2@mail.gmail.com> <3d96ac180806141038k46ea8058v60f8d78f59bc6a81@mail.gmail.com> <3d96ac180806141121k2c388ed4pd9f960bda540d45f@mail.gmail.com> Message-ID: <1213564676.15010.596.camel@localhost> On Sat, 2008-06-14 at 19:21 +0100, Sebastian Sylvan wrote: > I think that if GTK did use this system (rather than append the module > name to the function and export them "flatly") a lot of people would > resort to ugly hacks like putting the import statements in a file > somewhere and using the C preprocessor to include it, yuck! (OTOH this > may be just what's required to convince everyone that we need to > improve the module system)... Right. That's exactly why we've not done something like that. With 100+ modules in the Gtk package it's totally infeasible to do qualified imports of them all. If we get a proper way to export a non-flat namespace then Gtk2Hs will certainly switch to using it. Using 'buttonBlah' is horrible but there is currently nothing better. There have been a few suggestions along these lines. Check the archives. I'm not sure what is proposed for haskell', probably nothing since nothing is currently implemented and we're only supposed to be standardising existing practise. Duncan From duncan.coutts at worc.ox.ac.uk Sun Jun 15 17:27:30 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sun Jun 15 17:15:08 2008 Subject: [Haskell-cafe] Lazy IO. In-Reply-To: References: Message-ID: <1213565250.15010.604.camel@localhost> On Sat, 2008-06-14 at 18:18 +0200, Sebastiaan Visser wrote: > Hi, > > I've got a question about lazy IO in Haskell. The most well known > function to do lazy IO is the `hGetContents', which lazily reads all the > contents from a handle and returns this as a regular [Char]. > > The thing with hGetContents is that is puts the Handle in a semi-closed > state, no one can use the handle anymore. This behaviour is > understandable from the point of safety; it is not yet determined when > the result of hGetContents will actually be computed, using the handle > in the meantime is undesirable. > > The point is, I think I really have a situation in which I want to use > the handle again `after' a call to hGetContents. I think I can best > explain this using a code example. > > readHttpMessage :: IO (Headers, Data.ByteString.Lazy.ByteString) > readHttpMessage = do > myStream <- > request <- hGetContents myStream > header <- parseHttpHeader request > bs <- Data.ByteString.Lazy.hGetContents myStream > return (header, body) Can you get the contents as a bytestring, then unpack that to a String for the purpose of parsing a prefix of the input as the headers. Since unpacking to a String is lazy it means you should only end up using String for the headers and not for the payload. As others have pointed out it's not clear from the above how you separate the headers and the body. Returning the length of the headers might work and then drop that amount from the bytestring would give the body as a bytestring. Duncan From duncan.coutts at worc.ox.ac.uk Sun Jun 15 17:38:07 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sun Jun 15 17:25:46 2008 Subject: [Haskell-cafe] External query interface to HackageDB? In-Reply-To: References: Message-ID: <1213565887.15010.613.camel@localhost> On Sat, 2008-06-14 at 10:26 -0400, Dimitry Golubovsky wrote: > Hi, > > Is there any way to query the latest version of a particular package > stored on Hackage, that was successfully built? It is certainly part of the plan. There is currently no convenient way to get at the information. I've been working on the client side of things, actually generating decent build reports. That step is now done and it's included in cabal-install-0.5.0. The next step is letting people upload build reports to hackage and collating the data and extracting useful information from the data. Included in that would be some way for external clients to get at the data and summaries both via human readable info on the package page and something machine readable. > I mean, not _how_ to do that (I have some ideas that I have to > download directory listings, looking for failure logs, etc.), but is > there any tool or interface already available that does similar > things? In the mean time, using the current system, you can get at stuff by knowing what urls to look at. eg: http://hackage.haskell.org/packages/archive/pureMD5/0.2.0/logs/failure/ghc-6.8 So most recent packages have a logs subdir and either a success or failure dir with a log file for a particular version of ghc, which at the moment is 6.6 or 6.8. > Unfortunately, tarfiles provided on Hackage (like 00-index.tar.gz) do > not help, e. g. BerkeleyDB failed to build in all three versions, yet > its all cabal files are included in the tarball: Yes, the archive is complete. We do not remove anything. In future we may augment the index with extra meta-data on what works, what is obsolete or what is recommended. Duncan From pieter at laeremans.org Sun Jun 15 18:34:00 2008 From: pieter at laeremans.org (Pieter Laeremans) Date: Sun Jun 15 18:26:00 2008 Subject: [Haskell-cafe] Memory profiling Message-ID: Hi, Which tools do you recommand for memory profiling haskell programs on a *nix system. I'm using haskell to develop a CGI program/script. The application has to be deployed on shared hosting infrastructure. Since I would like to be a good citizen , I would need to meassure the maximum amount of memory allocated to the program during execution. The best I can do now is look at top but that 's not satisfactory. thanks, Pieter -- Pieter Laeremans From qdunkan at gmail.com Sun Jun 15 21:42:08 2008 From: qdunkan at gmail.com (Evan Laforge) Date: Sun Jun 15 21:34:09 2008 Subject: [Haskell-cafe] Documenting the impossible In-Reply-To: <4854CFB5.6010009@btinternet.com> References: <485414BF.30307@btinternet.com> <4854CFB5.6010009@btinternet.com> Message-ID: <2518b95d0806151842s68c0670x50a0d3f93a7ab704@mail.gmail.com> > Hmm, this gives me a new idea for a feature request - how about a function > that evaluates to the source code line number it was called from? ;-) Well, that wouldn't be a function, but one of the other "-hc"s (j? n?) has srcloc_annotate which is a macro that does that. It would be nice if ghc had it. Meanwhile, I use -pgmF to replace certain functions with *_srcloc ones that pass a SrcLoc argument, and it works mostly ok. I don't know what other people do, but having file:line in logs and test failures is pretty handy. Only "mostly" because it replaces things in strings, because I can't use cpp because it doesn't understand dots in identifiers, and can't use Language.Haskell.Parser because it *also* doesn't understand dots in identifiers, so it's Regex.subRegex (speaking of not being designed for qualified import...) until I get around to doing it with parsec. From magicloud.magiclouds at gmail.com Sun Jun 15 22:31:22 2008 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Sun Jun 15 22:23:22 2008 Subject: [Haskell-cafe] How to do this in FP way? Message-ID: <3bd412d40806151931s3cef9027x73d83943386f0cad@mail.gmail.com> Hello, I am getting familiar with FP now, and I have a "program design" kind of question. Say I have something like this in C: static int old; int diff (int now) { /* this would be called once a second */ int ret = now - old; old = now; return ret; } Because there is no "variable" in Haskell. So how to do this in a FP way? Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080616/394a4f58/attachment.htm From thomas.dubuisson at gmail.com Sun Jun 15 23:00:03 2008 From: thomas.dubuisson at gmail.com (Thomas M. DuBuisson) Date: Sun Jun 15 22:53:26 2008 Subject: [Haskell-cafe] How to do this in FP way? In-Reply-To: <3bd412d40806151931s3cef9027x73d83943386f0cad@mail.gmail.com> References: <3bd412d40806151931s3cef9027x73d83943386f0cad@mail.gmail.com> Message-ID: <1213585203.3291.9.camel@localhost.localdomain> Magicloud Magiclouds wrote: > Say I have something like this in C: > static int old; > int diff (int now) { /* this would be called once a second */ > int ret = now - old; > old = now; > return ret; > } > Because there is no "variable" in Haskell. So how to do this in a > FP way? So you have a global time count that is updated every second - I presume for the rest of the process to use, avoiding syscalls due to expense. Am I getting this right? You can use mutable variables in Haskell, though some people will frown, but it might fit your need. See MVar, STM, or IO Refs. At any rate, if what you are doing needs to check the clock time then this code isn't going to be pure. Perhaps you just want something in particular to be triggered every second then use control-timeout, event-list, or control-event. Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080615/cccd2049/attachment.bin From skynare at gmail.com Sun Jun 15 23:10:09 2008 From: skynare at gmail.com (sam lee) Date: Sun Jun 15 23:02:09 2008 Subject: [Haskell-cafe] How to do this in FP way? In-Reply-To: <3bd412d40806151931s3cef9027x73d83943386f0cad@mail.gmail.com> References: <3bd412d40806151931s3cef9027x73d83943386f0cad@mail.gmail.com> Message-ID: <4e7aa0f80806152010w4e79aef7je4f84e99a4ea3cb7@mail.gmail.com> I can think of 2 ways. > module Main where > > import Control.Monad.State First, normal way: > diff (now, old) = (now - old, now) diff takes now and old and returns result (now - old) and modified old (now). For example, diff (diff (1,0)) ==> diff (1 - 0, 1) ==> diff (1, 1) ==> (1 - 1, 1) ==> (0, 1) I think people use the word "threaded" to describe what diff is doing: the variable "old" is threaded through many calls to diff. > testDiff = diff . diff . diff . diff . diff . diff $ (2, 1) testDiff returns (2,1) Second way is using monads: > diff' now = do > old <- get > put now > return (now - old) diff' uses State monad. If you're not familiar with monads, State monad does similar to what diff function does (it threads the variable "old"). But, being a monadic action, diff' looks like imperative version syntactically. It gives illusion of having global variable (old). > testDiff' = do > result <- diff' 2 > result <- diff' result > result <- diff' result > result <- diff' result > result <- diff' result > result <- diff' result > return result > > runTestDiff' = runState testDiff' 1 runTestDiff' also returns (2,1) 2008/6/15 Magicloud Magiclouds : > Hello, > I am getting familiar with FP now, and I have a "program design" kind of > question. > Say I have something like this in C: > static int old; > int diff (int now) { /* this would be called once a second */ > int ret = now - old; > old = now; > return ret; > } > Because there is no "variable" in Haskell. So how to do this in a FP > way? > > Thanks. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From barsoap at web.de Mon Jun 16 00:00:33 2008 From: barsoap at web.de (Achim Schneider) Date: Sun Jun 15 23:52:40 2008 Subject: [Haskell-cafe] Re: How to do this in FP way? References: <3bd412d40806151931s3cef9027x73d83943386f0cad@mail.gmail.com> Message-ID: <20080616060033.396f1e5c@solaris> "Magicloud Magiclouds" wrote: > static int old; > int diff (int now) { /* this would be called once a second */ > int ret = now - old; > old = now; > return ret; > } > You do it with variables, of course. This is out of some GLUT code, using IORef's: idle :: State -> IdleCallback idle state = do t0 <- get $ t state t1 <- get elapsedTime t state $= t1 let td = fromIntegral t1 - fromIntegral t0 fps state $= 1/td * 1000 angle' state $~! (+2) (bpx, bpy) <- get $ ballPos state (bvx, bvy) <- get $ ballVel state ballPos state $= (bpx + bvx*td, bpy + bvy*td) postRedisplay Nothing One half of all Haskell coders will tell you that mutable state isn't a good starting point to learn Haskell, the other half will tell you the same because they want to be cool kids, too. -- (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 tom.davie at gmail.com Mon Jun 16 03:42:45 2008 From: tom.davie at gmail.com (Thomas Davie) Date: Mon Jun 16 03:34:48 2008 Subject: [Haskell-cafe] Re: How to do this in FP way? In-Reply-To: <20080616060033.396f1e5c@solaris> References: <3bd412d40806151931s3cef9027x73d83943386f0cad@mail.gmail.com> <20080616060033.396f1e5c@solaris> Message-ID: <9A3A3243-08F0-42DD-80BC-6FFD6BB73274@gmail.com> > > One half of all Haskell coders will tell you that mutable state > isn't a > good starting point to learn Haskell, the other half will tell you the > same because they want to be cool kids, too. And the one left over will point out that he asked how to do this the FP way, not the imperative way? If it was me btw, I'd take a stab at the problem being that each time we do something a time gets updated and we want to know how much time has passed since we last did "something". I'd approach this by generating a lazy list of times at which we started doing "something", and then generating a lazy list of time differences. Bob From chaddai.fouche at gmail.com Mon Jun 16 04:11:55 2008 From: chaddai.fouche at gmail.com (=?ISO-8859-1?Q?Chadda=EF_Fouch=E9?=) Date: Mon Jun 16 04:03:56 2008 Subject: [Haskell-cafe] Memory profiling In-Reply-To: References: Message-ID: 2008/6/16 Pieter Laeremans : > Hi, > > Which tools do you recommand for memory profiling haskell programs > on a *nix system. > I'm using haskell to develop a CGI program/script. > > The application has to be deployed on shared hosting infrastructure. > Since I would like to be a good citizen , > I would need to meassure the maximum amount of memory allocated to the > program during execution. > The best I can do now is look at top but that 's not satisfactory. Are you aware that by calling the program with the correct RTS options you can have memory profiling ? http://www.haskell.org/ghc/docs/latest/html/users_guide/runtime-control.html (see option -s for simple statistics) http://www.haskell.org/ghc/docs/latest/html/users_guide/prof-heap.html -- Jeda? From ketil at malde.org Mon Jun 16 04:19:16 2008 From: ketil at malde.org (Ketil Malde) Date: Mon Jun 16 04:10:48 2008 Subject: [Haskell-cafe] How to do this in FP way? In-Reply-To: <3bd412d40806151931s3cef9027x73d83943386f0cad@mail.gmail.com> (Magicloud Magiclouds's message of "Mon\, 16 Jun 2008 10\:31\:22 +0800") References: <3bd412d40806151931s3cef9027x73d83943386f0cad@mail.gmail.com> Message-ID: <87skvdzta3.fsf@malde.org> "Magicloud Magiclouds" writes: > static int old; > int diff (int now) { /* this would be called once a second */ > int ret = now - old; > old = now; > return ret; > } > Because there is no "variable" in Haskell. So how to do this in a FP way? I would claim the FP way is like this: -- | Repeatedly subtract values from a baseline, returning a list -- containing each intermediate result diff :: Int -> [Int] -> [Int] diff = scanl (-) Prelude> diff 100 [1..10] [100,99,97,94,90,85,79,72,64,55,45] -k -- If I haven't seen further, it is by standing in the footprints of giants From g9ks157k at acme.softbase.org Mon Jun 16 05:55:45 2008 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Mon Jun 16 05:47:53 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: <1213564676.15010.596.camel@localhost> References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <3d96ac180806141121k2c388ed4pd9f960bda540d45f@mail.gmail.com> <1213564676.15010.596.camel@localhost> Message-ID: <200806161155.46039.g9ks157k@acme.softbase.org> Am Sonntag, 15. Juni 2008 23:17 schrieb Duncan Coutts: > [?] > If we get a proper way to export a non-flat namespace then Gtk2Hs will > certainly switch to using it. Using 'buttonBlah' is horrible but there > is currently nothing better. So is there anyone who wants to file a feature request? > [?] Best wishes, Wolfgang From michal.palka at poczta.fm Mon Jun 16 06:48:38 2008 From: michal.palka at poczta.fm (=?UTF-8?Q?Micha=C5=82_Pa=C5=82ka?=) Date: Mon Jun 16 06:40:43 2008 Subject: [Haskell-cafe] How to do this in FP way? In-Reply-To: <87skvdzta3.fsf@malde.org> References: <3bd412d40806151931s3cef9027x73d83943386f0cad@mail.gmail.com> <87skvdzta3.fsf@malde.org> Message-ID: <1213613318.4200.6.camel@localhost> On Mon, 2008-06-16 at 10:19 +0200, Ketil Malde wrote: > "Magicloud Magiclouds" writes: > > > static int old; > > int diff (int now) { /* this would be called once a second */ > > int ret = now - old; > > old = now; > > return ret; > > } > > > Because there is no "variable" in Haskell. So how to do this in a FP way? > > I would claim the FP way is like this: > > -- | Repeatedly subtract values from a baseline, returning a list > -- containing each intermediate result > diff :: Int -> [Int] -> [Int] > diff = scanl (-) > > Prelude> diff 100 [1..10] > [100,99,97,94,90,85,79,72,64,55,45] Better yet, you could create a recursive type that reflects what you are actually doing: newtype Step a = Step (a -> (a, Step a)) diff' :: Int -> Step Int diff' x = Step (\a -> let r = a - x in (r, diff' r)) This way it will be easier to resume previous diff computations. Best, Micha? From abhay.parvate at gmail.com Mon Jun 16 06:50:13 2008 From: abhay.parvate at gmail.com (Abhay Parvate) Date: Mon Jun 16 06:42:14 2008 Subject: [Haskell-cafe] Lazy IO. In-Reply-To: References: Message-ID: <3c4d5adf0806160350h5b74d3f9p4847da987712f14a@mail.gmail.com> hGetContents reads the entire contents of the stream till the end (although lazily). The return value of hGetContents is logically the entire contents of the stream. That it has not read it completely is only a part of its laziness, so the result does not depend upon when the caller stops consuming the result. That is why the handle is semi-closed; logically the handle is already at the end of the stream. A complete parser to parse the header and the body has to be used on the entire contents, or some function which knows how to find the header end and stop there has to be used. Regards, Abhay On Sat, Jun 14, 2008 at 9:48 PM, Sebastiaan Visser wrote: > Hi, > > I've got a question about lazy IO in Haskell. The most well known > function to do lazy IO is the `hGetContents', which lazily reads all the > contents from a handle and returns this as a regular [Char]. > > The thing with hGetContents is that is puts the Handle in a semi-closed > state, no one can use the handle anymore. This behaviour is > understandable from the point of safety; it is not yet determined when > the result of hGetContents will actually be computed, using the handle > in the meantime is undesirable. > > The point is, I think I really have a situation in which I want to use > the handle again `after' a call to hGetContents. I think I can best > explain this using a code example. > > readHttpMessage :: IO (Headers, Data.ByteString.Lazy.ByteString) > readHttpMessage = do > myStream <- > request <- hGetContents myStream > header <- parseHttpHeader request > bs <- Data.ByteString.Lazy.hGetContents myStream > return (header, body) > > The Data.ByteString.Lazy.hGetContents in the example above obviously > fails because the handle is semi-closed. > > So, what I am trying to do here is apply a parser (on that consumes > Char's) to the input stream until it has succeeded. After this I want to > collect the remainings of the stream in a lazy ByteString, or maybe even > something else. > > I tried to open the handler again using some internal handle hackery, > but this failed (luckily). In the module GHC.IO there is a function > `lazyRead' that more or less seems to do what I want. But I'll guess > there is a good reason for not exporting it. > > Does anyone know a pattern in which I can do this easily? > > Thanks, > > -- > Sebastiaan > > _______________________________________________ > 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/20080616/59d823ab/attachment.htm From isaacdupree at charter.net Mon Jun 16 07:43:07 2008 From: isaacdupree at charter.net (Isaac Dupree) Date: Mon Jun 16 07:35:05 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <200806061412.23585.g9ks157k@acme.softbase.org> <20080607024543.52z9hkmgz4s8o4g8-nwo@webmail.spamcop.net> <87ve0ibt6n.fsf@malde.org> <1213036865.15010.448.camel@localhost> Message-ID: <485651CB.4000904@charter.net> Henning Thielemann wrote: > > On Mon, 9 Jun 2008, Duncan Coutts wrote: > >> On Mon, 2008-06-09 at 16:04 +0200, Ketil Malde wrote: >> >>> And - is there a way to make GHCi use aliased qualification? I find >>> my self typing detailed taxonomies all the time there. >> >> The ghci syntax currently is: >> :m Data.Set >> wouldn't it be much nicer as: >> import Data.Set >> then we could have the obvious: >> import Data.Set as Set > > This would be nice! Feature request? feature request filed for this, http://hackage.haskell.org/trac/ghc/ticket/2362 . For extending the import syntax in general, I wasn't sure we knew quite what we wanted yet, so it seemed a little premature for a feature request. (the first step in "implementing" the feature request would have to be specifying an exact design and probably asking for community feedback). So let's talk about what we do or don't want for that one some more, perhaps. From isaacdupree at charter.net Mon Jun 16 08:02:10 2008 From: isaacdupree at charter.net (Isaac Dupree) Date: Mon Jun 16 07:54:08 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: <1213564676.15010.596.camel@localhost> References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <3d96ac180806091353q6fd8cyc78eb513c8a6c4c5@mail.gmail.com> <3d96ac180806140728m1061e1bdr43f3a4759554b0b2@mail.gmail.com> <3d96ac180806141038k46ea8058v60f8d78f59bc6a81@mail.gmail.com> <3d96ac180806141121k2c388ed4pd9f960bda540d45f@mail.gmail.com> <1213564676.15010.596.camel@localhost> Message-ID: <48565642.2040403@charter.net> Duncan Coutts wrote: > Right. That's exactly why we've not done something like that. With 100+ > modules in the Gtk package it's totally infeasible to do qualified > imports of them all. > > If we get a proper way to export a non-flat namespace then Gtk2Hs will > certainly switch to using it. Using 'buttonBlah' is horrible but there > is currently nothing better. okay, it's horrible! It's no more manually-traceable than anything else either, if you just import Gtk2Hs unqualified. Is there any way it could possibly be acceptably concise *and* traceable? let's see If "GTK" appears in every usage (e.g. GTK.buttonBlah, gtkButtonBlah...), probably not at all concise enough for GUI code! But if it doesn't, then we would need at minimum to list each of those ones that we used (probably not all 100 of them). It couldn't get any more concise than this to use Button.blah etc.: import GTK.modules (Button, Window, ...) never mind the exact syntax yet -- is listing them acceptable? (and if there are so many, is it practically traceable by humans anyway? Perhaps we're assuming that these humans at least have "search this file" editor-capabilities?) Are there multiple "blah" functions among the GTK modules? I.e. would GTK.blah be unambiguous, not mentioning that it's a button function. (And would it be too confusing not to mention that it's a button function...) If it would be ambiguous, would typeclasses work to fix that (or renaming functions that have no good reason to have the same name, or occasionally including blahButton sort of names)? If 100 modules is too much, would it be a reasonable compromise between clarity and conciseness to export coarser-grained, so there are only maybe half a dozen GTK modules that your typical program imports? > There have been a few suggestions along these lines. Check the archives. > I'm not sure what is proposed for haskell', probably nothing since > nothing is currently implemented and we're only supposed to be > standardising existing practise. I had trouble in my first attempt to search the archives... Googling for "import" in haskell-cafe found too much code, and my personal e-mail records back to March 2007 found nothing else relevant with "import" in the title. -Isaac From bulat.ziganshin at gmail.com Mon Jun 16 08:12:45 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Jun 16 08:05:00 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: <48565642.2040403@charter.net> References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <3d96ac180806091353q6fd8cyc78eb513c8a6c4c5@mail.gmail.com> <3d96ac180806140728m1061e1bdr43f3a4759554b0b2@mail.gmail.com> <3d96ac180806141038k46ea8058v60f8d78f59bc6a81@mail.gmail.com> <3d96ac180806141121k2c388ed4pd9f960bda540d45f@mail.gmail.com> <1213564676.15010.596.camel@localhost> <48565642.2040403@charter.net> Message-ID: <1483943909.20080616161245@gmail.com> Hello Isaac, Monday, June 16, 2008, 4:02:10 PM, you wrote: > Are there multiple "blah" functions among the GTK modules? I.e. would > GTK.blah be unambiguous, not mentioning that it's a button function. yes. actually, gtk2hs uses typeclasses to overload functions over various types -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From claus.reinke at talk21.com Mon Jun 16 08:25:42 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Mon Jun 16 08:17:44 2008 Subject: [Haskell-cafe] cabal-install failure References: <1213392126.15010.547.camel@localhost> <20080614021052.GA8862@craft><1213430194.15010.556.camel@localhost><008501c8ce05$ec0ef260$f82b8351@cr3lt> <1213559354.15010.580.camel@localhost> Message-ID: <006201c8cfac$1920be80$3a448351@cr3lt> > The main point of the Program abstraction is about configuring and > running programs. As it happens some programs are provided by some > haskell packages (but not all, eg ld, ar, etc). > >> option to get version info and code to extract it (with one apparently >> very special case being hsc2hs). > > And ld.exe on windows (we find it in ghc's gcc-lib bin dir). I didn't notice this special case in Program.hs - are my sources just out of date, or is this special handling encoded elsewhere? >> Btw, most of the version extraction code looks like a regular >> expression match - wouldn't that make the specification easier >> (and turn the comments into part of the spec)? > > True, in most cases finding the name of the program involves running it > with some --version flag and matching some part of the output. However > that's not always the case. Some programs do silly things like produce > the version output on stderr instead of stdout. We figured the most > general thing was just a function > > FilePath -> IO (Maybe Version) > > which is what we've got. I'm not sure what the advantage would be to > make it more declarative by making it into data rather than a extraction > function. Usually, the most general approach for this kind of problem is good as a default/backup, but not so good for maintenance. The more cases can be handled with dedicated declarative specs, the smaller the risk of accidental/hidden breakage (eg, moving the comments into regex patterns), the more compact and understandable the specs (a line per tool, with option and regex, all in one place would be easier to comprehend than the current free-coding style). More importantly, concise declarative specs are easier to update and extend (could be done by users rather than Cabal maintainers, and preferably outside of Cabal sources). > Also, the Cabal lib cannot depend on any regular expression library > because they are not part of the bootstrapping library set. Sigh. I've heard that one before, and the ghc-pkg bulk queries are not as flexible as they could be because I had to use less expressive functions instead of regexes. Since Haskell-only regex packages exist, perhaps one should just be added to the bootlib set? After all, we bother with regexes because they are so frequently useful. >> 1. Haskell tools should register with Cabal, whether built with it >> (such as Alex, Happy, ..) or not (such as GHC, ..). That >> registration should include any build-relevant information >> (versions/variants, ..). >> >> 2. When checking a build-tools dependency, Cabal checks >> (a) whether the tool is registered with Cabal > > I'm not sure this helps. We want to know what to install when it's > missing. We can already tell if a program (not package) is available by > searching for it. But that means either configure or a subset of special configure rules baked into Cabal's sources, combined with fragile Setup.hs extensions to that subset. IMHO, the less of configure/hardcoded rules/Setup.hs, the better (simpler, less breakage with Cabal updates, etc.). How about this: instead of baking rules for those tools into the Cabal sources, why not have a single "known-tools" package? On (re-)installing that package, its configure/Setup is run once, to register availability and build-related information for all those tools with Cabal (currently, that would mean a package per tool; later, the known-tools package itself could expose multiple tools, but Cabal would still need to be able to check which of the "exposed-tools" have been found). That way, the known-tools could be updated independently, instead of requring Cabal source hacking and releases, and instead of spreading special configure rules for common tools over all packages, they'd be located in a single package (easier to maintain and improve, and improvements are shared). >> (b) whether the tool is registered with the system installation manager > > This is hard. Why? Because there are more installation managers than OSs, or because so many program installs bypass them? Querying an installation manager shouldn't be any more difficult than querying ghc-pkg, say. If a program is registered with, eg. Windows Add/Remove Programs, I can use "reg query " to find its registration info, and if I don't know the key, I can use reg query HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall /s to list all registered programs, or reg export HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall to get all registration info dumped to a file, and look for DisplayNames of the tools I'm interested in: >reg query HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall /s | find "DisplayName" | find "Opera" DisplayName REG_SZ Opera 9.50 >reg query HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall /s | find "DisplayName" | find "Hugs" DisplayName REG_SZ WinHugs >reg query HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall /s | find "DisplayName" | find "Haskell" DisplayName REG_SZ Glasgow Haskell Compiler, version 6.4.1 Of course, the tools I'm interested in very often bypass the Windows installer (eg, I prefer tarballs for GHC, and GHC comes with its own internally used set of tools, or Cygwin handles its own tools itself, and so on) and so won't appear in that output.. Claus >> (c) whether the tool can be found by other means (configure, >> built-in rules, ..) >> >> In other words, make tools look like packages (lifetime dependency >> management, not just build support), and make system packages look >> like Cabal packages (Cabal as the interface to native managers), using >> special treatment only if absolutely necessary. I thought those suggestions >> were clear from my earlier messages?-) > > Sure, haskell executable tools built by haskell packages are really > packages. > > So the problem currently is that build-tools refers to programs not > packages. One can list any known program in the build-tools field and > the list of programs is extensible in the Setup.hs script. > > As they are used so far by current packages on hackage, they always > refer to haskell tools built by haskell packages (almost only used to > refer to alex, happy and c2hs) so perhaps we should just quietly > redefine the meaning on build-tools to be another kind of build-depends. > That is it specifies a haskell package. > > If we have need to specify non-haskell build tools, perhaps we should do > that separately? eg "some-other-kind-of-build-tools: perl >= 5.8" > > Duncan > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From jules at jellybean.co.uk Mon Jun 16 08:51:14 2008 From: jules at jellybean.co.uk (Jules Bean) Date: Mon Jun 16 08:43:14 2008 Subject: [Haskell-cafe] Design your modules for qualified import In-Reply-To: <1213564676.15010.596.camel@localhost> References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <3d96ac180806091353q6fd8cyc78eb513c8a6c4c5@mail.gmail.com> <3d96ac180806140728m1061e1bdr43f3a4759554b0b2@mail.gmail.com> <3d96ac180806141038k46ea8058v60f8d78f59bc6a81@mail.gmail.com> <3d96ac180806141121k2c388ed4pd9f960bda540d45f@mail.gmail.com> <1213564676.15010.596.camel@localhost> Message-ID: <485661C2.6070701@jellybean.co.uk> Duncan Coutts wrote: > If we get a proper way to export a non-flat namespace then Gtk2Hs will > certainly switch to using it. Using 'buttonBlah' is horrible but there > is currently nothing better. Whilst I'm sure anyone who's used deep module structures has wondered about this feature, I've seen no serious proposal of any kind. Does anyone know what this should look like? Jules From jules at jellybean.co.uk Mon Jun 16 08:58:28 2008 From: jules at jellybean.co.uk (Jules Bean) Date: Mon Jun 16 08:50:24 2008 Subject: [Haskell-cafe] Lazy IO. In-Reply-To: References: Message-ID: <48566374.7070803@jellybean.co.uk> Sebastiaan Visser wrote: > Does anyone know a pattern in which I can do this easily? Don't use hGetContents on a socket. That's asking for trouble. Use hGetContents either NEVER (easy option) or only on throwaway handles/files which won't be used again. Jules From claus.reinke at talk21.com Mon Jun 16 09:01:20 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Mon Jun 16 08:53:29 2008 Subject: [Haskell-cafe] Design your modules for qualified import References: <90889fe70806050819x44313662s9c48ecb77d776f3@mail.gmail.com> <3d96ac180806091353q6fd8cyc78eb513c8a6c4c5@mail.gmail.com> <3d96ac180806140728m1061e1bdr43f3a4759554b0b2@mail.gmail.com> <3d96ac180806141038k46ea8058v60f8d78f59bc6a81@mail.gmail.com> <3d96ac180806141121k2c388ed4pd9f960bda540d45f@mail.gmail.com><1213564676.15010.596.camel@localhost> <485661C2.6070701@jellybean.co.uk> Message-ID: <00db01c8cfb1$174b48f0$3a448351@cr3lt> > Duncan Coutts wrote: >> If we get a proper way to export a non-flat namespace then Gtk2Hs will >> certainly switch to using it. Using 'buttonBlah' is horrible but there >> is currently nothing better. > > Whilst I'm sure anyone who's used deep module structures has wondered > about this feature, I've seen no serious proposal of any kind. google for "haskell package mounting" or "haskell package grafting". Perhaps the discussion has appeared under other keywords, but those are the ones that spring to mind. Claus From sfvisser at cs.uu.nl Mon Jun 16 09:11:03 2008 From: sfvisser at cs.uu.nl (Sebastiaan Visser) Date: Mon Jun 16 09:03:13 2008 Subject: [Haskell-cafe] Lazy IO. In-Reply-To: <48566374.7070803@jellybean.co.uk> References: <48566374.7070803@jellybean.co.uk> Message-ID: <7C297066-C27B-456E-B2C3-C526A09CD5B8@cs.uu.nl> On Jun 16, 2008, at 2:58 PM, Jules Bean wrote: > Sebastiaan Visser wrote: >> Does anyone know a pattern in which I can do this easily? > > Don't use hGetContents on a socket. That's asking for trouble. Can you please explain why? What is a more easier method to spool your HTTP post data to a file than: Bs.hGetContens sock >>= Bs.hPut fd ? > Use hGetContents either NEVER (easy option) or only on throwaway > handles/files which won't be used again. My sockets will be thrown away eventually. Isn't anything? I can imagine that this can be a problem when using Keep-Alive connections - or alike - but that is a whole different story. > Jules Thanks, Sebas. From jules at jellybean.co.uk Mon Jun 16 09:14:18 2008 From: jules at jellybean.co.uk (Jules Bean) Date: Mon Jun 16 09:06:14 2008 Subject: [Haskell-cafe] Lazy IO. In-Reply-To: <7C297066-C27B-456E-B2C3-C526A09CD5B8@cs.uu.nl> References: <48566374.7070803@jellybean.co.uk> <7C297066-C27B-456E-B2C3-C526A09CD5B8@cs.uu.nl> Message-ID: <4856672A.4020509@jellybean.co.uk> Sebastiaan Visser wrote: > On Jun 16, 2008, at 2:58 PM, Jules Bean wrote: > >> Sebastiaan Visser wrote: >>> Does anyone know a pattern in which I can do this easily? >> >> Don't use hGetContents on a socket. That's asking for trouble. > > Can you please explain why? Because it's a broken abstraction. It's only correct if all you will ever do is read all the data into one String and don't care about it after that. In my experience this is almost never true of sockets : there is always protocol overhead, handshaking, and the "next request". It might be fine for unusually simple socket setups. > > What is a more easier method to spool your HTTP post data to a file than: > > Bs.hGetContens sock >>= Bs.hPut fd > > ? Yes, that's fine. From barsoap at web.de Mon Jun 16 12:28:39 2008 From: barsoap at web.de (Achim Schneider) Date: Mon Jun 16 12:21:08 2008 Subject: [Haskell-cafe] Re: How to do this in FP way? References: <3bd412d40806151931s3cef9027x73d83943386f0cad@mail.gmail.com> <20080616060033.396f1e5c@solaris> <9A3A3243-08F0-42DD-80BC-6FFD6BB73274@gmail.com> Message-ID: <20080616182839.61db51cc@solaris> Thomas Davie wrote: > > > > One half of all Haskell coders will tell you that mutable state > > isn't a > > good starting point to learn Haskell, the other half will tell you > > the same because they want to be cool kids, too. > > And the one left over will point out that he asked how to do this > the FP way, not the imperative way? > There's no difference, as you can't do time-accounting non-strict and still expect it to give meaningful results: I'm merely trying to be helpful. None of the other solutions allow for the IO Monad. -- (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 Mon Jun 16 12:31:48 2008 From: barsoap at web.de (Achim Schneider) Date: Mon Jun 16 12:27:04 2008 Subject: [Haskell-cafe] Re: Lazy IO. References: <48566374.7070803@jellybean.co.uk> <7C297066-C27B-456E-B2C3-C526A09CD5B8@cs.uu.nl> <4856672A.4020509@jellybean.co.uk> Message-ID: <20080616183148.558e0047@solaris> Jules Bean wrote: > Sebastiaan Visser wrote: > > On Jun 16, 2008, at 2:58 PM, Jules Bean wrote: > > > >> Sebastiaan Visser wrote: > >>> Does anyone know a pattern in which I can do this easily? > >> > >> Don't use hGetContents on a socket. That's asking for trouble. > > > > Can you please explain why? > > Because it's a broken abstraction. > > It's only correct if all you will ever do is read all the data into > one String and don't care about it after that. > > In my experience this is almost never true of sockets : there is > always protocol overhead, handshaking, and the "next request". > It works for HTTP, as all responses MUST be in the same order as the requests. -- (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 ndmitchell at gmail.com Mon Jun 16 12:43:04 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Mon Jun 16 12:35:01 2008 Subject: [Haskell-cafe] Design suggestion for Data.Binary.Defer Message-ID: <404396ef0806160943r381f0b90ue418cb86bca0bc95@mail.gmail.com> Hi, I'm in the process of updating the Deferred Binary library, http://www-users.cs.york.ac.uk/~ndm/binarydefer/. The idea is that its does serialisation, but certain elements can be marked as deferred - instead of being written in the current file stream, they are merely pointed at and if needed, that pointer will be followed. Example:("hello","world"), where the first field is marked as deferred would write out: [6]"world""hello" i.e. [skip 6 characters if you want hello], the "world" data, the "hello" data we previously promised to put here. When reading, the "hello" would only be seeked to and read if necessary. So, its like binary, but some fields are lazy. The question is how to indicate which fields are lazy. There are three schemes I can think of: == Simple Instances == put (a,b) = putDefer a >> put b get = do a <- getDefer; b <- get; return (a,b) If the put/get and putDefer/getDefer items do not line up perfectly it will go very wrong at runtime - probably resulting in random values being created. You also can't derive the instances automatically, with something like Derive or DrIFT. == Complex Instances == This is the current scheme, based on lazy pattern matching and exceptions - very confusing, probably low performance. deferBoth = [\~(a,b) -> unit (,) <<~ a << b] Where <<~ a means write out the a field lazily, and << b means write out the b field strictly. The advantage over the simple instances is that a field being deferred is declared once. == Lazy Data Type == Instead of customizing the instance, you can write a data Defer a = Defer a type, and then instead of the original tuple write: (Defer "hello","world") But now the code must unwrap the Defer before accessing "hello", but the instance becomes much simpler, and can be derived. == The Question == Is there a simple way of tagging fields in a constructor as deferred, just once for reading and writing, and ideally outside the instance definition and not requiring additional code to unwrap? I can't think of any, but there may be something I have missed. Thanks Neil From tom.davie at gmail.com Mon Jun 16 13:06:21 2008 From: tom.davie at gmail.com (Thomas Davie) Date: Mon Jun 16 12:58:24 2008 Subject: [Haskell-cafe] Re: How to do this in FP way? In-Reply-To: <20080616182839.61db51cc@solaris> References: <3bd412d40806151931s3cef9027x73d83943386f0cad@mail.gmail.com> <20080616060033.396f1e5c@solaris> <9A3A3243-08F0-42DD-80BC-6FFD6BB73274@gmail.com> <20080616182839.61db51cc@solaris> Message-ID: <3A5E5DA6-62B3-44E0-9012-883E098CBEFB@gmail.com> On 16 Jun 2008, at 18:28, Achim Schneider wrote: > Thomas Davie wrote: > >>> >>> One half of all Haskell coders will tell you that mutable state >>> isn't a >>> good starting point to learn Haskell, the other half will tell you >>> the same because they want to be cool kids, too. >> >> And the one left over will point out that he asked how to do this >> the FP way, not the imperative way? >> > There's no difference, as you can't do time-accounting non-strict and > still expect it to give meaningful results: I'm merely trying to be > helpful. None of the other solutions allow for the IO Monad. Firstly, I'd phrase that differently -- the IO Monad doesn't allow for the other solutions -- the other solutions are the truly functional ones. Secondly, I'm curious as to why you think that the two are incompatible, are you saying that for any meaningful kind of computation we need to resort to IORefs? I'd strongly contest that idea. Bob From daveroundy at gmail.com Mon Jun 16 13:17:02 2008 From: daveroundy at gmail.com (David Roundy) Date: Mon Jun 16 13:09:01 2008 Subject: [Haskell-cafe] How to do this in FP way? In-Reply-To: <3bd412d40806151931s3cef9027x73d83943386f0cad@mail.gmail.com> References: <3bd412d40806151931s3cef9027x73d83943386f0cad@mail.gmail.com> Message-ID: <117f2cc80806161017w680f5c83p3165733e46256be0@mail.gmail.com> 2008/6/15 Magicloud Magiclouds : > Hello, > I am getting familiar with FP now, and I have a "program design" kind of > question. > Say I have something like this in C: > static int old; > int diff (int now) { /* this would be called once a second */ > int ret = now - old; > old = now; > return ret; > } > Because there is no "variable" in Haskell. So how to do this in a FP > way? A better question would be to think about what you are trying to accomplish, and then ask how to achieve that through functional programming. David From barsoap at web.de Mon Jun 16 13:24:06 2008 From: barsoap at web.de (Achim Schneider) Date: Mon Jun 16 13:16:12 2008 Subject: [Haskell-cafe] Re: How to do this in FP way? References: <3bd412d40806151931s3cef9027x73d83943386f0cad@mail.gmail.com> <20080616060033.396f1e5c@solaris> <9A3A3243-08F0-42DD-80BC-6FFD6BB73274@gmail.com> <20080616182839.61db51cc@solaris> <3A5E5DA6-62B3-44E0-9012-883E098CBEFB@gmail.com> Message-ID: <20080616192406.114c1a88@solaris> Thomas Davie wrote: > > On 16 Jun 2008, at 18:28, Achim Schneider wrote: > > > Thomas Davie wrote: > > > >>> > >>> One half of all Haskell coders will tell you that mutable state > >>> isn't a > >>> good starting point to learn Haskell, the other half will tell you > >>> the same because they want to be cool kids, too. > >> > >> And the one left over will point out that he asked how to do this > >> the FP way, not the imperative way? > >> > > There's no difference, as you can't do time-accounting non-strict > > and still expect it to give meaningful results: I'm merely trying > > to be helpful. None of the other solutions allow for the IO Monad. > > Firstly, I'd phrase that differently -- the IO Monad doesn't allow > for the other solutions -- the other solutions are the truly > functional ones. Secondly, I'm curious as to why you think that the > two are incompatible, are you saying that for any meaningful kind of > computation we need to resort to IORefs? I'd strongly contest that > idea. > We have to resort to IO actions to get the time, and to IORefs because we need to chain up different calls to getCurrentTime using the IO Monad. The rest of the program can work with whatever you like best. -- (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 k.pierre.k at gmail.com Mon Jun 16 13:54:44 2008 From: k.pierre.k at gmail.com (pierre) Date: Mon Jun 16 13:46:54 2008 Subject: [Haskell-cafe] How to do this in FP way? In-Reply-To: <3bd412d40806151931s3cef9027x73d83943386f0cad@mail.gmail.com> References: <3bd412d40806151931s3cef9027x73d83943386f0cad@mail.gmail.com> Message-ID: <20080616175444.GC11246@localdomain> On Mon, Jun 16, 2008 at 10:31:22AM +0800, Magicloud Magiclouds wrote: > Hello, > I am getting familiar with FP now, and I have a "program design" kind of > question. > Say I have something like this in C: > static int old; > int diff (int now) { /* this would be called once a second */ > int ret = now - old; > old = now; > return ret; > } > Because there is no "variable" in Haskell. So how to do this in a FP > way? > > Thanks. I think that "called once a second" suggests that you perhaps should not do that in a FP way. A state-changing function called frequently suggests that you are perhaps doing something with a notion of time, maybe a game? Then FRP is your FP approach. Or I would recommend you to explain your problem, because FP approach could lie on much more higher level than one can figure out looking at your short snippet. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- pierre From lemming at henning-thielemann.de Mon Jun 16 14:59:23 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon Jun 16 14:51:21 2008 Subject: [Haskell-cafe] Re: How to do this in FP way? In-Reply-To: <20080616192406.114c1a88@solaris> References: <3bd412d40806151931s3cef9027x73d83943386f0cad@mail.gmail.com> <20080616060033.396f1e5c@solaris> <9A3A3243-08F0-42DD-80BC-6FFD6BB73274@gmail.com> <20080616182839.61db51cc@solaris> <3A5E5DA6-62B3-44E0-9012-883E098CBEFB@gmail.com> <20080616192406.114c1a88@solaris> Message-ID: On Mon, 16 Jun 2008, Achim Schneider wrote: > We have to resort to IO actions to get the time, and to IORefs because > we need to chain up different calls to getCurrentTime using the IO > Monad. The rest of the program can work with whatever you like best. Isn't (StateT s IO a) the cleaner alternative to IORef? From barsoap at web.de Mon Jun 16 15:11:11 2008 From: barsoap at web.de (Achim Schneider) Date: Mon Jun 16 15:03:21 2008 Subject: [Haskell-cafe] Re: How to do this in FP way? References: <3bd412d40806151931s3cef9027x73d83943386f0cad@mail.gmail.com> <20080616060033.396f1e5c@solaris> <9A3A3243-08F0-42DD-80BC-6FFD6BB73274@gmail.com> <20080616182839.61db51cc@solaris> <3A5E5DA6-62B3-44E0-9012-883E098CBEFB@gmail.com> <20080616192406.114c1a88@solaris> Message-ID: <20080616211111.1b20f7b9@solaris> Henning Thielemann wrote: > > On Mon, 16 Jun 2008, Achim Schneider wrote: > > > We have to resort to IO actions to get the time, and to IORefs > > because we need to chain up different calls to getCurrentTime using > > the IO Monad. The rest of the program can work with whatever you > > like best. > > Isn't (StateT s IO a) the cleaner alternative to IORef? > Yes. But then using one IORef in one place won't make your program harder to understand, using Monad transformers quite certainly will. Admittedly, I'm becoming dodgy. -- (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 sebastian.sylvan at gmail.com Mon Jun 16 15:14:48 2008 From: sebastian.sylvan at gmail.com (Sebastian Sylvan) Date: Mon Jun 16 15:06:47 2008 Subject: [Haskell-cafe] How to do this in FP way? In-Reply-To: <3bd412d40806151931s3cef9027x73d83943386f0cad@mail.gmail.com> References: <3bd412d40806151931s3cef9027x73d83943386f0cad@mail.gmail.com> Message-ID: <3d96ac180806161214o7c6b7fd8q77e8811dd4803fd0@mail.gmail.com> On 6/16/08, Magicloud Magiclouds wrote: > > Hello, > I am getting familiar with FP now, and I have a "program design" kind > of question. > Say I have something like this in C: > static int old; > int diff (int now) { /* this would be called once a second */ > int ret = now - old; > old = now; > return ret; > } > Because there is no "variable" in Haskell. So how to do this in a FP > way? The short answer is that your question amounts to "How do I do imperative programming in an FP way", to which the answer is "you really should try to avoid it". Longer answer: I think you'll be bette served if you describe your problem on a much higher level than this. Chances are that if you write your program in an FP way, you wouldn't need a function like your diff. That said, Haskell do have variables (in this case an IORef would do what you want), but again, you probably don't want that, so if you post what problem you're trying to solve using "diff", then it will be easier to help you design it in an FP way. Doing things in an FP way tend to impact your program a lot more than just some minor changes to the functions at the "bottom", it will change the whole design. -- Sebastian Sylvan +44(0)7857-300802 UIN: 44640862 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080616/79698302/attachment.htm From ryani.spam at gmail.com Mon Jun 16 17:22:55 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Mon Jun 16 17:14:53 2008 Subject: [Haskell-cafe] monomorphism restriction In-Reply-To: <1213242536.6353.6.camel@jonathans-macbook> References: <20080612032402.GA25431@scytale.galois.com> <1213242536.6353.6.camel@jonathans-macbook> Message-ID: <2f9b2d30806161422m1278062eob0885aaf124c453d@mail.gmail.com> On 6/11/08, Jonathan Cast wrote: > This doesn't apply to f, though --- it has a function type, so the user > presumably already knows it won't be subject to updating, no? > Distinguishing functions from variables by the form of declaration, > rather than the type, seems somewhat questionable to me. Not necessarily, contrast these two definitions: f = foldr (+) 0 f_expensive = let n = head $ drop 100000 $ fibs 1 1 in foldr (+) n With the monomorphism restriction in place, f_expensive only calculates n once. Without, it gets calculated each time f is instantiated. -- ryan From andrewcoppin at btinternet.com Mon Jun 16 15:46:16 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Mon Jun 16 17:28:33 2008 Subject: [Haskell-cafe] How to do this in FP way? In-Reply-To: <117f2cc80806161017w680f5c83p3165733e46256be0@mail.gmail.com> References: <3bd412d40806151931s3cef9027x73d83943386f0cad@mail.gmail.com> <117f2cc80806161017w680f5c83p3165733e46256be0@mail.gmail.com> Message-ID: <4856C308.4050506@btinternet.com> David Roundy wrote: > > A better question would be to think about what you are trying to > accomplish, and then ask how to achieve that through functional > programming. > Amen! I was waiting for somebody to say that... There are a dozen situations in an imperative language where you'd write a loop. But in Haskell, you might well do something entirely different for each situation. So it really pays to focus on what the end result you're after is, rather than how to translate imperative code line-for-line into Haskell. From ryani.spam at gmail.com Mon Jun 16 17:40:07 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Mon Jun 16 17:32:04 2008 Subject: [Haskell-cafe] FunPtr error? In-Reply-To: <5ae4f2ba0806132340w39031820q3e1e86723760469@mail.gmail.com> References: <5ae4f2ba0806081917u3cbeada0ge4968bb5183c888e@mail.gmail.com> <1097402345.20080609095428@gmail.com> <5ae4f2ba0806082324t53691b06se7efa48f5df7c379@mail.gmail.com> <5ae4f2ba0806091118y922e881nbcb1a945cc765bb3@mail.gmail.com> <2f9b2d30806091216j137abcbbj34761d6f7861c5f4@mail.gmail.com> <5ae4f2ba0806092054q75176dc0h1d9da81d4eacf877@mail.gmail.com> <6d74b0d20806092125n31df313ex483f42fc0557b06e@mail.gmail.com> <5ae4f2ba0806092301p2b5e9530r828abf6436e4d07d@mail.gmail.com> <5ae4f2ba0806132259o26632f1bsa159839029529fc@mail.gmail.com> <5ae4f2ba0806132340w39031820q3e1e86723760469@mail.gmail.com> Message-ID: <2f9b2d30806161440m2385529co3e49e7f2c7ca1f5d@mail.gmail.com> The simple explanation is "because the FFI standard says so"; primitive types wrapped in newtypes automatically get wrapped and unwrapped during FFI calls. See http://www.cse.unsw.edu.au/~chak/haskell/ffi/ffi/ffise3.html#x6-120003.2 ; the FFI uses "renamed datatype" to mean newtype. Consider the following declarations translated to C: > type Weak = Word32 > {- typedef HsWord32 Weak; } Weak is just a type alias; you can use Word32 and Weak interchangeably in your code after delcaring this type. > newtype Strong = Strong Word32 > {- doesn't really exist in C; google for "c strong typedef" -} Strong behaves exactly like a Word32 at runtime, in terms of storage, but the typechecker can distinguish it from Word32. > data Holder = Holder Word32 > {- typedef struct { HsWord32 x; } Holder; -} Holder, on the other hand, is entirely separate from Word32; in fact, there are strictly more values in Haskell of type Holder than there are of type Word32: > ha, hb, hc :: Holder -- can all be distinguished at runtime > ha = undefined > hb = Holder undefined > hc = Holder 0 > sa, sb :: Strong -- cannot be distinguished > sa = undefined > sb = Strong undefined From robert.t.taepke at medtronic.com Mon Jun 16 17:51:24 2008 From: robert.t.taepke at medtronic.com (Taepke, Bob) Date: Mon Jun 16 17:43:22 2008 Subject: [Haskell-cafe] C-program calling Haskell program? Message-ID: Hello, I am very new to Haskell, and I work in Windows XP. Can anyone please point me to a working C / Haskell program pair that does the following: 1) The C routine passes one or more scalars, arrays, or matrices to the Haskell routine. 2) The Haskell routine reads a comma-delimited, ASCII file from the path, C:\my_directory\input_data\. 3) The Haskell routine writes a comma-delimited, ASCII file to the path, C:\my_directory\output_data\. 4) The Haskell routine returns to the C routine one or more scalars, arrays, or matrices. 5) For what it's worth, I'm only using the C-routine as an interface between MATLAB and Haskell, because MATLAB can call C-routines. Has anyone written C / Haskell code that does the above tasks? If so, would you please be willing to pass it along to me? Thank you! Bob [CONFIDENTIALITY AND PRIVACY NOTICE] Information transmitted by this email is proprietary to Medtronic and is intended for use only by the individual or entity to which it is addressed, and may contain information that is private, privileged, confidential or exempt from disclosure under applicable law. If you are not the intended recipient or it appears that this mail has been forwarded to you without proper authority, you are notified that any use or dissemination of this information in any manner is strictly prohibited. In such cases, please delete this mail from your records. To view this notice in other languages you can either select the following link or manually copy and paste the link into the address bar of a web browser: http://emaildisclaimer.medtronic.com From derek.a.elkins at gmail.com Mon Jun 16 18:40:24 2008 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Mon Jun 16 18:32:31 2008 Subject: [Haskell-cafe] Design suggestion for Data.Binary.Defer In-Reply-To: <404396ef0806160943r381f0b90ue418cb86bca0bc95@mail.gmail.com> References: <404396ef0806160943r381f0b90ue418cb86bca0bc95@mail.gmail.com> Message-ID: <1213656024.5557.23.camel@derek-laptop> On Mon, 2008-06-16 at 17:43 +0100, Neil Mitchell wrote: > Hi, > > I'm in the process of updating the Deferred Binary library, > http://www-users.cs.york.ac.uk/~ndm/binarydefer/. The idea is that its > does serialisation, but certain elements can be marked as deferred - > instead of being written in the current file stream, they are merely > pointed at and if needed, that pointer will be followed. > > Example:("hello","world"), where the first field is marked as deferred > would write out: > > [6]"world""hello" > > i.e. [skip 6 characters if you want hello], the "world" data, the > "hello" data we previously promised to put here. When reading, the > "hello" would only be seeked to and read if necessary. > > So, its like binary, but some fields are lazy. The question is how to > indicate which fields are lazy. There are three schemes I can think > of: > > == Simple Instances == > > put (a,b) = putDefer a >> put b > get = do a <- getDefer; b <- get; return (a,b) > > If the put/get and putDefer/getDefer items do not line up perfectly it > will go very wrong at runtime - probably resulting in random values > being created. You also can't derive the instances automatically, with > something like Derive or DrIFT. > > == Complex Instances == > > This is the current scheme, based on lazy pattern matching and > exceptions - very confusing, probably low performance. > > deferBoth = [\~(a,b) -> unit (,) <<~ a << b] > > Where <<~ a means write out the a field lazily, and << b means write > out the b field strictly. The advantage over the simple instances is > that a field being deferred is declared once. > > == Lazy Data Type == > > Instead of customizing the instance, you can write a data Defer a = > Defer a type, and then instead of the original tuple write: > > (Defer "hello","world") > > But now the code must unwrap the Defer before accessing "hello", but > the instance becomes much simpler, and can be derived. > > == The Question == > > Is there a simple way of tagging fields in a constructor as deferred, > just once for reading and writing, and ideally outside the instance > definition and not requiring additional code to unwrap? I can't think > of any, but there may be something I have missed. This isn't an answer to your question. This is just my opinion based on my values. I'd just immediately do option three. It seems the simplest, most composable and most flexible, and I like having things reflected in my types. It seems easy enough to code up the first option given the last. I don't really understand what you are getting at with the second option, but I suspect it too is easy to do on top of the third option. From qdunkan at gmail.com Mon Jun 16 19:07:33 2008 From: qdunkan at gmail.com (Evan Laforge) Date: Mon Jun 16 18:59:30 2008 Subject: [Haskell-cafe] 1/0 Message-ID: <2518b95d0806161607p207c20b1rcf083488d246efc5@mail.gmail.com> So, I know this has been discussed before, but: > 1/0 Infinity > 0/0 NaN ... so I see from the archives that Infinity is mandated by ieee754 even though my intuition says both should be NaN. Every other language throws an exception, even C will crash the program, so I'm guessing it's telling the processor / OS to turn these into signals, while GHC is turning that off. Or something. But then what about this note in Control.Exception: (NOTE: GHC currently does not throw ArithExceptions except for DivideByZero) Doesn't this imply GHC should be throwing DivideByZero? Why is it in the stdlib if it's turned off? And why would it be turned off? I suppose I could accept the above since Infinity *is* an exceptional value meant to represent things like 1/0, and it can be nice to see NaNs in your output instead of crashing everything (this is, I assume, why ieee754 has these modes in the first place), but how about this: > round (0/0) :: Integer (huge negative number) Ok, so integral types don't have that exceptional value. Shouldn't trying to convert NaN or Infinity to an Integral throw something? Is it a performance thing? I'd think if you're converting to Integer you don't really need hardware level performance anyway, so a couple of checks wouldn't kill anyone. From daveroundy at gmail.com Mon Jun 16 19:12:52 2008 From: daveroundy at gmail.com (David Roundy) Date: Mon Jun 16 19:04:50 2008 Subject: [Haskell-cafe] Design suggestion for Data.Binary.Defer In-Reply-To: <404396ef0806160943r381f0b90ue418cb86bca0bc95@mail.gmail.com> References: <404396ef0806160943r381f0b90ue418cb86bca0bc95@mail.gmail.com> Message-ID: <117f2cc80806161612oe3f2033q187cbf5c22592f03@mail.gmail.com> On Mon, Jun 16, 2008 at 9:43 AM, Neil Mitchell wrote: > == The Question == > > Is there a simple way of tagging fields in a constructor as deferred, > just once for reading and writing, and ideally outside the instance > definition and not requiring additional code to unwrap? I can't think > of any, but there may be something I have missed. Is there any reason not to just write all lazy fields of variable size in a deferred manner? That would seem like the best option to me, but maybe that's just because I don't see any downside besides the requirement that one use some space to write the size. But that seems like it would almost always be a trivial issue, as any small data element will have a fixed size (so that the deferred/non-deferred distinction doesn't exist). David From daveroundy at gmail.com Mon Jun 16 19:18:01 2008 From: daveroundy at gmail.com (David Roundy) Date: Mon Jun 16 19:09:58 2008 Subject: [Haskell-cafe] 1/0 In-Reply-To: <2518b95d0806161607p207c20b1rcf083488d246efc5@mail.gmail.com> References: <2518b95d0806161607p207c20b1rcf083488d246efc5@mail.gmail.com> Message-ID: <117f2cc80806161618x5c2a717bo551b8e4ff384633@mail.gmail.com> On Mon, Jun 16, 2008 at 4:07 PM, Evan Laforge wrote: > So, I know this has been discussed before, but: > >> 1/0 > Infinity >> 0/0 > NaN > > ... so I see from the archives that Infinity is mandated by ieee754 > even though my intuition says both should be NaN. There is a good reason for 1/0 being infinity, as it allows correct programs to give correct answers even in the presence of underflow and overflow. > Every other language throws an exception, even C will crash the > program, so I'm guessing it's telling the processor / OS to turn these > into signals, while GHC is turning that off. Or something. But then > what about this note in Control.Exception: That's just not true. It depends on how your system (compiler?) is configured, but the default on most systems that I've used is to return NaNs. David From daveroundy at gmail.com Mon Jun 16 19:21:24 2008 From: daveroundy at gmail.com (David Roundy) Date: Mon Jun 16 19:13:20 2008 Subject: [Haskell-cafe] 1/0 In-Reply-To: <117f2cc80806161618x5c2a717bo551b8e4ff384633@mail.gmail.com> References: <2518b95d0806161607p207c20b1rcf083488d246efc5@mail.gmail.com> <117f2cc80806161618x5c2a717bo551b8e4ff384633@mail.gmail.com> Message-ID: <117f2cc80806161621h1e4d9eb2j7e52d6973c307995@mail.gmail.com> On Mon, Jun 16, 2008 at 4:18 PM, David Roundy wrote: > On Mon, Jun 16, 2008 at 4:07 PM, Evan Laforge wrote: >> Every other language throws an exception, even C will crash the >> program, so I'm guessing it's telling the processor / OS to turn these >> into signals, while GHC is turning that off. Or something. But then >> what about this note in Control.Exception: > > That's just not true. It depends on how your system (compiler?) is > configured, but the default on most systems that I've used is to > return NaNs. Sorry, I just read my post, and realized I quoted too much. I was responding to the first sentence about other languages, thinking of octave, C and C++. David From john at repetae.net Mon Jun 16 19:28:26 2008 From: john at repetae.net (John Meacham) Date: Mon Jun 16 19:20:23 2008 Subject: [Haskell-cafe] 1/0 In-Reply-To: <2518b95d0806161607p207c20b1rcf083488d246efc5@mail.gmail.com> References: <2518b95d0806161607p207c20b1rcf083488d246efc5@mail.gmail.com> Message-ID: <20080616232826.GB12977@sliver.repetae.net> On Mon, Jun 16, 2008 at 04:07:33PM -0700, Evan Laforge wrote: > So, I know this has been discussed before, but: > Every other language throws an exception, even C will crash the > program, so I'm guessing it's telling the processor / OS to turn these > into signals, while GHC is turning that off. Or something. But then > what about this note in Control.Exception: No, The issue is that '/' is always floating point division in haskell, for integer division, use `div`. 1 `div` 0 throws an exception like you expect. GHC behaves exactly the same as C here. But in C whether '/' means floating point or integral division depends on the types of its arguments, in haskell they are separate operators. John -- John Meacham - ?repetae.net?john? From xj2106 at columbia.edu Mon Jun 16 19:35:24 2008 From: xj2106 at columbia.edu (Xiao-Yong Jin) Date: Mon Jun 16 19:33:06 2008 Subject: [Haskell-cafe] 1/0 In-Reply-To: <2518b95d0806161607p207c20b1rcf083488d246efc5@mail.gmail.com> (Evan Laforge's message of "Mon, 16 Jun 2008 16:07:33 -0700") References: <2518b95d0806161607p207c20b1rcf083488d246efc5@mail.gmail.com> Message-ID: <87r6axvtqb.fsf@columbia.edu> "Evan Laforge" writes: > So, I know this has been discussed before, but: > >> 1/0 > Infinity >> 0/0 > NaN > > ... so I see from the archives that Infinity is mandated by ieee754 > even though my intuition says both should be NaN. > > Every other language throws an exception, even C will crash the > program, so I'm guessing it's telling the processor / OS to turn these > into signals, while GHC is turning that off. [...] No, C will not, with floating point type. The following program prints out a string "inf\n". #include int main (void) { double a=1, b=0; double i; i = a / b; printf ("%g\n",i); return 0; } I believe Haskell is behaving rationally. Cheers, Xiao-Yong -- c/* __o/* <\ * (__ */\ < From qdunkan at gmail.com Mon Jun 16 19:41:23 2008 From: qdunkan at gmail.com (Evan Laforge) Date: Mon Jun 16 19:33:26 2008 Subject: [Haskell-cafe] 1/0 In-Reply-To: <20080616232826.GB12977@sliver.repetae.net> References: <2518b95d0806161607p207c20b1rcf083488d246efc5@mail.gmail.com> <20080616232826.GB12977@sliver.repetae.net> Message-ID: <2518b95d0806161641p72f7543cm72faf33b6b0700e4@mail.gmail.com> > No, The issue is that '/' is always floating point division in haskell, > for integer division, use `div`. > > 1 `div` 0 throws an exception like you expect. > > GHC behaves exactly the same as C here. But in C whether '/' means > floating point or integral division depends on the types of its > arguments, in haskell they are separate operators. Aha, I was missing something. Indeed, 1.0/0.0 gives me infinity with C. Thanks for the clarification. Python does throw for 1.0/0.0, but I think there's a (not very commonly used) module to turn that off. It might be nice for GHC to have a some way to turn exceptions on, but I can accept getting NaNs, and doing the ieee754 thing by default seems entirely reasonable. But what about that NaN->Integer conversion thing? From dan.doel at gmail.com Mon Jun 16 19:45:30 2008 From: dan.doel at gmail.com (Dan Doel) Date: Mon Jun 16 19:37:59 2008 Subject: [Haskell-cafe] 1/0 In-Reply-To: <2518b95d0806161607p207c20b1rcf083488d246efc5@mail.gmail.com> References: <2518b95d0806161607p207c20b1rcf083488d246efc5@mail.gmail.com> Message-ID: <200806161945.30976.dan.doel@gmail.com> On Monday 16 June 2008, Evan Laforge wrote: > So, I know this has been discussed before, but: > > 1/0 > > Infinity > > > 0/0 > > NaN > > ... so I see from the archives that Infinity is mandated by ieee754 > even though my intuition says both should be NaN. > > Every other language throws an exception, even C will crash the > program, so I'm guessing it's telling the processor / OS to turn these > into signals, while GHC is turning that off. Or something. But then > what about this note in Control.Exception: #include #include int main (int argc, char **argv) { float f1 = 1.0/0.0; float f2 = 0.0/0.0; printf("%f\n%f\n", f1, f2); return EXIT_SUCCESS; } % ./Inf inf nan In a Haskell program, 1/0 is floating point division. In C, 1/0 is integer division, which may get implicitly converted to a floating point if you say "float f = 1/0;". That's why you get the exception in C. > but how about this: > > round (0/0) :: Integer > > (huge negative number) > > Ok, so integral types don't have that exceptional value. Shouldn't > trying to convert NaN or Infinity to an Integral throw something? Is > it a performance thing? I'd think if you're converting to Integer you > don't really need hardware level performance anyway, so a couple of > checks wouldn't kill anyone. This is a (known by some) bug of sorts in the various floating point -> integral transformations (which ultimately boil down to decodeFloat or something like that at some point). It apparently doesn't know about the various exceptional values in the IEEE representation, so it just treats the representation like any other value. Infinity and NaN look like various huge numbers if you interpret them like any other value, so that's what you get out of round/ceiling/floor/etc. It's not ideal, but I guess no one's bothered to fix it. Might be something to bring up on the libraries mailing list. -- Dan From john at repetae.net Mon Jun 16 19:50:05 2008 From: john at repetae.net (John Meacham) Date: Mon Jun 16 19:42:02 2008 Subject: [Haskell-cafe] 1/0 In-Reply-To: <2518b95d0806161641p72f7543cm72faf33b6b0700e4@mail.gmail.com> References: <2518b95d0806161607p207c20b1rcf083488d246efc5@mail.gmail.com> <20080616232826.GB12977@sliver.repetae.net> <2518b95d0806161641p72f7543cm72faf33b6b0700e4@mail.gmail.com> Message-ID: <20080616235005.GC12977@sliver.repetae.net> On Mon, Jun 16, 2008 at 04:41:23PM -0700, Evan Laforge wrote: > But what about that NaN->Integer conversion thing? I think that may be a bug or at least a misfeature. The standard is somewhat vauge on a lot of issues dealing with floating point since it is such a tricky subject and depends a lot on the environment. The various rounding funcitons are particularly ugly IMHO. I added varients of them that preserved the floating point type and properly implemented IEEE behavior for jhc. John -- John Meacham - ?repetae.net?john? From droundy at darcs.net Mon Jun 16 20:05:03 2008 From: droundy at darcs.net (David Roundy) Date: Mon Jun 16 19:57:00 2008 Subject: [Haskell-cafe] 1/0 In-Reply-To: <20080616235005.GC12977@sliver.repetae.net> References: <2518b95d0806161607p207c20b1rcf083488d246efc5@mail.gmail.com> <20080616232826.GB12977@sliver.repetae.net> <2518b95d0806161641p72f7543cm72faf33b6b0700e4@mail.gmail.com> <20080616235005.GC12977@sliver.repetae.net> Message-ID: <20080617000502.GZ32397@darcs.net> On Mon, Jun 16, 2008 at 04:50:05PM -0700, John Meacham wrote: > On Mon, Jun 16, 2008 at 04:41:23PM -0700, Evan Laforge wrote: > > But what about that NaN->Integer conversion thing? > > I think that may be a bug or at least a misfeature. The standard is > somewhat vauge on a lot of issues dealing with floating point since > it is such a tricky subject and depends a lot on the environment. The > various rounding funcitons are particularly ugly IMHO. I added varients > of them that preserved the floating point type and properly implemented > IEEE behavior for jhc. I think the Data.Binary guys think it's a feature, since they rely in this behavior (well, they rely on the equivalently-foolish behavior of toRational). I think it's a bug. David From dons at galois.com Mon Jun 16 20:08:36 2008 From: dons at galois.com (Don Stewart) Date: Mon Jun 16 20:00:34 2008 Subject: [Haskell-cafe] 1/0 In-Reply-To: <20080617000502.GZ32397@darcs.net> References: <2518b95d0806161607p207c20b1rcf083488d246efc5@mail.gmail.com> <20080616232826.GB12977@sliver.repetae.net> <2518b95d0806161641p72f7543cm72faf33b6b0700e4@mail.gmail.com> <20080616235005.GC12977@sliver.repetae.net> <20080617000502.GZ32397@darcs.net> Message-ID: <20080617000836.GC9848@scytale.galois.com> droundy: > On Mon, Jun 16, 2008 at 04:50:05PM -0700, John Meacham wrote: > > On Mon, Jun 16, 2008 at 04:41:23PM -0700, Evan Laforge wrote: > > > But what about that NaN->Integer conversion thing? > > > > I think that may be a bug or at least a misfeature. The standard is > > somewhat vauge on a lot of issues dealing with floating point since > > it is such a tricky subject and depends a lot on the environment. The > > various rounding funcitons are particularly ugly IMHO. I added varients > > of them that preserved the floating point type and properly implemented > > IEEE behavior for jhc. > > I think the Data.Binary guys think it's a feature, since they rely in > this behavior (well, they rely on the equivalently-foolish behavior of > toRational). I think it's a bug. You mean: instance Binary Double where put d = put (decodeFloat d) get = liftM2 encodeFloat get get ? if you've a portable Double decoding that works in GHC and Hugs, I'm accepting patches. -- Don From droundy at darcs.net Mon Jun 16 20:31:22 2008 From: droundy at darcs.net (David Roundy) Date: Mon Jun 16 20:23:19 2008 Subject: [Haskell-cafe] 1/0 In-Reply-To: <20080617000836.GC9848@scytale.galois.com> References: <2518b95d0806161607p207c20b1rcf083488d246efc5@mail.gmail.com> <20080616232826.GB12977@sliver.repetae.net> <2518b95d0806161641p72f7543cm72faf33b6b0700e4@mail.gmail.com> <20080616235005.GC12977@sliver.repetae.net> <20080617000502.GZ32397@darcs.net> <20080617000836.GC9848@scytale.galois.com> Message-ID: <20080617003121.GA32397@darcs.net> On Mon, Jun 16, 2008 at 05:08:36PM -0700, Don Stewart wrote: > droundy: > > On Mon, Jun 16, 2008 at 04:50:05PM -0700, John Meacham wrote: > > > On Mon, Jun 16, 2008 at 04:41:23PM -0700, Evan Laforge wrote: > > > > But what about that NaN->Integer conversion thing? > > > > > > I think that may be a bug or at least a misfeature. The standard is > > > somewhat vauge on a lot of issues dealing with floating point since > > > it is such a tricky subject and depends a lot on the environment. The > > > various rounding funcitons are particularly ugly IMHO. I added varients > > > of them that preserved the floating point type and properly implemented > > > IEEE behavior for jhc. > > > > I think the Data.Binary guys think it's a feature, since they rely in > > this behavior (well, they rely on the equivalently-foolish behavior of > > toRational). I think it's a bug. > > You mean: > > instance Binary Double where > put d = put (decodeFloat d) > get = liftM2 encodeFloat get get > > ? > > if you've a portable Double decoding that works in GHC and Hugs, I'm > accepting patches. I really don't understand why being portable is such an issue. Is it really better to behave wrong on every platform rather than behaving wrong on a very small minority of platforms? Anyhow, I've not hacked on binary, because I've not used it, and have trouble seeing when I would use it. So maybe I shouldn't have brought the subject up, except that this use of decodeFloat/encodeFloat is a particularly egregious misuse of floating point numbers. decodeFloat really ought to be a partial function, and this should be a crashing bug, if the standard libraries were better-written. David From dons at galois.com Mon Jun 16 20:39:39 2008 From: dons at galois.com (Don Stewart) Date: Mon Jun 16 20:31:44 2008 Subject: [Haskell-cafe] 1/0 In-Reply-To: <20080617003121.GA32397@darcs.net> References: <2518b95d0806161607p207c20b1rcf083488d246efc5@mail.gmail.com> <20080616232826.GB12977@sliver.repetae.net> <2518b95d0806161641p72f7543cm72faf33b6b0700e4@mail.gmail.com> <20080616235005.GC12977@sliver.repetae.net> <20080617000502.GZ32397@darcs.net> <20080617000836.GC9848@scytale.galois.com> <20080617003121.GA32397@darcs.net> Message-ID: <20080617003939.GE9848@scytale.galois.com> droundy: > On Mon, Jun 16, 2008 at 05:08:36PM -0700, Don Stewart wrote: > > droundy: > > > On Mon, Jun 16, 2008 at 04:50:05PM -0700, John Meacham wrote: > > > > On Mon, Jun 16, 2008 at 04:41:23PM -0700, Evan Laforge wrote: > > > > > But what about that NaN->Integer conversion thing? > > > > > > > > I think that may be a bug or at least a misfeature. The standard is > > > > somewhat vauge on a lot of issues dealing with floating point since > > > > it is such a tricky subject and depends a lot on the environment. The > > > > various rounding funcitons are particularly ugly IMHO. I added varients > > > > of them that preserved the floating point type and properly implemented > > > > IEEE behavior for jhc. > > > > > > I think the Data.Binary guys think it's a feature, since they rely in > > > this behavior (well, they rely on the equivalently-foolish behavior of > > > toRational). I think it's a bug. > > > > You mean: > > > > instance Binary Double where > > put d = put (decodeFloat d) > > get = liftM2 encodeFloat get get > > > > ? > > > > if you've a portable Double decoding that works in GHC and Hugs, I'm > > accepting patches. > > I really don't understand why being portable is such an issue. Is it > really better to behave wrong on every platform rather than behaving > wrong on a very small minority of platforms? The Binary instances are required to be portable, as that's the part of the definition of Binary's mandate: a portable binary encoding. > Anyhow, I've not hacked on binary, because I've not used it, and have > trouble seeing when I would use it. So maybe I shouldn't have brought > the subject up, except that this use of decodeFloat/encodeFloat is a > particularly egregious misuse of floating point numbers. > decodeFloat > really ought to be a partial function, and this should be a crashing > bug, if the standard libraries were better-written. It's a bug in the H98 report then: Section 6.4.6: "The function decodeFloat applied to a real floating-point number returns the significand expressed as an Integer and an appropriately scaled exponent (an Int). If decodeFloat x yields (m,n), then x is equal in value to mb^n, where b is the floating-point radix, and furthermore, either m and n are both zero or else b^d-1<=m References: Message-ID: <48570A48.1060702@hot.ee> hi, I wasn't able to add an attachment to a ticket, is something wrong with permissions? Python Traceback Traceback (most recent call last): File "/var/lib/python-support/python2.4/trac/web/main.py", line 387, in dispatch_request dispatcher.dispatch(req) File "/var/lib/python-support/python2.4/trac/web/main.py", line 237, in dispatch resp = chosen_handler.process_request(req) File "/var/lib/python-support/python2.4/trac/attachment.py", line 361, in process_request self._do_save(req, attachment) File "/var/lib/python-support/python2.4/trac/attachment.py", line 494, in _do_save attachment.insert(filename, upload.file, size) File "/var/lib/python-support/python2.4/trac/attachment.py", line 180, in insert os.makedirs(self.path) File "os.py", line 156, in makedirs makedirs(head, mode) File "os.py", line 159, in makedirs mkdir(name, mode) OSError: [Errno 13] Permission denied: '/srv/trac/haddock/attachments/ticket' Cheers, Misha From john at repetae.net Mon Jun 16 21:11:27 2008 From: john at repetae.net (John Meacham) Date: Mon Jun 16 21:03:22 2008 Subject: [Haskell-cafe] 1/0 In-Reply-To: <20080617003939.GE9848@scytale.galois.com> References: <2518b95d0806161607p207c20b1rcf083488d246efc5@mail.gmail.com> <20080616232826.GB12977@sliver.repetae.net> <2518b95d0806161641p72f7543cm72faf33b6b0700e4@mail.gmail.com> <20080616235005.GC12977@sliver.repetae.net> <20080617000502.GZ32397@darcs.net> <20080617000836.GC9848@scytale.galois.com> <20080617003121.GA32397@darcs.net> <20080617003939.GE9848@scytale.galois.com> Message-ID: <20080617011126.GD12977@sliver.repetae.net> On Mon, Jun 16, 2008 at 05:39:39PM -0700, Don Stewart wrote: > It's a bug in the H98 report then: Yes, I consider a whole lot of the floating point stuff in the report a bug of sorts IMHO :) It is certainly something that I hope to work on for Haskell'. John -- John Meacham - ?repetae.net?john? From droundy at darcs.net Mon Jun 16 21:32:19 2008 From: droundy at darcs.net (David Roundy) Date: Mon Jun 16 21:24:15 2008 Subject: [Haskell-cafe] 1/0 In-Reply-To: <20080617003939.GE9848@scytale.galois.com> References: <2518b95d0806161607p207c20b1rcf083488d246efc5@mail.gmail.com> <20080616232826.GB12977@sliver.repetae.net> <2518b95d0806161641p72f7543cm72faf33b6b0700e4@mail.gmail.com> <20080616235005.GC12977@sliver.repetae.net> <20080617000502.GZ32397@darcs.net> <20080617000836.GC9848@scytale.galois.com> <20080617003121.GA32397@darcs.net> <20080617003939.GE9848@scytale.galois.com> Message-ID: <20080617013219.GB32397@darcs.net> On Mon, Jun 16, 2008 at 05:39:39PM -0700, Don Stewart wrote: > > decodeFloat really ought to be a partial function, and this should > > be a crashing bug, if the standard libraries were better-written. > > It's a bug in the H98 report then: > > Section 6.4.6: > > "The function decodeFloat applied to a real floating-point number returns > the significand expressed as an Integer and an appropriately scaled > exponent (an Int). If decodeFloat x yields (m,n), then x is equal in value > to mb^n, where b is the floating-point radix, and furthermore, either m > and n are both zero or else b^d-1<=m floatDigits x. encodeFloat performs the inverse of this transformation. > " Yes, it is a bug in the report, that it doesn't fully specify the behavior this function when given a NaN or infinity. There's also a bug in the standard libraries, which is that they don't conform to the report. let x = 0/0 let (m,n) = decodeFloat x Prelude> (m,n) (-6755399441055744,972) Prelude> let x = 0/0 Prelude> x NaN Prelude> let d = floatDigits x Prelude> let (m,n) = decodeFloat x Prelude> let x' = (fromInteger m :: Double)*2^n Prelude> x' -Infinity Prelude> 2^d-1<=m False Prelude> m<2^d True So for the ghc decodeFloat, when operating on a NaN, the specifications of decodeFloat are almost completely unsatisfied. On the plus side, at least it's true that m On 16 Jun 2008, at 19:24, Achim Schneider wrote: > Thomas Davie wrote: > >> >> On 16 Jun 2008, at 18:28, Achim Schneider wrote: >> >>> Thomas Davie wrote: >>> >>>>> >>>>> One half of all Haskell coders will tell you that mutable state >>>>> isn't a >>>>> good starting point to learn Haskell, the other half will tell you >>>>> the same because they want to be cool kids, too. >>>> >>>> And the one left over will point out that he asked how to do this >>>> the FP way, not the imperative way? >>>> >>> There's no difference, as you can't do time-accounting non-strict >>> and still expect it to give meaningful results: I'm merely trying >>> to be helpful. None of the other solutions allow for the IO Monad. >> >> Firstly, I'd phrase that differently -- the IO Monad doesn't allow >> for the other solutions -- the other solutions are the truly >> functional ones. Secondly, I'm curious as to why you think that the >> two are incompatible, are you saying that for any meaningful kind of >> computation we need to resort to IORefs? I'd strongly contest that >> idea. >> > We have to resort to IO actions to get the time, and to IORefs because > we need to chain up different calls to getCurrentTime using the IO > Monad. The rest of the program can work with whatever you like best. And in what way is this incompatible with either FRP as pierre suggested, or with generating an infinite list of times at which we call the function, and scanning it to find the differences? Bob From allbery at ece.cmu.edu Mon Jun 16 21:53:32 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Mon Jun 16 21:45:30 2008 Subject: [Haskell-cafe] 1/0 In-Reply-To: <117f2cc80806161618x5c2a717bo551b8e4ff384633@mail.gmail.com> References: <2518b95d0806161607p207c20b1rcf083488d246efc5@mail.gmail.com> <117f2cc80806161618x5c2a717bo551b8e4ff384633@mail.gmail.com> Message-ID: On 2008 Jun 16, at 19:18, David Roundy wrote: > On Mon, Jun 16, 2008 at 4:07 PM, Evan Laforge > wrote: >> Every other language throws an exception, even C will crash the >> program, so I'm guessing it's telling the processor / OS to turn >> these >> into signals, while GHC is turning that off. Or something. But then >> what about this note in Control.Exception: > > That's just not true. It depends on how your system (compiler?) is > configured, but the default on most systems that I've used is to > return NaNs. It's how the system FPU is configured; most FPU hardware on Unixlike systems let you configure the FPU behavior on a per-process basis, although the amount of configurability may vary. That said, the divide by zero exception you get in both C and Haskell is *integer* divide-by-zero. Floating is mandated by IEEE standard to produce Inf (but as said above, can usually be configured). -- 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 ok at cs.otago.ac.nz Mon Jun 16 21:54:46 2008 From: ok at cs.otago.ac.nz (Richard A. O'Keefe) Date: Mon Jun 16 21:46:46 2008 Subject: [Haskell-cafe] 1/0 In-Reply-To: <2518b95d0806161607p207c20b1rcf083488d246efc5@mail.gmail.com> References: <2518b95d0806161607p207c20b1rcf083488d246efc5@mail.gmail.com> Message-ID: <480BB455-0E66-4BFF-97D3-AF0A003FD3E7@cs.otago.ac.nz> On 17 Jun 2008, at 11:07 am, Evan Laforge wrote: > So, I know this has been discussed before, but: > >> 1/0 > Infinity >> 0/0 > NaN > > ... so I see from the archives that Infinity is mandated by ieee754 > even though my intuition says both should be NaN. Other people have other intuitions. It may be that your intuition is telling you that neither result should be an ordinary number, and if that's what it's really telling you, it's right: the C function isfinite(x) is true of all signed zero, subnormal, or normal x, false of signed infinities and NaNs. > Every other language throws an exception, even C will crash the > program, Not true. C99 *definitely* allows both infinities and NaNs (see Annex F of the C99 standard) and C89 practice also allowed it. Some C89 systems required you to use signal() with SIGFPE to turn IEEE extended results into exceptions; others required you to use signal() to disable this; others used yet other means. The Scheme systems I tried turn (/ 1.0 0.0) into a printed representation of IEEE infinity. Of the Prolog systems I checked, some did and some didn't. The Standard ML system I tried gave "inf" as the response to 1.0/0.0. Basically, with any programming language implementation that truthfully claims conformance to IEEE 754 or a successor standard, x/0 MUST NOT crash unless your program explicitly asks for such behaviour. As for programming language implementations that do not make such a claim, who knows what they will do? Since integers do not have the special IEEE values, conversion of IEEE values to integral values really ought to be checked. (Of course, in C what you typically get is garbage, but that can be put more generally...) From qdunkan at gmail.com Mon Jun 16 22:29:05 2008 From: qdunkan at gmail.com (Evan Laforge) Date: Mon Jun 16 22:21:03 2008 Subject: [Haskell-cafe] 1/0 In-Reply-To: <480BB455-0E66-4BFF-97D3-AF0A003FD3E7@cs.otago.ac.nz> References: <2518b95d0806161607p207c20b1rcf083488d246efc5@mail.gmail.com> <480BB455-0E66-4BFF-97D3-AF0A003FD3E7@cs.otago.ac.nz> Message-ID: <2518b95d0806161929n4532a948s6cf60a4d66c3b558@mail.gmail.com> >> ... so I see from the archives that Infinity is mandated by ieee754 >> even though my intuition says both should be NaN. > > Other people have other intuitions. It may be that your intuition > is telling you that neither result should be an ordinary number, > and if that's what it's really telling you, it's right: the C > function isfinite(x) is true of all signed zero, subnormal, or > normal x, false of signed infinities and NaNs. Yeah, on reflection, I think my "intuition" derives from me asking a math teacher back in high school "isn't n/0 infinity?" after looking at a graph, to which he said "no, it's undefined, you can only say it approaches infinity in the limit, but it isn't infinity". >> Every other language throws an exception, even C will crash the >> >> program, > > Not true. C99 *definitely* allows both infinities and NaNs (see > Annex F of the C99 standard) and C89 practice also allowed it. > Some C89 systems required you to use signal() with SIGFPE to > turn IEEE extended results into exceptions; others required you > to use signal() to disable this; others used yet other means. Yes, I was mistaken here, as has been pointed out. And I should definitely know better than to make some generalization about "every other language" among this crowd :) > (Of course, in C what you typically get is garbage, but that can > be put more generally...) Heh, one for the C-bashing quotes file... From barsoap at web.de Mon Jun 16 23:08:36 2008 From: barsoap at web.de (Achim Schneider) Date: Mon Jun 16 23:00:43 2008 Subject: [Haskell-cafe] Re: How to do this in FP way? References: <92E5131B-C13A-401E-BE76-1447A6E40FBF@gmail.com> Message-ID: <20080617050836.408039cb@solaris> Thomas Davie wrote: > > On 16 Jun 2008, at 19:24, Achim Schneider wrote: > > > Thomas Davie wrote: > > > >> > >> On 16 Jun 2008, at 18:28, Achim Schneider wrote: > >> > >>> Thomas Davie wrote: > >>> > >>>>> > >>>>> One half of all Haskell coders will tell you that mutable state > >>>>> isn't a > >>>>> good starting point to learn Haskell, the other half will tell > >>>>> you the same because they want to be cool kids, too. > >>>> > >>>> And the one left over will point out that he asked how to do this > >>>> the FP way, not the imperative way? > >>>> > >>> There's no difference, as you can't do time-accounting non-strict > >>> and still expect it to give meaningful results: I'm merely trying > >>> to be helpful. None of the other solutions allow for the IO Monad. > >> > >> Firstly, I'd phrase that differently -- the IO Monad doesn't allow > >> for the other solutions -- the other solutions are the truly > >> functional ones. Secondly, I'm curious as to why you think that > >> the two are incompatible, are you saying that for any meaningful > >> kind of computation we need to resort to IORefs? I'd strongly > >> contest that idea. > >> > > We have to resort to IO actions to get the time, and to IORefs > > because we need to chain up different calls to getCurrentTime using > > the IO Monad. The rest of the program can work with whatever you > > like best. > > And in what way is this incompatible with either FRP as pierre > suggested, or with generating an infinite list of times at which we > call the function, and scanning it to find the differences? > Argh. I should not have copypasted that GLUT code, as it introduces IORefs not because they're 100% necessary but because that code is called back from C. My main point is that his task, if it is as simple as he described it, will stay imperative. My point also depends on that code being part of a main driver loop, as you see it in games: It's just the thing I instantly recognised in his code. Consider this: update :: MyState -> Int -> MyState draw :: MyState -> IO () mainLoop :: MyState -> Int -> IO () mainLoop st old = do now <- getTimeOfDay let td = now - old st' = update st td draw st' mainLoop st' now This, to my understanding of things, is imperative, although there's no IORef to be found. OTOH, recursing like this is "the FP way" to do it. mainLoop's arguments are variables to my eyes. -- (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 ok at cs.otago.ac.nz Mon Jun 16 23:20:43 2008 From: ok at cs.otago.ac.nz (Richard A. O'Keefe) Date: Mon Jun 16 23:12:46 2008 Subject: [Haskell-cafe] 1/0 In-Reply-To: <2518b95d0806161929n4532a948s6cf60a4d66c3b558@mail.gmail.com> References: <2518b95d0806161607p207c20b1rcf083488d246efc5@mail.gmail.com> <480BB455-0E66-4BFF-97D3-AF0A003FD3E7@cs.otago.ac.nz> <2518b95d0806161929n4532a948s6cf60a4d66c3b558@mail.gmail.com> Message-ID: Since Haskell-Caf? often strays into mathematics, this may not be too far off topic. On 17 Jun 2008, at 2:29 pm, Evan Laforge wrote: > Yeah, on reflection, I think my "intuition" derives from me asking a > math teacher back in high school "isn't n/0 infinity?" after looking > at a graph, to which he said "no, it's undefined, you can only say it > approaches infinity in the limit, but it isn't infinity". Let's put this kindly: it is POSSIBLE that your maths teacher knew what he was talking about and was just telling what the "Science of Discworld" authors call "lies-to-children". It is certainly likely that it didn't occur to him that you might transfer what he said about the mathematical real numbers to a rather different algebraic system, IEEE floats. The usual "real numbers" R form an ordered field. *In that structure*, n/0 is undefined. But there is another algebraic structure which includes all the real numbers plus one more: infinity. It's call the real projective line. See http://en.wikipedia.org/wiki/Real_projective_line In that structure, n/0 is perfectly well defined, and is indeed infinity. That structure has all the properties you really need to do calculus, but isn't a field and isn't ordered. However, whenever an operation on elements of R is defined, the analogous operation on the corresponding elements of \hat R is defined and has the corresponding value. Basically, you can define operations any way you want as long as you are willing to live with the consequences. For example, it turns out to be possible to define an alternative arithmetic in which (-x)*(-y) = -(x*y) for positive x, y. The price is that it doesn't satisfy all the usual axioms, though it does satisfy other possibly useful ones that the usual systems don't. In an analogous way, the IEEE designers decided that it would be useful to have +/- epsilon instead of 0 and +/- (1/epsilon) instead of infinity, but then decided that the ordering operations should identify -epsilon with +epsilon, so the result still isn't quite a proper total order, even ignoring NaNs. (What happens if you sort a list of mixed +0.0 and -0.0? What, if anything, _should_ happen?) They obtained the benefits they wanted, at the price of making the resulting structure less like R. But then, floating point numbers never were _very_ much like R to start with. It's not clear to me that *R offers anything more than a heuristic analogy to IEEE arithmetic. For one thing, *R is ordered. From magicloud.magiclouds at gmail.com Mon Jun 16 23:40:04 2008 From: magicloud.magiclouds at gmail.com (Magicloud) Date: Mon Jun 16 23:32:05 2008 Subject: =?gb2312?B?tPC4tDogW0hhc2tlbGwtY2FmZV0gUmU6IEhvdyB0byBkbyB0aGlzIA==?= =?gb2312?B?aW4gRlAgd2F5Pw==?= In-Reply-To: <20080616060033.396f1e5c@solaris> References: <3bd412d40806151931s3cef9027x73d83943386f0cad@mail.gmail.com> <20080616060033.396f1e5c@solaris> Message-ID: <48573218.034c6e0a.18f9.ffffabe5@mx.google.com> Yes, that's it, State. Thanks. -----=D3=CA=BC=FE=D4=AD=BC=FE----- =B7=A2=BC=FE=C8=CB: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] =B4=FA=B1=ED Achim Schneider =B7=A2=CB=CD=CA=B1=BC=E4: 2008=C4=EA6=D4=C216=C8=D5 12:01 =CA=D5=BC=FE=C8=CB: haskell-cafe@haskell.org =D6=F7=CC=E2: [Haskell-cafe] Re: How to do this in FP way? "Magicloud Magiclouds" wrote: > static int old; > int diff (int now) { /* this would be called once a second */ > int ret =3D now - old; > old =3D now; > return ret; > } > You do it with variables, of course. This is out of some GLUT code, using IORef's: idle :: State -> IdleCallback idle state =3D do t0 <- get $ t state t1 <- get elapsedTime t state $=3D t1 let td =3D fromIntegral t1 - fromIntegral t0 fps state $=3D 1/td * 1000 angle' state $~! (+2) =20 (bpx, bpy) <- get $ ballPos state (bvx, bvy) <- get $ ballVel state =20 ballPos state $=3D (bpx + bvx*td, bpy + bvy*td) =20 postRedisplay Nothing One half of all Haskell coders will tell you that mutable state isn't a good starting point to learn Haskell, the other half will tell you the same because they want to be cool kids, too.=20 --=20 (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.=20 _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe From magicloud.magiclouds at gmail.com Mon Jun 16 23:43:04 2008 From: magicloud.magiclouds at gmail.com (Magicloud) Date: Mon Jun 16 23:35:05 2008 Subject: =?gb2312?B?tPC4tDogW0hhc2tlbGwtY2FmZV0gUmU6IEhvdyB0byBkbyB0aGlzIA==?= =?gb2312?B?aW4gRlAgd2F5Pw==?= In-Reply-To: <20080616060033.396f1e5c@solaris> References: <3bd412d40806151931s3cef9027x73d83943386f0cad@mail.gmail.com> <20080616060033.396f1e5c@solaris> Message-ID: <485732cb.05886e0a.0bdb.ffff9a4e@mx.google.com> I think if I do not use a state, and the function would be called for = many times, it would waste memory, if using something like loop, right? -----=D3=CA=BC=FE=D4=AD=BC=FE----- =B7=A2=BC=FE=C8=CB: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] =B4=FA=B1=ED Achim Schneider =B7=A2=CB=CD=CA=B1=BC=E4: 2008=C4=EA6=D4=C216=C8=D5 12:01 =CA=D5=BC=FE=C8=CB: haskell-cafe@haskell.org =D6=F7=CC=E2: [Haskell-cafe] Re: How to do this in FP way? "Magicloud Magiclouds" wrote: > static int old; > int diff (int now) { /* this would be called once a second */ > int ret =3D now - old; > old =3D now; > return ret; > } > You do it with variables, of course. This is out of some GLUT code, using IORef's: idle :: State -> IdleCallback idle state =3D do t0 <- get $ t state t1 <- get elapsedTime t state $=3D t1 let td =3D fromIntegral t1 - fromIntegral t0 fps state $=3D 1/td * 1000 angle' state $~! (+2) =20 (bpx, bpy) <- get $ ballPos state (bvx, bvy) <- get $ ballVel state =20 ballPos state $=3D (bpx + bvx*td, bpy + bvy*td) =20 postRedisplay Nothing One half of all Haskell coders will tell you that mutable state isn't a good starting point to learn Haskell, the other half will tell you the same because they want to be cool kids, too.=20 --=20 (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.=20 _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe From barsoap at web.de Mon Jun 16 23:48:54 2008 From: barsoap at web.de (Achim Schneider) Date: Mon Jun 16 23:41:00 2008 Subject: [Haskell-cafe] Re: How to do this in FP way? References: <3bd412d40806151931s3cef9027x73d83943386f0cad@mail.gmail.com> <20080616060033.396f1e5c@solaris> <485732cb.05886e0a.0bdb.ffff9a4e@mx.google.com> Message-ID: <20080617054854.47a5f8b6@solaris> "Magicloud" wrote: > I think if I do not use a state, and the function would be called for > many times, it would waste memory, if using something like loop, > right? > nope, at least not in general. update :: MyState -> Int -> MyState draw :: MyState -> IO () mainLoop :: MyState -> Int -> IO () mainLoop st old = do now <- getTimeOfDay let td = now - old st' = update st td draw st' mainLoop st' now runs in constant space. Look up "tail recursion" in wikipedia. > -----????----- > ???: haskell-cafe-bounces@haskell.org > [mailto:haskell-cafe-bounces@haskell.org] ?? Achim Schneider > ????: 2008?6?16? 12:01 > ???: haskell-cafe@haskell.org > ??: [Haskell-cafe] Re: How to do this in FP way? > > "Magicloud Magiclouds" wrote: > > > static int old; > > int diff (int now) { /* this would be called once a second */ > > int ret = now - old; > > old = now; > > return ret; > > } > > > You do it with variables, of course. This is out of some GLUT code, > using IORef's: > > idle :: State -> IdleCallback > idle state = do > t0 <- get $ t state > t1 <- get elapsedTime > t state $= t1 > let td = fromIntegral t1 - fromIntegral t0 > fps state $= 1/td * 1000 > > angle' state $~! (+2) > > (bpx, bpy) <- get $ ballPos state > (bvx, bvy) <- get $ ballVel state > > ballPos state $= (bpx + bvx*td, bpy + bvy*td) > postRedisplay Nothing > > One half of all Haskell coders will tell you that mutable state isn't > a good starting point to learn Haskell, the other half will tell you > the same because they want to be cool kids, too. > -- (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 magicloud.magiclouds at gmail.com Mon Jun 16 23:52:35 2008 From: magicloud.magiclouds at gmail.com (Magicloud) Date: Mon Jun 16 23:44:36 2008 Subject: =?gb2312?B?tPC4tDogW0hhc2tlbGwtY2FmZV0gUmU6IEhvdyB0byBkbyB0aGlzIA==?= =?gb2312?B?aW4gRlAgd2F5Pw==?= In-Reply-To: <20080616060033.396f1e5c@solaris> References: <3bd412d40806151931s3cef9027x73d83943386f0cad@mail.gmail.com> <20080616060033.396f1e5c@solaris> Message-ID: <48573506.0e1b6e0a.7c01.7e87@mx.google.com> But if there are some beautiful arithmetics that do not use something = like state, I won't say no to them. -----=D3=CA=BC=FE=D4=AD=BC=FE----- =B7=A2=BC=FE=C8=CB: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] =B4=FA=B1=ED Achim Schneider =B7=A2=CB=CD=CA=B1=BC=E4: 2008=C4=EA6=D4=C216=C8=D5 12:01 =CA=D5=BC=FE=C8=CB: haskell-cafe@haskell.org =D6=F7=CC=E2: [Haskell-cafe] Re: How to do this in FP way? "Magicloud Magiclouds" wrote: > static int old; > int diff (int now) { /* this would be called once a second */ > int ret =3D now - old; > old =3D now; > return ret; > } > You do it with variables, of course. This is out of some GLUT code, using IORef's: idle :: State -> IdleCallback idle state =3D do t0 <- get $ t state t1 <- get elapsedTime t state $=3D t1 let td =3D fromIntegral t1 - fromIntegral t0 fps state $=3D 1/td * 1000 angle' state $~! (+2) =20 (bpx, bpy) <- get $ ballPos state (bvx, bvy) <- get $ ballVel state =20 ballPos state $=3D (bpx + bvx*td, bpy + bvy*td) =20 postRedisplay Nothing One half of all Haskell coders will tell you that mutable state isn't a good starting point to learn Haskell, the other half will tell you the same because they want to be cool kids, too.=20 --=20 (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.=20 _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe From magicloud.magiclouds at gmail.com Tue Jun 17 01:03:06 2008 From: magicloud.magiclouds at gmail.com (Magicloud) Date: Tue Jun 17 00:55:10 2008 Subject: =?gb2312?B?tPC4tDogW0hhc2tlbGwtY2FmZV0gSG93IHRvIGRvIHRoaXMgaW4gRlAgd2E=?= =?gb2312?B?eT8=?= In-Reply-To: <117f2cc80806161017w680f5c83p3165733e46256be0@mail.gmail.com> References: <3bd412d40806151931s3cef9027x73d83943386f0cad@mail.gmail.com> <117f2cc80806161017w680f5c83p3165733e46256be0@mail.gmail.com> Message-ID: <48574590.034c6e0a.18fd.ffffb68d@mx.google.com> OK. Here it is. I want to make a monitor tool for linux. It runs for a long time, and = give out a certain process's io stat per second. The way I get io stat is to = read from /proc/pid/io. But the data in this file is a total, I need to read = it first, then next second, read it again, and shows the difference, and go = on. So, what is your idea? -----=D3=CA=BC=FE=D4=AD=BC=FE----- =B7=A2=BC=FE=C8=CB: David Roundy [mailto:daveroundy@gmail.com]=20 =B7=A2=CB=CD=CA=B1=BC=E4: 2008=C4=EA6=D4=C217=C8=D5 1:17 =CA=D5=BC=FE=C8=CB: Magicloud Magiclouds =B3=AD=CB=CD: haskell-cafe@haskell.org =D6=F7=CC=E2: Re: [Haskell-cafe] How to do this in FP way? 2008/6/15 Magicloud Magiclouds : > Hello, > I am getting familiar with FP now, and I have a "program design" = kind of > question. > Say I have something like this in C: > static int old; > int diff (int now) { /* this would be called once a second */ > int ret =3D now - old; > old =3D now; > return ret; > } > Because there is no "variable" in Haskell. So how to do this in a = FP > way? A better question would be to think about what you are trying to accomplish, and then ask how to achieve that through functional programming. David From valgarv at gmx.net Tue Jun 17 01:51:22 2008 From: valgarv at gmx.net (Ariel J. Birnbaum) Date: Tue Jun 17 01:43:20 2008 Subject: [Haskell-cafe] ANN: Topkata In-Reply-To: <4B3E7353-F7F2-4D2D-A335-30D2D3883A4A@gmail.com> References: <87zlpoguqh.fsf@elefant.olsbruecken.local> <4B3E7353-F7F2-4D2D-A335-30D2D3883A4A@gmail.com> Message-ID: <200806170851.22718.valgarv@gmx.net> > In the mean time -- who knows enough to make ghc target ARM, and get > this to link against the iPhone libraries? This would be quite a coup > if it could be made to run there! For that matter, there's another ARM-based target in which I'm interested: Nintendo DS. Has anyone got any Haskell code to run on one of these? PS: Maybe this discussion should be moved to a new "Haskell on ARM" thread? -- Ariel J. Birnbaum From lemming at henning-thielemann.de Tue Jun 17 02:01:42 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Tue Jun 17 01:53:38 2008 Subject: [Haskell-cafe] 1/0 In-Reply-To: <200806161945.30976.dan.doel@gmail.com> References: <2518b95d0806161607p207c20b1rcf083488d246efc5@mail.gmail.com> <200806161945.30976.dan.doel@gmail.com> Message-ID: On Mon, 16 Jun 2008, Dan Doel wrote: > On Monday 16 June 2008, Evan Laforge wrote: > >> (huge negative number) >> >> Ok, so integral types don't have that exceptional value. Shouldn't >> trying to convert NaN or Infinity to an Integral throw something? Is >> it a performance thing? I'd think if you're converting to Integer you >> don't really need hardware level performance anyway, so a couple of >> checks wouldn't kill anyone. > > This is a (known by some) bug of sorts in the various floating point -> > integral transformations (which ultimately boil down to decodeFloat or > something like that at some point). It apparently doesn't know about the > various exceptional values in the IEEE representation, so it just treats the > representation like any other value. Infinity and NaN look like various huge > numbers if you interpret them like any other value, so that's what you get > out of round/ceiling/floor/etc. > > It's not ideal, but I guess no one's bothered to fix it. Might be something to > bring up on the libraries mailing list. This could be combined with improving performance: http://hackage.haskell.org/trac/ghc/ticket/2281 http://hackage.haskell.org/trac/ghc/ticket/2271 http://hackage.haskell.org/trac/ghc/ticket/1434 From ndmitchell at gmail.com Tue Jun 17 02:55:51 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Tue Jun 17 02:47:47 2008 Subject: [Haskell-cafe] Design suggestion for Data.Binary.Defer In-Reply-To: <117f2cc80806161612oe3f2033q187cbf5c22592f03@mail.gmail.com> References: <404396ef0806160943r381f0b90ue418cb86bca0bc95@mail.gmail.com> <117f2cc80806161612oe3f2033q187cbf5c22592f03@mail.gmail.com> Message-ID: <404396ef0806162355m1bf083f2pcebdbfa64e17e42b@mail.gmail.com> Hi, Derek: Yes, I was slowly coming round to the idea of the third option. It does mean that if you want to change the deferredness of a field, you have to change the type, which is a substantial alteration. David: > Is there any reason not to just write all lazy fields of variable size > in a deferred manner? I completely hadn't though of this! You will loose a bit of time, for example reading fields which were previously not deferred will require a file seek, but the effort/thought/efficiency trade-off is good. I think I will go with this. Thanks Neil From hpacheco at gmail.com Tue Jun 17 05:53:49 2008 From: hpacheco at gmail.com (Hugo Pacheco) Date: Tue Jun 17 05:45:47 2008 Subject: [Haskell-cafe] Polymorphic QuickCheck arguments Message-ID: <7b92c2840806170253l7f53e07al7eedc1411934ca69@mail.gmail.com> Hi all, There is something about polymorphic tests in QuickCheck that I do not understand. If you write the simplest dummy test function tst :: a -> Bool tst _ = True and evaluate it we get > verboseCheck tst 0: () 1: () ... How come did the polymorphic value a get instanciated to ()? Is this done via the Testable type class? Could someone please explain this to me? I'm not saying it does not make sense, but I would like to understand how it works. Being possible to change this behavior, this is, assign another "default type" whenever polymorphic types occur, would be awesome. Cheers, hugo -- www.di.uminho.pt/~hpacheco -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080617/7d73a998/attachment.htm From dougal at dougalstanton.net Tue Jun 17 06:05:01 2008 From: dougal at dougalstanton.net (Dougal Stanton) Date: Tue Jun 17 05:57:08 2008 Subject: [Haskell-cafe] Polymorphic QuickCheck arguments In-Reply-To: <7b92c2840806170253l7f53e07al7eedc1411934ca69@mail.gmail.com> References: <7b92c2840806170253l7f53e07al7eedc1411934ca69@mail.gmail.com> Message-ID: <2d3641330806170305s7a062031lf9672cd595648b29@mail.gmail.com> 2008/6/17 Hugo Pacheco : > Hi all, > There is something about polymorphic tests in QuickCheck that I do not > understand. > If you write the simplest dummy test function > tst :: a -> Bool > tst _ = True > and evaluate it we get >> verboseCheck tst > 0: > () > 1: > () > ... > How come did the polymorphic value a get instanciated to ()? Is this done > via the Testable type class? I haven't got something here to check with, but from the formatting it looks like every odd line is a randomly-chosen boolean value, and the following line is the result? It might be just printing the result value of IO (). Maybe try a more complete test to see how that looks? Cheers, D -- Dougal Stanton dougal@dougalstanton.net // http://www.dougalstanton.net From hpacheco at gmail.com Tue Jun 17 06:13:35 2008 From: hpacheco at gmail.com (Hugo Pacheco) Date: Tue Jun 17 06:05:31 2008 Subject: [Haskell-cafe] Polymorphic QuickCheck arguments In-Reply-To: <2d3641330806170305s7a062031lf9672cd595648b29@mail.gmail.com> References: <7b92c2840806170253l7f53e07al7eedc1411934ca69@mail.gmail.com> <2d3641330806170305s7a062031lf9672cd595648b29@mail.gmail.com> Message-ID: <7b92c2840806170313j4df02951u6670370ec61ea210@mail.gmail.com> It does not seem like printing the result value from IO (), because with a more complicated example for lists. t :: [a] -> Bool t x = True then it randomly generates values of type [()]. *Quick> verboseCheck t 0: [] 1: [()] 2: [(),(),()] 3: [] 4: [()] 5: [(),(),(),()] I just wonder how the a got instantiated to (). Thanks, hugo On Tue, Jun 17, 2008 at 11:05 AM, Dougal Stanton wrote: > 2008/6/17 Hugo Pacheco : > > Hi all, > > There is something about polymorphic tests in QuickCheck that I do not > > understand. > > If you write the simplest dummy test function > > tst :: a -> Bool > > tst _ = True > > and evaluate it we get > >> verboseCheck tst > > 0: > > () > > 1: > > () > > ... > > How come did the polymorphic value a get instanciated to ()? Is this done > > via the Testable type class? > > I haven't got something here to check with, but from the formatting it > looks like every odd line is a randomly-chosen boolean value, and the > following line is the result? It might be just printing the result > value of IO (). Maybe try a more complete test to see how that looks? > > Cheers, > > D > > > -- > Dougal Stanton > dougal@dougalstanton.net // http://www.dougalstanton.net > -- www.di.uminho.pt/~hpacheco -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080617/5633e6c1/attachment.htm From sfvisser at cs.uu.nl Tue Jun 17 07:17:07 2008 From: sfvisser at cs.uu.nl (Sebastiaan Visser) Date: Tue Jun 17 07:09:14 2008 Subject: [Haskell-cafe] Polymorphic QuickCheck arguments In-Reply-To: <7b92c2840806170253l7f53e07al7eedc1411934ca69@mail.gmail.com> References: <7b92c2840806170253l7f53e07al7eedc1411934ca69@mail.gmail.com> Message-ID: <2A22B918-BD68-4C0E-97D8-FACDC33CF6AD@cs.uu.nl> On Jun 17, 2008, at 11:53 AM, Hugo Pacheco wrote: > Hi all, > > There is something about polymorphic tests in QuickCheck that I do > not understand. > > If you write the simplest dummy test function > > tst :: a -> Bool > tst _ = True > > and evaluate it we get > > > verboseCheck tst > 0: > () > 1: > () > ... > How come did the polymorphic value a get instanciated to ()? Is > this done via the Testable type class? > Could someone please explain this to me? I'm not saying it does not > make sense, but I would like to understand how it works. Being > possible to change this behavior, this is, assign another "default > type" whenever polymorphic types occur, would be awesome. I think it is GHCi that is instantiating the type with (). Try compiling the program, it will probably be rejected by the compiler when you do not specify a concrete type. You can, for example, try this: verboseCheck (tst :: [Int] -> Bool) > Cheers, > hugo From xj2106 at columbia.edu Tue Jun 17 08:09:29 2008 From: xj2106 at columbia.edu (Xiao-Yong Jin) Date: Tue Jun 17 08:07:12 2008 Subject: Haskell on ARM (was Re: [Haskell-cafe] ANN: Topkata) In-Reply-To: <200806170851.22718.valgarv@gmx.net> (Ariel J. Birnbaum's message of "Tue, 17 Jun 2008 08:51:22 +0300") References: <87zlpoguqh.fsf@elefant.olsbruecken.local> <4B3E7353-F7F2-4D2D-A335-30D2D3883A4A@gmail.com> <200806170851.22718.valgarv@gmx.net> Message-ID: <87ej6ww9dy.fsf_-_@columbia.edu> "Ariel J. Birnbaum" writes: >> In the mean time -- who knows enough to make ghc target >> ARM, and get this to link against the iPhone libraries? >> This would be quite a coup if it could be made to run >> there! > For that matter, there's another ARM-based target in which > I'm interested: Nintendo DS. Has anyone got any Haskell > code to run on one of these? PS: Maybe this discussion > should be moved to a new "Haskell on ARM" thread? I would be interested to see ghc running on Nokia n8xx or iRex iliad. Both of them are quite open linux based systems. -- c/* __o/* <\ * (__ */\ < From silva.samuel at gmail.com Tue Jun 17 08:19:47 2008 From: silva.samuel at gmail.com (Samuel Silva) Date: Tue Jun 17 08:11:41 2008 Subject: [Haskell-cafe] Compiling large code with old machine Message-ID: <382ead9b0806170519w3c2377f8v1584a97117a0d4f9@mail.gmail.com> Hello I'm using GHC to compile around 700K of Haskell Code generated by HaXml. How I compile this code. My machine is Windows-XP(512MB RAM, 1.5GHz) running GHC-6.8.2. How much time it spend to compile this file? I spent more than 1 hour and it doesn't finished. What flags make compiling fast? I try with -H500m but dont't expect. It is possible GHC running endless cycle at compilation stage? Thanks. -- Don't hug that, Hugs ME! Samuel Silva From bulat.ziganshin at gmail.com Tue Jun 17 08:27:50 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Jun 17 08:20:22 2008 Subject: [Haskell-cafe] Compiling large code with old machine In-Reply-To: <382ead9b0806170519w3c2377f8v1584a97117a0d4f9@mail.gmail.com> References: <382ead9b0806170519w3c2377f8v1584a97117a0d4f9@mail.gmail.com> Message-ID: <469977410.20080617162750@gmail.com> Hello Samuel, Tuesday, June 17, 2008, 4:19:47 PM, you wrote: > My machine is Windows-XP(512MB RAM, 1.5GHz) running GHC-6.8.2. > What flags make compiling fast? > I try with -H500m but dont't expect. bad idea since OS needs memory too. -H400m would be much better -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From aneumann at inf.fu-berlin.de Tue Jun 17 10:23:27 2008 From: aneumann at inf.fu-berlin.de (Adrian Neumann) Date: Tue Jun 17 10:15:37 2008 Subject: [Haskell-cafe] Compiling large code with old machine In-Reply-To: <382ead9b0806170519w3c2377f8v1584a97117a0d4f9@mail.gmail.com> References: <382ead9b0806170519w3c2377f8v1584a97117a0d4f9@mail.gmail.com> Message-ID: I would assume -O0, that is, turning off all optimizations, should make compilation faster Adrian Am 17.06.2008 um 14:19 schrieb Samuel Silva: > Hello > > I'm using GHC to compile around 700K of Haskell Code generated by > HaXml. > How I compile this code. > My machine is Windows-XP(512MB RAM, 1.5GHz) running GHC-6.8.2. > > How much time it spend to compile this file? > I spent more than 1 hour and it doesn't finished. > > What flags make compiling fast? > I try with -H500m but dont't expect. > > It is possible GHC running endless cycle at compilation stage? > > Thanks. > > -- > Don't hug that, Hugs ME! > Samuel Silva > _______________________________________________ > 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: PGP.sig Type: application/pgp-signature Size: 194 bytes Desc: Signierter Teil der Nachricht Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080617/09b9f16a/PGP.bin From hoknamahn at gmail.com Tue Jun 17 11:04:11 2008 From: hoknamahn at gmail.com (Olex P) Date: Tue Jun 17 10:56:07 2008 Subject: [Haskell-cafe] Suggestion for implementation of vector library Message-ID: Hi guys, Sorry for a silly questions but I didn't find a proper answer in Google. I've started to learn Haskell and would like to implement a library for work with vectors. I found different implementations of this stuff but all of them made just for fun in a short as possible terms using lists or tuples. I suppose there should be a better way to go. First idea came to my mind was using of classes. Something like this: [code] -- Template Vector class class Vector v where (<+>) :: v -> v -> v (<->) :: v -> v -> v (<*>) :: v -> v -> v (*>) :: v -> Float -> v -- other methods here -- Vector3 instance -- Declare new Vector3 type data Vector3 = Vector3 (Float, Float, Float) instance Vector Vector3 where (<+>) (Vector3 (x1, y1, z1)) (Vector3 (x2, y2, z2)) = Vector3 (x1 + x2, y1 + y2, z1 + z2) (<->) (Vector3 (x1, y1, z1)) (Vector3 (x2, y2, z2)) = Vector3 (x1 - x2, y1 - y2, z1 - z2) (<*>) (Vector3 (x1, y1, z1)) (Vector3 (x2, y2, z2)) = Vector3 (x1 * x2, y1 * y2, z1 * z2) (*>) (Vector3 (x, y, z)) f = Vector3 (x * f, y * f, z * f) length (Vector3 (x, y, z)) = sqrt (x * x + y * y + z * z) -- the rest of methods [/code] What I don't like here is using of data type constructors when even simple expression like v1 + v2 becomes too long (<+>) (Vector3 (1,2,3)) (Vector3 (4,5,6)) Do I really need a data type constructor (in this particular case)? Or better to declare a vector3 type as: type Vector3 = (Float, Float, Float)? Next question is how to make one instance which derives from several classes? For example from Eq, Num and Vector (if I want to overload +, -, <, >, == etc.) Is it good idea to use classes and ad hoc polymorphism or better to use parametric polymorphism? How you would implement such library? (not just for educational purposes but for development of _very_good_extensible_ software) Thank you, Alex. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080617/ee94bf9c/attachment.htm From john at repetae.net Tue Jun 17 11:24:58 2008 From: john at repetae.net (John Meacham) Date: Tue Jun 17 11:16:51 2008 Subject: [Haskell-cafe] Suggestion for implementation of vector library In-Reply-To: References: Message-ID: <20080617152458.GE12977@sliver.repetae.net> On Tue, Jun 17, 2008 at 04:04:11PM +0100, Olex P wrote: > Hi guys, > > Sorry for a silly questions but I didn't find a proper answer in Google. > I've started to learn Haskell and would like to implement a library for work > with vectors. I found different implementations of this stuff but all of > them made just for fun in a short as possible terms using lists or tuples. I > suppose there should be a better way to go. First idea came to my mind was > using of classes. Something like this: > > [code] > -- Template Vector class > > class Vector v where > (<+>) :: v -> v -> v > (<->) :: v -> v -> v > (<*>) :: v -> v -> v > (*>) :: v -> Float -> v > -- other methods here > > -- Vector3 instance > > -- Declare new Vector3 type > > data Vector3 = Vector3 (Float, Float, Float) > > instance Vector Vector3 where > (<+>) (Vector3 (x1, y1, z1)) (Vector3 (x2, y2, z2)) = Vector3 (x1 + x2, > y1 + y2, z1 + z2) > (<->) (Vector3 (x1, y1, z1)) (Vector3 (x2, y2, z2)) = Vector3 (x1 - x2, > y1 - y2, z1 - z2) > (<*>) (Vector3 (x1, y1, z1)) (Vector3 (x2, y2, z2)) = Vector3 (x1 * x2, > y1 * y2, z1 * z2) > (*>) (Vector3 (x, y, z)) f = Vector3 (x * f, y * f, z * f) > length (Vector3 (x, y, z)) = sqrt (x * x + y * y + z * z) > -- the rest of methods > [/code] > > What I don't like here is using of data type constructors when even simple > expression like v1 + v2 becomes too long (<+>) (Vector3 (1,2,3)) (Vector3 > (4,5,6)) > Do I really need a data type constructor (in this particular case)? Or > better to declare a vector3 type as: type Vector3 = (Float, Float, Float)? > Next question is how to make one instance which derives from several > classes? For example from Eq, Num and Vector (if I want to overload +, -, <, > >, == etc.) > Is it good idea to use classes and ad hoc polymorphism or better to use > parametric polymorphism? How you would implement such library? (not just for > educational purposes but for development of _very_good_extensible_ software) Well, The type I would use for Vector3 is data Vector3 = Vector3 !Float !Float !Float That will give you 3 strict (and perhaps unboxed) floats and reduce your need for parenthesis. In general, real types (declared with data or newtype) are a good idea, they often allow compiler optimizations, make your code more robust, and provide nice abstraction capabilities. The 'newtype deriving' extension is particularly useful. You can also create helper functions like v3 = Vector3 so you can do (v3 1 2 3 <+> v3 4 5 6) John -- John Meacham - ?repetae.net?john? From dons at galois.com Tue Jun 17 11:40:32 2008 From: dons at galois.com (Don Stewart) Date: Tue Jun 17 11:32:28 2008 Subject: [Haskell-cafe] Suggestion for implementation of vector library In-Reply-To: References: Message-ID: <20080617154032.GB18127@scytale.galois.com> hoknamahn: > Hi guys, > > Sorry for a silly questions but I didn't find a proper answer in Google. > I've started to learn Haskell and would like to implement a library for > work with vectors. I found different implementations of this stuff but all > of them made just for fun in a short as possible terms using lists or The main serious implementation is probably hmatrix, blas or numeric-prelude http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hmatrix http://hackage.haskell.org/cgi-bin/hackage-scripts/package/blas http://hackage.haskell.org/cgi-bin/hackage-scripts/package/numeric-prelude > tuples. I suppose there should be a better way to go. First idea came to > my mind was using of classes. Something like this: > > data Vector3 = Vector3 (Float, Float, Float) data Vector3 = Vector3 {-# UNPACK #-} !Double {-# UNPACK #-} !Double {-# UNPACK #-} !Double Compile with -O2 -fvia-C -optc-O2 and keep them in registers. -- Don From dons at galois.com Tue Jun 17 11:48:58 2008 From: dons at galois.com (Don Stewart) Date: Tue Jun 17 11:41:41 2008 Subject: =?utf-8?B?562U5aSN?= =?utf-8?Q?=3A?= [Haskell-cafe] How to do this in FP way? In-Reply-To: <48574590.034c6e0a.18fd.ffffb68d@mx.google.com> References: <3bd412d40806151931s3cef9027x73d83943386f0cad@mail.gmail.com> <117f2cc80806161017w680f5c83p3165733e46256be0@mail.gmail.com> <48574590.034c6e0a.18fd.ffffb68d@mx.google.com> Message-ID: <20080617154858.GC18127@scytale.galois.com> magicloud.magiclouds: > OK. Here it is. > I want to make a monitor tool for linux. It runs for a long time, and give > out a certain process's io stat per second. The way I get io stat is to read > from /proc/pid/io. But the data in this file is a total, I need to read it > first, then next second, read it again, and shows the difference, and go on. > So, what is your idea? Easy, import Control.Concurrent import Control.Monad main = go 0 where go st = forever $ do n <- read `fmap` readFile "/proc/pid/io" print (n - st) -- display difference threadDelay (10^6) -- Don From dons at galois.com Tue Jun 17 11:56:31 2008 From: dons at galois.com (Don Stewart) Date: Tue Jun 17 11:48:30 2008 Subject: =?utf-8?B?562U5aSN?= =?utf-8?Q?=3A?= [Haskell-cafe] How to do this in FP way? In-Reply-To: <20080617154858.GC18127@scytale.galois.com> References: <3bd412d40806151931s3cef9027x73d83943386f0cad@mail.gmail.com> <117f2cc80806161017w680f5c83p3165733e46256be0@mail.gmail.com> <48574590.034c6e0a.18fd.ffffb68d@mx.google.com> <20080617154858.GC18127@scytale.galois.com> Message-ID: <20080617155631.GD18127@scytale.galois.com> dons: > magicloud.magiclouds: > > OK. Here it is. > > I want to make a monitor tool for linux. It runs for a long time, and give > > out a certain process's io stat per second. The way I get io stat is to read > > from /proc/pid/io. But the data in this file is a total, I need to read it > > first, then next second, read it again, and shows the difference, and go on. > > So, what is your idea? > > Easy, > > import Control.Concurrent > import Control.Monad > > main = go 0 > where > go st = forever $ do > n <- read `fmap` readFile "/proc/pid/io" > print (n - st) -- display difference > threadDelay (10^6) Oops, not 'forever' :) go st = do ... go n From karoly at negyesi.net Tue Jun 17 12:45:09 2008 From: karoly at negyesi.net (Karoly Negyesi) Date: Tue Jun 17 12:37:15 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? Message-ID: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> Hi, The PHP community is discussing the adding of closures and lambdas to the language, see the proposal at http://wiki.php.net/rfc/closures If someone with knowledge of both languages could take a quick look it would be great. Thanks a lot Karoly Negyesi Ps. I am not a member of the PHP internals team, I am just a PHP developer but I am very very interested in getting these in my favourite language. From lemming at henning-thielemann.de Tue Jun 17 11:30:34 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Tue Jun 17 13:25:52 2008 Subject: [Haskell-cafe] Suggestion for implementation of vector library In-Reply-To: References: Message-ID: On Tue, 17 Jun 2008, Olex P wrote: > Hi guys, > > Sorry for a silly questions but I didn't find a proper answer in Google. > I've started to learn Haskell and would like to implement a library for work > with vectors. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hmatrix http://hackage.haskell.org/cgi-bin/hackage-scripts/package/blas http://hackage.haskell.org/cgi-bin/hackage-scripts/package/vector-space From prstanley at ntlworld.com Tue Jun 17 13:46:51 2008 From: prstanley at ntlworld.com (PR Stanley) Date: Tue Jun 17 13:38:46 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.co m> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> Message-ID: <20080617174953.WVJK29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> Blimey! Talk about rearranging the deckchairs :-) With respect, do you not think it'd be wiser for the community to deal with a total lack of proper type checking, the lack of any notion of the general concept of a function, or a whole range of other fundamental issues in PHP first before worrying about closures and lambda functions? I'm no language purist but PHP really does take the biscuit. My personal views and not in any way representing the list . Paul At 17:45 17/06/2008, you wrote: >Hi, > >The PHP community is discussing the adding of closures and lambdas to >the language, see the proposal at http://wiki.php.net/rfc/closures > >If someone with knowledge of both languages could take a quick look it >would be great. > >Thanks a lot > >Karoly Negyesi > >Ps. I am not a member of the PHP internals team, I am just a PHP >developer but I am very very interested in getting these in my >favourite language. >_______________________________________________ >Haskell-Cafe mailing list >Haskell-Cafe@haskell.org >http://www.haskell.org/mailman/listinfo/haskell-cafe From hoknamahn at gmail.com Tue Jun 17 13:50:25 2008 From: hoknamahn at gmail.com (Olex P) Date: Tue Jun 17 13:42:31 2008 Subject: [Haskell-cafe] Suggestion for implementation of vector library In-Reply-To: References: Message-ID: Thank you guys, I'll check it. On Tue, Jun 17, 2008 at 4:30 PM, Henning Thielemann < lemming@henning-thielemann.de> wrote: > > On Tue, 17 Jun 2008, Olex P wrote: > > Hi guys, >> >> Sorry for a silly questions but I didn't find a proper answer in Google. >> I've started to learn Haskell and would like to implement a library for >> work >> with vectors. >> > > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hmatrix > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/blas > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/vector-space > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080617/a3901436/attachment.htm From droundy at darcs.net Tue Jun 17 14:27:01 2008 From: droundy at darcs.net (David Roundy) Date: Tue Jun 17 14:18:57 2008 Subject: [Haskell-cafe] Design suggestion for Data.Binary.Defer In-Reply-To: <404396ef0806162355m1bf083f2pcebdbfa64e17e42b@mail.gmail.com> References: <404396ef0806160943r381f0b90ue418cb86bca0bc95@mail.gmail.com> <117f2cc80806161612oe3f2033q187cbf5c22592f03@mail.gmail.com> <404396ef0806162355m1bf083f2pcebdbfa64e17e42b@mail.gmail.com> Message-ID: <20080617182700.GD32397@darcs.net> On Tue, Jun 17, 2008 at 07:55:51AM +0100, Neil Mitchell wrote: > Hi, Hello! > David: > > Is there any reason not to just write all lazy fields of variable size > > in a deferred manner? > > I completely hadn't though of this! You will loose a bit of time, for > example reading fields which were previously not deferred will require > a file seek, but the effort/thought/efficiency trade-off is good. I > think I will go with this. Actually, you ought to be able to pretty easily remove this tradeoff by introducing a strict read function as a new method in your class. So anyone who wants to strictly read lazy data can use that function instead of the lazy one. The writing of data is unaffected... or rather, it *is* affected, but only in the sense that writing deferred data cannot be as lazy as the writing of undeferred data. e.g. when writing a deferred list, you can't output the first word until you've already read through the entire list in order to find out how long it is. That could actually be quite a problem for code that relies on laziness to handle massive amounts of data. :( Lazy reading seems to require strict writing, while lazy writing requires strict reading! So perhaps you want a pair of read functions, one strict, one lazy, and a pair of write functions. That doesn't provide any sort of fine-grained control, but at least allows streaming in either direction. You could use the same data format for either strictly or lazily pickled data as long as you have a reserved value for the length-to-be-skipped, so the lazy reader could tell if it reaches data that whose length it doesn't know. David From droundy at darcs.net Tue Jun 17 14:31:31 2008 From: droundy at darcs.net (David Roundy) Date: Tue Jun 17 14:23:29 2008 Subject: [Haskell-cafe] Suggestion for implementation of vector library In-Reply-To: <20080617152458.GE12977@sliver.repetae.net> References: <20080617152458.GE12977@sliver.repetae.net> Message-ID: <20080617183130.GE32397@darcs.net> On Tue, Jun 17, 2008 at 08:24:58AM -0700, John Meacham wrote: > You can also create helper functions like > > v3 = Vector3 > > so you can do (v3 1 2 3 <+> v3 4 5 6) Or just use data Vector3 = V3 !Float !Float !Float and you've got compact pattern matching as well as constructing. David From droundy at darcs.net Tue Jun 17 14:39:11 2008 From: droundy at darcs.net (David Roundy) Date: Tue Jun 17 14:31:08 2008 Subject: =?utf-8?B?562U5aSN?= =?utf-8?Q?=3A?= [Haskell-cafe] How to do this in FP way? In-Reply-To: <20080617155631.GD18127@scytale.galois.com> References: <3bd412d40806151931s3cef9027x73d83943386f0cad@mail.gmail.com> <117f2cc80806161017w680f5c83p3165733e46256be0@mail.gmail.com> <48574590.034c6e0a.18fd.ffffb68d@mx.google.com> <20080617154858.GC18127@scytale.galois.com> <20080617155631.GD18127@scytale.galois.com> Message-ID: <20080617183910.GF32397@darcs.net> On Tue, Jun 17, 2008 at 08:56:31AM -0700, Don Stewart wrote: > dons: > > magicloud.magiclouds: > > > OK. Here it is. > > > I want to make a monitor tool for linux. It runs for a long time, and give > > > out a certain process's io stat per second. The way I get io stat is to read > > > from /proc/pid/io. But the data in this file is a total, I need to read it > > > first, then next second, read it again, and shows the difference, and go on. > > > So, what is your idea? > > > > Easy, > > > > import Control.Concurrent > > import Control.Monad > > > > main = go 0 > > where > > go st = forever $ do > > n <- read `fmap` readFile "/proc/pid/io" > > print (n - st) -- display difference > > threadDelay (10^6) > > Oops, not 'forever' :) > > go st = do > ... > go n or doEverySecond :: (a -> IO a) -> a -> IO () doEverySecond job n = do n' <- job n threadDelay (10^6) doEverySecond job n' showChange :: Int -> IO Int showChange n = do n' <- read `fmap` readFile "/proc/pid/io" print (n' - n) -- display difference return n' main = doEverySecond showChange 0 -- note: prints bogus value first time This demonstrates how you can abstract the ideas in Don's solution just a bit, so that you could reuse these functions for somewhat different purposes. For such a simple function you'd probably be better with Don's solution, but if your monitor tool is starting to look more complicated than this, perhaps you're better off breaking it into different functions. David From byorgey at gmail.com Tue Jun 17 14:46:27 2008 From: byorgey at gmail.com (Brent Yorgey) Date: Tue Jun 17 14:38:26 2008 Subject: [Haskell-cafe] send in material for the HWN! Message-ID: <22fcbd520806171146q22d54029m7fbfe077ea9fefa3@mail.gmail.com> Hi all, Do you know of a blog post about Haskell that wasn't syndicated on Planet Haskell? Do you have a Haskell-related story to tell or announcement to make? Do you have a link to some great pictures from the latest meetup/hackathon/talk/conference? A funny story about Don Stewart? If so, consider submitting it to the Haskell Weekly News. The HWN isn't really about Haskell so much as it is about the Haskell *community* -- and that means you! In addition to the above sorts of submissions, I am also thinking of adding a "Community News" section with announcements of (not-necessarily-Haskell-related) major events in the lives of community members -- but obviously this depends on submissions, so if you get a new job/move/start a new company/graduate/increment your age/have a comet named after you/bring forth a new life (aka future Haskeller) into the world, please share, and let the community celebrate with you! Submissions can be sent to byorgey at seas dot upenn dot edu. Be sure to include "HWN" in the subject line. For now I'm planning to put an issue out every Wednesday afternoon, so the submission deadline is Wednesday at 11am GMT (6am Eastern US). -Brent -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080617/7833aff1/attachment.htm From miguelimo38 at yandex.ru Tue Jun 17 14:58:04 2008 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Tue Jun 17 14:50:44 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <20080617174953.WVJK29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <20080617174953.WVJK29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> Message-ID: Calm down, PR, that's not so bad, all we're going to see is an example of closures done wrong, nothing more. On 17 Jun 2008, at 21:46, PR Stanley wrote: > Blimey! Talk about rearranging the deckchairs :-) > With respect, do you not think it'd be wiser for the community to > deal with a total lack of proper type checking, the lack of any > notion of the general concept of a function, or a whole range of > other fundamental issues in PHP first before worrying about closures > and lambda functions? I'm no language purist but PHP really does > take the biscuit. > My personal views and not in any way representing the list . > Paul > > At 17:45 17/06/2008, you wrote: >> Hi, >> >> The PHP community is discussing the adding of closures and lambdas to >> the language, see the proposal at http://wiki.php.net/rfc/closures >> >> If someone with knowledge of both languages could take a quick look >> it >> would be great. >> >> Thanks a lot >> >> Karoly Negyesi >> >> Ps. I am not a member of the PHP internals team, I am just a PHP >> developer but I am very very interested in getting these in my >> favourite language. >> _______________________________________________ >> 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 barsoap at web.de Tue Jun 17 15:31:23 2008 From: barsoap at web.de (Achim Schneider) Date: Tue Jun 17 15:23:35 2008 Subject: [Haskell-cafe] Re: Lambda and closures in PHP -- could someone please comment? References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.co m> <20080617174953.WVJK29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> Message-ID: <20080617213123.43e5e63b@solaris> PR Stanley wrote: > Blimey! Talk about rearranging the deckchairs :-) > With respect, do you not think it'd be wiser for the community to > deal with a total lack of proper type checking, the lack of any > notion of the general concept of a function, or a whole range of > other fundamental issues in PHP first before worrying about closures > and lambda functions? I'm no language purist but PHP really does > take the biscuit. > My personal views and not in any way representing the list . > Oh yes they are. I'd rather smash my head repeatedly into a wall than suffering the agony of using a hacked cat. -- (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 lanny at cisco.com Tue Jun 17 15:43:26 2008 From: lanny at cisco.com (Lanny Ripple) Date: Tue Jun 17 15:35:15 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <20080617174953.WVJK29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <20080617174953.WVJK29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> Message-ID: <485813DE.1050706@cisco.com> But all the cool kids have em! Seriously though computer languages are about getting things done. If this gets more things done for the PHP community in ways easier/simpler/faster than before then it's a win. They are after all /their/ deckchairs to play with. -ljr PR Stanley wrote: > Blimey! Talk about rearranging the deckchairs :-) > With respect, do you not think it'd be wiser for the community to deal > with a total lack of proper type checking, the lack of any notion of the > general concept of a function, or a whole range of other fundamental > issues in PHP first before worrying about closures and lambda > functions? I'm no language purist but PHP really does take the biscuit. > My personal views and not in any way representing the list . > Paul > > At 17:45 17/06/2008, you wrote: >> Hi, >> >> The PHP community is discussing the adding of closures and lambdas to >> the language, see the proposal at http://wiki.php.net/rfc/closures >> >> If someone with knowledge of both languages could take a quick look it >> would be great. >> >> Thanks a lot >> >> Karoly Negyesi >> >> Ps. I am not a member of the PHP internals team, I am just a PHP >> developer but I am very very interested in getting these in my >> favourite language. >> _______________________________________________ >> 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 hpacheco at gmail.com Tue Jun 17 15:51:09 2008 From: hpacheco at gmail.com (Hugo Pacheco) Date: Tue Jun 17 15:43:07 2008 Subject: [Haskell-cafe] Polymorphic QuickCheck arguments In-Reply-To: <2A22B918-BD68-4C0E-97D8-FACDC33CF6AD@cs.uu.nl> References: <7b92c2840806170253l7f53e07al7eedc1411934ca69@mail.gmail.com> <2A22B918-BD68-4C0E-97D8-FACDC33CF6AD@cs.uu.nl> Message-ID: <7b92c2840806171251p7a27ff08w54dde46e208bfdf5@mail.gmail.com> You are right! If I try to compile it, then it complains about a Show instance for a, what in fact forces a monomorphic type signature for t. I have found under Test.Quickcheck.Poly a way to generate Int values for a polymorphic type, but because it requires an abstraction Poly a for some type a I do not see how it can improve. What it concretely states the module is - This is the basic pseudo-polymorphic object. - The idea is you can't cheat, and use the integer - directly, but need to use the abstraction. Is it possible to cheat? I would like to... Thanks, hugo On Tue, Jun 17, 2008 at 12:17 PM, Sebastiaan Visser wrote: > On Jun 17, 2008, at 11:53 AM, Hugo Pacheco wrote: > >> Hi all, >> >> There is something about polymorphic tests in QuickCheck that I do not >> understand. >> >> If you write the simplest dummy test function >> >> tst :: a -> Bool >> tst _ = True >> >> and evaluate it we get >> >> > verboseCheck tst >> 0: >> () >> 1: >> () >> ... >> > > > How come did the polymorphic value a get instanciated to ()? Is this done >> via the Testable type class? >> Could someone please explain this to me? I'm not saying it does not make >> sense, but I would like to understand how it works. Being possible to change >> this behavior, this is, assign another "default type" whenever polymorphic >> types occur, would be awesome. >> > > I think it is GHCi that is instantiating the type with (). Try compiling > the program, it will probably be rejected by the compiler when you do not > specify a concrete type. > > You can, for example, try this: > > verboseCheck (tst :: [Int] -> Bool) > > Cheers, >> hugo >> > -- www.di.uminho.pt/~hpacheco -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080617/6444afe4/attachment.htm From dons at galois.com Tue Jun 17 16:12:33 2008 From: dons at galois.com (Don Stewart) Date: Tue Jun 17 16:04:30 2008 Subject: Haskell on ARM (was Re: [Haskell-cafe] ANN: Topkata) In-Reply-To: <87ej6ww9dy.fsf_-_@columbia.edu> References: <87zlpoguqh.fsf@elefant.olsbruecken.local> <4B3E7353-F7F2-4D2D-A335-30D2D3883A4A@gmail.com> <200806170851.22718.valgarv@gmx.net> <87ej6ww9dy.fsf_-_@columbia.edu> Message-ID: <20080617201233.GD19304@scytale.galois.com> xj2106: > "Ariel J. Birnbaum" writes: > > >> In the mean time -- who knows enough to make ghc target > >> ARM, and get this to link against the iPhone libraries? > >> This would be quite a coup if it could be made to run > >> there! > > For that matter, there's another ARM-based target in which > > I'm interested: Nintendo DS. Has anyone got any Haskell > > code to run on one of these? PS: Maybe this discussion > > should be moved to a new "Haskell on ARM" thread? > > I would be interested to see ghc running on Nokia n8xx or > iRex iliad. Both of them are quite open linux based > systems. Jeremy Shaw had ghc targeting the nokia last year, iirc. Perhaps he'll have more info. -- Don From dons at galois.com Tue Jun 17 16:16:15 2008 From: dons at galois.com (Don Stewart) Date: Tue Jun 17 16:08:13 2008 Subject: [Haskell-cafe] Compiling large code with old machine In-Reply-To: <382ead9b0806170519w3c2377f8v1584a97117a0d4f9@mail.gmail.com> References: <382ead9b0806170519w3c2377f8v1584a97117a0d4f9@mail.gmail.com> Message-ID: <20080617201615.GE19304@scytale.galois.com> silva.samuel: > Hello > > I'm using GHC to compile around 700K of Haskell Code generated by HaXml. > How I compile this code. > My machine is Windows-XP(512MB RAM, 1.5GHz) running GHC-6.8.2. > > How much time it spend to compile this file? > I spent more than 1 hour and it doesn't finished. > > What flags make compiling fast? > I try with -H500m but dont't expect. > > It is possible GHC running endless cycle at compilation stage? Hmm. Try -Onot -fasm -- Don From ronwalf at volus.net Tue Jun 17 16:40:51 2008 From: ronwalf at volus.net (Ron Alford) Date: Tue Jun 17 16:32:54 2008 Subject: [Haskell-cafe] Haskell's type system Message-ID: I'm trying to wrap my head around the theoretical aspects of haskell's type system. Is there a discussion of the topic separate from the language itself? Since I come from a rather logic-y background, I have this (far-fetched) hope that there is a translation from haskell's type syntax to first order logic (or an extension there-of). Is this done? Doable? -Ron From nicolas.pouillard at gmail.com Tue Jun 17 16:47:10 2008 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Tue Jun 17 16:39:30 2008 Subject: [Haskell-cafe] Design suggestion for Data.Binary.Defer In-Reply-To: <20080617182700.GD32397@darcs.net> References: <404396ef0806160943r381f0b90ue418cb86bca0bc95@mail.gmail.com> <117f2cc80806161612oe3f2033q187cbf5c22592f03@mail.gmail.com> <404396ef0806162355m1bf083f2pcebdbfa64e17e42b@mail.gmail.com> <20080617182700.GD32397@darcs.net> Message-ID: <1213735407-sup-7909@ausone.local> Excerpts from David Roundy's message of Tue Jun 17 20:27:01 +0200 2008: > On Tue, Jun 17, 2008 at 07:55:51AM +0100, Neil Mitchell wrote: > > Hi, > > Hello! Hello, > :( Lazy reading seems to > require strict writing, while lazy writing requires strict reading! I'm wondering if it would be an option to read the file backward. If so length annotations could be put at the end. Reading backward seems to only fail with streamed data, which won't support the "seek"ing required by a lazy reading anyway. Regards, -- Nicolas Pouillard aka Ertai -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 194 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080617/8d750618/signature.bin From nielsadb at gmail.com Tue Jun 17 17:24:11 2008 From: nielsadb at gmail.com (Niels Aan de Brugh) Date: Tue Jun 17 17:16:06 2008 Subject: [Haskell-cafe] Compiling large code with old machine In-Reply-To: <382ead9b0806170519w3c2377f8v1584a97117a0d4f9@mail.gmail.com> References: <382ead9b0806170519w3c2377f8v1584a97117a0d4f9@mail.gmail.com> Message-ID: <1213737851.19520.15.camel@porcupine> On Tue, 2008-06-17 at 13:19 +0100, Samuel Silva wrote: > > I'm using GHC to compile around 700K of Haskell Code generated by HaXml. > How I compile this code. > My machine is Windows-XP(512MB RAM, 1.5GHz) running GHC-6.8.2. > > How much time it spend to compile this file? > I spent more than 1 hour and it doesn't finished. Just out of curiosity, is all that 700K just one big file or did you split it up into multiple files? Are you using any "expensive" features? I'm not a GHC exert, but I'd expect things like type manipulations (e.g. phantom types) to be expensive (please correct me if this assumption is wrong). Bottom line: if compiling is so slow consider changing the code generator so the result is easier to process by GHC instead of fiddling with command line switches. Since you've chosen to generate the code it will probably change often and you'll run into this problem more than once. Regards, Niels From prstanley at ntlworld.com Tue Jun 17 18:03:42 2008 From: prstanley at ntlworld.com (PR Stanley) Date: Tue Jun 17 17:55:32 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <485813DE.1050706@cisco.com> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <20080617174953.WVJK29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> <485813DE.1050706@cisco.com> Message-ID: <20080617220921.UFRL16854.aamtaout01-winn.ispmail.ntl.com@pine.ntlworld.com> >But all the cool kids have em! > >Seriously though computer languages are about getting things done. >If this gets more things done for the PHP community in ways >easier/simpler/faster than before then it's a win. nerve gas would sort out the problem with mice in our building too, easier simpler faster than the stupid traps. >They are after all /their/ deckchairs to play with. Yes, playing with deckchairs while the ship sinks with that bloody woman singing "my Heart Will Go on". > -ljr > >PR Stanley wrote: > > Blimey! Talk about rearranging the deckchairs :-) > > With respect, do you not think it'd be wiser for the community to deal > > with a total lack of proper type checking, the lack of any notion of the > > general concept of a function, or a whole range of other fundamental > > issues in PHP first before worrying about closures and lambda > > functions? I'm no language purist but PHP really does take the biscuit. > > My personal views and not in any way representing the list . > > Paul > > > > At 17:45 17/06/2008, you wrote: > >> Hi, > >> > >> The PHP community is discussing the adding of closures and lambdas to > >> the language, see the proposal at http://wiki.php.net/rfc/closures > >> > >> If someone with knowledge of both languages could take a quick look it > >> would be great. > >> > >> Thanks a lot > >> > >> Karoly Negyesi > >> > >> Ps. I am not a member of the PHP internals team, I am just a PHP > >> developer but I am very very interested in getting these in my > >> favourite language. > >> _______________________________________________ > >> 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 loup.vaillant at gmail.com Tue Jun 17 19:11:30 2008 From: loup.vaillant at gmail.com (Loup Vaillant) Date: Tue Jun 17 19:03:24 2008 Subject: [Haskell-cafe] Re: Lambda and closures in PHP -- could someone please comment? In-Reply-To: <20080617213123.43e5e63b@solaris> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <20080617174953.WVJK29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> <20080617213123.43e5e63b@solaris> Message-ID: <6f9f8f4a0806171611u3537da12x5f915517a1515927@mail.gmail.com> 2008/6/17 Achim Schneider : > PR Stanley wrote: > >> Blimey! Talk about rearranging the deckchairs :-) >> With respect, do you not think it'd be wiser for the community to >> deal with a total lack of proper type checking, the lack of any >> notion of the general concept of a function, or a whole range of >> other fundamental issues in PHP first before worrying about closures >> and lambda functions? I'm no language purist but PHP really does >> take the biscuit. >> My personal views and not in any way representing the list . >> > Oh yes they are. I'd rather smash my head repeatedly into a wall than > suffering the agony of using a hacked cat. Well, it's not like they're going to turn python into Haskell :-) If any flaw in a language is fundamental, fixing it is likely to cause compatibility... issues. And about closures done wrong, I think the biggest mistake (the only I spotted, actually) is the keyword "lexical". It seems to add unnecessary verbosity where plain lexical scope would suffice. It would be OK if lexical scope is impossible (which I doubt), and plain wrong if done for readability reasons. Is there any discussion about this point? Concerning OOP, I didn't really pay attention. My 2 cents. Take with a grain of salt, for I don't really know PHP Loup From dons at galois.com Tue Jun 17 22:08:27 2008 From: dons at galois.com (Don Stewart) Date: Tue Jun 17 22:00:24 2008 Subject: [Haskell-cafe] Haskell's type system In-Reply-To: References: Message-ID: <20080618020827.GB21778@scytale.galois.com> ronwalf: > I'm trying to wrap my head around the theoretical aspects of haskell's > type system. Is there a discussion of the topic separate from the > language itself? > > Since I come from a rather logic-y background, I have this > (far-fetched) hope that there is a translation from haskell's type > syntax to first order logic (or an extension there-of). Is this done? > Doable? A quick link to get you started on the topic, I'm sure others will add more material. Haskell's type system is based on System F, the polymorphic lambda calculus. By the Curry-Howard isomorphism, this corresponds to second-order logic. The GHC compiler itself implements Haskell and extensions by encoding them in System Fc internally, "which extends System F with support for non-syntactic type equality.". JHC, I believe, encodes Haskell into a pure type system internally, some sort of higher order dependently-typed polymorphic lambda calculus. -- Don From jonathanccast at fastmail.fm Tue Jun 17 22:26:21 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Tue Jun 17 22:17:54 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> Message-ID: <1213755981.3338.15.camel@jonathans-macbook> On Tue, 2008-06-17 at 18:45 +0200, Karoly Negyesi wrote: > Hi, > > The PHP community is discussing the adding of closures and lambdas to > the language, see the proposal at http://wiki.php.net/rfc/closures > > If someone with knowledge of both languages could take a quick look it > would be great. I program in Perl for a living, so hopefully you'll understand when I say (a) I would *never* want to use an implementation of closures like that. (b) Closures as proposed are *far* better than not having closures. jcc From gwern0 at gmail.com Tue Jun 17 22:41:38 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Tue Jun 17 22:34:18 2008 Subject: [Haskell-cafe] ANN: Mueval 0.3 Message-ID: <20080618024138.GA30776@craft> Hiya everyone. So I've uploaded Mueval 0.3 (release early, release often) . What's new? Well, I changed the printing output to be cleaner, and I made printing the inferred type optional (through a --print-type flag). In addition, I've made sure it can run (for me, at least) under -N4, and the watchdog threads should be sturdier. (Plus extra tests.) However, I've been hearing that a number of people (3 at last count) have been having a lot of trouble with the ResourceLimits stuff. So, I have a few requests of people who install mueval: * First, does it work out of the box, with no tweaking of the resource limits? * Second, if it doesn't work out of the box, which resource limits did you need to disable or increase? * Thirdly, if you changed the resource limits, could you run ./build.sh and tell me whether all the tests pass? Finally, I've been pondering removing the rlimits entirely since they are both very unportable, empirically derived, and apparently don't even work consistently on Linux. Any thoughts? -- gwern PABX MEMEX 868 1* TSCI @ shelter Yukon el ASLET -------------- 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/20080617/779f84d2/attachment.bin From aeyakovenko at gmail.com Wed Jun 18 00:00:26 2008 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Tue Jun 17 23:52:24 2008 Subject: [Haskell-cafe] blas bindings, why are they so much slower the C? Message-ID: here is the C: #include #include int main() { int size = 1024; int ii = 0; double* v1 = malloc(sizeof(double) * (size)); double* v2 = malloc(sizeof(double) * (size)); for(ii = 0; ii < size*size; ++ii) { double _dd = cblas_ddot(0, v1, size, v2, size); } free(v1); free(v2); } this is the haskell: module Main where import Data.Vector.Dense.IO main = do let size = 1024 v1::IOVector Int Double <- newListVector size [0..] v2::IOVector Int Double <- newListVector size [0..] mapM_ (\ ii -> do v1 `getDot` v2) [0..size*size] time ./testdot real 0m0.017s user 0m0.010s sys 0m0.010s time ./htestdot real 0m4.692s user 0m4.670s sys 0m0.030s so like 250x difference htestdot.prof is no help Tue Jun 17 20:46 2008 Time and Allocation Profiling Report (Final) htestdot +RTS -p -RTS total time = 3.92 secs (196 ticks @ 20 ms) total alloc = 419,653,032 bytes (excludes profiling overheads) COST CENTRE MODULE %time %alloc main Main 88.3 83.0 CAF Main 11.7 17.0 individual inherited COST CENTRE MODULE no. entries %time %alloc %time %alloc MAIN MAIN 1 0 0.0 0.0 100.0 100.0 CAF Main 216 7 11.7 17.0 100.0 100.0 main Main 222 1 88.3 83.0 88.3 83.0 CAF GHC.Float 187 1 0.0 0.0 0.0 0.0 CAF GHC.Handle 168 3 0.0 0.0 0.0 0.0 From karoly at negyesi.net Wed Jun 18 00:36:23 2008 From: karoly at negyesi.net (Karoly Negyesi) Date: Wed Jun 18 00:28:23 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <1213755981.3338.15.camel@jonathans-macbook> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <1213755981.3338.15.camel@jonathans-macbook> Message-ID: <7e270cea0806172136m67f5eb22o6fda46db93b49053@mail.gmail.com> > (a) I would *never* want to use an implementation of closures like that. > (b) Closures as proposed are *far* better than not having closures. Could you elaborate on a) ? From lrpalmer at gmail.com Wed Jun 18 01:00:36 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Wed Jun 18 00:52:31 2008 Subject: [Haskell-cafe] Haskell's type system In-Reply-To: References: Message-ID: <7ca3f0160806172200s2a7631eaub5453101c6713279@mail.gmail.com> On Tue, Jun 17, 2008 at 2:40 PM, Ron Alford wrote: > I'm trying to wrap my head around the theoretical aspects of haskell's > type system. Is there a discussion of the topic separate from the > language itself? > > Since I come from a rather logic-y background, I have this > (far-fetched) hope that there is a translation from haskell's type > syntax to first order logic (or an extension there-of). Is this done? > Doable? Sort of, via the Curry-Howard Correspondence. Haskell's type system corresponds to a constructive logic (no law of excluded middle). Arbitrary quantifiers are also introduced via the RankNTypes (I think that's what it's called) extension. Haskell's type system is a straightforward polymorphic type system for the lambda calculus, so researching the Curry-Howard Correspondence will probably get you what you want. Luke From vigalchin at gmail.com Wed Jun 18 01:12:28 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Wed Jun 18 01:04:21 2008 Subject: [Haskell-cafe] Haskell data types and Storable class Message-ID: <5ae4f2ba0806172212ge0ea659paa2c767bb12700ed@mail.gmail.com> Hello, I am reading the FFI spec. Something is unclear to me. Let's assume we have data A = {b:B, .......} and data B ={ .............} both of which belong to class Storable. In the A instance of Storable I want to do a poke and peek of "b" into and out-of, respectively, B. How do I write the poke and peek function of "b" in the "instance Storable A"? thank you, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080618/e5f1fdd7/attachment.htm From ok at cs.otago.ac.nz Wed Jun 18 01:16:10 2008 From: ok at cs.otago.ac.nz (Richard A. O'Keefe) Date: Wed Jun 18 01:08:36 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <485813DE.1050706@cisco.com> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <20080617174953.WVJK29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> <485813DE.1050706@cisco.com> Message-ID: I believe C# already has lambdas, and Java is supposed to be getting them. PHP is playing catchup, is all. (Oh, and Eiffel has 'agents', and I think I saw something about C++ Next Degeneration, and ...) Heck, the idea has only been around in computing since the 1950s... From barsoap at web.de Wed Jun 18 02:06:46 2008 From: barsoap at web.de (Achim Schneider) Date: Wed Jun 18 01:58:53 2008 Subject: [Haskell-cafe] Something like scan1 Message-ID: <20080618080646.29abd52f@solaris> Is there a generalisation of scan1, such that eg. foo (+) [0,1] (1,2) = [0,1,1,2,3,5,8,13,...] ? I came up with it while thinking about the equivalence of laziness and strictness resp. pull and push. To be more specific, I was thinking about ArrowLoop and how that beast generalises over time-varying values. It's some kind of helixoid fixed point (which might not help at all if your visualisation is incompatible with mine). -- (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 andrewcoppin at btinternet.com Tue Jun 17 16:05:31 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Wed Jun 18 02:38:50 2008 Subject: [Haskell-cafe] Bit streams Message-ID: <4858190B.4090909@btinternet.com> OK, so today I tried to write my first program using the Binary library. And I've hit a snag: It appears the library will only handle data that is byte-aligned. So if I try to write three Bool values, it uses three bytes, not three bits. Before I sit down and spend 3 months designing my own library from scratch, does anybody know of an existing library that allows you to do what Binary does, but with single-bit precision? [I presume Binary is byte-aligned for efficiency...] From jonathanccast at fastmail.fm Wed Jun 18 03:11:19 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Wed Jun 18 03:03:12 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <7e270cea0806172136m67f5eb22o6fda46db93b49053@mail.gmail.com> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <1213755981.3338.15.camel@jonathans-macbook> <7e270cea0806172136m67f5eb22o6fda46db93b49053@mail.gmail.com> Message-ID: <1213773079.7014.22.camel@jonathans-macbook> On Wed, 2008-06-18 at 06:36 +0200, Karoly Negyesi wrote: > > (a) I would *never* want to use an implementation of closures like that. > > (b) Closures as proposed are *far* better than not having closures. > > Could you elaborate on a) ? I dislike the habit of implicit declaration --- strongly --- and the consequent need for the lexical keyword (although at this point PHP's stuck with it). I can see myself forgetting to use lexical far more often than accidentally leaving off a `my' in Perl I should have used (I hardly ever shadow variable names anyway, so if I forget `my' is usually a use strict 'vars' error). I dislike curly braces. Syntax that extends as far to the right as possible tends to end up with fewer delimiters and a cleaner appearance. It's basically a way to replace a bunch of closing braces with a single ) or (in Haskell, implicit) ; lintPat p0 $ \ ty0 -> lintPat p1 $ \ ty1 -> lint e vs lintPat($p0, sub { my ($ty0) = @_; lintPat($p1, sub { my ($ty1) = @_; lint($e) })}) Four closing delimiters seems excessive. Nit: `function' is verbose. ML uses fun or fn (I forget which and am too lazy to google). Perl's regular keyword is sub, so they use that. There are worse fates than duck typing (C++ comes to mind :), and given a language with neither lexical closures/anonymous functions nor HM typing, I'd complain about the lack of lambdas first. But, still, no HM means no type classes. That ultimately becomes limiting. (I still haven't seen a decent implementation of monads in a dynamically typed language). But PHP is probably pretty much stuck with it. Not to criticize, mind you --- the proposal looks excellent for what it does. But I like what Haskell does worlds better. jcc From dominic.steinitz at blueyonder.co.uk Wed Jun 18 03:17:07 2008 From: dominic.steinitz at blueyonder.co.uk (Dominic Steinitz) Date: Wed Jun 18 03:09:18 2008 Subject: [Haskell-cafe] Re: Compiling large code with old machine References: <382ead9b0806170519w3c2377f8v1584a97117a0d4f9@mail.gmail.com> Message-ID: Samuel Silva gmail.com> writes: > > Hello > > I'm using GHC to compile around 700K of Haskell Code generated by HaXml. > How I compile this code. > My machine is Windows-XP(512MB RAM, 1.5GHz) running GHC-6.8.2. > Samuel, You may not want to take this approach. I'm assuming you are generating haskell types from a (large) DTD. I went this way (admittedly quite a few years ago) for svg. In the end it was much easier to hand generate a few combinators to produced the svg. I don't know what your application is but it may worth thinking about an alternative to 700k loc. Dominic. From dominic.steinitz at blueyonder.co.uk Wed Jun 18 03:46:08 2008 From: dominic.steinitz at blueyonder.co.uk (Dominic Steinitz) Date: Wed Jun 18 03:38:10 2008 Subject: [Haskell-cafe] Re: Bit Streams Message-ID: OK, so today I tried to write my first program using the Binary library. And I've hit a snag: It appears the library will only handle data that is byte-aligned. So if I try to write three Bool values, it uses three bytes, not three bits. Before I sit down and spend 3 months designing my own library from scratch, does anybody know of an existing library that allows you to do what Binary does, but with single-bit precision? [I presume Binary is byte-aligned for efficiency...] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/binary-strict From karoly at negyesi.net Wed Jun 18 04:19:13 2008 From: karoly at negyesi.net (Karoly Negyesi) Date: Wed Jun 18 04:11:08 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <1213773079.7014.22.camel@jonathans-macbook> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <1213755981.3338.15.camel@jonathans-macbook> <7e270cea0806172136m67f5eb22o6fda46db93b49053@mail.gmail.com> <1213773079.7014.22.camel@jonathans-macbook> Message-ID: <7e270cea0806180119y30c56184m9b16969f05b5517f@mail.gmail.com> > Not to criticize, mind you --- the proposal looks excellent for what it > does. But I like what Haskell does worlds better. Obviously you like Haskell better given this mailing list :) I am not here to compare PHP and Haskell, I was just asking advice from people who know closures and lambdas very well and it seems that I got it in the words of "the proposal looks excellent for what it does". Thanks a lot. Karoly Negyesi From jules at jellybean.co.uk Wed Jun 18 04:46:30 2008 From: jules at jellybean.co.uk (Jules Bean) Date: Wed Jun 18 04:38:22 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <20080617174953.WVJK29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <20080617174953.WVJK29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> Message-ID: <4858CB66.1040605@jellybean.co.uk> PR Stanley wrote: > With respect, do you not think it'd be wiser for the community [snip] *disgusted* This is exactly the sort of message that haskell-cafe does not normally contain. Let's not start now. This is a civilized mailing list. Either comment on the nice gentlemen's PHP closure proposal from a language point of view, or don't say anything. Jules From devriese at cs.tcd.ie Wed Jun 18 05:32:02 2008 From: devriese at cs.tcd.ie (Edsko de Vries) Date: Wed Jun 18 05:23:58 2008 Subject: [Haskell-cafe] Haskell's type system In-Reply-To: References: Message-ID: <20080618093202.GA18893@netsoc.tcd.ie> On Tue, Jun 17, 2008 at 04:40:51PM -0400, Ron Alford wrote: > I'm trying to wrap my head around the theoretical aspects of haskell's > type system. Is there a discussion of the topic separate from the > language itself? > > Since I come from a rather logic-y background, I have this > (far-fetched) hope that there is a translation from haskell's type > syntax to first order logic (or an extension there-of). Is this done? > Doable? I'll give you some terms to Google for. The "ideal" type system for Haskell (ignoring type classes) is System F. Haskell'98 doesn't quite get there, but recent extensions such as boxy types and FPH do. System F corresponds to second order propositional logic: types correspond to propositions in this logic, and Haskell programs as the corresponding proofs (by the Curry-Howard isomorphism). The type system of Haskell'98 is a bit weird from a logical perspective, and sort of corresponds to the rank 1.5 predicative fragment of second order propositional logic (I say rank 1.5 because although no abstraction over rank 1 types is allowed normally, limited abstractions over rank 1 types is allowed through let-polymorphism -- so this is *almost* first order logic but not quite: slightly more powerful). Regarding type classes, I'm not 100% what the logical equivalent is, although one can regard a type such as forall a. Eq a => a -> a as requiring a proof (evidence) that equality on a is decidable. Where this sits formally as a logic I'm not sure though. Edsko From prstanley at ntlworld.com Wed Jun 18 06:38:00 2008 From: prstanley at ntlworld.com (PR Stanley) Date: Wed Jun 18 06:29:45 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <4858CB66.1040605@jellybean.co.uk> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <20080617174953.WVJK29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> <4858CB66.1040605@jellybean.co.uk> Message-ID: <20080618104723.YEKX8797.aamtaout03-winn.ispmail.ntl.com@pine.ntlworld.com> >>With respect, do you not think it'd be wiser for the community > >[snip] > >*disgusted* > >This is exactly the sort of message that haskell-cafe does not >normally contain. Let's not start now. > >This is a civilized mailing list. Either comment on the nice >gentlemen's PHP closure proposal from a language point of view, or >don't say anything. Paul: Uncivilised you say. Well, I would have thought the civilised thing would be to share your concerns discretely with the list moderator. Instead you've chosen to make a public show of it. The Chinese have a saying, and I paraphrase - when you point the finger of accusation at someone/something you have three pointing back at yourself. Paul From sfvisser at cs.uu.nl Wed Jun 18 06:45:54 2008 From: sfvisser at cs.uu.nl (Sebastiaan Visser) Date: Wed Jun 18 06:38:01 2008 Subject: [Haskell-cafe] Bit streams In-Reply-To: <4858190B.4090909@btinternet.com> References: <4858190B.4090909@btinternet.com> Message-ID: <6E0C8147-0075-4FFE-9AC8-7606392370C8@cs.uu.nl> On Jun 17, 2008, at 10:05 PM, Andrew Coppin wrote: > OK, so today I tried to write my first program using the Binary > library. And I've hit a snag: It appears the library will only > handle data that is byte-aligned. So if I try to write three Bool > values, it uses three bytes, not three bits. > > Before I sit down and spend 3 months designing my own library from > scratch, does anybody know of an existing library that allows you > to do what Binary does, but with single-bit precision? [I presume > Binary is byte-aligned for efficiency...] Andrew, Maybe you could look at the generic encode/decode in this paper: people.cs.uu.nl/johanj/publications/ComparingGP.pdf When you look at some more literature about generic programming the (bit-aligned) encode and decode are quite common examples. It shouldn't be that hard to de-generify them, if you even want that. -- Sebastiaan. From silva.samuel at gmail.com Wed Jun 18 07:07:22 2008 From: silva.samuel at gmail.com (Samuel Silva) Date: Wed Jun 18 06:59:14 2008 Subject: [Haskell-cafe] Compiling large code with old machine In-Reply-To: <382ead9b0806180022i605d069y199d44e7330bebd2@mail.gmail.com> References: <382ead9b0806170519w3c2377f8v1584a97117a0d4f9@mail.gmail.com> <1213737851.19520.15.camel@porcupine> <382ead9b0806180022i605d069y199d44e7330bebd2@mail.gmail.com> Message-ID: <382ead9b0806180407o80ee94dmf51bcf235f271d11@mail.gmail.com> Hello On Tue, Jun 17, 2008 at 10:24 PM, Niels Aan de Brugh wrote: > On Tue, 2008-06-17 at 13:19 +0100, Samuel Silva wrote: >> >> I'm using GHC to compile around 700K of Haskell Code generated by HaXml. >> How I compile this code. >> My machine is Windows-XP(512MB RAM, 1.5GHz) running GHC-6.8.2. >> >> How much time it spend to compile this file? >> I spent more than 1 hour and it doesn't finished. > > Just out of curiosity, is all that 700K just one big file or did you > split it up into multiple files? It's just two big files with 700K each generated by DtdToHaskell from two big DTD files around 70K each. > Are you using any "expensive" features? I'm not a GHC exert, but I'd > expect things like type manipulations (e.g. phantom types) to be > expensive (please correct me if this assumption is wrong). This large module only contains datatype declarations and instance classes for HTypeable, XmlContent, XmlAttributes and XmlAttrType. > Bottom line: if compiling is so slow consider changing the code > generator so the result is easier to process by GHC instead of fiddling > with command line switches. Since you've chosen to generate the code it > will probably change often and you'll run into this problem more than > once. > > Regards, > Niels > > Each Haskell file have almost 15000 lines. It is huge. It's compiling very fast(some minutes) using -H300m without cabal and -H200m with cabal. GHC it is amazing. This was a valuable help. -- Don't hug that, Hugs ME! Samuel Silva From duncan.coutts at worc.ox.ac.uk Wed Jun 18 07:45:20 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Jun 18 07:32:56 2008 Subject: [Haskell-cafe] ANNOUNCE: cabal-install 0.5 Message-ID: <1213789520.15010.837.camel@localhost> cabal-install 0.5 ================= cabal-install version 0.5 is out: http://haskell.org/cabal/download.html or get it from hackage: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/cabal-install If you are already using a cabal-install pre-release then you can just: $ cabal update $ cabal install cabal-install New features in cabal-install ============================= Command line improvements ------------------------- The most immediately noticeable thing is that the command line interface now has all the commands that runhaskell Setup.hs has. Of course it still has the features to download and install packages from hackage. It also gained an upload command. So it now provides a command line interface to the whole Cabal/Hackage system. There?s no need to use runhaskell Setup.hs ever again. There is also bash command line completion support included which I find is a great time saver. Installing and upgrading ------------------------ The next big thing is that it includes a new package dependency resolution system that finds correct and sensible solutions more of the time and has better default behaviour. The new behaviour should be similar to other package managers that people are used to. For example, suppose you?ve got xmonad-0.5 installed and version 0.7 is the latest on hackage, then $ cabal install xmonad will install xmonad-0.7. The older version, xmonad-0.5, will remain installed. The behaviour of install is to upgrade as little as possible to satisfy your request, but sometimes you want to upgrade all the dependencies too. Supposing now that we have xmonad-0.7 installed, but we?re still using X11-1.4.1 and the latest version on hackage is X11-1.4.2, then $ cabal upgrade xmonad will install X11-1.4.2 and *re-install* xmonad-0.7, this time built against the newer X11-1.4.2. So in general, the install command will install the latest version of things but will try and use any existing installed versions of dependencies while the upgrade command will also try to use the latest versions of all dependencies. As a special case, cabal upgrade on its own will try to upgrade all the packages that you have installed. For both command there is a --dry-run flag so you can see what would be installed without actually doing it. Hugs ---- Yes, it even works with hugs. That is, cabal-install built by ghc can manage the installation of packages for hugs. In principle cabal-install should be able to be run by hugs but currently the zlib binding is using a function that hugs does not support. Note that for hugs, Cabal does not know what packages are already installed because there is no equivalent of the package database that ghc has. So that means cabal-install cannot do very sensible installation planning. It should work ok so long as all the dependencies are already installed. Windows ------- Yes, it even works on Windows. The one caveat is that cabal-install cannot currently upgrade itself because Windows makes it hard for a process to overwrite its own executable file. It needs more complex trickery with the Win32 API. In the meantime the workaround is to rename the cabal.exe file first eg to cabal-foo.exe, then run cabal-foo install cabal-install. Build reporting --------------- One feature that made it into this release is build reporting. cabal-install keeps logs of all packages that you install (at least packages from hackage, not local ones). It records a bit of information about each package, in particular whether the outcome was successful or not. You can see these build reports in ~/.cabal/packages/$server/build-reports.log. For example, there is one from my machine for xmonad: package: xmonad-0.7 os: linux arch: x86_64 compiler: ghc-6.8.2 client: cabal-install-0.5.1 flags: -testing small_base dependencies: X11-1.4.2 base-3.0.1.0 containers-0.1.0.1 directory-1.0.0.0 mtl-1.1.0.0 process-1.0.0.0 unix-2.3.0.0 install-outcome: InstallOk docs-outcome: NotTried tests-outcome: NotTried The plan in the longer term is to let people upload these build reports to hackage so we can get a wider range of testing data about the packages on hackage. Duncan From daniel.is.fischer at web.de Wed Jun 18 08:28:25 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Jun 18 08:19:00 2008 Subject: [Haskell-cafe] Problem building GHC 6.8.3 Message-ID: <200806181428.25083.daniel.is.fischer@web.de> Sorry, probably stupid questions for knowledgeable folks, but after having built for a couple of hours, make died with if ifBuildable/ifBuildable base; then \ cd base && setup/Setup haddock --html-location='../$pkg' \ --hyperlink-source; \ fi Preprocessing library base-3.0.2.0... Running hscolour for base-3.0.2.0... Preprocessing library base-3.0.2.0... Running Haddock for base-3.0.2.0... Warning: The documentation for package rts-1.0 is not installed. No links to it will be generated. Setup: Haddock's internal GHC version must match the configured GHC version make[1]: *** [doc.library.base] Fehler 1 make[1]: Leaving directory `/home/dafis/HasCom/ghc-6.8.3/libraries' make: *** [stage1] Fehler 2 So, what is Haddock's internal GHC version? Is it the version, haddock was built with? And what is the configured GHC version, is it the one I'm trying to build or the one I'm building with? If the former, I seem to have landed in a circulus vitiosus, if the latter, that is the GHC, haddock was built with, too. For the record: dafis@linux:~/HasCom/ghc-6.8.3> haddock --version Haddock version 2.1.0, (c) Simon Marlow 2006 Ported to use the GHC API by David Waern 2006-2008 How should I proceed now? Thanks, Daniel From Malcolm.Wallace at cs.york.ac.uk Wed Jun 18 08:36:40 2008 From: Malcolm.Wallace at cs.york.ac.uk (Malcolm Wallace) Date: Wed Jun 18 08:31:50 2008 Subject: [Haskell-cafe] Bit streams In-Reply-To: <4858190B.4090909@btinternet.com> References: <4858190B.4090909@btinternet.com> Message-ID: <20080618133640.24b78310.Malcolm.Wallace@cs.york.ac.uk> Andrew Coppin wrote: > It appears the library will only handle > data that is byte-aligned. So if I try to write three Bool values, it > uses three bytes, not three bits. The original Binary library, circa 1998, was based on bit-streams rather than bytes. You might be able to dig up a copy and bring it back to life. http://citeseer.ist.psu.edu/wallace98bits.html ftp://ftp.cs.york.ac.uk/pub/malcolm/ismm98.html Regards, Malcolm From dgorin at dc.uba.ar Wed Jun 18 08:44:30 2008 From: dgorin at dc.uba.ar (=?ISO-8859-1?Q?Daniel_Gor=EDn?=) Date: Wed Jun 18 08:36:52 2008 Subject: [Haskell-cafe] Haskell's type system In-Reply-To: <20080618020827.GB21778@scytale.galois.com> References: <20080618020827.GB21778@scytale.galois.com> Message-ID: <5783CCE5-9C5B-4B03-A673-61867D9A37F9@dc.uba.ar> On Jun 17, 2008, at 11:08 PM, Don Stewart wrote: > Haskell's type system is based on System F, the polymorphic lambda > calculus. By the Curry-Howard isomorphism, this corresponds to > second-order logic. just nitpicking a little.... this should read "second-order propositional logic", right? daniel From voigt at tcs.inf.tu-dresden.de Wed Jun 18 09:09:12 2008 From: voigt at tcs.inf.tu-dresden.de (Janis Voigtlaender) Date: Wed Jun 18 08:56:08 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <20080618104723.YEKX8797.aamtaout03-winn.ispmail.ntl.com@pine.ntlworld.com> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <20080617174953.WVJK29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> <4858CB66.1040605@jellybean.co.uk> <20080618104723.YEKX8797.aamtaout03-winn.ispmail.ntl.com@pine.ntlworld.com> Message-ID: <485908F8.4040001@tcs.inf.tu-dresden.de> PR Stanley wrote: > >>> With respect, do you not think it'd be wiser for the community >> >> >> [snip] >> >> *disgusted* >> >> This is exactly the sort of message that haskell-cafe does not >> normally contain. Let's not start now. >> >> This is a civilized mailing list. Either comment on the nice >> gentlemen's PHP closure proposal from a language point of view, or >> don't say anything. > > Paul: Uncivilised you say. Well, I would have thought the civilised > thing would be to share your concerns discretely with the list > moderator. Hmm, I wonder who exactly this "list moderator" is supposed to be. We are usually adult enough around here to not need someone to look after us. I think Jules was well entitled to raise his objections about the tone of your email in public. > Instead you've chosen to make a public show of it. > The Chinese have a saying, and I paraphrase - when you point the finger > of accusation at someone/something you have three pointing back at > yourself. Well, at least not this finger... -- Dr. Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:voigt@tcs.inf.tu-dresden.de From asandroq at gmail.com Wed Jun 18 09:11:36 2008 From: asandroq at gmail.com (Alex Sandro Queiroz e Silva) Date: Wed Jun 18 09:03:45 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <4858CB66.1040605@jellybean.co.uk> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <20080617174953.WVJK29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> <4858CB66.1040605@jellybean.co.uk> Message-ID: <48590988.1020100@gmail.com> Hallo, Jules Bean wrote: > PR Stanley wrote: >> With respect, do you not think it'd be wiser for the community > > [snip] > > *disgusted* > > This is exactly the sort of message that haskell-cafe does not normally > contain. Let's not start now. > > This is a civilized mailing list. Either comment on the nice gentlemen's > PHP closure proposal from a language point of view, or don't say anything. > Thanks Jules, I was starting to worry about Haskell-caf?. -alex http://www.ventonegro.org/ From bulat.ziganshin at gmail.com Wed Jun 18 09:08:53 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Jun 18 09:09:17 2008 Subject: [Haskell-cafe] Bit streams In-Reply-To: <4858190B.4090909@btinternet.com> References: <4858190B.4090909@btinternet.com> Message-ID: <1281584231.20080618170853@gmail.com> Hello Andrew, Wednesday, June 18, 2008, 12:05:31 AM, you wrote: > what Binary does, but with single-bit precision? [I presume Binary is http://haskell.org/haskellwiki/Library/AltBinary it's not maintained, so consider it as "last hope" :) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bulat.ziganshin at gmail.com Wed Jun 18 09:11:30 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Jun 18 09:12:26 2008 Subject: [Haskell-cafe] Re: Compiling large code with old machine In-Reply-To: References: <382ead9b0806170519w3c2377f8v1584a97117a0d4f9@mail.gmail.com> Message-ID: <1293573671.20080618171130@gmail.com> Hello Dominic, Wednesday, June 18, 2008, 11:17:07 AM, you wrote: >> I'm using GHC to compile around 700K of Haskell Code generated by HaXml. > may worth thinking about an alternative to 700k loc. i think he means bytes, not lines :) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bulat.ziganshin at gmail.com Wed Jun 18 09:19:15 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Jun 18 09:19:19 2008 Subject: [Haskell-cafe] Bit streams In-Reply-To: <20080618133640.24b78310.Malcolm.Wallace@cs.york.ac.uk> References: <4858190B.4090909@btinternet.com> <20080618133640.24b78310.Malcolm.Wallace@cs.york.ac.uk> Message-ID: <136220278.20080618171915@gmail.com> Hello Malcolm, Wednesday, June 18, 2008, 4:36:40 PM, you wrote: > The original Binary library, circa 1998, was based on bit-streams rather > than bytes. You might be able to dig up a copy and bring it back to > life. > http://citeseer.ist.psu.edu/wallace98bits.html > ftp://ftp.cs.york.ac.uk/pub/malcolm/ismm98.html well, i've seen ghc-compatible Binary library flying around which supported bit fields. it was in pre-hackage days, but it should be pretty easy to find this module -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From prstanley at ntlworld.com Wed Jun 18 09:42:23 2008 From: prstanley at ntlworld.com (PR Stanley) Date: Wed Jun 18 09:34:12 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <485908F8.4040001@tcs.inf.tu-dresden.de> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <20080617174953.WVJK29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> <4858CB66.1040605@jellybean.co.uk> <20080618104723.YEKX8797.aamtaout03-winn.ispmail.ntl.com@pine.ntlworld.com> <485908F8.4040001@tcs.inf.tu-dresden.de> Message-ID: <20080618134525.JKIM29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> PR Stanley wrote: With respect, do you not think it'd be wiser for the community [snip] *disgusted* This is exactly the sort of message that haskell-cafe does not normally contain. Let's not start now. This is a civilized mailing list. Either comment on the nice gentlemen's PHP closure proposal from a language point of view, or don't say anything. Paul: Uncivilised you say. Well, I would have thought the civilised thing would be to share your concerns discretely with the list moderator. Hmm, I wonder who exactly this "list moderator" is supposed to be. We are usually adult enough around here to not need someone to look after us. I think Jules was well entitled to raise his objections about the tone of your email in public. Paul: As you say, we "are adult enougharound here to not need someone to look after us". So I don't need you or any other interfearing busybody to tell me what I can and can't say on Haskell Cafe. I expressed an opinion in a tongue-in-cheek way and at the end of my message expressed in clear terms that those were merely my views. Now, if you, Jules, Alex or some other wannabe Hitler have a problem with my freedom of expression then your best solution is to saddle up and get the hell out yourselves. This is the wrong place for setting up your tinpot dictatorship, Doctor! I am grateful for the help I've been getting from the list and my understanding of FP has vastly improved since my membership of this list but I refuse to tolerate bullies who use the list as a way of lifting themselves out of their own shitty lives. Now I am angry! Instead you've chosen to make a public show of it. The Chinese have a saying, and I paraphrase - when you point the finger of accusation at someone/something you have three pointing back at yourself. Well, at least not this finger... Paul: you're not making sense. From voigt at tcs.inf.tu-dresden.de Wed Jun 18 09:52:33 2008 From: voigt at tcs.inf.tu-dresden.de (Janis Voigtlaender) Date: Wed Jun 18 09:39:22 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <20080618134525.JKIM29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <20080617174953.WVJK29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> <4858CB66.1040605@jellybean.co.uk> <20080618104723.YEKX8797.aamtaout03-winn.ispmail.ntl.com@pine.ntlworld.com> <485908F8.4040001@tcs.inf.tu-dresden.de> <20080618134525.JKIM29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> Message-ID: <48591321.5040602@tcs.inf.tu-dresden.de> With respect, I will not engage in further communication on that level. PR Stanley wrote: > PR Stanley wrote: > > With respect, do you not think it'd be wiser for the community > > > [snip] > > *disgusted* > > This is exactly the sort of message that haskell-cafe does not normally > contain. Let's not start now. > > This is a civilized mailing list. Either comment on the nice gentlemen's > PHP closure proposal from a language point of view, or don't say anything. > Paul: Uncivilised you say. Well, I would have thought the civilised > thing would be to share your concerns discretely with the list moderator. > > Hmm, I wonder who exactly this "list moderator" is supposed to be. We > are usually adult enough around here to not need someone to look after > us. I think Jules was well entitled to raise his objections about the > tone of your email in public. > > Paul: As you say, we "are adult enougharound here to not need someone to > look after us". So I don't need you or any other interfearing busybody > to tell me what I can and can't say on Haskell Cafe. I expressed an > opinion in a tongue-in-cheek way and at the end of my message expressed > in clear terms that those were merely my views. > Now, if you, Jules, Alex or some other wannabe Hitler have a problem > with my freedom of expression then your best solution is to saddle up > and get the hell out yourselves. This is the wrong place for setting up > your tinpot dictatorship, Doctor! > I am grateful for the help I've been getting from the list and my > understanding of FP has vastly improved since my membership of this list > but I refuse to tolerate bullies who use the list as a way of lifting > themselves out of their own shitty lives. Now I am angry! > > Instead you've chosen to make a public show of it. > The Chinese have a saying, and I paraphrase - when you point the finger > of accusation at someone/something you have three pointing back at > yourself. > > Well, at least not this finger... > > Paul: you're not making sense. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Dr. Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:voigt@tcs.inf.tu-dresden.de From lrpalmer at gmail.com Wed Jun 18 09:57:14 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Wed Jun 18 09:49:06 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <20080618134525.JKIM29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <20080617174953.WVJK29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> <4858CB66.1040605@jellybean.co.uk> <20080618104723.YEKX8797.aamtaout03-winn.ispmail.ntl.com@pine.ntlworld.com> <485908F8.4040001@tcs.inf.tu-dresden.de> <20080618134525.JKIM29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> Message-ID: <7ca3f0160806180657q3722e2bfv57967e6d66e8401a@mail.gmail.com> On Wed, Jun 18, 2008 at 1:42 PM, PR Stanley wrote: > Now, if you, Jules, Alex or some other wannabe Hitler have a problem with > my freedom of expression then your best solution is to saddle up and get the > hell out yourselves. This is the wrong place for setting up your tinpot > dictatorship, Doctor! Just more evidence... http://en.wikipedia.org/wiki/Godwin's_law Luke From prstanley at ntlworld.com Wed Jun 18 10:14:49 2008 From: prstanley at ntlworld.com (PR Stanley) Date: Wed Jun 18 10:06:36 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <7ca3f0160806180657q3722e2bfv57967e6d66e8401a@mail.gmail.co m> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <20080617174953.WVJK29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> <4858CB66.1040605@jellybean.co.uk> <20080618104723.YEKX8797.aamtaout03-winn.ispmail.ntl.com@pine.ntlworld.com> <485908F8.4040001@tcs.inf.tu-dresden.de> <20080618134525.JKIM29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> <7ca3f0160806180657q3722e2bfv57967e6d66e8401a@mail.gmail.com> Message-ID: <20080618141750.JXTS29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> > > Now, if you, Jules, Alex or some other wannabe Hitler have a problem with > > my freedom of expression then your best solution is to saddle up > and get the > > hell out yourselves. This is the wrong place for setting up your tinpot > > dictatorship, Doctor! > >Just more evidence... > >http://en.wikipedia.org/wiki/Godwin's_law > >Paul: I think you're missing a big painfully obvious point here, Mr >smarty pants. No, actually, I think I'll leave it at that. I just >can't be bothered. However, I'll say this - anyone sticking his >bloody big hooter into my business in the future will get a similar reaction! Paul >Luke From sethg at ropine.com Wed Jun 18 10:19:50 2008 From: sethg at ropine.com (Seth Gordon) Date: Wed Jun 18 10:11:43 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <20080617174953.WVJK29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <20080617174953.WVJK29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> Message-ID: <48591986.1020304@ropine.com> PR Stanley wrote: > Blimey! Talk about rearranging the deckchairs :-) Today's xkcd seems apropos: http://xkcd.com/438/ It seems to me that if a PHP developer sees the Haskell community as a resource for advice on programming language implementation, we should take this as a compliment to the Haskell community. Repaying that compliment with "your language sucks rocks" strikes me as unwise. I'm familiar with a lot of arguments for why PHP is a poorly-designed language, and have found them sufficiently persuasive that I haven't bothered to learn PHP. But I don't see any point to repeating those arguments on this list. From lemming at henning-thielemann.de Wed Jun 18 10:30:05 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Wed Jun 18 10:22:09 2008 Subject: [Haskell-cafe] Something like scan1 In-Reply-To: <20080618080646.29abd52f@solaris> References: <20080618080646.29abd52f@solaris> Message-ID: On Wed, 18 Jun 2008, Achim Schneider wrote: > Is there a generalisation of scan1, such that eg. > > foo (+) [0,1] (1,2) = [0,1,1,2,3,5,8,13,...] > > ? What is the (1,2) for? I could think of foo f = List.unfoldr (\ xt@(x:xs) -> Just (x, xs ++ [f xt])) foo sum [0,1] = [0,1,1,2,3,5,8,13,21,34,... From lemming at henning-thielemann.de Wed Jun 18 10:33:25 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Wed Jun 18 10:25:57 2008 Subject: [Haskell-cafe] Haskell data types and Storable class In-Reply-To: <5ae4f2ba0806172212ge0ea659paa2c767bb12700ed@mail.gmail.com> References: <5ae4f2ba0806172212ge0ea659paa2c767bb12700ed@mail.gmail.com> Message-ID: On Wed, 18 Jun 2008, Galchin, Vasili wrote: > Hello, > > I am reading the FFI spec. Something is unclear to me. Let's assume we > have > > data A = {b:B, .......} > > and > > data B ={ .............} > > both of which belong to class Storable. In the A instance of Storable I want > to do a poke and peek of "b" into and out-of, respectively, B. How do I > write the poke and peek function of "b" in the "instance Storable A"? You will write a Storable instance for B and then just use the class methods 'poke' and 'peek' in the instance for A. From prstanley at ntlworld.com Wed Jun 18 10:40:06 2008 From: prstanley at ntlworld.com (PR Stanley) Date: Wed Jun 18 10:31:51 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <48591986.1020304@ropine.com> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <20080617174953.WVJK29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> <48591986.1020304@ropine.com> Message-ID: <20080618144004.HOQC18637.aamtaout04-winn.ispmail.ntl.com@pine.ntlworld.com> >It seems to me that if a PHP developer sees the Haskell community as >a resource for advice on programming language implementation, we >should take this as a compliment to the Haskell community. Repaying >that compliment with "your language sucks rocks" > strikes me as unwise. > >I'm familiar with a lot of arguments for why PHP is a >poorly-designed language, and have found them sufficiently >persuasive that I haven't bothered to learn PHP. But I don't see >any point to repeating those arguments on this list. Paul: So, you've never bothered to learn PHP. Well, I happen to know the language very well and therefore feel I am in a good position to express my views about it. Unlike you, I don't base my judgment on rumours and hearsay. It is true that PHP fails to capture the spirit of the classical concept of a function. Type checking in PHP is equally poor. These are not just my opinions. Are we not to say anything critical about a programming language even if it happens to be substantively relevant lestwe should offend someone? God, if you want to stick up for your mates here at least come up with a convincing cover. Paul >_______________________________________________ >Haskell-Cafe mailing list >Haskell-Cafe@haskell.org >http://www.haskell.org/mailman/listinfo/haskell-cafe From lrpalmer at gmail.com Wed Jun 18 10:50:00 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Wed Jun 18 10:41:53 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> Message-ID: <7ca3f0160806180750m7d2ab838s1db4bd07b9bf4b6e@mail.gmail.com> On Tue, Jun 17, 2008 at 4:45 PM, Karoly Negyesi wrote: > Hi, > > The PHP community is discussing the adding of closures and lambdas to > the language, see the proposal at http://wiki.php.net/rfc/closures > > If someone with knowledge of both languages could take a quick look it > would be great. > > Thanks a lot > > Karoly Negyesi > > Ps. I am not a member of the PHP internals team, I am just a PHP > developer but I am very very interested in getting these in my > favourite language. Whew. Well I suspect you weren't expecting that kind of reaction. Or maybe you were... I used to be a Perl developer, and it didn't take long before I got a level 12 resistence to flame... Anyway, the proposal looks mostly okay. I don't know that much PHP, but I find the "lexical" keyword to be a nuisance. What are the semantics if the lexical keyword is omitted? (i.e. does the variable become function-local, global, what?) If it is consistent with the rest of the language, it'll do. There is a much more important point with closures: their implementation cannot be half-assed! I'm not claiming that the patch is--I have not reviewed it--but there is nothing worse than coming up with a design that relies on a language feature you only later find out has been nerfed in some way. Story of my life in C#. And nerfed closures are especially bad, because it's so hard to predict the code path. What I mean by this is the following must all be supported: * A closure must only keep alive the varables it references, not the whole pad on which they are allocated (Python messed up here) * A closure must be able to call itself recursively (via a higher-order function typically) (Squeak messed up here IIRC) * Multiple references to the same body of code with different bindings must be able to exist at the same time (duh, that's kinda what makes it a closure) * Closures must be nestable. Looking over the "Zend internal perspective" section, it looks like that implementation will mostly work. There are a couple of red flags, though: * I would recommend only saving $this in the op_array structure if the closure actually references $this -- if that is possible to deduce at the time. Otherwise you might run into unexpected poor memory performances in certain cases. (This kind of thing can make an *asymptotic* difference in memory performance; i.e. bringing the memory usage of an algorithm from O(1) to O(n), for example) * I'm worried that nested closures do not work properly with this implementation sketch. Here's a test case: $f = function ($y) { return function ($z) { return $y + $z; } }; $f(1)(2) # should give 3 And congratulations, PHP, for adopting a most essential and powerful feature! Luke From barsoap at web.de Wed Jun 18 10:54:07 2008 From: barsoap at web.de (Achim Schneider) Date: Wed Jun 18 10:46:14 2008 Subject: [Haskell-cafe] Re: Something like scan1 References: <20080618080646.29abd52f@solaris> Message-ID: <20080618165407.4760bdc9@solaris> Henning Thielemann wrote: > > On Wed, 18 Jun 2008, Achim Schneider wrote: > > > Is there a generalisation of scan1, such that eg. > > > > foo (+) [0,1] (1,2) = [0,1,1,2,3,5,8,13,...] > > > > ? > > What is the (1,2) for? > Specifying the relative indexes an element depends on. Ideally, it should be generalised for n-ary functions. > I could think of > foo f = List.unfoldr (\ xt@(x:xs) -> Just (x, xs ++ [f xt])) > > foo sum [0,1] = [0,1,1,2,3,5,8,13,21,34,... > I should elaborate: foo (+) [0,1,4] (1,2) = _|_, as 4 isn't 0+1 foo (+) [0,1] (2,3) = [0,1,_|_,1,_|_,_|_] foo (+) [0,1,1,2,3,5] (1,2) = [0,1,1,2,3,5,8,13,...] foo (+) [1] (1,1) = [1,2,4,8,16,32,...] If you allow for inverse functions, you could even say foo (+-) [0,...,3,..] (1,2) = [0,0,0,...,0,0,1,1,2,3,5,...] It seems like I'm searching for some primitive that lets me combine lists and currying. Think of passing a matrix, with each column (or row, if you prefer) separately uniquely typed, into a function. -- (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 miguelimo38 at yandex.ru Wed Jun 18 10:54:19 2008 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Wed Jun 18 10:46:32 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <48591986.1020304@ropine.com> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <20080617174953.WVJK29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> <48591986.1020304@ropine.com> Message-ID: <2AA970B8-05C6-47D1-B3A9-DE2C5FA2B3FF@yandex.ru> On 18 Jun 2008, at 18:19, Seth Gordon wrote: > It seems to me that if a PHP developer sees the Haskell community as > a resource for advice on programming language implementation, we > should take this as a compliment to the Haskell community. Repaying > that compliment with "your language sucks rocks" strikes me as unwise. Not necessarily. It can be that they'd implement closures in PHP, make a dog's dinner of it (as they always do), and then we would be blamed for giving them wrong advises. Anyway, it seems that PR Stanley was forced to use PHP, no wonder he's a little mad at it. From prstanley at ntlworld.com Wed Jun 18 11:00:29 2008 From: prstanley at ntlworld.com (PR Stanley) Date: Wed Jun 18 10:52:24 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <2AA970B8-05C6-47D1-B3A9-DE2C5FA2B3FF@yandex.ru> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <20080617174953.WVJK29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> <48591986.1020304@ropine.com> <2AA970B8-05C6-47D1-B3A9-DE2C5FA2B3FF@yandex.ru> Message-ID: <20080618150957.CRUB8797.aamtaout03-winn.ispmail.ntl.com@pine.ntlworld.com> >>It seems to me that if a PHP developer sees the Haskell community as >>a resource for advice on programming language implementation, we >>should take this as a compliment to the Haskell community. Repaying >>that compliment with "your language sucks rocks" strikes me as unwise. > >Not necessarily. It can be that they'd implement closures in PHP, make >a dog's dinner of it (as they always do), and then we would be blamed >for giving them bad advice. > >Anyway, it seems that PR Stanley was forced to use PHP, no wonder he's >a little mad at it. Paul: How did you know? :-) You know, the funny thing is that all these so-called civilised people can find time and energy to have a go at me but can't be bothered to help the chap with the original query. >_______________________________________________ >Haskell-Cafe mailing list >Haskell-Cafe@haskell.org >http://www.haskell.org/mailman/listinfo/haskell-cafe From lemming at henning-thielemann.de Wed Jun 18 11:06:13 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Wed Jun 18 10:58:04 2008 Subject: [Haskell-cafe] Re: Something like scan1 In-Reply-To: <20080618165407.4760bdc9@solaris> References: <20080618080646.29abd52f@solaris> <20080618165407.4760bdc9@solaris> Message-ID: On Wed, 18 Jun 2008, Achim Schneider wrote: > Henning Thielemann wrote: > >> On Wed, 18 Jun 2008, Achim Schneider wrote: >> >>> Is there a generalisation of scan1, such that eg. >>> >>> foo (+) [0,1] (1,2) = [0,1,1,2,3,5,8,13,...] >>> >>> ? >> >> What is the (1,2) for? >> > Specifying the relative indexes an element depends on. Ideally, it > should be generalised for n-ary functions. foo f prefix (n,m) = let k = length prefix xs = prefix ++ zipWith f (xss!!(k-n)) (xss!!(k-m)) xss = List.tails xs in xs From jonathanccast at fastmail.fm Wed Jun 18 11:07:59 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Wed Jun 18 10:59:55 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <20080618150957.CRUB8797.aamtaout03-winn.ispmail.ntl.com@pine.ntlworld.com> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <20080617174953.WVJK29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> <48591986.1020304@ropine.com> <2AA970B8-05C6-47D1-B3A9-DE2C5FA2B3FF@yandex.ru> <20080618150957.CRUB8797.aamtaout03-winn.ispmail.ntl.com@pine.ntlworld.com> Message-ID: <1213801679.7014.25.camel@jonathans-macbook> On Wed, 2008-06-18 at 16:00 +0100, PR Stanley wrote: > >>It seems to me that if a PHP developer sees the Haskell community as > >>a resource for advice on programming language implementation, we > >>should take this as a compliment to the Haskell community. Repaying > >>that compliment with "your language sucks rocks" strikes me as unwise. > > > >Not necessarily. It can be that they'd implement closures in PHP, make > >a dog's dinner of it (as they always do), and then we would be blamed > >for giving them bad advice. > > > >Anyway, it seems that PR Stanley was forced to use PHP, no wonder he's > >a little mad at it. > > Paul: How did you know? :-) > You know, the funny thing is that all these so-called civilised > people can find time and energy to have a go at me but can't be > bothered to help the chap with the original query. I could, and I think you're full of it, too. So there. jcc From bos at serpentine.com Wed Jun 18 11:11:14 2008 From: bos at serpentine.com (Bryan O'Sullivan) Date: Wed Jun 18 11:03:17 2008 Subject: [Haskell-cafe] blas bindings, why are they so much slower the C? In-Reply-To: References: Message-ID: On Tue, Jun 17, 2008 at 9:00 PM, Anatoly Yakovenko wrote: > here is the C: > > #include > #include > > int main() { > int size = 1024; > int ii = 0; > double* v1 = malloc(sizeof(double) * (size)); > double* v2 = malloc(sizeof(double) * (size)); > for(ii = 0; ii < size*size; ++ii) { > double _dd = cblas_ddot(0, v1, size, v2, size); > } > free(v1); > free(v2); > } Your C compiler sees that you're not using the result of cblas_ddot, so it doesn't even bother to call it. That loop never gets run. All your program does at runtime is call malloc and free twice, which is very fast :-) From bos at serpentine.com Wed Jun 18 11:14:57 2008 From: bos at serpentine.com (Bryan O'Sullivan) Date: Wed Jun 18 11:06:55 2008 Subject: [Haskell-cafe] Bit streams In-Reply-To: <4858190B.4090909@btinternet.com> References: <4858190B.4090909@btinternet.com> Message-ID: On Tue, Jun 17, 2008 at 1:05 PM, Andrew Coppin wrote: > Before I sit down and spend 3 months designing my own library from scratch, > does anybody know of an existing library that allows you to do what Binary > does, but with single-bit precision? The binary-strict library includes this functionality. It also has several other useful pieces of functionality. It's rather a shame the binary and binary-strict developers haven't merged their efforts :-( From bos at serpentine.com Wed Jun 18 11:19:57 2008 From: bos at serpentine.com (Bryan O'Sullivan) Date: Wed Jun 18 11:11:52 2008 Subject: [Haskell-cafe] Problem building GHC 6.8.3 In-Reply-To: <200806181428.25083.daniel.is.fischer@web.de> References: <200806181428.25083.daniel.is.fischer@web.de> Message-ID: On Wed, Jun 18, 2008 at 5:28 AM, Daniel Fischer wrote: > Sorry, probably stupid questions for knowledgeable folks Not stupid at all, but possibly the wrong mailing list. glasgow-haskell-users would usually be a better place to ask. > Setup: Haddock's internal GHC version must match the configured GHC version You're using Haddock 2.0 or newer. It's not actually possible to build GHC with it; you must use Haddock 0.9. Many other packages apparently break with Haddock 2, but GHC is certainly rather visible :-) It is possible to have Haddock 0.9 and 2.0 installed simultaneously under different names or in different locations, but you'll have to patch GHC's sources in order to specify which Haddock to use. It's a small patch; look on Trac for it. From prstanley at ntlworld.com Wed Jun 18 11:24:35 2008 From: prstanley at ntlworld.com (PR Stanley) Date: Wed Jun 18 11:16:18 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <1213801679.7014.25.camel@jonathans-macbook> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <20080617174953.WVJK29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> <48591986.1020304@ropine.com> <2AA970B8-05C6-47D1-B3A9-DE2C5FA2B3FF@yandex.ru> <20080618150957.CRUB8797.aamtaout03-winn.ispmail.ntl.com@pine.ntlworld.com> <1213801679.7014.25.camel@jonathans-macbook> Message-ID: <20080618153359.DETZ8797.aamtaout03-winn.ispmail.ntl.com@pine.ntlworld.com> > > >>It seems to me that if a PHP developer sees the Haskell community as > > >>a resource for advice on programming language implementation, we > > >>should take this as a compliment to the Haskell community. Repaying > > >>that compliment with "your language sucks rocks" strikes me as unwise. > > > > > >Not necessarily. It can be that they'd implement closures in PHP, make > > >a dog's dinner of it (as they always do), and then we would be blamed > > >for giving them bad advice. > > > > > >Anyway, it seems that PR Stanley was forced to use PHP, no wonder he's > > >a little mad at it. > > > > Paul: How did you know? :-) > > You know, the funny thing is that all these so-called civilised > > people can find time and energy to have a go at me but can't be > > bothered to help the chap with the original query. > >I could, and I think you're full of it, too. > >So there. Paul: I rest my case! :-) you cowardly hypocrit! From iainspeed at gmail.com Wed Jun 18 11:26:55 2008 From: iainspeed at gmail.com (Iain Barnett) Date: Wed Jun 18 11:18:51 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <4858CB66.1040605@jellybean.co.uk> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <20080617174953.WVJK29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> <4858CB66.1040605@jellybean.co.uk> Message-ID: On 18 Jun 2008, at 9:46 am, Jules Bean wrote: > This is exactly the sort of message that haskell-cafe does not > normally contain. Let's not start now. Reactions/arguments like the ones on this thread are perfect for Haskell - recursive and exponential. :) Could we have closure too? :-) Sorry, couldn't resist that one! Iain frequent firestarter and purveyor of bad puns From dons at galois.com Wed Jun 18 11:36:25 2008 From: dons at galois.com (Don Stewart) Date: Wed Jun 18 11:28:32 2008 Subject: [Haskell-cafe] Re: Bit Streams In-Reply-To: References: Message-ID: <20080618153625.GB23761@scytale.galois.com> dominic.steinitz: > OK, so today I tried to write my first program using the Binary library. > And I've hit a snag: It appears the library will only handle data that > is byte-aligned. So if I try to write three Bool values, it uses three > bytes, not three bits. > > Before I sit down and spend 3 months designing my own library from > scratch, does anybody know of an existing library that allows you to do > what Binary does, but with single-bit precision? [I presume Binary is > byte-aligned for efficiency...] > > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/binary-strict The bitsyntax library perhaps? or a StateT over Binary for carrying arround the bit packet to write. -- Don From aeyakovenko at gmail.com Wed Jun 18 12:16:24 2008 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Wed Jun 18 12:08:20 2008 Subject: [Haskell-cafe] blas bindings, why are they so much slower the C? In-Reply-To: References: Message-ID: >> #include >> #include >> >> int main() { >> int size = 1024; >> int ii = 0; >> double* v1 = malloc(sizeof(double) * (size)); >> double* v2 = malloc(sizeof(double) * (size)); >> for(ii = 0; ii < size*size; ++ii) { >> double _dd = cblas_ddot(0, v1, size, v2, size); >> } >> free(v1); >> free(v2); >> } > > Your C compiler sees that you're not using the result of cblas_ddot, > so it doesn't even bother to call it. That loop never gets run. All > your program does at runtime is call malloc and free twice, which is > very fast :-) C doesn't work like that :). functions always get called. but i did find a problem with my C code, i am incorrectly calling the dot production function: #include #include #include #include int main() { int size = 1024; int ii = 0; double dd = 0.0; double* v1 = malloc(sizeof(double) * (size)); double* v2 = malloc(sizeof(double) * (size)); for(ii = 0; ii < size; ++ii) { v1[ii] = 0.1; v2[ii] = 0.1; } for(ii = 0; ii < size*size; ++ii) { dd += cblas_ddot(size, v1, 0, v2, 0); } free(v1); free(v2); printf("%f\n", dd); return 0; } time ./testdot 10737418.240187 real 0m2.200s user 0m2.190s sys 0m0.010s So C is about twice as fast. I can live with that. From qdunkan at gmail.com Wed Jun 18 12:18:29 2008 From: qdunkan at gmail.com (Evan Laforge) Date: Wed Jun 18 12:10:23 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <7ca3f0160806180750m7d2ab838s1db4bd07b9bf4b6e@mail.gmail.com> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <7ca3f0160806180750m7d2ab838s1db4bd07b9bf4b6e@mail.gmail.com> Message-ID: <2518b95d0806180918n40001d40i1b4f77ff7ee8d88f@mail.gmail.com> > * A closure must only keep alive the varables it references, not the > whole pad on which they are allocated (Python messed up here) Getting off subject, but I didn't know this about python. I'm not saying you're incorrect, but my experimentation shows: % cat t.py class A(object): def __init__(self, name): self.name = name def __del__(self): print self.name, 'gone' def f(): x = A('x') y = A('y') def g(): print x.name, 'alive' return g % python Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04) [GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin Type "help", "copyright", "credits" or "license" for more information. import t g = t.f() y gone g() x alive g.func_closure #-> (,) del g x gone % So it looks to me like 'y' is not preserved by the closure returned by 'f', and you can see that in its func_closure which keeps the reference to one A object, but not two. Python closures do have a "unique" quirk, which is that variables bound in a nested function are read-only. This is something that a schemer might take issue with, but a haskeller probably wouldn't notice :) And for the longest time python had its "two space" namespace thing going on, so it wasn't even really lexically scoped, but that's many years ago now. From jim at sdf-eu.org Wed Jun 18 12:34:33 2008 From: jim at sdf-eu.org (Jim Burton) Date: Wed Jun 18 12:26:24 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <20080618153359.DETZ8797.aamtaout03-winn.ispmail.ntl.com@pine.ntlworld.com> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <20080617174953.WVJK29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> <48591986.1020304@ropine.com> <2AA970B8-05C6-47D1-B3A9-DE2C5FA2B3FF@yandex.ru> <20080618150957.CRUB8797.aamtaout03-winn.ispmail.ntl.com@pine.ntlworld.com> <1213801679.7014.25.camel@jonathans-macbook> <20080618153359.DETZ8797.aamtaout03-winn.ispmail.ntl.com@pine.ntlworld.com> Message-ID: <17986275.post@talk.nabble.com> PR Stanley wrote: > > [...] > > Paul: I rest my case! :-) > you cowardly hypocrit! > Please take your own advice now, and rest your case. Like it or not (I think most people do like it), haskell-cafe has norms of behaviour that make it different to many pl mailing lists. Your sarky comments would have gone unnoticed if they had been accompanied with something constructive. Name calling is out. Jim > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- View this message in context: http://www.nabble.com/Lambda-and-closures-in-PHP----could-someone-please-comment--tp17918732p17986275.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From agl at imperialviolet.org Wed Jun 18 12:49:26 2008 From: agl at imperialviolet.org (Adam Langley) Date: Wed Jun 18 12:41:18 2008 Subject: [Haskell-cafe] Re: Bit Streams In-Reply-To: References: Message-ID: <396556a20806180949u1542b803l895d8967f0762c5f@mail.gmail.com> On Wed, Jun 18, 2008 at 12:46 AM, Dominic Steinitz wrote: > OK, so today I tried to write my first program using the Binary library. > And I've hit a snag: It appears the library will only handle data that > is byte-aligned. So if I try to write three Bool values, it uses three > bytes, not three bits. There's a BitGet[1] and BitPut in the Hackage version of binary-strict. However, these versions work on strict ByteStrings. Putting, for one, is pretty inefficient. In the darcs version[2] of binary-strict, there's a fully lazy BitPut[3]. There was a request for a lazy BitGet, but I never wrote it. Most of the time, bit fields are small and you can use the lazy Get from binary to extract a ByteString and parse that with strict BitGet. However, the BitPut should be just fine (including doing things like writing ByteStrings by shifting each byte etc). If it's missing anything obvious, ping me and I'll see what I can do. Cheers, [1] http://darcs.imperialviolet.org/darcsweb.cgi?r=binary-strict;a=headblob;f=/src/Data/Binary/Strict/BitGet.hs [2] http://darcs.imperialviolet.org/binary-strict/ [3] http://darcs.imperialviolet.org/darcsweb.cgi?r=binary-strict;a=headblob;f=/src/Data/Binary/BitPut.hs -- Adam Langley agl@imperialviolet.org http://www.imperialviolet.org From hthiel.char at zonnet.nl Wed Jun 18 12:48:18 2008 From: hthiel.char at zonnet.nl (Hans van Thiel) Date: Wed Jun 18 12:42:12 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <4858CB66.1040605@jellybean.co.uk> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <20080617174953.WVJK29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> <4858CB66.1040605@jellybean.co.uk> Message-ID: <1213807698.6937.30.camel@localhost.localdomain> On Wed, 2008-06-18 at 09:46 +0100, Jules Bean wrote: > PR Stanley wrote: > > With respect, do you not think it'd be wiser for the community > > [snip] > > *disgusted* > > This is exactly the sort of message that haskell-cafe does not normally > contain. Let's not start now. > > This is a civilized mailing list. Either comment on the nice gentlemen's > PHP closure proposal from a language point of view, or don't say anything. > > Jules Hear, hear... Hans van Thiel > From agl at imperialviolet.org Wed Jun 18 12:51:45 2008 From: agl at imperialviolet.org (Adam Langley) Date: Wed Jun 18 12:43:35 2008 Subject: [Haskell-cafe] blas bindings, why are they so much slower the C? In-Reply-To: References: Message-ID: <396556a20806180951w57599c6fj4b70b3c57e776fa8@mail.gmail.com> On Wed, Jun 18, 2008 at 9:16 AM, Anatoly Yakovenko wrote: > C doesn't work like that :) Yes it can. You would have to check the disassembly to be sure, but C compilers can, and do, perform dead code elimination. AGL -- Adam Langley agl@imperialviolet.org http://www.imperialviolet.org From prstanley at ntlworld.com Wed Jun 18 12:52:42 2008 From: prstanley at ntlworld.com (PR Stanley) Date: Wed Jun 18 12:44:24 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <17986275.post@talk.nabble.com> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <20080617174953.WVJK29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> <48591986.1020304@ropine.com> <2AA970B8-05C6-47D1-B3A9-DE2C5FA2B3FF@yandex.ru> <20080618150957.CRUB8797.aamtaout03-winn.ispmail.ntl.com@pine.ntlworld.com> <1213801679.7014.25.camel@jonathans-macbook> <20080618153359.DETZ8797.aamtaout03-winn.ispmail.ntl.com@pine.ntlworld.com> <17986275.post@talk.nabble.com> Message-ID: <20080618165819.HFYI16854.aamtaout01-winn.ispmail.ntl.com@pine.ntlworld.com> >PR Stanley wrote: > > > > [...] > > > > Paul: I rest my case! :-) > > you cowardly hypocrit! Paul: Why did you remove Jonathan Cast's message? Afraid somebody might understand why I responded the way I did? > > >Please take your own advice now, and rest your case. Like it or not (I think >most people do like it), haskell-cafe has norms of behaviour that make it >different to many pl mailing lists. Your sarky comments would have gone >unnoticed if they had been accompanied with something constructive. Name >calling is out. Paul: and who the bloody hell are you to tell me what's in or out? If you want the matter to rest then shut up yourself. I'm getting sick of you hypocrites who allow yourselves the audacity to attack me, totally gratuitously, yet when I try to defend myself you take the moral high ground. Tell me, why did you remove Jonathan Cast's message? Is he too big for you? Why don't you tell all the other people who have been busy attacking me to modify their language? Are you afraid of upsetting the Haskell Cafe Mafia? Well, guess what, you damn thugs, I 'aint taking this lying down. You come back with more and I'll give you even more! From prstanley at ntlworld.com Wed Jun 18 13:01:07 2008 From: prstanley at ntlworld.com (PR Stanley) Date: Wed Jun 18 12:52:49 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <1213807698.6937.30.camel@localhost.localdomain> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <20080617174953.WVJK29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> <4858CB66.1040605@jellybean.co.uk> <1213807698.6937.30.camel@localhost.localdomain> Message-ID: <20080618170644.HKAV16854.aamtaout01-winn.ispmail.ntl.com@pine.ntlworld.com> > > PR Stanley wrote: > > > With respect, do you not think it'd be wiser for the community > > > > [snip] > > > > *disgusted* > > > > This is exactly the sort of message that haskell-cafe does not normally > > contain. Let's not start now. > > > > This is a civilized mailing list. Either comment on the nice gentlemen's > > PHP closure proposal from a language point of view, or don't say anything. > > > > Jules >Hear, hear... Paul: You can shut up too, you bloody troll! From jules at jellybean.co.uk Wed Jun 18 13:03:42 2008 From: jules at jellybean.co.uk (Jules Bean) Date: Wed Jun 18 12:55:36 2008 Subject: [Haskell-cafe] blas bindings, why are they so much slower the C? In-Reply-To: References: Message-ID: <48593FEE.70907@jellybean.co.uk> Anatoly Yakovenko wrote: >>> #include >>> #include >>> >>> int main() { >>> int size = 1024; >>> int ii = 0; >>> double* v1 = malloc(sizeof(double) * (size)); >>> double* v2 = malloc(sizeof(double) * (size)); >>> for(ii = 0; ii < size*size; ++ii) { >>> double _dd = cblas_ddot(0, v1, size, v2, size); >>> } >>> free(v1); >>> free(v2); >>> } >> Your C compiler sees that you're not using the result of cblas_ddot, >> so it doesn't even bother to call it. That loop never gets run. All >> your program does at runtime is call malloc and free twice, which is >> very fast :-) > > C doesn't work like that :). C compilers can do what they like ;) GCC in particular is pretty good at removing dead code, including entire loops. However it shouldn't eliminate the call to cblas_ddot unless it thinks cblas_ddot has no side effects at all, which would be surprising unless it's inlined somehow. Jules From droundy at darcs.net Wed Jun 18 13:05:44 2008 From: droundy at darcs.net (David Roundy) Date: Wed Jun 18 12:57:36 2008 Subject: [Haskell-cafe] blas bindings, why are they so much slower the C? In-Reply-To: References: Message-ID: <20080618170543.GK32397@darcs.net> On Wed, Jun 18, 2008 at 09:16:24AM -0700, Anatoly Yakovenko wrote: > >> #include > >> #include > >> > >> int main() { > >> int size = 1024; > >> int ii = 0; > >> double* v1 = malloc(sizeof(double) * (size)); > >> double* v2 = malloc(sizeof(double) * (size)); > >> for(ii = 0; ii < size*size; ++ii) { > >> double _dd = cblas_ddot(0, v1, size, v2, size); > >> } > >> free(v1); > >> free(v2); > >> } > > > > Your C compiler sees that you're not using the result of cblas_ddot, > > so it doesn't even bother to call it. That loop never gets run. All > > your program does at runtime is call malloc and free twice, which is > > very fast :-) > > C doesn't work like that :). functions always get called. but i did > find a problem with my C code, i am incorrectly calling the dot > production function: See a recent article in lwn on pure and const functions to see how gcc is able to perform dead code elimination and CSE, provided its given annotations on the relevant functions. I'd certainly hope that your blas library is properly annotated! > #include > #include > #include > #include > > int main() { > int size = 1024; > int ii = 0; > double dd = 0.0; > double* v1 = malloc(sizeof(double) * (size)); > double* v2 = malloc(sizeof(double) * (size)); > for(ii = 0; ii < size; ++ii) { > v1[ii] = 0.1; > v2[ii] = 0.1; > } > for(ii = 0; ii < size*size; ++ii) { > dd += cblas_ddot(size, v1, 0, v2, 0); > } > free(v1); > free(v2); > printf("%f\n", dd); > return 0; > } > > time ./testdot > 10737418.240187 > > real 0m2.200s > user 0m2.190s > sys 0m0.010s > > So C is about twice as fast. I can live with that. I suspect that it is your initialization that is the difference. For one thing, you've initialized the arrays to different values, and in your C code you've fused what are two separate loops in your Haskell code. So you've not only given the C compiler an easier loop to run (since you're initializing the array to a constant rather than to a sequence of numbers), but you've also manually optimized that initialization. In fact, this fusion could be precisely the factor of two. Why not see what happens in Haskell if you create just one vector and dot it with itself? (of course, that'll also make the blas call faster, so you'll need to be careful in your interpretation of your results.) David From droundy at darcs.net Wed Jun 18 13:06:17 2008 From: droundy at darcs.net (David Roundy) Date: Wed Jun 18 12:58:08 2008 Subject: [Haskell-cafe] blas bindings, why are they so much slower the C? In-Reply-To: <48593FEE.70907@jellybean.co.uk> References: <48593FEE.70907@jellybean.co.uk> Message-ID: <20080618170616.GL32397@darcs.net> On Wed, Jun 18, 2008 at 06:03:42PM +0100, Jules Bean wrote: > Anatoly Yakovenko wrote: > >>>#include > >>>#include > >>> > >>>int main() { > >>> int size = 1024; > >>> int ii = 0; > >>> double* v1 = malloc(sizeof(double) * (size)); > >>> double* v2 = malloc(sizeof(double) * (size)); > >>> for(ii = 0; ii < size*size; ++ii) { > >>> double _dd = cblas_ddot(0, v1, size, v2, size); > >>> } > >>> free(v1); > >>> free(v2); > >>>} > >>Your C compiler sees that you're not using the result of cblas_ddot, > >>so it doesn't even bother to call it. That loop never gets run. All > >>your program does at runtime is call malloc and free twice, which is > >>very fast :-) > > > >C doesn't work like that :). > > C compilers can do what they like ;) > > GCC in particular is pretty good at removing dead code, including entire > loops. However it shouldn't eliminate the call to cblas_ddot unless it > thinks cblas_ddot has no side effects at all, which would be surprising > unless it's inlined somehow. Or unless it's been annotated as pure, which it should be. David From jim at sdf-eu.org Wed Jun 18 13:17:09 2008 From: jim at sdf-eu.org (Jim Burton) Date: Wed Jun 18 13:09:00 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <20080618165819.HFYI16854.aamtaout01-winn.ispmail.ntl.com@pine.ntlworld.com> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <20080617174953.WVJK29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> <48591986.1020304@ropine.com> <2AA970B8-05C6-47D1-B3A9-DE2C5FA2B3FF@yandex.ru> <20080618150957.CRUB8797.aamtaout03-winn.ispmail.ntl.com@pine.ntlworld.com> <1213801679.7014.25.camel@jonathans-macbook> <20080618153359.DETZ8797.aamtaout03-winn.ispmail.ntl.com@pine.ntlworld.com> <17986275.post@talk.nabble.com> <20080618165819.HFYI16854.aamtaout01-winn.ispmail.ntl.com@pine.ntlworld.com> Message-ID: <17987734.post@talk.nabble.com> PR Stanley wrote: > > >>PR Stanley wrote: >> > >> > [...] >> > >> > Paul: I rest my case! :-) >> > you cowardly hypocrit! > > Paul: Why did you remove Jonathan Cast's message? Afraid somebody > might understand why I responded the way I did? > >> > >>Please take your own advice now, and rest your case. Like it or not (I think >>most people do like it), haskell-cafe has norms of behaviour that make it >>different to many pl mailing lists. Your sarky comments would have gone >>unnoticed if they had been accompanied with something constructive. Name >>calling is out. > Paul: and who the bloody hell are you to tell me what's in or out? If > you want the matter to rest then shut up yourself. I'm getting sick > of you hypocrites who allow yourselves the audacity to attack me, > totally gratuitously, yet when I try to defend myself you take the > moral high ground. Tell me, why did you remove Jonathan Cast's > message? Is he too big for you? Why don't you tell all the other > people who have been busy attacking me to modify their language? Are > you afraid of upsetting the Haskell Cafe Mafia? > Well, guess what, you damn thugs, I 'aint taking this lying down. > You come back with more and I'll give you even more! > I snipped Jonathan's message just because I was commenting on the tone of your response. Sorry if you think I presented your reply out of context, but my point is that I don't think there is any need for this in any context here. I do have a right to say that, even as someone who hardly ever posts but prefers to read the list...it's owned by everybody. This isn't the same thing as censorship and you'll notice I said norms, not rules of behaviour. No one's going to stop you making yourself look silly if you insist on doing it. As for Jonathan being too big for me, erm, who is he again? :-) > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- View this message in context: http://www.nabble.com/Lambda-and-closures-in-PHP----could-someone-please-comment--tp17918732p17987734.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From prstanley at ntlworld.com Wed Jun 18 13:28:39 2008 From: prstanley at ntlworld.com (PR Stanley) Date: Wed Jun 18 13:20:36 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <17987734.post@talk.nabble.com> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <20080617174953.WVJK29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> <48591986.1020304@ropine.com> <2AA970B8-05C6-47D1-B3A9-DE2C5FA2B3FF@yandex.ru> <20080618150957.CRUB8797.aamtaout03-winn.ispmail.ntl.com@pine.ntlworld.com> <1213801679.7014.25.camel@jonathans-macbook> <20080618153359.DETZ8797.aamtaout03-winn.ispmail.ntl.com@pine.ntlworld.com> <17986275.post@talk.nabble.com> <20080618165819.HFYI16854.aamtaout01-winn.ispmail.ntl.com@pine.ntlworld.com> <17987734.post@talk.nabble.com> Message-ID: <20080618173140.NIPX29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> At 18:17 18/06/2008, you wrote: >PR Stanley wrote: > > > > > >>PR Stanley wrote: > >> > > >> > [...] > >> > > >> > Paul: I rest my case! :-) > >> > you cowardly hypocrit! > > > > Paul: Why did you remove Jonathan Cast's message? Afraid somebody > > might understand why I responded the way I did? > > > >> > > >>Please take your own advice now, and rest your case. Like it or not (I >think > >>most people do like it), haskell-cafe has norms of behaviour that make it > >>different to many pl mailing lists. Your sarky comments would have gone > >>unnoticed if they had been accompanied with something constructive. Name > >>calling is out. > > Paul: and who the bloody hell are you to tell me what's in or out? If > > you want the matter to rest then shut up yourself. I'm getting sick > > of you hypocrites who allow yourselves the audacity to attack me, > > totally gratuitously, yet when I try to defend myself you take the > > moral high ground. Tell me, why did you remove Jonathan Cast's > > message? Is he too big for you? Why don't you tell all the other > > people who have been busy attacking me to modify their language? Are > > you afraid of upsetting the Haskell Cafe Mafia? > > Well, guess what, you damn thugs, I 'aint taking this lying down. > > You come back with more and I'll give you even more! > > >I snipped Jonathan's message just because I was commenting on the tone of >your response. Sorry if you think I presented your reply out of context, but >my point is that I don't think there is any need for this in any context >here. I do have a right to say that, even as someone who hardly ever posts >but prefers to read the list...it's owned by everybody. This isn't the same >thing as censorship and you'll notice I said norms, not rules of behaviour. >No one's going to stop you making yourself look silly if you insist on doing >it. As for Jonathan being too big for me, erm, who is he again? :-) Paul: So, now I am silly! I'd still prefer that to a coward and a hypocrite From andrewcoppin at btinternet.com Wed Jun 18 13:43:25 2008 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Wed Jun 18 13:37:17 2008 Subject: [Haskell-cafe] Re: Bit Streams In-Reply-To: References: Message-ID: <4859493D.7070609@btinternet.com> Dominic Steinitz wrote: > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/binary-strict > Ooo... looks interesting. Pity I can't look at any documentation for it. (Is that *really* Haddoc failing with a parse error on a pragma? Surely not...) I'll take a look at this. Thanks. Andrew. From dons at galois.com Wed Jun 18 13:52:07 2008 From: dons at galois.com (Don Stewart) Date: Wed Jun 18 13:44:06 2008 Subject: [Haskell-cafe] Re: Bit Streams In-Reply-To: <396556a20806180949u1542b803l895d8967f0762c5f@mail.gmail.com> References: <396556a20806180949u1542b803l895d8967f0762c5f@mail.gmail.com> Message-ID: <20080618175207.GB24043@scytale.galois.com> agl: > On Wed, Jun 18, 2008 at 12:46 AM, Dominic Steinitz > wrote: > > OK, so today I tried to write my first program using the Binary library. > > And I've hit a snag: It appears the library will only handle data that > > is byte-aligned. So if I try to write three Bool values, it uses three > > bytes, not three bits. > > There's a BitGet[1] and BitPut in the Hackage version of > binary-strict. However, these versions work on strict ByteStrings. > Putting, for one, is pretty inefficient. In the darcs version[2] of > binary-strict, there's a fully lazy BitPut[3]. > > There was a request for a lazy BitGet, but I never wrote it. Most of > the time, bit fields are small and you can use the lazy Get from > binary to extract a ByteString and parse that with strict BitGet. > However, the BitPut should be just fine (including doing things like > writing ByteStrings by shifting each byte etc). > > If it's missing anything obvious, ping me and I'll see what I can do. > > Cheers, > > > [1] http://darcs.imperialviolet.org/darcsweb.cgi?r=binary-strict;a=headblob;f=/src/Data/Binary/Strict/BitGet.hs > [2] http://darcs.imperialviolet.org/binary-strict/ > [3] http://darcs.imperialviolet.org/darcsweb.cgi?r=binary-strict;a=headblob;f=/src/Data/Binary/BitPut.hs Adam, Would you recommend binary-strict over bitsyntax now? Or are none yet entirely satisfactory -- Don From asandroq at gmail.com Wed Jun 18 13:51:16 2008 From: asandroq at gmail.com (Alex Sandro Queiroz e Silva) Date: Wed Jun 18 13:44:30 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <20080618134525.JKIM29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <20080617174953.WVJK29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> <4858CB66.1040605@jellybean.co.uk> <20080618104723.YEKX8797.aamtaout03-winn.ispmail.ntl.com@pine.ntlworld.com> <485908F8.4040001@tcs.inf.tu-dresden.de> <20080618134525.JKIM29365.aamtaout02-winn.ispmail.ntl.com@pine.ntlworld.com> Message-ID: <48594B14.1090202@gmail.com> Hallo, PR Stanley wrote: > Now, if you, Jules, Alex or some other wannabe Hitler have a problem > with my freedom of expression then your best solution is to saddle up > and get the hell out yourselves. This is the wrong place for setting up > your tinpot dictatorship, Doctor! > I am grateful for the help I've been getting from the list and my > understanding of FP has vastly improved since my membership of this list > but I refuse to tolerate bullies who use the list as a way of lifting > themselves out of their own shitty lives. Now I am angry! > Wow, Godwin's in record time. Please don't confuse freedom of speech with name-calling, or distasteful, non-constructive comments about someone else's programming language. Stop making yourself look like a fool. -alex http://www.ventonegro.org/ From agl at imperialviolet.org Wed Jun 18 14:00:20 2008 From: agl at imperialviolet.org (Adam Langley) Date: Wed Jun 18 13:52:12 2008 Subject: [Haskell-cafe] Re: Bit Streams In-Reply-To: <20080618175207.GB24043@scytale.galois.com> References: <396556a20806180949u1542b803l895d8967f0762c5f@mail.gmail.com> <20080618175207.GB24043@scytale.galois.com> Message-ID: <396556a20806181100jdeeb0c8x98c56cfdaf734112@mail.gmail.com> On Wed, Jun 18, 2008 at 10:52 AM, Don Stewart wrote: > Would you recommend binary-strict over bitsyntax now? > Or are none yet entirely satisfactory Probably, yes. Bitsyntax was, after all, the first Haskell code I ever wrote :) It works, but I think the monad style of binary-strict is better. AGL -- Adam Langley agl@imperialviolet.org http://www.imperialviolet.org From qdunkan at gmail.com Wed Jun 18 14:00:58 2008 From: qdunkan at gmail.com (Evan Laforge) Date: Wed Jun 18 13:52:49 2008 Subject: [Haskell-cafe] Re: Bit Streams In-Reply-To: <4859493D.7070609@btinternet.com> References: <4859493D.7070609@btinternet.com> Message-ID: <2518b95d0806181100p4168bc22neb46dafdc3262e6e@mail.gmail.com> On Wed, Jun 18, 2008 at 10:43 AM, Andrew Coppin wrote: > Dominic Steinitz wrote: >> >> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/binary-strict >> > > Ooo... looks interesting. Pity I can't look at any documentation for it. (Is > that *really* Haddoc failing with a parse error on a pragma? Surely not...) > I'll take a look at this. Yeah, I just ran into that myself, and "solved" it by removing the haddock comments for those types. I think Haddock is a bit oversensitive when it comes to parsing. It would be nice if it would at least try to continue when it failed to parse something. Of course, that might be easier said than done! While I'm on the subject, what is the future for binary-strict? I recently wanted it since I wanted to catch parse errors, but didn't wind up using it because I would have had to rewrite a whole bunch of Binary instances to be separate Binary.Put Binary.Strict.Get instances, and I'm lazy. So I did 'length (show result) `seq` return result" which doesn't win any beauty contests but seems to work. Inclusion in the official Data.Binary would be nice, especially if it could be a drop-in replacement, say by changing the Data.Binary instance definitions to Strict.Binary or something. From bos at serpentine.com Wed Jun 18 14:07:09 2008 From: bos at serpentine.com (Bryan O'Sullivan) Date: Wed Jun 18 13:59:00 2008 Subject: [Haskell-cafe] Re: Bit Streams In-Reply-To: <396556a20806181100jdeeb0c8x98c56cfdaf734112@mail.gmail.com> References: <396556a20806180949u1542b803l895d8967f0762c5f@mail.gmail.com> <20080618175207.GB24043@scytale.galois.com> <396556a20806181100jdeeb0c8x98c56cfdaf734112@mail.gmail.com> Message-ID: On Wed, Jun 18, 2008 at 11:00 AM, Adam Langley wrote: > On Wed, Jun 18, 2008 at 10:52 AM, Don Stewart wrote: >> Would you recommend binary-strict over bitsyntax now? >> Or are none yet entirely satisfactory > > Probably, yes. Bitsyntax was, after all, the first Haskell code I ever > wrote :) It works, but I think the monad style of binary-strict is > better. If you provide Applicative and Alternative instances for your getter monads (perhaps you already do?), that will get us very close to the kind of notational succinctness that Erlang's bit-level pattern matching gives, using entirely general Haskell mechanisms, and without the fuglitude of TH. That, I think, would be just lovely. From gsauthof at TechFak.Uni-Bielefeld.DE Wed Jun 18 14:19:10 2008 From: gsauthof at TechFak.Uni-Bielefeld.DE (Georg Sauthoff) Date: Wed Jun 18 14:11:02 2008 Subject: [Haskell-cafe] Fast sorting with Bytestring Message-ID: <20080618181910.GB25272@TechFak.Uni-Bielefeld.DE> Hi, I played a bit around with the nice bytestring package. At some point I implemented a simple sorting program, because I needed line-sorting a file with a custom line-compare function. I was a bit surprised, that the resulting code is very fast. A lot of faster than sorting via GNU sort (with the standard line-compare function). Then I got suspicious and tested standard GNU sort against a trivial standard sort implementation in Haskell using bytestring. The Haskell implementation looks like: > module Main > where > import qualified Data.ByteString.Lazy.Char8 as B > import Data.List > main = do > c <- B.getContents > let l = B.lines c > let r = sort l > B.putStr $ B.unlines r Sorting a file of '[]'-strings I get: time ./sort < brackets > /dev/null # ~ 0.01 s time sort < brackets > /dev/null # ~ 14 s Ok, strane ... Well, let's test with some 'normal' text: time ./sort < bible > /dev/null # ~ 0.4 s time sort < bible > /dev/null # ~ 0.56 s Ok, not that different. But with Haskell you often expect to get very slow code compared to an implementation in C. And I am surprised, that the Haskell is fast _and_ nice to read - because for example the ultra fast 'wc -l' Haskell implementation from the Haskell-Wiki uses some insider-knowledge about bytestring, and looks to a beginner not that intuitive, I guess. ./sort is the shown Haskell implementation. I used ghc 6.8.2, installed bytestring 0.9.1.0 as a user-local package (don't now I this superseeds the global bytestring package), compiled via ghc -O2. The tests are run at a Pentium M 1.3 GHz computer. As GNU sort I tested the version from coreutils 6.9. You can get the test files from: http://www.techfak.uni-bielefeld.de/~gsauthof/stuff/brackets.gz http://www.techfak.uni-bielefeld.de/~gsauthof/stuff/bible.gz (obviously, you have to gunzip them after downloading ...) Of course, the naive Haskell implementation doesn't care about locales (i.e. collating locale sequences), but this shouldn't explain the observed differences sorting the brackets file. Best regards Georg Sauthoff -- Fortune : 'Real programmers don't comment their code. It was hard to write, it should be hard to understand.' ;) From stefanor at cox.net Wed Jun 18 14:23:00 2008 From: stefanor at cox.net (Stefan O'Rear) Date: Wed Jun 18 14:14:52 2008 Subject: [Haskell-cafe] Fast sorting with Bytestring In-Reply-To: <20080618181910.GB25272@TechFak.Uni-Bielefeld.DE> References: <20080618181910.GB25272@TechFak.Uni-Bielefeld.DE> Message-ID: <20080618182300.GA3585@localhost.localdomain> On Wed, Jun 18, 2008 at 08:19:10PM +0200, Georg Sauthoff wrote: > Hi, > > I played a bit around with the nice bytestring package. At some point I > implemented a simple sorting program, because I needed line-sorting a file > with a custom line-compare function. I was a bit surprised, that the > resulting code is very fast. A lot of faster than sorting via GNU sort > (with the standard line-compare function). > > Then I got suspicious and tested standard GNU sort against a trivial > standard sort implementation in Haskell using bytestring. The Haskell > implementation looks like: > [snip] > Ok, strane ... Well, let's test with some 'normal' text: > > time ./sort < bible > /dev/null # ~ 0.4 s > time sort < bible > /dev/null # ~ 0.56 s > > Ok, not that different. But with Haskell you often expect to get very > slow code compared to an implementation in C. > > And I am surprised, that the Haskell is fast _and_ nice to read - because > for example the ultra fast 'wc -l' Haskell implementation from the > Haskell-Wiki uses some insider-knowledge about bytestring, and looks to > a beginner not that intuitive, I guess. > > ./sort is the shown Haskell implementation. I used ghc 6.8.2, installed > bytestring 0.9.1.0 as a user-local package (don't now I this superseeds > the global bytestring package), compiled via ghc -O2. The tests are run at a > Pentium M 1.3 GHz computer. As GNU sort I tested the version from > coreutils 6.9. > > You can get the test files from: > http://www.techfak.uni-bielefeld.de/~gsauthof/stuff/brackets.gz > http://www.techfak.uni-bielefeld.de/~gsauthof/stuff/bible.gz > (obviously, you have to gunzip them after downloading ...) > > Of course, the naive Haskell implementation doesn't care about locales > (i.e. collating locale sequences), but this shouldn't explain the > observed differences sorting the brackets file. GNU 'sort' uses an external sort algorithm. You can, with 200M of memory, give it a 50G input file, and it will work. This might explain the difference.. Stefan -------------- 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/20080618/2f6ee2ad/attachment.bin From gsauthof at TechFak.Uni-Bielefeld.DE Wed Jun 18 14:38:34 2008 From: gsauthof at TechFak.Uni-Bielefeld.DE (Georg Sauthoff) Date: Wed Jun 18 14:30:27 2008 Subject: [Haskell-cafe] Fast sorting with Bytestring In-Reply-To: <20080618182300.GA3585@localhost.localdomain> References: <20080618181910.GB25272@TechFak.Uni-Bielefeld.DE> <20080618182300.GA3585@localhost.localdomain> Message-ID: <20080618183834.GC25272@TechFak.Uni-Bielefeld.DE> On Wed, Jun 18, 2008 at 11:23:00AM -0700, Stefan O'Rear wrote: > GNU 'sort' uses an external sort algorithm. You can, with 200M of > memory, give it a 50G input file, and it will work. This might explain > the difference.. But the input files are both < 10 mb ... If I create a 'big_bible' file like 'cat bible bible | dd of=big_bible count=1 bs=SIZE_OF_BRACKETS' then the timings are: time sort < big_bible > /dev/null # ~ 1.2 s time ./sort < big_bible > /dev/null # ~ 0.8 s I.e. the difference here is like a low constant factor, and not like a factor of 1000 with the brackets. Best regards Georg Sauthoff -- Fortune : 'Real programmers don't comment their code. It was hard to write, it should be hard to understand.' ;) From ketil at malde.org Wed Jun 18 14:56:43 2008 From: ketil at malde.org (Ketil Malde) Date: Wed Jun 18 14:48:18 2008 Subject: [Haskell-cafe] Fast sorting with Bytestring In-Reply-To: <20080618182300.GA3585@localhost.localdomain> (Stefan O'Rear's message of "Wed\, 18 Jun 2008 11\:23\:00 -0700") References: <20080618181910.GB25272@TechFak.Uni-Bielefeld.DE> <20080618182300.GA3585@localhost.localdomain> Message-ID: <87wskmk1w4.fsf@malde.org> Stefan O'Rear writes: >> Ok, strane ... Well, let's test with some 'normal' text: >> >> time ./sort < bible > /dev/null # ~ 0.4 s >> time sort < bible > /dev/null # ~ 0.56 s >> Ok, not that different. But with Haskell you often expect to get very >> slow code compared to an implementation in C. > GNU 'sort' uses an external sort algorithm. You can, with 200M of > memory, give it a 50G input file, and it will work. This might explain > the difference.. GNU sort also handles locale-based comparison, which I suspect explains more of the difference. Try with LC_ALL=C. -k -- If I haven't seen further, it is by standing in the footprints of giants From stephen at enterity.com Wed Jun 18 15:31:18 2008 From: stephen at enterity.com (Stephen Howard) Date: Wed Jun 18 15:22:30 2008 Subject: [Haskell-cafe] type constructor confusion Message-ID: <48596286.6050201@enterity.com> hello list, loading the code below into ghci gives me this error: HttpMessage.hs:36:20: Not in scope: type constructor or class `HttpRequest' The troublesome line is the definition of the cookie function at the end of the code. I've made HttpRequest and HttpResponse constructors of HttpMessage as I've sketched out an action that might return either one. Given that I thought what I was doing below was defining these as type constructors (maybe I have my vocabulary mixed up) I don't know why ghci is returning this error. module HttpMessage ( HttpMessage(..), HttpRequestMethod(..), cookie ) where import Data.Map as M data HttpHeaders = HttpHeaders !(M.Map String String ) data HttpMessage = HttpRequest { headers :: HttpHeaders, body :: String, request_method :: HttpRequestMethod, uri :: URI, http_version :: Float, cookies :: !(M.Map String String) } | HttpResponse { headers :: HttpHeaders, body :: String, status :: HttpStatus } data HttpRequestMethod = Get | Head | Post | Put | Delete | Unsupported String data HttpStatus = OK | NotFound | NotAuthorized | ServerError data URI = URI { protocol :: String, domain :: String, port :: String, path :: String, query :: !(M.Map String String), anchor :: String } cookie :: String -> HttpRequest -> Maybe String cookie n request = M.lookup n (cookies request) From allbery at ece.cmu.edu Wed Jun 18 15:38:15 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Wed Jun 18 15:30:03 2008 Subject: [Haskell-cafe] type constructor confusion In-Reply-To: <48596286.6050201@enterity.com> References: <48596286.6050201@enterity.com> Message-ID: On Jun 18, 2008, at 15:31 , Stephen Howard wrote: > HttpMessage.hs:36:20: Not in scope: type constructor or class > `HttpRequest' > > The troublesome line is the definition of the cookie function at > the end of the code. I've made Right. "HttpRequest" is a data constructor associated with the type constructor "HttpMessage". (Data constructors are effectively functions; you used it in the context of a type, not a function name.) -- 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 stephen at enterity.com Wed Jun 18 15:39:02 2008 From: stephen at enterity.com (Stephen Howard) Date: Wed Jun 18 15:30:17 2008 Subject: [Haskell-cafe] Re: working with Random.randoms In-Reply-To: References: <4852A281.8000508@enterity.com> Message-ID: <48596456.6000108@enterity.com> Thanks for the replies. This was my solution: module RandomTest ( random_test ) where import Random random_test :: Int -> IO String random_test n = do g <- newStdGen return $ take n (randomRs printable_ascii g) where printable_ascii = ('!','~') The "struggling with the type system" was supposed to be tongue-in-cheek. I trust it, it just takes some time to get used to it. And I appreciate Dan's comments about separating the pure code from the non-pure, but in this case the code was succinct enough that one more layer of functions seemed to do more harm than good when it came to legibility. - Stephen Jon Fairbairn wrote: > Stephen Howard writes: > > >> I am a newcomer doing my obligatory struggling with >> Haskell's type system, >> > > That's your mistake. Don't struggle with the type system, > the type system is your friend; when it tells you you are > doing something wrong, it's usually right. > > >> and I've got a nut I've not been able to crack. Given: >> >> import Random >> >> random_test :: Int -> String >> random_test n = do >> g <- getStdGen >> take n (randoms g)::String >> > > My immediate reaction on seeing this is that "do" is for > manipulating monads, but the only monad you've indicated in > the type is [] (from String = [Char]), and that's probably > an accident. > > In GHCi: > > Prelude> :t Random.getStdGen > Random.getStdGen :: IO System.Random.StdGen > > What this says is that getStdGen isn't a function, which is > to say it doesn't always return the same value (ie it isn't > pure -- it wouldn't be much use if it were!). In effect it > uses the real world to get a new value, and such things are > kept safely in the IO monad. In C, everything is in the IO > monad; there's no way of telling from the type whether > something is pure or not?. In Haskell (apart from some > ugliness that's supposed to stay hidden) you have to > distinguish between pure and impure, and the type checker > keeps track of all this for you. > > >> And yet, when I run these lines in GHCI by hand, >> > > The top level of GHCi is IO (which shouldn't come as a > surprise!) > > >> things seem to work (though the string is the same set of >> random characters each time, another bit that I need to >> solve >> > > That's a somewhat obscure aspect of GHCi, I think, to do > with "not reverting top-level expressions". If you do this: > > Prelude> :set +r > Prelude> g <- Random.getStdGen -- what's the type? > 1954047482 7573 > Prelude> g <- Random.getStdGen -- what's the type? > 1626678354 7697 > Prelude> > > you see that you get a different StdGen each time. > > >> I'm guessing that randoms is returning an IO type but I'm >> not sure how to go about extracting the String to return to >> the calling action. Changing the type signature to Int -> >> IO String only gives me a different error. >> > > If you do any IO, you've done some IO! So you need to lift > out the StdGen and pass that to the functions that you want > to use it. > > main :: IO() > do gen <- getStdGen > the_list <- real_programme gen > print the_list > > You should be able to deduce from the fact that the first > argument of real_programme here is of type StdGen (not IO > anything) and its result type is [something] that > real_programme is pure, and gen has only one value > throughout. So if you want more than one random list out of > it, you either need to use Random.split or pass more than > one gen in. > > > [1] Were you truly perverse, you could define your own > libraries in Haskell so that YourInt = IO Int; YourDouble = > IO Double etc, and make appropriate classes in place of Num > &c (hiding the proper ones), so that > > + :: YourInt -> YourInt -> YourInt > > and so on (you'd have to define your own Bool and if, too, > but Haskell can do that). Then the type checker would > overlook all sorts of mistakes that it could otherwise have > caught. > > > From gsauthof at TechFak.Uni-Bielefeld.DE Wed Jun 18 15:43:23 2008 From: gsauthof at TechFak.Uni-Bielefeld.DE (Georg Sauthoff) Date: Wed Jun 18 15:35:14 2008 Subject: [Haskell-cafe] Fast sorting with Bytestring In-Reply-To: <87wskmk1w4.fsf@malde.org> References: <20080618181910.GB25272@TechFak.Uni-Bielefeld.DE> <20080618182300.GA3585@localhost.localdomain> <87wskmk1w4.fsf@malde.org> Message-ID: <20080618194323.GD25272@TechFak.Uni-Bielefeld.DE> On Wed, Jun 18, 2008 at 08:56:43PM +0200, Ketil Malde wrote: > Stefan O'Rear writes: > > GNU 'sort' uses an external sort algorithm. You can, with 200M of > > memory, give it a 50G input file, and it will work. This might explain > > the difference.. > GNU sort also handles locale-based comparison, which I suspect > explains more of the difference. Try with LC_ALL=C. Well, for input 'bible' with locale en_US.utf8 GNU sort is ~ 6 times slower than with locale C. But for input 'brackets' it is ~ 433 times slower ... Best regards Georg Sauthoff -- Fortune : 'Real programmers don't comment their code. It was hard to write, it should be hard to understand.' ;) From alfonso.acosta at gmail.com Wed Jun 18 16:13:13 2008 From: alfonso.acosta at gmail.com (Alfonso Acosta) Date: Wed Jun 18 16:05:04 2008 Subject: [Haskell-cafe] Meaning of "ribbonsPerLine" at Text.PrettyPrint.HughesPJ ? Message-ID: <6a7c66fc0806181313o447839et23358d5ba0523ac0@mail.gmail.com> Hi, Can anyone give a good explanation of what ribbonsPerLine means? Maybe it would be better to simply ask for the meaning of ribbon in this context. The documentation is totally meaningless to me: "reibbonsPerLine: Ratio of ribbon length to line length". I asked at #haskell and frankly, I was surprised by the answer: fons: can anyone tell me what the heck does ribbonsPerLine mean in Text.PrettyPrint.HughesPJ? fons: > renderStyle style{lineLength=10, ribbonsPerLine=1} $ sep [text "foo" ,text "bar"] lambdabot: "foo bar" fons: > renderStyle style{lineLength=10, ribbonsPerLine=2} $ sep [text "foo" ,text "bar"] lambdabot: "foo\nbar" fons: ok, somehow it affects the line width ... byorgey: fons: I can't explain it, all I know is that you must set it to 1 or else it does bizarre things fons: hahah, ok fons: byorgey: that's funny considering its default value is 1.5 byorgey: if you set it to 1 then lineLength means what you think it should byorgey: fons: EXACTLY Cheers, Fons From byorgey at seas.upenn.edu Wed Jun 18 16:43:36 2008 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Wed Jun 18 16:35:26 2008 Subject: [Haskell-cafe] Haskell Weekly News: Issue 73 - June 18, 2008 Message-ID: <20080618204336.GA1701@plus.seas.upenn.edu> --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20080618 Issue 73 - June 18, 2008 --------------------------------------------------------------------------- Welcome to issue 73 of HWN, a newsletter covering developments in the [1]Haskell community. The Google Summer of Code is in full swing, preparations are underway for ICFP and the eleventh ICFP Programming Contest, and cabal-install is oh-so-sexy. It's an exciting time to be a part of the Haskell community! Community News Andy Gill has completed his move from Portland, OR to Kansas. Luke Palmer (luqui) has [2]begun work for [3]Anygma, Peter Verswyvelen's startup using Haskell (among other languages) to ``generate easy-to-use tools for creating audio-visual 2D/3D content.'' Congrats to Andy and Luke on their new beginnings! Announcements Final CFP: 2008 Haskell Symposium. Andy Gill [4]announced the final call for papers for the [5]2008 Haskell Symposium. The deadline is the 23rd of this month; please submit a paper! cabal-install. Duncan Coutts [6]announced the release of [7]cabal-install-0.5, along with the release of Cabal-1.4 to support it. It features an improved command line interface, smarter upgrading, and is made of win. If you are still stuck in the dark ages of runhaskell Setup configure blah blah, then the imperative monkeys have already won. ICFP programming contest. Tim Chevalier [8]announced the eleventh annual [9]ICFP programming contest, to be held from Friday, July 11, 2008 to Monday, July 14, 2008. Are you ready? c.h.o trac. Ian Lynagh [10]announced that it is now possible for projects on [11]community.haskell.org to [12]create themselves a trac, providing a bug tracking system and wiki. random-access-list. Stephan Friedrichs [13]announced an [14]implementation of Chris Okasaki's random-access lists, providing typical list operations (cons, head, tail) in O(1) and indexed random-access in O(log n). GHC version 6.8.3. Ian Lynagh [15]announced a [16]new patchlevel release of [17]GHC, containing a number of bugfixes relative to 6.8.2. Printf-TH. Marc Weber [18]announced that he has taken over maintenance of the [19]Printf-TH library, which implements a printf function via [20]Template Haskell, in order to guarantee that wrong argument types or the wrong number of arguments will result in compile time errors. Mueval. Gwern Branwen [21]announced the release of the [22]mueval package, providing a standalone executable for evaluating Haskell expressions based on the GHC API. Topkata. Christoph Bauer [23]announced the release of [24]Topkata, a simple OpenGL game written in Haskell. The goal is to guide a ball through a labyrinth to the opposite corner. Haddock Trac. David Waern [25]announced a new [26]bug-tracker and wiki for the [27]Haddock project. Fortress talk. Jeff Polakow [28]announced that a [29]talk on [30]Fortress, a new OO/functional language from Sun, will take place on Wednesday, June 25 at 6:30pm in Manhattan, New York, USA. ieee-0.2. Patrick Perry [31]announced the release of [32]ieee, a library that provides approximate comparison of floating point numbers based, NaN-aware minimum and maximum, and a type class for approximate comparisons. Google Summer of Code Hoogle 4. Neil Mitchell (ndm) is [33]working on Hoogle 4, recently adding support for generating Hoogle databases to [34]Haddock, using the GHC API. This week he plans to work on database creation and text searches. DPH physics engine. Roman Cheplyaka (Feuerbach) is [35]working on a physics engine using [36]Data Parallel Haskell, recently adding rotations, represented by quaternions. Next he plans to handle collisions properly with respect to rotation, and to add documentation. Generic tries. Jamie Brandon is writing a library for efficient maps using generalized tries. He has come up with a preliminary API and is [37]asking for feedback. Cabal dependency framework. Andrea Vezzosi (Saizan) is working on a make-like dependency analysis framework for Cabal, recently refining the core model, that has built its first sources in the testing environment. The next step will be dealing with preprocessor chaining. Language.C. Benedikt Huber (visq) is working on Language.C, a standalone parser/pretty printer library for C99. The test suite is finished, the parser and pretty printer support most GNU extensions, and all failing tests of gcc.dg are documented. GHC API. Thomas Schilling (nominolo) is working on improvements to the GHC API. GHC plugins. Maximilian Conroy Bolingbroke is working on dynamically loaded plugins for GHC. Discussion Low-level array performance. Dan Doel began a [38]discussion about the [39]fannkuch benchmark and the current state of Haskell support for fast low-level array operations. 1/0. Evan Laforge began a lively [40]discussion about Infinity, NaN, and Haskell's support for the IEEE floating-point standard. Documenting the impossible. Andrew Coppin began a [41]discussion on the relative merits of {-# IMPOSSIBLE #-} pragmas, calls to 'error' and 'assert', the use of tools like [42]Catch, and other methods of annotating impossible cases. Blog noise [43]Haskell news from the [44]blogosphere. * [45]PE Problem #1 in Haskell * [46]osfameron: Countdown words game solver in Haskell * [47]Algebraic Data Types in JavaScript * [48]Finance and Haskell * [49]Well-Typed.Com: New Cabal and cabal-install releases * [50]Neil Mitchell: GSoC Hoogle: Week 3 * [51]Max Bolingbroke: Compiler Plugins For GHC: The First Week * [52]Dan Piponi (sigfpe): Categories of polynomials and comonadic plumbing * [53]Roman Cheplyaka: Status report: week 3 * [54]Thomas DuBuisson (TomMD): Static Buffers Considered Harmful Quotes of the Week * ddarius: Here's the short guide to Haskell for OO programmers: Haskell isn't at all an OO language. * swalters: I'm starting to believe that learning haskell is mostly about carefully crafting small and clever functions and then finding out that they are already part of the standard library. About the Haskell Weekly News New editions are posted to [55]the Haskell mailing list as well as to [56]the Haskell Sequence and [57]Planet Haskell. [58]RSS is also available, and headlines appear on [59]haskell.org. Headlines are available as [60]PDF. To help create new editions of this newsletter, please see the information on [61]how to contribute. Send stories to byorgey at seas dot upenn dot edu. The darcs repository is available at darcs get [62]http://code.haskell.org/~byorgey/code/hwn/ . References 1. http://haskell.org/ 2. http://luqui.org/blog/archives/2008/06/18/new-job/ 3. http://anygma.com/ 4. http://article.gmane.org/gmane.comp.lang.haskell.general/16249 5. http://haskell.org/haskell-symposium/2008 6. http://article.gmane.org/gmane.comp.lang.haskell.cabal.devel/3267 7. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/cabal-install 8. http://article.gmane.org/gmane.comp.lang.haskell.general/16238 9. http://icfpcontest.org/ 10. http://article.gmane.org/gmane.comp.lang.haskell.general/16241 11. http://community.haskell.org/ 12. http://community.haskell.org/admin/using_project.html#trac 13. http://article.gmane.org/gmane.comp.lang.haskell.general/16237 14. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/random-access-list 15. http://article.gmane.org/gmane.comp.lang.haskell.glasgow.user/14645 16. http://haskell.org/ghc/docs/6.8.3/html/users_guide/release-6-8-3.html 17. http://www.haskell.org/ghc/ 18. http://article.gmane.org/gmane.comp.lang.haskell.cafe/41293 19. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Printf-TH 20. http://www.haskell.org/th/ 21. http://article.gmane.org/gmane.comp.lang.haskell.cafe/41265 22. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/mueval 23. http://article.gmane.org/gmane.comp.lang.haskell.cafe/41263 24. http://home.arcor.de/chr_bauer/topkata.html 25. http://article.gmane.org/gmane.comp.lang.haskell.cafe/41249 26. http://trac.haskell.org/haddock 27. http://www.haskell.org/haddock/ 28. http://article.gmane.org/gmane.comp.lang.haskell.cafe/41235 29. http://lisp.meetup.com/59 30. http://research.sun.com/projects/plrg/ 31. http://article.gmane.org/gmane.comp.lang.haskell.cafe/41201 32. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/ieee 33. http://neilmitchell.blogspot.com/2008/06/gsoc-hoogle-week-3.html 34. http://www.haskell.org/haddock/ 35. http://physics-dph.blogspot.com/2008/06/status-report-week-3.html 36. http://www.haskell.org/haskellwiki/GHC/Data_Parallel_Haskell 37. http://article.gmane.org/gmane.comp.lang.haskell.libraries/9259 38. http://article.gmane.org/gmane.comp.lang.haskell.glasgow.user/14637 39. http://shootout.alioth.debian.org/gp4/benchmark.php?test=fannkuch 40. http://article.gmane.org/gmane.comp.lang.haskell.cafe/41368 41. http://article.gmane.org/gmane.comp.lang.haskell.cafe/41295 42. http://www-users.cs.york.ac.uk/~ndm/catch/ 43. http://planet.haskell.org/ 44. http://haskell.org/haskellwiki/Blog_articles 45. http://jdfrens.blogspot.com/2008/06/pe-problem-1-in-haskell.html 46. http://osfameron.vox.com/library/post/countdown-words-game-solver-in-haskell.html 47. http://w3future.com/weblog/stories/2008/06/16/adtinjs.xml 48. http://blog.gmosx.com/2008/06/finance-and-haskell.html 49. http://blog.well-typed.com/2008/06/new-cabal-and-cabal-install-releases/ 50. http://neilmitchell.blogspot.com/2008/06/gsoc-hoogle-week-3.html 51. http://blog.omega-prime.co.uk/2008/06/15/compiler-plugins-for-ghc-the-first-week/ 52. http://sigfpe.blogspot.com/2008/06/categories-of-polynomials-and-comonadic.html 53. http://physics-dph.blogspot.com/2008/06/status-report-week-3.html 54. http://tommd.wordpress.com/2008/05/25/static-buffers-considered-harmful/ 55. http://www.haskell.org/mailman/listinfo/haskell 56. http://sequence.complete.org/ 57. http://planet.haskell.org/ 58. http://sequence.complete.org/node/feed 59. http://haskell.org/ 60. http://code.haskell.org/~byorgey/code/hwn/archives/20080618.pdf 61. http://haskell.org/haskellwiki/HWN 62. http://code.haskell.org/~byorgey/code/hwn/ From daniel.is.fischer at web.de Wed Jun 18 16:44:52 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Jun 18 16:36:13 2008 Subject: [Haskell-cafe] Using cabal-install Message-ID: <200806182244.52183.daniel.is.fischer@web.de> Is there a tutorial/user's guide for cabal-install somewhere? My limited google skills haven't found one and I really need it, because there MUST be a better way to get a package and its dependencies built and the haddock documentation generated, installed and hyperlinked than manually unpacking each .tar.gz and running cabal haddock there. Thanks, Daniel From qdunkan at gmail.com Wed Jun 18 16:55:32 2008 From: qdunkan at gmail.com (Evan Laforge) Date: Wed Jun 18 16:47:22 2008 Subject: [Haskell-cafe] Meaning of "ribbonsPerLine" at Text.PrettyPrint.HughesPJ ? In-Reply-To: <6a7c66fc0806181313o447839et23358d5ba0523ac0@mail.gmail.com> References: <6a7c66fc0806181313o447839et23358d5ba0523ac0@mail.gmail.com> Message-ID: <2518b95d0806181355r5f301c41l3321ff3437222829@mail.gmail.com> > byorgey: fons: I can't explain it, all I know is that you must set it > to 1 or else it does bizarre things > fons: hahah, ok > fons: byorgey: that's funny considering its default value is 1.5 > byorgey: if you set it to 1 then lineLength means what you think it should > byorgey: fons: EXACTLY Excellent, thanks for solving a nagging problem I couldn't be bothered to track down. I was wondering why my pretty printing was a little messed up and slightly too wide. And isn't 100 columns a bit non-standard for a default? I thought 80 columns had more traction? I know that's what my terminals are at... From dons at galois.com Wed Jun 18 16:57:46 2008 From: dons at galois.com (Don Stewart) Date: Wed Jun 18 16:49:38 2008 Subject: [Haskell-cafe] Using cabal-install In-Reply-To: <200806182244.52183.daniel.is.fischer@web.de> References: <200806182244.52183.daniel.is.fischer@web.de> Message-ID: <20080618205746.GL24043@scytale.galois.com> http://blog.well-typed.com/2008/06/new-cabal-and-cabal-install-releases/ Basically, build and install cabal-install, then let have it. daniel.is.fischer: > Is there a tutorial/user's guide for cabal-install somewhere? > My limited google skills haven't found one and I really need it, because there > MUST be a better way to get a package and its dependencies built and the > haddock documentation generated, installed and hyperlinked than manually > unpacking each .tar.gz and running cabal haddock there. > > Thanks, > Daniel > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From david.waern at gmail.com Wed Jun 18 17:11:46 2008 From: david.waern at gmail.com (David Waern) Date: Wed Jun 18 17:03:37 2008 Subject: [Haskell-cafe] Problem building GHC 6.8.3 In-Reply-To: References: <200806181428.25083.daniel.is.fischer@web.de> Message-ID: 2008/6/18 Bryan O'Sullivan : > On Wed, Jun 18, 2008 at 5:28 AM, Daniel Fischer > wrote: >> Sorry, probably stupid questions for knowledgeable folks > > Not stupid at all, but possibly the wrong mailing list. > glasgow-haskell-users would usually be a better place to ask. > >> Setup: Haddock's internal GHC version must match the configured GHC version > > You're using Haddock 2.0 or newer. It's not actually possible to build > GHC with it; you must use Haddock 0.9. We're discussing how to fix this problem in future releases of GHC and Haddock. In the meantime, it is actually possible to build GHC with Haddock 2.1.0 by first building GHC without docs, then installing Haddock with this GHC, and then building the GHC documentation. David From daniel.is.fischer at web.de Wed Jun 18 17:17:06 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Jun 18 17:06:56 2008 Subject: [Haskell-cafe] Using cabal-install In-Reply-To: <20080618205746.GL24043@scytale.galois.com> References: <200806182244.52183.daniel.is.fischer@web.de> <20080618205746.GL24043@scytale.galois.com> Message-ID: <200806182317.06321.daniel.is.fischer@web.de> Am Mittwoch, 18. Juni 2008 22:57 schrieb Don Stewart: > http://blog.well-typed.com/2008/06/new-cabal-and-cabal-install-releases/ > > Basically, build and install cabal-install, then let have it. I have cabal-install installed, and I'm thankful for it. My problem is, when I do cabal install foo it downloads foo and its dependencies, builds and installs, but it doesn't generate the documentation. How do I get it to build, install and link the documentation for all packages automatically, too? > > daniel.is.fischer: > > Is there a tutorial/user's guide for cabal-install somewhere? > > My limited google skills haven't found one and I really need it, because > > there MUST be a better way to get a package and its dependencies built > > and the haddock documentation generated, installed and hyperlinked than > > manually unpacking each .tar.gz and running cabal haddock there. > > > > Thanks, > > Daniel From jeremy at n-heptane.com Wed Jun 18 17:35:28 2008 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Wed Jun 18 17:25:16 2008 Subject: [Haskell-cafe] Bit streams In-Reply-To: <20080618133640.24b78310.Malcolm.Wallace@cs.york.ac.uk> References: <4858190B.4090909@btinternet.com> <20080618133640.24b78310.Malcolm.Wallace@cs.york.ac.uk> Message-ID: <87wskmifz3.wl%jeremy@n-heptane.com> Malcolm Wallace wrote: > The original Binary library, circa 1998, was based on bit-streams rather > than bytes. You might be able to dig up a copy and bring it back to > life. This derivative (by Hal Daume III) works with GHC 6.8.2 (I haven't tried 6.8.3): http://hackage.haskell.org/cgi-bin/hackage-scripts/package/NewBinary Not sure how to compares to the original version. It does appear to still support bit-oriented I/O though. j. (Note: I just fixed the cabal stuff to work with 6.8.2 minutes ago, so if have tried it before, it should work now). From duncan.coutts at worc.ox.ac.uk Wed Jun 18 17:40:07 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Jun 18 17:27:22 2008 Subject: [Haskell-cafe] Using cabal-install In-Reply-To: <200806182244.52183.daniel.is.fischer@web.de> References: <200806182244.52183.daniel.is.fischer@web.de> Message-ID: <1213825207.15010.857.camel@localhost> On Wed, 2008-06-18 at 22:44 +0200, Daniel Fischer wrote: > Is there a tutorial/user's guide for cabal-install somewhere? > My limited google skills haven't found one and I really need it, because there > MUST be a better way to get a package and its dependencies built and the > haddock documentation generated, installed and hyperlinked than manually > unpacking each .tar.gz and running cabal haddock there. The feature you are looking for is not implemented yet. "cabal-install should be able to generate haddock docs" http://hackage.haskell.org/trac/hackage/ticket/206 Go add your comments to that ticket and tell us how you think it should work. I mean what command would you expect to run to have it work and what would it do exactly? A closely related feature and one it probably overlaps with is this one: "allow installing just specific bits, like just docs" http://hackage.haskell.org/trac/hackage/ticket/225 so we should also think about what the user interface / mode of interaction of this feature should be. The issue is that previously we had separate commands for each phase so it was obvious where to put various phase-specific flags. Now with cabal-install's install command it does all the phases in one go. Currently it takes just the flags that the configure command takes (plus one or two others). So do we just make the install command take the union of the flags of the other phases? And how to say that we want optional phases like docs and tests. That's basically the issue, how do we expect to interact with it? If it can be relatively consistent and memorable then that's all the better. We also want all flags that you can pass on the command line to be able to be set as defaults in the ~/.cabal/config file. Currently there's just a subset but we want to have it cover everything. In general, adding yourself to the cc list of a ticket counts as a vote for the importance of that ticket and commenting on why it's important even more so (eg how painful and time consuming the alternative is). Duncan From duncan.coutts at worc.ox.ac.uk Wed Jun 18 17:41:52 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Jun 18 17:29:03 2008 Subject: [Haskell-cafe] Meaning of "ribbonsPerLine" at Text.PrettyPrint.HughesPJ ? In-Reply-To: <2518b95d0806181355r5f301c41l3321ff3437222829@mail.gmail.com> References: <6a7c66fc0806181313o447839et23358d5ba0523ac0@mail.gmail.com> <2518b95d0806181355r5f301c41l3321ff3437222829@mail.gmail.com> Message-ID: <1213825312.15010.858.camel@localhost> On Wed, 2008-06-18 at 13:55 -0700, Evan Laforge wrote: > > byorgey: fons: I can't explain it, all I know is that you must set it > > to 1 or else it does bizarre things > > fons: hahah, ok > > fons: byorgey: that's funny considering its default value is 1.5 > > byorgey: if you set it to 1 then lineLength means what you think it should > > byorgey: fons: EXACTLY > > Excellent, thanks for solving a nagging problem I couldn't be bothered > to track down. I was wondering why my pretty printing was a little > messed up and slightly too wide. > > And isn't 100 columns a bit non-standard for a default? I thought 80 > columns had more traction? I know that's what my terminals are at... Yeah. I'd vote for 80. That's what we use in pretty printing messages in Cabal. Duncan From pasalic at cs.rice.edu Wed Jun 18 16:49:54 2008 From: pasalic at cs.rice.edu (Emir Pasalic) Date: Wed Jun 18 17:39:11 2008 Subject: [Haskell-cafe] First Call for Papers: DSL WC Message-ID: IFIP Working Conference on Domain Specific Languages (DSL WC) July 15-17, 2009, Oxford CALL FOR PAPERS Domain-specific languages are emerging as a fundamental component of software engineering practice. DSLs are often introduced when new domains such as web-scripting or markup come into existence, but it is also common to see DSLs being introduced and adopted for traditional domains such as parsing and data description. Developing software using DSLs has many benefits. DSLs are often designed based on existing notations that are already in use by experts in a given domain. As such, successful DSLs often reduce or eliminate the effort needed to transform the concept or innovation produced by the domain expert into an executable artifact or even a deliverable software product. DSL implementations can capture and mechanize a significant portion of the repetitive and mechanical tasks that a domain expert traditionally needed to perform in order to produce an executable. DSLs can in many cases capture and make widely available special expertise that only top specialists in a given domain might have. By capturing expert knowledge and reducing repetitive tasks, DSLs often also lead to software that is significantly more portable, more reliable and more understandable than it would otherwise be. DSLs can be viewed as having a dual role to general-purpose languages: whereas general purpose languages try to do everything as well as possible, DSLs are designed to find a domain where they can solve some class of problems -- no matter how small -- in the best possible way. Widely known examples of DSLs include Matlab, Verilog, SQL, LINQ, JavaScript, PERL, HTML, Open GL, Tcl/Tk, Macromedia Director, Mathematica/Maple, AutoLisp/AutoCAD, XSLT, RPM, Make, lex/yacc, LaTeX, PostScript, Excel, among many others. But while these tools have been widely successful, they still fall short of realizing the full idea behind them. The goal of this conference is to explore the extent to which incorporating modern principles of language design and software engineering can benefit existing and future domain-specific languages. The ultimate goal of using DSLs is to improve programmer productivity and software quality. Often, this is achieved by reducing the cost of initial software development as well as maintenance costs. These improvements - programs being easier to write and maintain - materialize as a result of domain-specific guarantees, analyses, testing techniques, verification techniques, and optimizations. * Paper Criteria Papers are sought addressing the research problems, fundamental principles, and practical techniques of DSLs, including but not limited to: - Foundations, including semantics, formal methods, type theory, and complexity theory - Language design, ranging from concrete syntax to semantic and typing issues - Software engineering, including domain analysis, software design, and round-trip engineering - Software processes, including metrics for software and language evaluation - Implementation techniques, including parsing, compiling, and program generation - Program analysis and automated transformation - Reverse engineering, re-engineering, design discovery, automated refactoring - Hardware/software codesign - Programming environments, including visual languages, debuggers, and testing infrastructure - Teaching DSLs and the use of DSLs in teaching - Case studies, including engineering, bioinformatics, hardware specification languages, parallel computing languages, real-time and embedded systems, and networked and distributed domains Papers will be judged on the depth of their insight and the extent to which they translate specific experience into general lessons for domain-specific language designers and implementers, and software engineers. Papers can range from the practical to the theoretical; where appropriate, they should refer to actual languages, tools, and techniques, provide pointers to full definitions and implementations, and include empirical data on results. * Important Dates - December 14th, 2008: Abstract submission due. Firm, will not have any extensions - December 21st, 2008: Paper submission deadline. Firm, will not have any extensions - February 23rd, 2009: Author notification of decisions - March 22nd, 2009: Camera ready manuscripts due * Program Committee - Jon Bentley, Avayalabs - Martin Erwig, Oregon State University - Jeff Gray, University of Alabama at Birmingham - Robert Grimm, New York University - Jim Grundy, Intel Strategic CAD Labs - Tom Henzinger, EPFL - Sam Kamin, UIUC - Dick Kieburtz, Portland State University - Ralf L?mmel, University of Koblenz - Julia Lawall, University of Copenhagen - Benjamin Pierce, University of Pennsylvania - Vivek Sarkar, Rice University - Jeremy Siek, University of Colorado at Boulder - Jos? Nuno Oliveira, University of Minho - Doaitse Swierstra, Utrecht University - Walid Taha (Chair), Rice University - Eelco Visser, Delft University - William Waite, University of Colorado at Boulder - Stephanie Weirich, University of Pennsylvania * Organizers - General Chair: Jeremy Gibbons, Oxford University - Publicity Chair: Emir Pasalic, LogicBlox From dominic.steinitz at blueyonder.co.uk Wed Jun 18 17:56:32 2008 From: dominic.steinitz at blueyonder.co.uk (Dominic Steinitz) Date: Wed Jun 18 17:47:29 2008 Subject: [Haskell-cafe] Re: Bit Streams In-Reply-To: <20080618153625.GB23761@scytale.galois.com> References: <20080618153625.GB23761@scytale.galois.com> Message-ID: <48598490.5070403@blueyonder.co.uk> Don Stewart wrote: > dominic.steinitz: >> OK, so today I tried to write my first program using the Binary library. >> And I've hit a snag: It appears the library will only handle data that >> is byte-aligned. So if I try to write three Bool values, it uses three >> bytes, not three bits. >> >> Before I sit down and spend 3 months designing my own library from >> scratch, does anybody know of an existing library that allows you to do >> what Binary does, but with single-bit precision? [I presume Binary is >> byte-aligned for efficiency...] >> >> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/binary-strict > > The bitsyntax library perhaps? or a StateT over Binary for carrying > arround the bit packet to write. > > -- Don > > The vagaries of gmane have made it appear that I asked the question. In fact, Andrew Coppin asked the question and I responded with a pointer to the library Adam Langley pulled together. Dominic. From ok at cs.otago.ac.nz Wed Jun 18 19:19:37 2008 From: ok at cs.otago.ac.nz (Richard A. O'Keefe) Date: Wed Jun 18 19:11:35 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <7e270cea0806172136m67f5eb22o6fda46db93b49053@mail.gmail.com> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <1213755981.3338.15.camel@jonathans-macbook> <7e270cea0806172136m67f5eb22o6fda46db93b49053@mail.gmail.com> Message-ID: On 18 Jun 2008, at 4:36 pm, Karoly Negyesi wrote: >> (a) I would *never* want to use an implementation of closures like >> that. >> Could you elaborate on a) ? It wasn't me who wrote it, but consider - non-local variables are *not* captured unless you explicitly hoist them into the lambda expression using the 'lexical' keyword. - references to non-local variables that are not so hoisted are not syntax errors, they just quietly do something else. - ordinary functions do not act as if defined by lambda expressions; 'lexical' is required in lambdas and forbidden in functions. - ordinary functions do not act as if defined by lambda expressions; the latter can outlive their lexical scope, the former can't. - what you get is a reference to a variable (as you do in Scheme) but loop variables really are variables, not names for values, so lambdas created in different iterations of the same loop point so the same loop variable, and do not remember the value it had when they were created. The proposal explains how to work around this. All of this boils down to something in which you *can* with care do the things you expect to do with closures, but the language gently leads you to the edge of the Pit and the compiler just smiles quietly as you fall over. From ok at cs.otago.ac.nz Wed Jun 18 20:17:58 2008 From: ok at cs.otago.ac.nz (Richard A. O'Keefe) Date: Wed Jun 18 20:09:51 2008 Subject: [Haskell-cafe] blas bindings, why are they so much slower the C? In-Reply-To: References: Message-ID: On 19 Jun 2008, at 4:16 am, Anatoly Yakovenko wrote: > C doesn't work like that :). functions always get called. Not true. A C compiler must produce the same *effect* as if the function had been called, but if by some means the compiler knows that the function has no effect, it is entitled to skip the call. In particular, the C compiler I normally use offers these pragmas, amongst others: #pragma does_not_write_global_data (funcname [, funcname]) #pragma no_side_effect(funcname[, funcname]) So with a declaration like extern double cblas_ddot( int, double const *, int, double const *, int); #pragma no_side_effect (cblas_ddot) > the compiler would be completely within its rights to discard any call to cblas_ddot() whose result was not used. (As it happens, it didn't, but it would have been allowed to.) If using gcc, extern double cblas_ddot( ... as before ...) __attribute__ ((const)); seems to have the same effect, certainly the test case I tried did in fact completely eliminate a call to cblas_ddot() when so declared. Since the malloc() results pointed to uninitialised memory, the C compiler was entitled to do anything it pleased anyway. From stephen at enterity.com Wed Jun 18 22:02:27 2008 From: stephen at enterity.com (Stephen Howard) Date: Wed Jun 18 21:53:40 2008 Subject: [Haskell-cafe] type constructor confusion In-Reply-To: References: <48596286.6050201@enterity.com> Message-ID: <4859BE33.2040008@enterity.com> Thanks Brandon, forgot to send my reply to the list: Ok, so I am confusing things. Good to know. So my question is how do I fulfill this scenario? - I have an action that might return either an HttpResponse or an HttpRequest, depending on if the IO in the action determined more work needed doing. It's here, though I doubt it's "correct" yet: requestHandler :: HttpRequest -> IO HttpResponse requestHandler request = do session <- sessionHandler request ret <- uriHandler request case ret of HttpResponse -> ret HttpRequest -> resourceHandler session ret uriHandler :: HttpRequest -> IO HttpMessage sessionHandler :: HttpRequest -> IO HttpSession I've given the uriHandler a signature of IO HttpMessage because the HttpMessage might be either an HttpResponse or an HttpRequest, and I don't know how I should be specifying that. Ideas? - Stephen Brandon S. Allbery KF8NH wrote: > > On Jun 18, 2008, at 15:31 , Stephen Howard wrote: > >> HttpMessage.hs:36:20: Not in scope: type constructor or class >> `HttpRequest' >> >> The troublesome line is the definition of the cookie function at the >> end of the code. I've made > > Right. "HttpRequest" is a data constructor associated with the type > constructor "HttpMessage". > (Data constructors are effectively functions; you used it in the > context of a type, not a function name.) > From ryani.spam at gmail.com Wed Jun 18 22:46:57 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Wed Jun 18 22:38:48 2008 Subject: [Haskell-cafe] Haskell's type system In-Reply-To: <20080618093202.GA18893@netsoc.tcd.ie> References: <20080618093202.GA18893@netsoc.tcd.ie> Message-ID: <2f9b2d30806181946gc809426p7a65ccea89a73982@mail.gmail.com> On 6/18/08, Edsko de Vries wrote: > Regarding type classes, I'm not 100% what the logical equivalent is, > although one can regard a type such as > > forall a. Eq a => a -> a > > as requiring a proof (evidence) that equality on a is decidable. Where > this sits formally as a logic I'm not sure though. You can take the minimalist view and treat a typeclass parameter as an explicitly passed dictionary; that is: (Eq a => a -> a) is isomorphic to (a -> a -> Bool, a -> a -> Bool) -> a -> a In fact, this is basically what GHC does. You then treat an instance declaration: instance Eq Int where (==) = eqInt# (/=) = neqInt# as just a constant Eq_Int = (eqInt#, neqInt#) -- ryan From ryani.spam at gmail.com Wed Jun 18 23:04:24 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Wed Jun 18 22:56:15 2008 Subject: [Haskell-cafe] type constructor confusion In-Reply-To: <4859BE33.2040008@enterity.com> References: <48596286.6050201@enterity.com> <4859BE33.2040008@enterity.com> Message-ID: <2f9b2d30806182004g6b60bb72w9a57fa5e0a9f1401@mail.gmail.com> It sounds like you need to split up your types a bit more. data HttpRequest = HttpRequest ... data HttpResponse = HttpResponse ... data HttpMessage = MsgRequest HttpRequest | MsgResponse HttpResponse -- alternatively -- type HttpMessage = Either HttpRequest HttpResponse Now you can have functions that take/return just an HttpRequest or just an HttpResponse, as well as functions that use either one via HttpMessage. In the latter case, you do need to pattern match to decide which one you have. -- ryan On 6/18/08, Stephen Howard wrote: > Thanks Brandon, forgot to send my reply to the list: > > Ok, so I am confusing things. Good to know. So my question is how do I > fulfill this scenario? > > - I have an action that might return either an HttpResponse or an > HttpRequest, depending on if the IO in the action determined more work > needed doing. It's here, though I doubt it's "correct" yet: > > requestHandler :: HttpRequest -> IO HttpResponse > requestHandler request = do > session <- sessionHandler request > ret <- uriHandler request > case ret of > HttpResponse -> ret > HttpRequest -> resourceHandler session ret > > uriHandler :: HttpRequest -> IO HttpMessage > sessionHandler :: HttpRequest -> IO HttpSession > > I've given the uriHandler a signature of IO HttpMessage because the > HttpMessage might be either an HttpResponse or an HttpRequest, and I don't > know how I should be specifying that. Ideas? > > - Stephen > > Brandon S. Allbery KF8NH wrote: > > > > On Jun 18, 2008, at 15:31 , Stephen Howard wrote: > > > > > > > HttpMessage.hs:36:20: Not in scope: type constructor or class > `HttpRequest' > > > > > > The troublesome line is the definition of the cookie function at the end > of the code. I've made > > > > > > > Right. "HttpRequest" is a data constructor associated with the type > constructor "HttpMessage". > > (Data constructors are effectively functions; you used it in the context > of a type, not a function name.) > > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From newsham at lava.net Wed Jun 18 23:23:11 2008 From: newsham at lava.net (Tim Newsham) Date: Wed Jun 18 23:15:02 2008 Subject: [Haskell-cafe] Gtk2Hs and GCs Message-ID: I don't see a way to fetch an existing standard GC from a widget. In other Gtk bindings I usually do this by fetching the widget's style and then grabbing one of the gc's (such as fg_gc[STATE_NORMAL]). In Gtk2Hs docs: http://www.haskell.org/gtk2hs/docs/gtk2hs-docs-0.9.12/Graphics-UI-Gtk-General-Style.html it looks like you can only get Colors, not the whole GC. I can't seem to find any other way short of making a whole new GC (as is done in Gtk2Hs/demos/graphic/Drawing.hs). Am I missing something? Is there a reason the GC's arent retrievable? Tim Newsham http://www.thenewsh.com/~newsham/ From nfjinjing at gmail.com Wed Jun 18 23:33:56 2008 From: nfjinjing at gmail.com (jinjing) Date: Wed Jun 18 23:25:48 2008 Subject: [Haskell-cafe] message passing style like in Haskell? Message-ID: <81ea7d400806182033h40885ac5l96b415849f2d9d11@mail.gmail.com> Hi guys, This is my second attempt to learn Haskell :) Any way here's the code: module Dot where import Prelude hiding ( (.) ) (.) :: a -> (a -> b) -> b a . f = f a infixl 9 . So for example, 99 questions: Problem 10 (*) Run-length encoding of a list. comparing: encode xs = map (\x -> (length x,head x)) (group xs) to encode xs = xs.group.map token where token x = (x.length, x.head) I found starting with data and working my way to a solution seems to be easier to think with, or maybe it's just me ... What is your thought? Jinjing From levi.stephen at optusnet.com.au Thu Jun 19 01:34:46 2008 From: levi.stephen at optusnet.com.au (Levi Stephen) Date: Thu Jun 19 01:26:39 2008 Subject: [Haskell-cafe] (Lazy) SmallCheck and peano numbers Message-ID: <8341e4f40806182234w43cd1c99l64b9c2bf7e784f2@mail.gmail.com> Hi, I have the following definitions type Zero type Succ a so that I can muck around with a Vector type that includes its length encoded in its type. I was wondering whether it was possible to use SmallCheck (or QuickCheck) to generate random Peano numbers? Is there an issue here in that what I actually want to generate is a type rather than a value? I do have reifyInt :: Int -> (forall a. ReflectNum a => a -> b) -> b but, I'm not sure if this can help me when I need to generate other values based upon that type (e.g., two vectors with the same size type) Thanks, Levi From jules at jellybean.co.uk Thu Jun 19 01:53:47 2008 From: jules at jellybean.co.uk (Jules Bean) Date: Thu Jun 19 01:45:39 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <1213755981.3338.15.camel@jonathans-macbook> <7e270cea0806172136m67f5eb22o6fda46db93b49053@mail.gmail.com> Message-ID: <4859F46B.5060602@jellybean.co.uk> Richard A. O'Keefe wrote: > - what you get is a reference to a variable (as you do in Scheme) > but loop variables really are variables, not names for values, > so lambdas created in different iterations of the same loop point > so the same loop variable, and do not remember the value it had > when they were created. The proposal explains how to work around this. This one trips everyone up in Javascript. I think I'm of the opinion that variable capture from lambda formation should always be by value. However you can certainly make an argument that that's inconsistent in a language which generally has mutation/reference semantics. Whichever choice you make, though, document it loudly I predict it will be a source of confusion. Jules From ok at cs.otago.ac.nz Thu Jun 19 02:05:56 2008 From: ok at cs.otago.ac.nz (Richard A. O'Keefe) Date: Thu Jun 19 01:57:49 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <4859F46B.5060602@jellybean.co.uk> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <1213755981.3338.15.camel@jonathans-macbook> <7e270cea0806172136m67f5eb22o6fda46db93b49053@mail.gmail.com> <4859F46B.5060602@jellybean.co.uk> Message-ID: <279D0571-7E22-41C1-8F46-8FF40E12506A@cs.otago.ac.nz> On 19 Jun 2008, at 5:53 pm, Jules Bean wrote: > Richard A. O'Keefe wrote: > >> - what you get is a reference to a variable (as you do in Scheme) >> but loop variables really are variables, not names for values, >> so lambdas created in different iterations of the same loop point >> so the same loop variable, and do not remember the value it had >> when they were created. The proposal explains how to work around >> this. > > This one trips everyone up in Javascript. What's going on here is a nasty interaction with the semantics of loops. In Smalltalk and Scheme (to name two languages with closures and mutable variables), each iteration of a loop in principle creates a new variable binding. Scheme example: (do ((i 0 (+ i 1)) (l '() (cons (lambda (x) (* x i)) l))) ((>= i 10) l)) is equivalent to let f i l = if i >= 10 then l else f (i + 1) ((\x -> x * i) : l) in f 0 [] except for i and l being potentially mutable in Scheme but not Haskell. The Smalltalk equivalent would be (0 to: 9) collect: [:i | [:x | x*i]] in which (a) each iteration creates a *new* i, and (b) method and block parameters are *not* mutable, because they never are in Smalltalk. Importing only values into closures would not work for Smalltalk. Consider the usual implementation of Smalltalk's equivalent of 'fold: Collection>> inject: initial into: function |r| r := initial. self do: [:each | r := function value: r value: each]. ^r The mutablity of r here really isn't a problem. Nor is the mutability of variables _as such_ really the problem in the PHP proposal. The problem is that it's the *same* variable every time. If PHP loops introduced new bindings on every iteration, this particular problem would not exist. From jules at jellybean.co.uk Thu Jun 19 02:25:05 2008 From: jules at jellybean.co.uk (Jules Bean) Date: Thu Jun 19 02:16:57 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <279D0571-7E22-41C1-8F46-8FF40E12506A@cs.otago.ac.nz> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <1213755981.3338.15.camel@jonathans-macbook> <7e270cea0806172136m67f5eb22o6fda46db93b49053@mail.gmail.com> <4859F46B.5060602@jellybean.co.uk> <279D0571-7E22-41C1-8F46-8FF40E12506A@cs.otago.ac.nz> Message-ID: <4859FBC1.2070102@jellybean.co.uk> Richard A. O'Keefe wrote: > The mutablity of r here really isn't a problem. Nor is the mutability > of variables _as such_ really the problem in the PHP proposal. > The problem is that it's the *same* variable every time. If PHP > loops introduced new bindings on every iteration, this particular > problem would not exist. Well, arguably it's not only the loop variable that can be susceptible to this problem. There could be other variables in the loop body which change each time through (e.g. while loops). Consider this pseudo-code (sorry, my PHP is a bit rusty, this syntax is C really) char c; while (!eof(fp)) { c = getChar(fp); bind_event(... some lambda expression referencing c ...); } It's pretty surprising to the programmer if all that family of lambda expressions reference the *variable* c (and hence, in practice, its final value) rather than the *value* c. Well, maybe that doesn't surprise everyone. It surprised me the first time I used closures in Javascript and judging by a few google searches I wasn't alone in that. Jules From alfonso.acosta at gmail.com Thu Jun 19 02:39:29 2008 From: alfonso.acosta at gmail.com (Alfonso Acosta) Date: Thu Jun 19 02:31:20 2008 Subject: [Haskell-cafe] Meaning of "ribbonsPerLine" at Text.PrettyPrint.HughesPJ ? In-Reply-To: <1213825312.15010.858.camel@localhost> References: <6a7c66fc0806181313o447839et23358d5ba0523ac0@mail.gmail.com> <2518b95d0806181355r5f301c41l3321ff3437222829@mail.gmail.com> <1213825312.15010.858.camel@localhost> Message-ID: <6a7c66fc0806182339k1516fa98ue308cb6c2d94dd28@mail.gmail.com> On Wed, Jun 18, 2008 at 5:41 PM, Duncan Coutts wrote: >> And isn't 100 columns a bit non-standard for a default? I thought 80 >> columns had more traction? I know that's what my terminals are at... > > Yeah. I'd vote for 80. That's what we use in pretty printing messages in > Cabal. Yep, me too, I'm also using 80. I'd also vote for a default ribbonsPerLine of 1 (whatever that is). From naur at post11.tele.dk Thu Jun 19 03:14:10 2008 From: naur at post11.tele.dk (Thorkil Naur) Date: Thu Jun 19 03:08:14 2008 Subject: [Haskell-cafe] Meaning of "ribbonsPerLine" at Text.PrettyPrint.HughesPJ ? In-Reply-To: <6a7c66fc0806181313o447839et23358d5ba0523ac0@mail.gmail.com> References: <6a7c66fc0806181313o447839et23358d5ba0523ac0@mail.gmail.com> Message-ID: <200806190914.10745.naur@post11.tele.dk> Hello, On Wednesday 18 June 2008 22:13, Alfonso Acosta wrote: > Hi, > > Can anyone give a good explanation of what ribbonsPerLine means? > > Maybe it would be better to simply ask for the meaning of ribbon in > this context. The documentation is totally meaningless to me: > "reibbonsPerLine: Ratio of ribbon length to line length". In the paper "The Design of a Pretty-printing Library" by John Hughes (http://www.cs.chalmers.se/~rjmh/Papers/pretty.ps) that introduced this pretty printing library, the ribbon concept is introduced like this (apologies for the layout, please use the original .ps file for accuracy): > 7.4 Choosing a Pretty Layout > > Now that we have designed combinators for constructing documents with many possible layouts, it is time to discuss choosing among those alternatives. Many prettyprinters aim simply to avoid exceeding a given page width. However, we found that using this criterion alone tends to produce layouts such as > > for i = 1 to 100 do for j = 1 to 100 do for k = 1 to 100 do a[i,j,k] := 0 > > which fits on a page, but cannot be described as pretty. We therefore impose an additional constraint limiting the number of characters on each line (excluding indentation) to a smaller number. The idea is to avoid placing too much information on a line -- even a line that begins at the left margin. Under this constraint the example above might instead be laid out as > > for i = 1 to 100 do > for j = 1 to 100 do > for k = 1 to 100 do a[i,j,k] := 0 > > In general a pretty layout will consist of a ribbon of text snaking across the page. To see that this is reasonable, ask yourself: `is the prettiest layout on an infinitely wide page really to place everything on one line?' So pretty printing is guided by two lengths: The line length and the (smaller) ribbon length. The ribbons per line ratio that you can specify is simply a way of specifying the ribbon length relative to the line length. So, for example, if the line length is 80 and the ratio is 1.5, the ribbon length would be 80/1.5 which is rounded to 53. > ... Best regards Thorkil From ketil at malde.org Thu Jun 19 03:35:08 2008 From: ketil at malde.org (Ketil Malde) Date: Thu Jun 19 03:26:42 2008 Subject: [Haskell-cafe] message passing style like in Haskell? In-Reply-To: <81ea7d400806182033h40885ac5l96b415849f2d9d11@mail.gmail.com> (jinjing's message of "Thu\, 19 Jun 2008 11\:33\:56 +0800") References: <81ea7d400806182033h40885ac5l96b415849f2d9d11@mail.gmail.com> Message-ID: <878wx1khcj.fsf@malde.org> jinjing writes: > Any way here's the code: > module Dot where > import Prelude hiding ( (.) ) > (.) :: a -> (a -> b) -> b > a . f = f a > infixl 9 . Isn't this (roughly?) the same as flip ($)? As a side note, may I advise you to use another symbol, and leave the poor dot alone? Overloading it as a module separator is bad enough. If you have a keyboard that allows greater-than-ascii input, there are plenty of options: ? ? ? ? ? ? ? ? ?... > comparing: > encode xs = map (\x -> (length x,head x)) (group xs) > encode xs = xs.group.map token where token x = (x.length, x.head) To be fair, you could write the first line as: encode xs = map token (group xs) where token x = (length x, head x) I'm not normally too enthusiastic about point-free style, but when the left and right side of the = both end with the same term, there's really no need to name them, so: encode = map token . group where token x = (length x, head x) -- using function composition (.), not your definition I'm not sure that would work with left-to-right composition. > I found starting with data and working my way to a solution seems to be > easier to think with, or maybe it's just me ... For monadic code, there "default" is >>= and >> which pass things forward. There's also =<< which goes the other way - so I guess opinions differ. -k -- If I haven't seen further, it is by standing in the footprints of giants From magnus at therning.org Thu Jun 19 05:46:26 2008 From: magnus at therning.org (Magnus Therning) Date: Thu Jun 19 05:38:19 2008 Subject: [Haskell-cafe] ANN: dataenc 0.11 and omnicodec 0.2 Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 A few days ago I uploaded dataenc 0.11[1] and omnicode 0.2[2]. The short description of the (most visible) changes would be the added support for Base85 encoding and decoding in dataenc. The dataenc package (version 0.11) Data encoding library currently providing Uuencode, Base64, Base64Url, Base32, Base32Hex, Base16, and Base85. Other versions0.9, 0.10.1, 0.10.2 Dependenciesbase LicenseLGPL CopyrightMagnus Therning, 2007 AuthorMagnus Therning Maintainermagnus@therning.org CategoryCodec Exposed modulesCodec.Binary.DataEncoding, Codec.Binary.Base16, Codec.Binary.Base32Hex, Codec.Binary.Base32, Codec.Binary.Uu, Codec.Binary.Base64Url, Codec.Binary.Base64, Codec.Binary.Base85 Upload dateThu Jun 12 15:18:19 PDT 2008 Uploaded byMagnusTherning Built onghc-6.8 The omnicodec package (version 0.2) Two simply command line tools built on dataenc. Other versions0.1 Dependenciesbase, dataenc (>=0.11), directory, filepath, haskell98 LicenseGPL CopyrightMagnus Therning, 2007 AuthorMagnus Therning Maintainermagnus@therning.org CategoryCodec Executablesodec, oenc Upload dateThu Jun 12 15:19:07 PDT 2008 Uploaded byMagnusTherning Built onghc-6.8 /M [1]: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/dataenc [2]: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/omnicodec -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkhaKtsACgkQiMWTaatN+6Ru6wCdFBrMfmFWbqTbkWhml8idgbb7 e8sAoN58Xil4ZnbFmSH7xPUtrPUCyZq9 =vlsA -----END PGP SIGNATURE----- From ndmitchell at gmail.com Thu Jun 19 05:48:30 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Thu Jun 19 05:40:19 2008 Subject: [Haskell-cafe] Design suggestion for Data.Binary.Defer In-Reply-To: <1213735407-sup-7909@ausone.local> References: <404396ef0806160943r381f0b90ue418cb86bca0bc95@mail.gmail.com> <117f2cc80806161612oe3f2033q187cbf5c22592f03@mail.gmail.com> <404396ef0806162355m1bf083f2pcebdbfa64e17e42b@mail.gmail.com> <20080617182700.GD32397@darcs.net> <1213735407-sup-7909@ausone.local> Message-ID: <404396ef0806190248g73a4441byfae1795770f362ad@mail.gmail.com> Hi > Actually, you ought to be able to pretty easily remove this tradeoff > by introducing a strict read function as a new method in your class. > So anyone who wants to strictly read lazy data can use that function > instead of the lazy one. Not quite, the library is written so that strict fields are at the current file pointer while deferred fields require a position jump. For example, two strict strings would be: "hello""world" But two lazy strings would be: [ptr 5][ptr 10]"hello""world" > > :( Lazy reading seems to > > require strict writing, while lazy writing requires strict reading! The library is all designed around making reading maximally efficient, and minimizing file seeks, but writing can be totally inefficient. As you mention, the lazy/strict IO trade off is very interesting, its just fortunate that for my application (Hoogle) the files are written once and read many many times. > I'm wondering if it would be an option to read the file backward. If so > length annotations could be put at the end. > > Reading backward seems to only fail with streamed data, which won't support > the "seek"ing required by a lazy reading anyway. You still want to minimize seeking, even if it is possible. In my case having length information at the front helps reading, and I don't care about writing, so its an easy win. I think I've got my design nailed down, and have most of it implemented and used in Hoogle. These discussions and points were very helpful! Thanks Neil From duncan.coutts at worc.ox.ac.uk Thu Jun 19 06:26:21 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Jun 19 06:13:30 2008 Subject: [Haskell-cafe] message passing style like in Haskell? In-Reply-To: <81ea7d400806182033h40885ac5l96b415849f2d9d11@mail.gmail.com> References: <81ea7d400806182033h40885ac5l96b415849f2d9d11@mail.gmail.com> Message-ID: <1213871181.15010.863.camel@localhost> On Thu, 2008-06-19 at 11:33 +0800, jinjing wrote: > Hi guys, > > This is my second attempt to learn Haskell :) > > Any way here's the code: > > module Dot where > import Prelude hiding ( (.) ) > > (.) :: a -> (a -> b) -> b > a . f = f a > > infixl 9 . Note that if you redefine (.) composition to be backward application (flip ($)) then nobody will understand your programs. It's also quite probably that after reading your own code for a while that you'll not understand the code that everyone else writes either! :-) If you want an operator like that, I suggest picking some other symbol. Duncan From barsoap at web.de Thu Jun 19 08:10:00 2008 From: barsoap at web.de (Achim Schneider) Date: Thu Jun 19 08:02:02 2008 Subject: [Haskell-cafe] News of the day: C fails to stay self-hosting Message-ID: <20080619141001.01f36fe0@solaris> http://article.gmane.org/gmane.comp.gcc.patches/165063 -- (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 gwern0 at gmail.com Thu Jun 19 08:29:25 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Thu Jun 19 08:22:07 2008 Subject: [Haskell-cafe] message passing style like in Haskell? In-Reply-To: <81ea7d400806182033h40885ac5l96b415849f2d9d11@mail.gmail.com> References: <81ea7d400806182033h40885ac5l96b415849f2d9d11@mail.gmail.com> Message-ID: <20080619122925.GA12077@craft> On 2008.06.19 11:33:56 +0800, jinjing scribbled 0.5K characters: > Hi guys, > > This is my second attempt to learn Haskell :) > > Any way here's the code: > > module Dot where > import Prelude hiding ( (.) ) > > (.) :: a -> (a -> b) -> b > a . f = f a > > infixl 9 . > > So for example, 99 questions: Problem 10 > (*) Run-length encoding of a list. > > comparing: > > encode xs = map (\x -> (length x,head x)) (group xs) > > to > > encode xs = xs.group.map token where token x = (x.length, x.head) > > I found starting with data and working my way to a solution seems to be > easier to think with, or maybe it's just me ... > > What is your thought? > > Jinjing http://cgi.cse.unsw.edu.au/~dons/blog/2007/07 sez: encode = map (length &&& head) . group decode = concatMap (uncurry replicate) for a different twist on your approach using arrows. -- gwern Kerry W NAVSVS industrial Parvus NAVWAN ISM 8182 NRC Reno -------------- 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/20080619/32e37b85/attachment.bin From benjovi at gmx.net Thu Jun 19 08:31:14 2008 From: benjovi at gmx.net (Benedikt Huber) Date: Thu Jun 19 08:23:10 2008 Subject: [Haskell-cafe] Re: Meaning of "ribbonsPerLine" at Text.PrettyPrint.HughesPJ ? In-Reply-To: <2518b95d0806181355r5f301c41l3321ff3437222829@mail.gmail.com> References: <6a7c66fc0806181313o447839et23358d5ba0523ac0@mail.gmail.com> <2518b95d0806181355r5f301c41l3321ff3437222829@mail.gmail.com> Message-ID: <485A5192.8030400@gmx.net> Evan Laforge schrieb: >> byorgey: fons: I can't explain it, all I know is that you must set it >> to 1 or else it does bizarre things >> fons: hahah, ok >> fons: byorgey: that's funny considering its default value is 1.5 >> byorgey: if you set it to 1 then lineLength means what you think it should >> byorgey: fons: EXACTLY > > Excellent, thanks for solving a nagging problem I couldn't be bothered > to track down. I was wondering why my pretty printing was a little > messed up and slightly too wide. > > And isn't 100 columns a bit non-standard for a default? I thought 80 > columns had more traction? I know that's what my terminals are at... Hi, The "ribbon length" is used when choosing the most beautiful layout: I'll just summarize the relevant section from John Hughes paper (http://www.cs.chalmers.se/~rjmh/Papers/pretty.ps), which explains it very nicely: "... Using [the criterion whether the text fits on the page] alone tends to produce layouts such as > for i = 1 to 100; for j=1 to 100; for k=1 to 100; a[i][j][k]:=0; which fits on a page {==> line-width} but cannot be described as pretty. We therefore impose an additional constraint limiting the number of characters on each line [==> ribbon-width} [...] > for i = 1 to 100 > for j = 1 to 100 > ... " So the pretty printer tries to avoid sequences (ribbons) of characters which are longer than ribbon_length, when using auto layout stuff like `sep'. In the source code, we have (paraphrased) > ribbon_length = line_length / ribbonsPerLine and > choose_nicest_layout indent p q = > if p + indent fits into line_length and p fits into ribbon_length > then p > else q Working example below. I'm not sure 80 characters is still standard when _pretty_-printing - the longest line in Text.PrettyPrint.HughesPJ is 109 characters wide ;) Setting the ribbon ratio to 1 essentially disables the ribbon feature. Btw: while studying the source code, I also found the cat (and sep) can be implemented in a more space efficient way (currently, cat needs to evaluate every document in a list to yield some output). Does this make sense (see below) ? cheers, benedikt -- * ribbon example > -- lineLength = 26, ribbonsPerLine = 1.5 ==> ribbonLength = 17 > -- therefore, we have a line break if width-indent > 17 or width > 26 > testStyle = Style { mode = PageMode, > lineLength = 26, > ribbonsPerLine = 1.5 } > ribbonTest = renderStyle testStyle $ > > -- use hsep as width == 17 <= ribbonLength > sep [ txt 5, txt 11 ] > > -- linebreak, as width-indent = width = 18 > ribbonLength > $+$ sep [ txt 5, txt 12 ] > > -- use hsep, as width - indent == 17, and width == 22 < lineLength > $+$ sep (map (nest 5) $ [txt 5, txt 11] ) > > -- linebreak, as width would be 27 > lineLength > $+$ sep (map (nest 10) $ [txt 5, txt 11] ) > > txt :: Int -> Doc > txt 0 = text "" > txt k = text $ > let ks = show k in > (replicate (k - (length ks)) '_') ++ ks -- * lazy variants of vcat and hcat -- you need the constructors from the HughesPJ module > vcat' = foldAbove . foldr vcomp2 empty > hcat' = foldBeside . foldr hcomp2 empty > > foldAbove :: Doc -> Doc > foldAbove (Above Empty _ d2) = d2 > foldAbove (Above d1 f d2) = Above d1 f $ foldAbove d2 > foldAbove doc = doc > > vcomp2 :: Doc -> Doc -> Doc > vcomp2 d1 Empty = d1 > -- do not match `vcomp2 Empty d1' ! > vcomp2 d1 d2 = Above d1 False d2 > > foldBeside :: Doc -> Doc > foldBeside (Beside Empty _ d2) = d2 > foldBeside (Beside d1 f d2) = Beside d1 f $ foldBeside d2 > foldBeside doc = doc > > hcomp2 :: Doc -> Doc -> Doc > hcomp2 p Empty = p > hcomp2 p q = Beside p False q From benjovi at gmx.net Thu Jun 19 08:31:14 2008 From: benjovi at gmx.net (Benedikt Huber) Date: Thu Jun 19 08:23:18 2008 Subject: [Haskell-cafe] Re: Meaning of "ribbonsPerLine" at Text.PrettyPrint.HughesPJ ? In-Reply-To: <2518b95d0806181355r5f301c41l3321ff3437222829@mail.gmail.com> References: <6a7c66fc0806181313o447839et23358d5ba0523ac0@mail.gmail.com> <2518b95d0806181355r5f301c41l3321ff3437222829@mail.gmail.com> Message-ID: <485A5192.8030400@gmx.net> Evan Laforge schrieb: >> byorgey: fons: I can't explain it, all I know is that you must set it >> to 1 or else it does bizarre things >> fons: hahah, ok >> fons: byorgey: that's funny considering its default value is 1.5 >> byorgey: if you set it to 1 then lineLength means what you think it should >> byorgey: fons: EXACTLY > > Excellent, thanks for solving a nagging problem I couldn't be bothered > to track down. I was wondering why my pretty printing was a little > messed up and slightly too wide. > > And isn't 100 columns a bit non-standard for a default? I thought 80 > columns had more traction? I know that's what my terminals are at... Hi, The "ribbon length" is used when choosing the most beautiful layout: I'll just summarize the relevant section from John Hughes paper (http://www.cs.chalmers.se/~rjmh/Papers/pretty.ps), which explains it very nicely: "... Using [the criterion whether the text fits on the page] alone tends to produce layouts such as > for i = 1 to 100; for j=1 to 100; for k=1 to 100; a[i][j][k]:=0; which fits on a page {==> line-width} but cannot be described as pretty. We therefore impose an additional constraint limiting the number of characters on each line [==> ribbon-width} [...] > for i = 1 to 100 > for j = 1 to 100 > ... " So the pretty printer tries to avoid sequences (ribbons) of characters which are longer than ribbon_length, when using auto layout stuff like `sep'. In the source code, we have (paraphrased) > ribbon_length = line_length / ribbonsPerLine and > choose_nicest_layout indent p q = > if p + indent fits into line_length and p fits into ribbon_length > then p > else q Working example below. I'm not sure 80 characters is still standard when _pretty_-printing - the longest line in Text.PrettyPrint.HughesPJ is 109 characters wide ;) Setting the ribbon ratio to 1 essentially disables the ribbon feature. Btw: while studying the source code, I also found the cat (and sep) can be implemented in a more space efficient way (currently, cat needs to evaluate every document in a list to yield some output). Does this make sense (see below) ? cheers, benedikt -- * ribbon example > -- lineLength = 26, ribbonsPerLine = 1.5 ==> ribbonLength = 17 > -- therefore, we have a line break if width-indent > 17 or width > 26 > testStyle = Style { mode = PageMode, > lineLength = 26, > ribbonsPerLine = 1.5 } > ribbonTest = renderStyle testStyle $ > > -- use hsep as width == 17 <= ribbonLength > sep [ txt 5, txt 11 ] > > -- linebreak, as width-indent = width = 18 > ribbonLength > $+$ sep [ txt 5, txt 12 ] > > -- use hsep, as width - indent == 17, and width == 22 < lineLength > $+$ sep (map (nest 5) $ [txt 5, txt 11] ) > > -- linebreak, as width would be 27 > lineLength > $+$ sep (map (nest 10) $ [txt 5, txt 11] ) > > txt :: Int -> Doc > txt 0 = text "" > txt k = text $ > let ks = show k in > (replicate (k - (length ks)) '_') ++ ks -- * lazy variants of vcat and hcat -- you need the constructors from the HughesPJ module > vcat' = foldAbove . foldr vcomp2 empty > hcat' = foldBeside . foldr hcomp2 empty > > foldAbove :: Doc -> Doc > foldAbove (Above Empty _ d2) = d2 > foldAbove (Above d1 f d2) = Above d1 f $ foldAbove d2 > foldAbove doc = doc > > vcomp2 :: Doc -> Doc -> Doc > vcomp2 d1 Empty = d1 > -- do not match `vcomp2 Empty d1' ! > vcomp2 d1 d2 = Above d1 False d2 > > foldBeside :: Doc -> Doc > foldBeside (Beside Empty _ d2) = d2 > foldBeside (Beside d1 f d2) = Beside d1 f $ foldBeside d2 > foldBeside doc = doc > > hcomp2 :: Doc -> Doc -> Doc > hcomp2 p Empty = p > hcomp2 p q = Beside p False q From Malcolm.Wallace at cs.york.ac.uk Thu Jun 19 08:44:47 2008 From: Malcolm.Wallace at cs.york.ac.uk (Malcolm Wallace) Date: Thu Jun 19 08:37:06 2008 Subject: [Haskell-cafe] Meaning of "ribbonsPerLine" at Text.PrettyPrint.HughesPJ ? In-Reply-To: <6a7c66fc0806182339k1516fa98ue308cb6c2d94dd28@mail.gmail.com> References: <6a7c66fc0806181313o447839et23358d5ba0523ac0@mail.gmail.com> <2518b95d0806181355r5f301c41l3321ff3437222829@mail.gmail.com> <1213825312.15010.858.camel@localhost> <6a7c66fc0806182339k1516fa98ue308cb6c2d94dd28@mail.gmail.com> Message-ID: <20080619134447.116a4837.Malcolm.Wallace@cs.york.ac.uk> To answer the original question (in the subject line), "The ribbon ratio is the number of times the ribbon fits into a line. The ribbon is the number of characters on a line excluding leading and trailing white spaces. " See also the original paper on which the Text.PrettyPrint.HughesPJ code is based: http://www.cs.chalmers.se/~rjmh/Papers/pretty.ps section 7.4. The idea is that the pretty-printer should not cram lots of text into a single line, if it would look nicer split across two (shorter) lines. The ribbonsPerLine ratio is the factor that determines this level of "prettiness". A ratio of 1.0 means to cram everything into the line if you can. A larger ratio means to go for more lines, but less text on each. Somewhere between 1.2 and 1.8 is likely to be more or less pleasing: 1.0 will be ugly, 2.0 or above will look decidedly fragmented. Regards, Malcolm From lemming at henning-thielemann.de Thu Jun 19 11:17:38 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Jun 19 11:09:28 2008 Subject: [Haskell-cafe] Access to Oracle database from Haskell Message-ID: Is there a way of accessing a remote Oracle database by one of the common Haskell database interfaces (HaskellDB, Takusen, etc.) ? I tried to get unixODBC and Oracle's Instant Client running on a Linux machine, but I'm trapped in the notorious error: $ isql USER -v [IM004][unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed [ISQL]ERROR: Could not SQLConnect This error message is discussed in various web forums, but there seems to be no systematic way to track down the problem. So I wonder whether there is another way to access the Oracle data base from Haskell. From byorgey at gmail.com Thu Jun 19 12:00:00 2008 From: byorgey at gmail.com (Brent Yorgey) Date: Thu Jun 19 11:51:50 2008 Subject: [Haskell-cafe] network-related segfaults Message-ID: <22fcbd520806190900q7683be90x8de1d89a2e840c23@mail.gmail.com> Hi all, Has anyone else experienced segfaults related to network stuff? Observe: [11:50:56 brent@xenophon:~]$ ghci -ignore-dot-ghci GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help Loading package base ... linking ... done. Prelude> :m +Text.HTML.Download Prelude Text.HTML.Download> txt <- openURL "http://www.google.com" Loading package bytestring-0.9.1.0 ... linking ... done. Loading package mtl-1.1.0.0 ... linking ... done. Loading package parsec-3.0.0 ... linking ... done. Loading package network-2.1.0.0 ... linking ... done. Loading package array-0.1.0.0 ... linking ... done. Loading package containers-0.1.0.1 ... linking ... done. Loading package tagsoup-0.6 ... linking ... done. Segmentation fault (core dumped) This just started happening yesterday. I think I may have just upgraded some packages via cabal-install but I'm not sure which ones. Now is a time when I wish all my terminal sessions were automatically logged. (Hmm, perhaps I should look into that...) -Brent -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080619/14dd1713/attachment.htm From stephen at enterity.com Thu Jun 19 12:28:22 2008 From: stephen at enterity.com (Stephen Howard) Date: Thu Jun 19 12:19:32 2008 Subject: [Haskell-cafe] type constructor confusion In-Reply-To: <2f9b2d30806182004g6b60bb72w9a57fa5e0a9f1401@mail.gmail.com> References: <48596286.6050201@enterity.com> <4859BE33.2040008@enterity.com> <2f9b2d30806182004g6b60bb72w9a57fa5e0a9f1401@mail.gmail.com> Message-ID: <485A8926.7010902@enterity.com> Cool, "Either" looks like what I'm looking for. I'll have to look into that. What do I do about the fact that both HttpRequest and HttpResponse have some of the same named fields (headers and body, for example). Seems a pain to drop them into separate modules just so I can keep the naming conventions consistent. - Stephen Ryan Ingram wrote: > It sounds like you need to split up your types a bit more. > > data HttpRequest = HttpRequest ... > > data HttpResponse = HttpResponse ... > > data HttpMessage = MsgRequest HttpRequest | MsgResponse HttpResponse > -- alternatively > -- type HttpMessage = Either HttpRequest HttpResponse > > Now you can have functions that take/return just an HttpRequest or > just an HttpResponse, as well as functions that use either one via > HttpMessage. In the latter case, you do need to pattern match to > decide which one you have. > > -- ryan > > > On 6/18/08, Stephen Howard wrote: > >> Thanks Brandon, forgot to send my reply to the list: >> >> Ok, so I am confusing things. Good to know. So my question is how do I >> fulfill this scenario? >> >> - I have an action that might return either an HttpResponse or an >> HttpRequest, depending on if the IO in the action determined more work >> needed doing. It's here, though I doubt it's "correct" yet: >> >> requestHandler :: HttpRequest -> IO HttpResponse >> requestHandler request = do >> session <- sessionHandler request >> ret <- uriHandler request >> case ret of >> HttpResponse -> ret >> HttpRequest -> resourceHandler session ret >> >> uriHandler :: HttpRequest -> IO HttpMessage >> sessionHandler :: HttpRequest -> IO HttpSession >> >> I've given the uriHandler a signature of IO HttpMessage because the >> HttpMessage might be either an HttpResponse or an HttpRequest, and I don't >> know how I should be specifying that. Ideas? >> >> - Stephen >> >> Brandon S. Allbery KF8NH wrote: >> >>> On Jun 18, 2008, at 15:31 , Stephen Howard wrote: >>> >>> >>> >>>> HttpMessage.hs:36:20: Not in scope: type constructor or class >>>> >> `HttpRequest' >> >>>> The troublesome line is the definition of the cookie function at the end >>>> >> of the code. I've made >> >>> Right. "HttpRequest" is a data constructor associated with the type >>> >> constructor "HttpMessage". >> >>> (Data constructors are effectively functions; you used it in the context >>> >> of a type, not a function name.) >> >>> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> From gwern0 at gmail.com Thu Jun 19 12:30:56 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Thu Jun 19 12:24:16 2008 Subject: [Haskell-cafe] cabal-install failure In-Reply-To: <1213430194.15010.556.camel@localhost> References: <1213392126.15010.547.camel@localhost> <20080614021052.GA8862@craft> <1213430194.15010.556.camel@localhost> Message-ID: <20080619163056.GD28192@craft> On 2008.06.14 08:56:34 +0100, Duncan Coutts scribbled 1.3K characters: > > On Fri, 2008-06-13 at 22:10 -0400, Gwern Branwen wrote: > > > I think this may be Cabal's fault anyway. The yi.cabal includes the line: > > build-tools: alex >= 2.0.1 && < 3 > > > > in the 'executable yi' section, right after the build-depends, so Yi > > is being straightforward and upfront about its needs. Now, Cabal is > > obviously checking that the build-depends is satisfied first, but why > > isn't it checking that alex is available when it has the information > > it needs to check, presumably anything in build-tools is *required*, > > and the field name suggests that it would be checked? > > Yes, you're right. This is the ticket you filed last time: > > http://hackage.haskell.org/trac/hackage/ticket/227 > > and my comment: > > One problem is that not all build-tools correspond to haskell > packages. Some do some don't. We have a hard coded list of them > at the moment (which can be extended in Setup.hs files) so we > could extend that with what haskell package if any the tools > correspond to. Any better suggestions to make it a tad more > generic? > > If anyone has a godd suggestion I'm happy to hear it. Otherwise we can > just add a Maybe Dependency to the Program type to indicate that some > build tools have a corresponding haskell package. > > Duncan Well, one work-around would be to have everyone do a library/executable split for their tools. This exposes a library module and allows it to be listed in build-depends:. (This is something of a hack, but I think it has some nice effects - it's polite to allow people access to the core logic so they can try to improve on your version, and it encourages you to make the executable more of a wrapper around a library.) -- gwern benelux EIP Red CISD LUK on botux Bletchley 2E781 Connections -------------- 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/20080619/973fb6c0/attachment.bin From agl at imperialviolet.org Thu Jun 19 12:34:06 2008 From: agl at imperialviolet.org (Adam Langley) Date: Thu Jun 19 12:25:56 2008 Subject: [Haskell-cafe] Re: Bit Streams In-Reply-To: <2518b95d0806181100p4168bc22neb46dafdc3262e6e@mail.gmail.com> References: <4859493D.7070609@btinternet.com> <2518b95d0806181100p4168bc22neb46dafdc3262e6e@mail.gmail.com> Message-ID: <396556a20806190934t384e16e2je53f336f94ab32be@mail.gmail.com> On Wed, Jun 18, 2008 at 11:00 AM, Evan Laforge wrote: > Inclusion in the official Data.Binary would be nice, especially if it > could be a drop-in replacement, say by changing the Data.Binary > instance definitions to Strict.Binary or something. I have a class defined to abstract the various Get monads, i.e. you can write generic code which will work over a strict get, or an incremental (continuation based) get. I don't have the same for put yet. The trick is to make it so that it doesn't end up with any runtime cost. dons would not be happy if I took his highly tuned binary library and made it slow :) AGL -- Adam Langley agl@imperialviolet.org http://www.imperialviolet.org From agl at imperialviolet.org Thu Jun 19 12:35:15 2008 From: agl at imperialviolet.org (Adam Langley) Date: Thu Jun 19 12:27:04 2008 Subject: [Haskell-cafe] Re: Bit Streams In-Reply-To: References: <396556a20806180949u1542b803l895d8967f0762c5f@mail.gmail.com> <20080618175207.GB24043@scytale.galois.com> <396556a20806181100jdeeb0c8x98c56cfdaf734112@mail.gmail.com> Message-ID: <396556a20806190935j7c0bf35anad1856dc55639ada@mail.gmail.com> On Wed, Jun 18, 2008 at 11:07 AM, Bryan O'Sullivan wrote: > If you provide Applicative and Alternative instances for your getter > monads (perhaps you already do?) I have Alternative instances, and they're used a fair bit in my HTTP parser (network-minihttp). You're right that I should add Applicative too; maybe this weekend. AGL -- Adam Langley agl@imperialviolet.org http://www.imperialviolet.org From mfn-haskell-cafe at cs.york.ac.uk Thu Jun 19 12:50:12 2008 From: mfn-haskell-cafe at cs.york.ac.uk (Matthew) Date: Thu Jun 19 12:46:46 2008 Subject: [Haskell-cafe] (Lazy) SmallCheck and peano numbers In-Reply-To: <8341e4f40806182234w43cd1c99l64b9c2bf7e784f2@mail.gmail.com> References: <8341e4f40806182234w43cd1c99l64b9c2bf7e784f2@mail.gmail.com> Message-ID: <20080619165012.GA7049@pc149.staff.cs.york.ac.uk> Hi Levi, > so that I can muck around with a Vector type that includes its length > encoded in its type. I suppose you have some operations over these vectors, such as nil :: Vec Zero a (|>) :: a -> Vec n a -> Vec (Succ n) a If so, you could write a SmallCheck Series instance as follows. instance Serial (Vec Zero a) where series = cons0 nil instance (Serial a, Serial (Vec n a)) => Serial (Vec (Succ n) a) where series = cons2 (|>) Let's assume the earlier ops are defined as data Vec n a = V [a] nil :: Vec Zero a nil = V [] (|>) :: a -> Vec n a -> Vec (Succ n) a x |> V xs = V (x:xs) If we have the property prop_vector :: Vec (Succ (Succ Zero)) Bool -> Bool prop_vector (V xs) = xs == xs we can check it, and only 2 element vectors will be tested: *Main> smallCheck 4 prop_vector Depth 0: Completed 0 test(s) without failure. Depth 1: Completed 0 test(s) without failure. Depth 2: Completed 4 test(s) without failure. Depth 3: Completed 4 test(s) without failure. Depth 4: Completed 4 test(s) without failure. Now, it seems what you really want to do is define polymorphic properties like prop_poly :: Vec n Bool -> Vec n Bool -> Bool and have SmallCheck check all equal-sized vectors. If so, good question! :-) Anybody else? Matt. From byorgey at gmail.com Thu Jun 19 13:12:59 2008 From: byorgey at gmail.com (Brent Yorgey) Date: Thu Jun 19 13:04:49 2008 Subject: [Haskell-cafe] Re: network-related segfaults In-Reply-To: <22fcbd520806190900q7683be90x8de1d89a2e840c23@mail.gmail.com> References: <22fcbd520806190900q7683be90x8de1d89a2e840c23@mail.gmail.com> Message-ID: <22fcbd520806191012n564c652alb2aaf75ba74c3f63@mail.gmail.com> On Thu, Jun 19, 2008 at 12:00 PM, Brent Yorgey wrote: > Hi all, > > Has anyone else experienced segfaults related to network stuff? Observe: > Well, just to keep everyone updated, I suddenly remembered that cabal-install now writes log information! =D So I looked in the logs and found that I had indeed recently installed network-2.1.0.0 when trying to upgrade the urlcheck package. So I upgraded to the latest version of network (2.2.0.0) and now everything is peachy again. So, it seems that network-2.1.0.0 was the culprit... -Brent -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080619/295c09af/attachment.htm From vogt.adam at gmail.com Thu Jun 19 13:18:13 2008 From: vogt.adam at gmail.com (Adam Vogt) Date: Thu Jun 19 13:10:06 2008 Subject: [Haskell-cafe] message passing style like in Haskell? In-Reply-To: <878wx1khcj.fsf@malde.org> References: <81ea7d400806182033h40885ac5l96b415849f2d9d11@mail.gmail.com> <878wx1khcj.fsf@malde.org> Message-ID: <20080619171812.GA25606@dell> * On Thursday, June 19 2008, Ketil Malde wrote: >As a side note, may I advise you to use another symbol, and leave the >poor dot alone? Overloading it as a module separator is bad enough. >If you have a keyboard that allows greater-than-ascii input, there are >plenty of options: ? ? ? ? ? ? ? ? ?... And even if you have a plain us layout in hardware, you can use us-international layout (or whatever it is called). So we can make haskell sort of like apl... While we are kind of on this topic, what makes the characters ? ? prefix operator by default, while ? and most other odd ones infix? From derek.a.elkins at gmail.com Thu Jun 19 13:29:35 2008 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Thu Jun 19 13:22:02 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <4859FBC1.2070102@jellybean.co.uk> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <1213755981.3338.15.camel@jonathans-macbook> <7e270cea0806172136m67f5eb22o6fda46db93b49053@mail.gmail.com> <4859F46B.5060602@jellybean.co.uk> <279D0571-7E22-41C1-8F46-8FF40E12506A@cs.otago.ac.nz> <4859FBC1.2070102@jellybean.co.uk> Message-ID: <1213896576.5557.55.camel@derek-laptop> On Thu, 2008-06-19 at 07:25 +0100, Jules Bean wrote: > Richard A. O'Keefe wrote: > > The mutablity of r here really isn't a problem. Nor is the mutability > > of variables _as such_ really the problem in the PHP proposal. > > The problem is that it's the *same* variable every time. If PHP > > loops introduced new bindings on every iteration, this particular > > problem would not exist. > > Well, arguably it's not only the loop variable that can be susceptible > to this problem. There could be other variables in the loop body which > change each time through (e.g. while loops). Consider this pseudo-code > (sorry, my PHP is a bit rusty, this syntax is C really) > > char c; > > while (!eof(fp)) { > c = getChar(fp); > bind_event(... some lambda expression referencing c ...); > } > > It's pretty surprising to the programmer if all that family of lambda > expressions reference the *variable* c (and hence, in practice, its > final value) rather than the *value* c. > > Well, maybe that doesn't surprise everyone. It surprised me the first > time I used closures in Javascript and judging by a few google searches > I wasn't alone in that. Lambda abstractions should close over bindings. Full stop. The first "surprising" behaviour is the correct one. The latter would be broken. In my opinion, the reason this behaviour is "surprising" isn't mutability, but -implicit- mutability. Let's make bindings immutable, but add ML-style references to your example. char ref c = ref(undefined); while(!eof(fp)) { c := getChar(fp); bind_event( ... print !c; ... ); } compare this to while(!eof(fp)) { char c = getChar(fp); bind_event( ... print c; ...); } or while(!eof(fp)) { char ref c = ref(getChar(fp)); bind_event( ... print !c; ...); } Each of these examples makes it clearer what is going on. Admittedly, if we write a 'foreachChar' HOF, the difference between the first implementation and the last will not be apparent from the type. That's just the nature of the beast; there is simply more than one implementation. At any rate, as Richard O'Keefe stated, it's not the lambda's behaviour that needs to be documented, it's the loop's (or HOFs in general), for the iteration variables. The ones you introduce are your own concern; say what you mean. From silva.samuel at gmail.com Thu Jun 19 13:55:11 2008 From: silva.samuel at gmail.com (Samuel Silva) Date: Thu Jun 19 13:47:28 2008 Subject: [Haskell-cafe] This is a bug? Message-ID: <382ead9b0806191055k7aba616bh3ff1e527648037ca@mail.gmail.com> Hello I'm using HaXml library to handle XML. How I solve this issue when call "readXml": >in , In a sequence: > in , In a sequence: > in , Too many elements inside at > file ../../../parsers/elite2.xml at line 75 col 15 > Found excess: > > >Done. I don't understood this error. I'm using HaXml-1.19.4 with GHC-6.8.2 -- Don't hug that, Hugs ME! Samuel Silva From benjovi at gmx.net Thu Jun 19 14:00:50 2008 From: benjovi at gmx.net (Benedikt Huber) Date: Thu Jun 19 13:52:41 2008 Subject: [Haskell-cafe] Re: (Lazy) SmallCheck and peano numbers In-Reply-To: <8341e4f40806182234w43cd1c99l64b9c2bf7e784f2@mail.gmail.com> References: <8341e4f40806182234w43cd1c99l64b9c2bf7e784f2@mail.gmail.com> Message-ID: <485A9ED2.5050703@gmx.net> Levi Stephen schrieb: > Hi, > > I have the following definitions > > type Zero > type Succ a > > so that I can muck around with a Vector type that includes its length > encoded in its type. > > I was wondering whether it was possible to use SmallCheck (or > QuickCheck) to generate random Peano numbers? Is there an issue here > in that what I actually want to generate is a type rather than a > value? > > I do have > > reifyInt :: Int -> (forall a. ReflectNum a => a -> b) -> b > > but, I'm not sure if this can help me when I need to generate other > values based upon that type (e.g., two vectors with the same size > type) Hi Levi, For QuickCheck, I know it is possible as long as you do not need to use type level functions in your tests. For example, using Alfonso's type-level and parametrized-data packages, one can write: > instance (Nat n, Arbitrary a) => Arbitrary (FSVec n a) where > arbitrary = > liftM (unsafeVector (undefined :: n)) $ > mapM (const arbitrary) [1..toInt (undefined :: n)] > propLength :: forall n a. (Nat n) => FSVec n Integer -> Bool > propLength (FSVec xs) = P.length xs == toInt (undefined :: n) > propLengthEqual :: forall n a. (Nat n) => > FSVec n Integer -> FSVec n Integer -> Bool > propLengthEqual v1 v2 = length v1 == length v2 > tests1 = forM_ [0..100] $ \n -> reifyIntegral n $ \(t :: ty) -> > quickCheck (propLength :: FSVec ty Integer -> Bool) > tests2 = forM_ [0..100] $ \n -> reifyIntegral n $ \(t :: ty) -> > quickCheck (uncurry propLengthEqual :: > (FSVec ty Integer,FSVec ty Integer) -> Bool) It is also possible to reify type-level numbers with more context; I managed to get as far as (iirc) > reifyPos :: Integer -> > (forall n. (Pos n, Succ n n', DivMod10 n nd nm) => > n -> r) -> r This way you can test head, tail e.g., but I found it to be a lot of work to write additional reifications. I do not know if it is possible (I think it is not) to have a reification which allows you to use total type level functions such as Add, e.g. > tylvl = reifyIntegral? k $ \(n :: ty) -> toInt (m :: Add ty D9) > -- (D9 is the type level number 9) I'm really curious what exactly would make this possible. best regards, benedikt From jefferson.r.heard at gmail.com Thu Jun 19 14:04:03 2008 From: jefferson.r.heard at gmail.com (Jefferson Heard) Date: Thu Jun 19 13:55:53 2008 Subject: [Haskell-cafe] Wrapping FTGL in FFI calls Message-ID: <4165d3a70806191104h5b8105cfo222058cba5518bc6@mail.gmail.com> I've been looking for awhile now for a simple way to get truetype fonts into my visualizations so I can abandon the hideous GLUT fonts and make things that look like they were developed in the 1990s instead of back in the days of TRON. I found FTGL, but I'm mostly a Haskell developer these days, and resent having to go back to C just to write a simple application. So I was wondering if anyone had ever wrapped the FTGL library in Haskel FFI or whether those out there who are experts on the FFI think at first glance it should be readily wrappable by a rank amateur at FFI such as myself. http://ftgl.sourceforge.net/docs/html/ -- Jeff -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080619/5fe46a92/attachment.htm From sk at k-hornz.de Thu Jun 19 14:08:46 2008 From: sk at k-hornz.de (stefan kersten) Date: Thu Jun 19 14:01:10 2008 Subject: [Haskell-cafe] reactive and <> Message-ID: hi, i'm having problems with a very simple example using conal elliott's 'reactive' library: module Main where import Control.Applicative import Control.Concurrent import Control.Monad import Data.Reactive import System.Random main :: IO () main = do (e, snk) <- mkEvent forkIO $ forever ((getStdRandom random :: IO Double) >>= snk >> threadDelay 10000) runE (print `fmap` withPrevE e) return () which starts to output this after a while: reactive_loop.hs: <> this is with ghc 6.8.1 on osx 10.4. any ideas what might be going wrong? many thanks, From chaddai.fouche at gmail.com Thu Jun 19 14:36:05 2008 From: chaddai.fouche at gmail.com (=?ISO-8859-1?Q?Chadda=EF_Fouch=E9?=) Date: Thu Jun 19 14:27:56 2008 Subject: [Haskell-cafe] message passing style like in Haskell? In-Reply-To: <81ea7d400806182033h40885ac5l96b415849f2d9d11@mail.gmail.com> References: <81ea7d400806182033h40885ac5l96b415849f2d9d11@mail.gmail.com> Message-ID: 2008/6/19 jinjing : > encode xs = xs.group.map token where token x = (x.length, x.head) Working in this direction is a question of taste, but the choice of the dot for the operator is a pretty bad idea... On the other hand, my favourite would be : encode = map (length &&& head) . group -- Jeda? From westondan at imageworks.com Thu Jun 19 14:42:20 2008 From: westondan at imageworks.com (Dan Weston) Date: Thu Jun 19 14:34:19 2008 Subject: [Haskell-cafe] type constructor confusion In-Reply-To: <2f9b2d30806182004g6b60bb72w9a57fa5e0a9f1401@mail.gmail.com> References: <48596286.6050201@enterity.com> <4859BE33.2040008@enterity.com> <2f9b2d30806182004g6b60bb72w9a57fa5e0a9f1401@mail.gmail.com> Message-ID: <485AA88C.1000003@imageworks.com> If it helps, feel free to use a different name for the data constructors and their data type until the difference is painfully clear to you (maybe suffix the constructor with a C or prefix by Mk). Data types and constructors live in different namespaces and can happily use the same identifier. That doesn't mean you have to, if it means more work deciphering error messages. Computers would be just as happy with identifiers like g2ch_Sw'K54h (just take a look at the GHC simple core dump!), so pick ones that you yourself find perspicuous. Dan Ryan Ingram wrote: > It sounds like you need to split up your types a bit more. > > data HttpRequest = HttpRequest ... > > data HttpResponse = HttpResponse ... > > data HttpMessage = MsgRequest HttpRequest | MsgResponse HttpResponse > -- alternatively > -- type HttpMessage = Either HttpRequest HttpResponse > > Now you can have functions that take/return just an HttpRequest or > just an HttpResponse, as well as functions that use either one via > HttpMessage. In the latter case, you do need to pattern match to > decide which one you have. > > -- ryan > > > On 6/18/08, Stephen Howard wrote: >> Thanks Brandon, forgot to send my reply to the list: >> >> Ok, so I am confusing things. Good to know. So my question is how do I >> fulfill this scenario? >> >> - I have an action that might return either an HttpResponse or an >> HttpRequest, depending on if the IO in the action determined more work >> needed doing. It's here, though I doubt it's "correct" yet: >> >> requestHandler :: HttpRequest -> IO HttpResponse >> requestHandler request = do >> session <- sessionHandler request >> ret <- uriHandler request >> case ret of >> HttpResponse -> ret >> HttpRequest -> resourceHandler session ret >> >> uriHandler :: HttpRequest -> IO HttpMessage >> sessionHandler :: HttpRequest -> IO HttpSession >> >> I've given the uriHandler a signature of IO HttpMessage because the >> HttpMessage might be either an HttpResponse or an HttpRequest, and I don't >> know how I should be specifying that. Ideas? >> >> - Stephen >> >> Brandon S. Allbery KF8NH wrote: >>> On Jun 18, 2008, at 15:31 , Stephen Howard wrote: >>> >>> >>>> HttpMessage.hs:36:20: Not in scope: type constructor or class >> `HttpRequest' >>>> The troublesome line is the definition of the cookie function at the end >> of the code. I've made >>> Right. "HttpRequest" is a data constructor associated with the type >> constructor "HttpMessage". >>> (Data constructors are effectively functions; you used it in the context >> of a type, not a function name.) >>> >> _______________________________________________ >> 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 george.moschovitis at gmail.com Thu Jun 19 15:08:47 2008 From: george.moschovitis at gmail.com (George Moschovitis) Date: Thu Jun 19 15:00:39 2008 Subject: [Haskell-cafe] HDBC converting a date sql value to UTCTime Message-ID: Hello, I am HDBC with the Postgres driver. I am trying to read a simple date column from the DB: stmt <- DB.prepare conn "SELECT date FROM my_table ORDER BY date DESC LIMIT 1" DB.execute stmt [] DB.commit conn rows <- fetchAllRows' stmt let ((d:_):_) = rows the d variable is of type: SqlEpochTime 1213736400 I am wondering how to convert this value to an UTCTime value. Any help appreciated (I am a newbie). -g. -- http://gmosx.me.gr http://joy.gr http://cull.gr http://nitroproject.org http://phidz.com http://joyerz.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080619/80f35aa6/attachment.htm From jeff at renci.org Thu Jun 19 15:10:41 2008 From: jeff at renci.org (Jefferson Heard) Date: Thu Jun 19 15:02:30 2008 Subject: [Haskell-cafe] Wrapping FTGL in FFI calls In-Reply-To: <4165d3a70806191104h5b8105cfo222058cba5518bc6@mail.gmail.com> References: <4165d3a70806191104h5b8105cfo222058cba5518bc6@mail.gmail.com> Message-ID: <4165d3a70806191210t57f06235y55b068d98ce33429@mail.gmail.com> I've been looking for awhile now for a simple way to get truetype fonts into my visualizations so I can abandon the hideous GLUT fonts and make things that look like they were developed in the 1990s instead of back in the days of TRON. I found FTGL, but I'm mostly a Haskell developer these days, and resent having to go back to C just to write a simple application. So I was wondering if anyone had ever wrapped the FTGL library in Haskel FFI or whether those out there who are experts on the FFI think at first glance it should be readily wrappable by a rank amateur at FFI such as myself. http://ftgl.sourceforge.net/docs/html/ -- Jeff -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080619/643c4188/attachment.htm From byorgey at gmail.com Thu Jun 19 15:24:19 2008 From: byorgey at gmail.com (Brent Yorgey) Date: Thu Jun 19 15:16:08 2008 Subject: [Haskell-cafe] message passing style like in Haskell? In-Reply-To: <878wx1khcj.fsf@malde.org> References: <81ea7d400806182033h40885ac5l96b415849f2d9d11@mail.gmail.com> <878wx1khcj.fsf@malde.org> Message-ID: <22fcbd520806191224n3145ef92xeb5fd79be7ff0ccb@mail.gmail.com> On Thu, Jun 19, 2008 at 3:35 AM, Ketil Malde wrote: > jinjing writes: > > > Any way here's the code: > > > module Dot where > > import Prelude hiding ( (.) ) > > > (.) :: a -> (a -> b) -> b > > a . f = f a > > > infixl 9 . > > Isn't this (roughly?) the same as flip ($)? > > As a side note, may I advise you to use another symbol, and leave the > poor dot alone? Overloading it as a module separator is bad enough. > If you have a keyboard that allows greater-than-ascii input, there are > plenty of options: ? ? ? ? ? ? ? (R) ?... > Note that there already is a standard symbol for this, (>>>) from Control.Arrow. Well, actually (>>>) is more general than backwards function composition, so maybe making your own symbol is still a good idea while you're learning. -Brent -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080619/f67657f2/attachment.htm From barsoap at web.de Thu Jun 19 15:41:42 2008 From: barsoap at web.de (Achim Schneider) Date: Thu Jun 19 15:33:42 2008 Subject: [Haskell-cafe] Burn ACM Message-ID: <20080619214142.78370c4d@solaris> for monetary reasons. I just wanted my voice to be heard, you may pass on now. -- (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 duncan.coutts at worc.ox.ac.uk Thu Jun 19 15:56:46 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Jun 19 15:43:51 2008 Subject: [Haskell-cafe] cabal-install failure In-Reply-To: <006201c8cfac$1920be80$3a448351@cr3lt> References: <1213392126.15010.547.camel@localhost> <20080614021052.GA8862@craft> <1213430194.15010.556.camel@localhost> <008501c8ce05$ec0ef260$f82b8351@cr3lt> <1213559354.15010.580.camel@localhost> <006201c8cfac$1920be80$3a448351@cr3lt> Message-ID: <1213905406.15010.908.camel@localhost> On Mon, 2008-06-16 at 13:25 +0100, Claus Reinke wrote: > > The main point of the Program abstraction is about configuring and > > running programs. As it happens some programs are provided by some > > haskell packages (but not all, eg ld, ar, etc). > > > >> option to get version info and code to extract it (with one apparently > >> very special case being hsc2hs). > > > > And ld.exe on windows (we find it in ghc's gcc-lib bin dir). > > I didn't notice this special case in Program.hs - are my sources > just out of date, or is this special handling encoded elsewhere? It's in the configuration code for ghc. If it's on windows then it tries to find ld.exe relative to where ghc was found. > >> Btw, most of the version extraction code looks like a regular > >> expression match - wouldn't that make the specification easier > >> (and turn the comments into part of the spec)? > > > > True, in most cases finding the name of the program involves running it > > with some --version flag and matching some part of the output. However > > that's not always the case. Some programs do silly things like produce > > the version output on stderr instead of stdout. We figured the most > > general thing was just a function > > > > FilePath -> IO (Maybe Version) > > > > which is what we've got. I'm not sure what the advantage would be to > > make it more declarative by making it into data rather than a extraction > > function. > > Usually, the most general approach for this kind of problem is > good as a default/backup, but not so good for maintenance. The > more cases can be handled with dedicated declarative specs, the > smaller the risk of accidental/hidden breakage (eg, moving the > comments into regex patterns), the more compact and understandable > the specs (a line per tool, with option and regex, all in one place > would be easier to comprehend than the current free-coding style). So we can provide a more compact helper function for the common case bu since not all of them fit the common case we cannot change the general interface. > More importantly, concise declarative specs are easier to update > and extend (could be done by users rather than Cabal maintainers, > and preferably outside of Cabal sources). > > > Also, the Cabal lib cannot depend on any regular expression library > > because they are not part of the bootstrapping library set. > > Sigh. I've heard that one before, and the ghc-pkg bulk queries are > not as flexible as they could be because I had to use less expressive > functions instead of regexes. Since Haskell-only regex packages > exist, perhaps one should just be added to the bootlib set? After > all, we bother with regexes because they are so frequently useful. In the specific case of parsing --version strings, I'm not sure regexes are any easier. Using words and then selecting the Nth word seems to do pretty well. > >> 1. Haskell tools should register with Cabal, whether built with it > >> (such as Alex, Happy, ..) or not (such as GHC, ..). That > >> registration should include any build-relevant information > >> (versions/variants, ..). > >> > >> 2. When checking a build-tools dependency, Cabal checks > >> (a) whether the tool is registered with Cabal > > > > I'm not sure this helps. We want to know what to install when it's > > missing. We can already tell if a program (not package) is available by > > searching for it. > > But that means either configure or a subset of special configure > rules baked into Cabal's sources, combined with fragile Setup.hs > extensions to that subset. IMHO, the less of configure/hardcoded > rules/Setup.hs, the better (simpler, less breakage with Cabal > updates, etc.). > > How about this: instead of baking rules for those tools into the > Cabal sources, why not have a single "known-tools" package? > On (re-)installing that package, its configure/Setup is run once, > to register availability and build-related information for all those > tools with Cabal (currently, that would mean a package per > tool; later, the known-tools package itself could expose multiple > tools, but Cabal would still need to be able to check which of > the "exposed-tools" have been found). > > That way, the known-tools could be updated independently, > instead of requring Cabal source hacking and releases, and > instead of spreading special configure rules for common tools > over all packages, they'd be located in a single package > (easier to maintain and improve, and improvements are shared). Yeah this would be better. The same goes for things like pre-processors, but their rules are harder to express. > >> (b) whether the tool is registered with the system installation manager > > > > This is hard. > > Why? Because there are more installation managers than OSs, > or because so many program installs bypass them? Querying > an installation manager shouldn't be any more difficult than > querying ghc-pkg, say. Both. There are many of them, each with their own quirks and things installed in /usr/local. Duncan From monnier at iro.umontreal.ca Thu Jun 19 17:07:13 2008 From: monnier at iro.umontreal.ca (Stefan Monnier) Date: Thu Jun 19 16:59:07 2008 Subject: [Haskell-cafe] do and ifthenelse indentation in GHC Message-ID: http://hackage.haskell.org/trac/haskell-prime/wiki/DoAndIfThenElse says (and my memory seems to agree) that GHC has been changed to accept things like readnums f n = do eof <- hIsEOF f if eof then return n else do l <- hGetLine f readnums f (n + read l) where the `then' and `else' are aligned with the `if' rather than being slightly more indented as the Haskell 98 standard requires. Yet, when I try it with GHCi 6.8.2 I get an error: Prelude> :load "/home/monnier/tmp/foo.hs" [1 of 1] Compiling Main ( /home/monnier/tmp/foo.hs, interpreted ) /home/monnier/tmp/foo.hs:6:18: parse error (possibly incorrect indentation) Failed, modules loaded: none. Prelude> Does anybody know what's up with that? Stefan From allbery at ece.cmu.edu Thu Jun 19 17:57:18 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Thu Jun 19 17:50:04 2008 Subject: [Haskell-cafe] Gtk2Hs and GCs In-Reply-To: References: Message-ID: <5EA3C4E4-287D-4A98-B42D-D10D5A184A6C@ece.cmu.edu> On 2008 Jun 18, at 23:23, Tim Newsham wrote: > I can't seem to find any other way short of making a whole new GC > (as is done in Gtk2Hs/demos/graphic/Drawing.hs). Am I missing > something? Is there a reason the GC's arent retrievable? Join the gtk2hs list ( https://lists.sourceforge.net/lists/listinfo/gtk2hs-users ) and propose it? Duncan has told me the interface is still evolving based on user feedback. -- 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 allbery at ece.cmu.edu Thu Jun 19 18:14:33 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Thu Jun 19 18:06:27 2008 Subject: [Haskell-cafe] type constructor confusion In-Reply-To: <485A8926.7010902@enterity.com> References: <48596286.6050201@enterity.com> <4859BE33.2040008@enterity.com> <2f9b2d30806182004g6b60bb72w9a57fa5e0a9f1401@mail.gmail.com> <485A8926.7010902@enterity.com> Message-ID: <358A036F-BA04-491A-AC63-AC7735514985@ece.cmu.edu> On 2008 Jun 19, at 12:28, Stephen Howard wrote: > Cool, "Either" looks like what I'm looking for. I'll have to look > into that. What do I do about the fact that both HttpRequest and > HttpResponse have some of the same named fields (headers and body, > for example). Seems a pain to drop them into separate modules just > so I can keep the naming conventions consistent. IIRC as long as they have the same types you can use them in both. -- 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 claus.reinke at talk21.com Thu Jun 19 18:28:54 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Thu Jun 19 18:24:58 2008 Subject: [Haskell-cafe] cabal-install failure References: <1213392126.15010.547.camel@localhost> <20080614021052.GA8862@craft> <1213430194.15010.556.camel@localhost> <008501c8ce05$ec0ef260$f82b8351@cr3lt> <1213559354.15010.580.camel@localhost> <006201c8cfac$1920be80$3a448351@cr3lt> <1213905406.15010.908.camel@localhost> Message-ID: <015401c8d25c$7224d5e0$5b057ad5@cr3lt> > In the specific case of parsing --version strings, I'm not sure regexes > are any easier. Using words and then selecting the Nth word seems to do > pretty well. for comparison, see the examples below:-) There's no reason this can't be massaged further, but it already allows for IO if necessary (I like that it is compact and self-documenting -the comments have become part of the patterns, but if you don't want to match against the precise message format, you can use more of [^[:space:]]* - pity that \S* isn't posix..). Claus import Text.Regex import System.Process(runInteractiveProcess) import System.IO(hGetContents) test = mapM_ ((print =<<) . getVersion) programs getVersion (prg,flag,io,extract) = do (i,o,e,p) <- runInteractiveProcess prg [flag] Nothing Nothing version <- hGetContents ([o,e]!!(io-1)) >>= extract return (prg,version) defaultMatch :: String -> String -> IO String defaultMatch pattern = return . maybe "" head . (matchRegex (mkRegex pattern)) programs = [ghc,ghcPkg,happy,alex,haddock] ghc = ("ghc","--numeric-version",1, defaultMatch "([^[:space:]]*)") ghcPkg = ("ghc-pkg","--version",1, defaultMatch "GHC package manager version ([^[:space:]]*)") happy = ("happy","--version",1, defaultMatch "Happy Version ([^[:space:]]*)") alex = ("alex","--version",1, defaultMatch "Alex version ([.0-9]*)") haddock = ("haddock","--version",1, defaultMatch "Haddock version ([.0-9]*)") From waqner at gmx.net Thu Jun 19 18:53:19 2008 From: waqner at gmx.net (Alexander Wagner) Date: Thu Jun 19 18:45:10 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? Message-ID: <200806200053.19198.waqner@gmx.net> On Wednesday 18 June 2008, Luke Palmer wrote: > I don't know that much PHP, but I find the "lexical" keyword to be a > nuisance. What are the semantics if the lexical keyword is omitted? In PHP Variables are local by default, the keyword global defines them as references to the global namespace. There are some exceptions, like the availability of $this in methods or a couple of predefined superglobal variables that are implicitly global in all functions. Given how much it works like "global", the keyword "lexical" seems quite consistent with the style of PHP. Gesundheit Wag -- There?s a phrase we live by in America: ?In God We Trust?. It?s right there where Jesus would want it: on our money. - Steven Colbert From waqner at gmx.net Thu Jun 19 18:54:51 2008 From: waqner at gmx.net (Alexander Wagner) Date: Thu Jun 19 18:46:42 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <7ca3f0160806180750m7d2ab838s1db4bd07b9bf4b6e@mail.gmail.com> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <7ca3f0160806180750m7d2ab838s1db4bd07b9bf4b6e@mail.gmail.com> Message-ID: <200806200054.51714.waqner@gmx.net> CC to Christian Seiler http://www.haskell.org/pipermail/haskell-cafe/2008-June/044379.html http://www.haskell.org/pipermail/haskell-cafe/2008-June/thread.html On Wednesday 18 June 2008, Luke Palmer wrote: > * A closure must be able to call itself recursively (via a > higher-order function typically) I see two ways a closure might get a hold of itself, in order it can call itself: $f = function () { lexical $whatever; lexical $f; //get yourself by lexical scope return $f(); }; $f(); $g = function ($g) { //get yourself by parameter lexical $whatever; return $g($g); }; $g($g); Getting the first version to work is somewhat tricky in a non-lazy language, but it would be nice to have. The second should definately work. I guess I'll download the patch and try. > * I would recommend only saving $this in the op_array structure if the > closure actually references $this -- if that is possible to deduce at > the time. Otherwise you might run into unexpected poor memory > performances in certain cases. Agreed. A closure created inside an object should be able to outlive the object by not holding a reference to it. Since many PHP programmers put pretty much all of their functions into classes for style reasons, which would mean most closures are created in the context of an object, implicitly referencing $this might prevent a lot of objects from being garbage-collected. Also, doesn't that turn all lambdas defined inside an object into closures, which are heavier? Between always referencing $this in a lamda and requiring "lexical $this", the latter seems like the smaller evil to me. Gesundheit Wag From trebla at vex.net Thu Jun 19 18:59:23 2008 From: trebla at vex.net (Albert Y. C. Lai) Date: Thu Jun 19 18:51:15 2008 Subject: [Haskell-cafe] message passing style like in Haskell? In-Reply-To: <20080619171812.GA25606@dell> References: <81ea7d400806182033h40885ac5l96b415849f2d9d11@mail.gmail.com> <878wx1khcj.fsf@malde.org> <20080619171812.GA25606@dell> Message-ID: <485AE4CB.4080708@vex.net> Adam Vogt wrote: > While we are kind of on this topic, what makes the characters ? ? prefix > operator by default, while ? and most other odd ones infix? alphanumeric vs non-alphanumeric From levi.stephen at optusnet.com.au Thu Jun 19 20:03:57 2008 From: levi.stephen at optusnet.com.au (Levi Stephen) Date: Thu Jun 19 19:55:45 2008 Subject: [Haskell-cafe] Re: (Lazy) SmallCheck and peano numbers In-Reply-To: <8341e4f40806191630o62ed9e35q863cb3261d8b5f1c@mail.gmail.com> References: <8341e4f40806182234w43cd1c99l64b9c2bf7e784f2@mail.gmail.com> <20080619165012.GA7049@pc149.staff.cs.york.ac.uk> <8341e4f40806191630o62ed9e35q863cb3261d8b5f1c@mail.gmail.com> Message-ID: <8341e4f40806191703t2623fb42m7a96100f6324744c@mail.gmail.com> > If so, you could write a SmallCheck Series instance as follows. > > instance Serial (Vec Zero a) where > series = cons0 nil > > instance (Serial a, Serial (Vec n a)) => Serial (Vec (Succ n) a) where > series = cons2 (|>) > If we have the property > > prop_vector :: Vec (Succ (Succ Zero)) Bool -> Bool > prop_vector (V xs) = xs == xs > > we can check it, and only 2 element vectors will be tested I have some code up now at http://hpaste.org/8420 It looks pretty much like what you've written above and is what I am doing for the moment, but for various size vectors from zero to four. > Now, it seems what you really want to do is define polymorphic > properties like > > prop_poly :: Vec n Bool -> Vec n Bool -> Bool > > and have SmallCheck check all equal-sized vectors. If so, good > question! :-) Yep, this would be exactly what I'm after. Thanks for a better write up and background on what I'm after than I gave :) I'm thinking the property might be written as prop_poly:: size -> Vec size Bool -> Vec size Bool -> Bool, so that the size is generated randomly and the types take care of ensuring the vectors generated are of the same size. Levi From levi.stephen at optusnet.com.au Thu Jun 19 20:04:30 2008 From: levi.stephen at optusnet.com.au (Levi Stephen) Date: Thu Jun 19 19:56:19 2008 Subject: [Haskell-cafe] Re: (Lazy) SmallCheck and peano numbers In-Reply-To: <8341e4f40806191643h79e96cbav314ed7932f0eecee@mail.gmail.com> References: <8341e4f40806182234w43cd1c99l64b9c2bf7e784f2@mail.gmail.com> <485A9ED2.5050703@gmx.net> <8341e4f40806191643h79e96cbav314ed7932f0eecee@mail.gmail.com> Message-ID: <8341e4f40806191704y5e2f8f87v95e3805b6a3d1b85@mail.gmail.com> On Fri, Jun 20, 2008 at 3:30 AM, Benedikt Huber wrote: > Levi Stephen schrieb: >> >> Hi, >> >> I have the following definitions >> >> type Zero >> type Succ a >> >> so that I can muck around with a Vector type that includes its length >> encoded in its type. >> >> I was wondering whether it was possible to use SmallCheck (or >> QuickCheck) to generate random Peano numbers? Is there an issue here >> in that what I actually want to generate is a type rather than a >> value? >> >> I do have >> >> reifyInt :: Int -> (forall a. ReflectNum a => a -> b) -> b >> >> but, I'm not sure if this can help me when I need to generate other >> values based upon that type (e.g., two vectors with the same size >> type) > > Hi Levi, > > For QuickCheck, I know it is possible as long as you do not need to use type > level functions in your tests. For example, using Alfonso's type-level and > parametrized-data packages, one can write: > >> instance (Nat n, Arbitrary a) => Arbitrary (FSVec n a) where >> arbitrary = >> liftM (unsafeVector (undefined :: n)) $ >> mapM (const arbitrary) [1..toInt (undefined :: n)] > >> propLength :: forall n a. (Nat n) => FSVec n Integer -> Bool >> propLength (FSVec xs) = P.length xs == toInt (undefined :: n) > >> propLengthEqual :: forall n a. (Nat n) => >> FSVec n Integer -> FSVec n Integer -> Bool >> propLengthEqual v1 v2 = length v1 == length v2 > >> tests1 = forM_ [0..100] $ \n -> reifyIntegral n $ \(t :: ty) -> >> quickCheck (propLength :: FSVec ty Integer -> Bool) >> tests2 = forM_ [0..100] $ \n -> reifyIntegral n $ \(t :: ty) -> >> quickCheck (uncurry propLengthEqual :: >> (FSVec ty Integer,FSVec ty Integer) -> Bool) Thanks for the example code. Ideally it would be great to have n generated also. Any thoughts on whether something like propLengthEqual :: forall n a. (Nat n) => n -> FSVec n Integer -> FSVec n Integer -> Bool propLengthEqual _ v1 v 2 = length v1 == length v2 with an arbitrary instance for generate all Nat n's is possible? Is something like instance (forall n. Nat n) => Arbitrary n possible/legal haskell? and would it for the above test? > > best regards, > > benedikt > Thanks, Levi From derek.a.elkins at gmail.com Thu Jun 19 21:53:54 2008 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Thu Jun 19 21:47:08 2008 Subject: [Haskell-cafe] message passing style like in Haskell? In-Reply-To: <22fcbd520806191224n3145ef92xeb5fd79be7ff0ccb@mail.gmail.com> References: <81ea7d400806182033h40885ac5l96b415849f2d9d11@mail.gmail.com> <878wx1khcj.fsf@malde.org> <22fcbd520806191224n3145ef92xeb5fd79be7ff0ccb@mail.gmail.com> Message-ID: <1213926834.26144.1.camel@derek-laptop> On Thu, 2008-06-19 at 15:24 -0400, Brent Yorgey wrote: > > On Thu, Jun 19, 2008 at 3:35 AM, Ketil Malde wrote: > jinjing writes: > > > Any way here's the code: > > > module Dot where > > import Prelude hiding ( (.) ) > > > (.) :: a -> (a -> b) -> b > > a . f = f a > > > infixl 9 . > > > Isn't this (roughly?) the same as flip ($)? > > As a side note, may I advise you to use another symbol, and > leave the > poor dot alone? Overloading it as a module separator is bad > enough. > If you have a keyboard that allows greater-than-ascii input, > there are > plenty of options: ? ? ? ? ? ? ? ? ?... > > Note that there already is a standard symbol for this, (>>>) from > Control.Arrow. Well, actually (>>>) is more general than backwards > function composition, so maybe making your own symbol is still a good > idea while you're learning. Application, not composition. Cont's return would work if it weren't for the wrapping. Similarly, (>>=) for the Id monad. > From oddron at gmail.com Thu Jun 19 22:45:19 2008 From: oddron at gmail.com (Ronald Guida) Date: Thu Jun 19 22:37:08 2008 Subject: [Haskell-cafe] Haddock compilation problem Message-ID: <62728db30806191945n6e8d8835pd8bef91a658c2b7b@mail.gmail.com> I just upgraded to ghc-6.8.3, using a linux binary, and I am having a problem compiling Haddock. Haddock 2.1.0 and Haddock 2.0.0.0 both fail to build under ghc-6.8.3, but they both build successfully with ghc-6.8.2. I don't know if this is a Haddock problem, or a GHC problem, or perhaps something else entirely? Here is the error I'm getting. It is the same error for either version of Haddock. [15 of 24] Compiling Haddock.GHC.Typecheck ( src/Haddock/GHC/Typecheck.hs, dist/build/haddock/haddock-tmp/Haddock/GHC/Typecheck.o ) src/Haddock/GHC/Typecheck.hs:82:4: Constructor `HsModule' should have 7 arguments, but has been given 8 In the pattern: HsModule _ _ _ _ _ mbOpts _ _ In a pattern binding: HsModule _ _ _ _ _ mbOpts _ _ = unLoc parsed In the definition of `mkGhcModule': mkGhcModule (mod, file, checkedMod) dynflags = GhcModule {ghcModule = mod, ghcFilename = file, ghcMbDocOpts = mbOpts, ghcHaddockModInfo = info, ghcMbDoc = mbDoc, ghcGroup = group, ghcMbExports = mbExports, ghcExportedNames = modInfoExports modInfo, ghcNamesInScope = fromJust $ modInfoTopLevelScope modInfo, ghcInstances = modInfoInstances modInfo} where HsModule _ _ _ _ _ mbOpts _ _ = unLoc parsed (group, _, mbExports, mbDoc, info) = renamed (parsed, renamed, _, modInfo) = checkedMod From alistair at abayley.org Fri Jun 20 01:10:41 2008 From: alistair at abayley.org (Alistair Bayley) Date: Fri Jun 20 01:02:28 2008 Subject: [Haskell-cafe] Access to Oracle database from Haskell In-Reply-To: References: Message-ID: <79d7c4980806192210j11796038sc5008d669df926b5@mail.gmail.com> > Is there a way of accessing a remote Oracle database by one of the common > Haskell database interfaces (HaskellDB, Takusen, etc.) ? I tried to get > unixODBC and Oracle's Instant Client running on a Linux machine, but I'm > trapped in the notorious error: Takusen's Oracle backend uses the Oracle Call Interface (OCI) library directly. I think most Oracle client drivers (ODBC, ADO.Net, etc) use the OCI. I don't know what the Oracle Instant Client is; I'll assume that it includes an oci.so or liboci.so. On Windows, with which I am most familiar, the Oracle client software is all installed in $ORACLE_HOME, and the OCI library is $ORACLE_HOME/bin/oci.dll. If you can locate that, then you ought to be able to use Takusen with it. Alistair From barsoap at web.de Fri Jun 20 01:16:12 2008 From: barsoap at web.de (Achim Schneider) Date: Fri Jun 20 01:08:07 2008 Subject: [Haskell-cafe] Re: Wrapping FTGL in FFI calls References: <4165d3a70806191104h5b8105cfo222058cba5518bc6@mail.gmail.com> Message-ID: <20080620071612.12d7e6c2@solaris> "Jefferson Heard" wrote: > I've been looking for awhile now for a simple way to get truetype > fonts into my visualizations so I can abandon the hideous GLUT fonts > and make things that look like they were developed in the 1990s > instead of back in the days of TRON. I found FTGL, but I'm mostly a > Haskell developer these days, and resent having to go back to C just > to write a simple application. > > So I was wondering if anyone had ever wrapped the FTGL library in > Haskel FFI or whether those out there who are experts on the FFI > think at first glance it should be readily wrappable by a rank > amateur at FFI such as myself. > > http://ftgl.sourceforge.net/docs/html/ > Using the FFI is generally straight forward, as long as you can live with using the IO monad and the C code uses objects (well, pointers to structs passed as first argument, where's the difference...). Things only depend on the purity of the C code and how high-level you want your interface to be. In this case, I estimate half an hour if you're a fast typist. That includes the time needed to read the FFI docs. -- (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 simonpj at microsoft.com Fri Jun 20 01:50:58 2008 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Fri Jun 20 01:42:37 2008 Subject: [Haskell-cafe] Re: Meaning of "ribbonsPerLine" at Text.PrettyPrint.HughesPJ ? In-Reply-To: <485A5192.8030400@gmx.net> References: <6a7c66fc0806181313o447839et23358d5ba0523ac0@mail.gmail.com> <2518b95d0806181355r5f301c41l3321ff3437222829@mail.gmail.com> <485A5192.8030400@gmx.net> Message-ID: <638ABD0A29C8884A91BC5FB5C349B1C32AE6D38428@EA-EXMSG-C334.europe.corp.microsoft.com> Benedikt Despite the name, neither I nor John Hughes are actively maintaining this library, so if you have got some better implementations of 'cat' and 'sep', do please submit a patch. That's how it'll improve. Do test carefully! Preferably add some Quickcheck tests too. Thanks Simon | -----Original Message----- | From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe- | bounces@haskell.org] On Behalf Of Benedikt Huber | Sent: 19 June 2008 13:31 | To: Evan Laforge | Cc: haskell | Subject: [Haskell-cafe] Re: Meaning of "ribbonsPerLine" at | Text.PrettyPrint.HughesPJ ? | | Evan Laforge schrieb: | >> byorgey: fons: I can't explain it, all I know is that you must set it | >> to 1 or else it does bizarre things | >> fons: hahah, ok | >> fons: byorgey: that's funny considering its default value is 1.5 | >> byorgey: if you set it to 1 then lineLength means what you think it should | >> byorgey: fons: EXACTLY | > | > Excellent, thanks for solving a nagging problem I couldn't be bothered | > to track down. I was wondering why my pretty printing was a little | > messed up and slightly too wide. | > | > And isn't 100 columns a bit non-standard for a default? I thought 80 | > columns had more traction? I know that's what my terminals are at... | | Hi, | | The "ribbon length" is used when choosing the most beautiful layout: | I'll just summarize the relevant section from John Hughes paper | (http://www.cs.chalmers.se/~rjmh/Papers/pretty.ps), which explains it | very nicely: | | "... Using [the criterion whether the text fits on the page] alone tends | to produce layouts such as | | > for i = 1 to 100; for j=1 to 100; for k=1 to 100; a[i][j][k]:=0; | | which fits on a page {==> line-width} but cannot be described as pretty. | We therefore impose an additional constraint limiting the number of | characters on each line [==> ribbon-width} [...] | | > for i = 1 to 100 | > for j = 1 to 100 | > ... | " | | So the pretty printer tries to avoid sequences (ribbons) of characters | which are longer than ribbon_length, when using auto layout stuff like | `sep'. | | In the source code, we have (paraphrased) | | > ribbon_length = line_length / ribbonsPerLine | | and | | > choose_nicest_layout indent p q = | > if p + indent fits into line_length and p fits into ribbon_length | > then p | > else q | | Working example below. | | I'm not sure 80 characters is still standard when _pretty_-printing - | the longest line in Text.PrettyPrint.HughesPJ is 109 characters wide ;) | | Setting the ribbon ratio to 1 essentially disables the ribbon feature. | | Btw: while studying the source code, I also found the cat (and sep) can | be implemented in a more space efficient way (currently, cat needs to | evaluate every document in a list to yield some output). Does this make | sense (see below) ? | | cheers, | | benedikt | | | -- * ribbon example | | > -- lineLength = 26, ribbonsPerLine = 1.5 ==> ribbonLength = 17 | > -- therefore, we have a line break if width-indent > 17 or width > 26 | > testStyle = Style { mode = PageMode, | > lineLength = 26, | > ribbonsPerLine = 1.5 } | > ribbonTest = renderStyle testStyle $ | > | > -- use hsep as width == 17 <= ribbonLength | > sep [ txt 5, txt 11 ] | > | > -- linebreak, as width-indent = width = 18 > ribbonLength | > $+$ sep [ txt 5, txt 12 ] | > | > -- use hsep, as width - indent == 17, and width == 22 < lineLength | > $+$ sep (map (nest 5) $ [txt 5, txt 11] ) | > | > -- linebreak, as width would be 27 > lineLength | > $+$ sep (map (nest 10) $ [txt 5, txt 11] ) | > | > txt :: Int -> Doc | > txt 0 = text "" | > txt k = text $ | > let ks = show k in | > (replicate (k - (length ks)) '_') ++ ks | | | -- * lazy variants of vcat and hcat | -- you need the constructors from the HughesPJ module | | > vcat' = foldAbove . foldr vcomp2 empty | > hcat' = foldBeside . foldr hcomp2 empty | > | > foldAbove :: Doc -> Doc | > foldAbove (Above Empty _ d2) = d2 | > foldAbove (Above d1 f d2) = Above d1 f $ foldAbove d2 | > foldAbove doc = doc | > | > vcomp2 :: Doc -> Doc -> Doc | > vcomp2 d1 Empty = d1 | > -- do not match `vcomp2 Empty d1' ! | > vcomp2 d1 d2 = Above d1 False d2 | > | > foldBeside :: Doc -> Doc | > foldBeside (Beside Empty _ d2) = d2 | > foldBeside (Beside d1 f d2) = Beside d1 f $ foldBeside d2 | > foldBeside doc = doc | > | > hcomp2 :: Doc -> Doc -> Doc | > hcomp2 p Empty = p | > hcomp2 p q = Beside p False q | | _______________________________________________ | Haskell-Cafe mailing list | Haskell-Cafe@haskell.org | http://www.haskell.org/mailman/listinfo/haskell-cafe From ketil at malde.org Fri Jun 20 01:57:58 2008 From: ketil at malde.org (Ketil Malde) Date: Fri Jun 20 01:49:20 2008 Subject: [Haskell-cafe] message passing style like in Haskell? In-Reply-To: <485AE4CB.4080708@vex.net> (Albert Y. C. Lai's message of "Thu\, 19 Jun 2008 18\:59\:23 -0400") References: <81ea7d400806182033h40885ac5l96b415849f2d9d11@mail.gmail.com> <878wx1khcj.fsf@malde.org> <20080619171812.GA25606@dell> <485AE4CB.4080708@vex.net> Message-ID: <874p7ops0p.fsf@malde.org> "Albert Y. C. Lai" writes: >> While we are kind of on this topic, what makes the characters ? ? >> prefix operator by default, while ? and most other odd ones infix? > alphanumeric vs non-alphanumeric Testing this, I find that isAlpha is True also for '?', but as the OP claims, Haskell will use it as a(n infix) symbol. Neither does isSymbol (all False), isLetter (all True), isMark (False), nor isPunctuation (Fals) help to separate these. The HR defines uniSymbol -> any Unicode symbol or punctuation but I couldn't find any clear way to identify of these. -k -- If I haven't seen further, it is by standing in the footprints of giants From benjovi at gmx.net Fri Jun 20 03:37:41 2008 From: benjovi at gmx.net (Benedikt Huber) Date: Fri Jun 20 03:29:29 2008 Subject: [Haskell-cafe] Re: (Lazy) SmallCheck and peano numbers In-Reply-To: <8341e4f40806191704y5e2f8f87v95e3805b6a3d1b85@mail.gmail.com> References: <8341e4f40806182234w43cd1c99l64b9c2bf7e784f2@mail.gmail.com> <485A9ED2.5050703@gmx.net> <8341e4f40806191643h79e96cbav314ed7932f0eecee@mail.gmail.com> <8341e4f40806191704y5e2f8f87v95e3805b6a3d1b85@mail.gmail.com> Message-ID: <485B5E45.2020202@gmx.net> Levi Stephen schrieb: > On Fri, Jun 20, 2008 at 3:30 AM, Benedikt Huber wrote: >> Levi Stephen schrieb: >>> Hi, >>> >>> I have the following definitions >>> >>> type Zero >>> type Succ a >>> >>> so that I can muck around with a Vector type that includes its length >>> encoded in its type. >>> >>> I was wondering whether it was possible to use SmallCheck (or >>> QuickCheck) to generate random Peano numbers? Is there an issue here >>> in that what I actually want to generate is a type rather than a >>> value? >>> >>> I do have >>> >>> reifyInt :: Int -> (forall a. ReflectNum a => a -> b) -> b >>> >>> but, I'm not sure if this can help me when I need to generate other >>> values based upon that type (e.g., two vectors with the same size >>> type) >> Hi Levi, >> >> For QuickCheck, I know it is possible as long as you do not need to use type >> level functions in your tests. For example, using Alfonso's type-level and >> parametrized-data packages, one can write: >> >>> instance (Nat n, Arbitrary a) => Arbitrary (FSVec n a) where >>> arbitrary = >>> liftM (unsafeVector (undefined :: n)) $ >>> mapM (const arbitrary) [1..toInt (undefined :: n)] >>> propLength :: forall n a. (Nat n) => FSVec n Integer -> Bool >>> propLength (FSVec xs) = P.length xs == toInt (undefined :: n) >>> propLengthEqual :: forall n a. (Nat n) => >>> FSVec n Integer -> FSVec n Integer -> Bool >>> propLengthEqual v1 v2 = length v1 == length v2 >>> tests1 = forM_ [0..100] $ \n -> reifyIntegral n $ \(t :: ty) -> >>> quickCheck (propLength :: FSVec ty Integer -> Bool) >>> tests2 = forM_ [0..100] $ \n -> reifyIntegral n $ \(t :: ty) -> >>> quickCheck (uncurry propLengthEqual :: >>> (FSVec ty Integer,FSVec ty Integer) -> Bool) > > Thanks for the example code. Ideally it would be great to have n generated also. Generating n isn't hard, in IO above you could just use Random. But I assume you want to use QuickCheck, so see below. > Any thoughts on whether something like > > propLengthEqual :: forall n a. (Nat n) => n -> FSVec n Integer -> > FSVec n Integer -> Bool > propLengthEqual _ v1 v 2 = length v1 == length v2 > > with an arbitrary instance for generate all Nat n's is possible? propLengthEqual is exactly the same as propLength, I just left out the first argument (it is redundant). You cannot use an `Arbitrary' instance to generate some type level number, at least not in the same way as for ordinary numbers. What you can do is introduce an existential type > data SomeNat = forall n. (Nat n) => SomeNat Int n > instance Show SomeNat where show (SomeNat value typ) = show value > instance Arbitrary SomeNat where > arbitrary = sized $ \n -> reifyIntegral n (return . SomeNat n) If you look into the QuickCheck source, you'll find that a property is a result generator: newtype Property = Prop (Gen Result) So a property can be written as a result generator: > propLength' :: SomeNat -> Gen Result > propLength' (SomeNat vn (n :: t)) = do > (vector :: FSVec t Integer) <- arbitrary > buildResult [show vn , show vec] $ propLength vector -- What follows next is the neccessary boilerplate to have a working example ---- > buildResult :: [String] -> Bool -> Gen Result > buildResult args b = evaluate b >>= \r -> > return $ r { arguments = show args : arguments r} > natProp :: (SomeNat -> Gen Result) -> Property > natProp f = flip forAll id $ do > (k::Int) <- choose (0,10) > n <- resize k arbitrary > f n > deriving instance Show Result ---- Finally, run the tests > tests = verboseCheck (natProp propLength') Hope that helps. best regards, benedikt From malcolm.wallace at cs.york.ac.uk Fri Jun 20 03:56:53 2008 From: malcolm.wallace at cs.york.ac.uk (Malcolm Wallace) Date: Fri Jun 20 03:48:46 2008 Subject: [Haskell-cafe] This is a bug? In-Reply-To: <382ead9b0806191055k7aba616bh3ff1e527648037ca@mail.gmail.com> References: <382ead9b0806191055k7aba616bh3ff1e527648037ca@mail.gmail.com> Message-ID: <2C3FBC33-8658-403C-BF88-8B557167B26B@cs.york.ac.uk> > How I solve this issue when call "readXml": >> in , In a sequence: >> in , In a sequence: >> in , Too many elements inside at >> file ../../../parsers/elite2.xml at line 75 col 15 >> Found excess: So, your XML document contains a , which contains a sequence of , at least one of which contains a sequence of . But the at line 75 does not match the declared DTD. The non-conforming text appears to be pure whitespace, which does seem a little odd. This could be a bug in the HaXml parser, but it is hard to know for sure without seeing both the DTD and the failing file. Can you send them to me (not to the list)? Regards, Malcolm From david.waern at gmail.com Fri Jun 20 04:02:24 2008 From: david.waern at gmail.com (David Waern) Date: Fri Jun 20 03:54:10 2008 Subject: [Haskell-cafe] Haddock compilation problem In-Reply-To: <62728db30806191945n6e8d8835pd8bef91a658c2b7b@mail.gmail.com> References: <62728db30806191945n6e8d8835pd8bef91a658c2b7b@mail.gmail.com> Message-ID: 2008/6/20 Ronald Guida : > I just upgraded to ghc-6.8.3, using a linux binary, and I am having a > problem compiling Haddock. Haddock 2.1.0 and Haddock 2.0.0.0 both > fail to build under ghc-6.8.3, but they both build successfully with > ghc-6.8.2. I don't know if this is a Haddock problem, or a GHC > problem, or perhaps something else entirely? The current Haddock isn't compatible with GHC 6.8.3, but I think the next release will be. David From alistair at abayley.org Fri Jun 20 05:51:01 2008 From: alistair at abayley.org (Alistair Bayley) Date: Fri Jun 20 05:42:46 2008 Subject: [Haskell-cafe] Access to Oracle database from Haskell In-Reply-To: <79d7c4980806192210j11796038sc5008d669df926b5@mail.gmail.com> References: <79d7c4980806192210j11796038sc5008d669df926b5@mail.gmail.com> Message-ID: <79d7c4980806200251o6e74e409mbd993a09c835014@mail.gmail.com> 2008/6/20 Alistair Bayley : >> Is there a way of accessing a remote Oracle database by one of the common >> Haskell database interfaces (HaskellDB, Takusen, etc.) ? I tried to get >> unixODBC and Oracle's Instant Client running on a Linux machine, but I'm >> trapped in the notorious error: > > Takusen's Oracle backend uses the Oracle Call Interface (OCI) library > directly. I think most Oracle client drivers (ODBC, ADO.Net, etc) use > the OCI. I don't know what the Oracle Instant Client is; I'll assume > that it includes an oci.so or liboci.so. On Windows, with which I am > most familiar, the Oracle client software is all installed in > $ORACLE_HOME, and the OCI library is $ORACLE_HOME/bin/oci.dll. If you > can locate that, then you ought to be able to use Takusen with it. Having just taken a closer took at what Oracle Instant Client is, I suspect that you might have some trouble getting Takusen to compile against it. The Instant Client lacks header files, while Takusen's FFI imports specify oci.h. I don't know what happens if ghc can't find the header files. Oracle do state that the Instant Client is for deployment only; developers (that means you) will need the full client installation. Another problem is that the Oracle installation process assumes that, for all platforms, the library is called oci i.e. the linker option -loci is used. For Unix clients, the OCI library seems to be libclnstsh.so, so I guess it should pass -lclnstsh. This highlights the lack of testing on non-Windows platforms. If you'd like to help get this working better, perhaps we can discuss off-list. Alistair From jules at jellybean.co.uk Fri Jun 20 07:34:01 2008 From: jules at jellybean.co.uk (Jules Bean) Date: Fri Jun 20 07:25:49 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <1213896576.5557.55.camel@derek-laptop> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <1213755981.3338.15.camel@jonathans-macbook> <7e270cea0806172136m67f5eb22o6fda46db93b49053@mail.gmail.com> <4859F46B.5060602@jellybean.co.uk> <279D0571-7E22-41C1-8F46-8FF40E12506A@cs.otago.ac.nz> <4859FBC1.2070102@jellybean.co.uk> <1213896576.5557.55.camel@derek-laptop> Message-ID: <485B95A9.2090002@jellybean.co.uk> Derek Elkins wrote: > Lambda abstractions should close over bindings. Full stop. Interesting. I agree with your analysis. I don't think I agree with your conclusion. > > The first "surprising" behaviour is the correct one. The latter would > be broken. > > In my opinion, the reason this behaviour is "surprising" isn't > mutability, but -implicit- mutability. Let's make bindings immutable, > but add ML-style references to your example. > > char ref c = ref(undefined); > while(!eof(fp)) { > c := getChar(fp); > bind_event( ... print !c; ... ); > } > > compare this to > > while(!eof(fp)) { > char c = getChar(fp); > bind_event( ... print c; ...); > } > > or > > while(!eof(fp)) { > char ref c = ref(getChar(fp)); > bind_event( ... print !c; ...); > } > > Each of these examples makes it clearer what is going on. Agreed. I think where I differ on you is how to map the semantics of a C-like language to explicit references. I would argue that the glyph "c" in a C-like language denotes the value of C, not the reference to it. C-like languages have, for the most part, value semantics, and call-by-value. The exception of course is what C-like languages called "lvalues", but lvalues are only really on the left of the = sign and a few other special positions. I think that's the exception and not the rule. I think the rule is that "c" denotes the value of c, and that's why I expect a closure to capture the value, not the reference. In C, of course, if you want to capture the reference you do it explicitly with "&c". Jules From harald.rotter at sagem.com Fri Jun 20 08:01:13 2008 From: harald.rotter at sagem.com (Harald ROTTER) Date: Fri Jun 20 07:54:10 2008 Subject: [Haskell-cafe] number-parameterized types and heterogeneous lists Message-ID: Dear Haskellers, after reading Oleg Kiselyov's paper on number-parameterized types I started to play around with the class Digits that encodes decimal numbers in types. The "typed number" 10 would e.g. be defined as D1 $ D0 $ Sz I wondered if it would be possible replace the expression above by a heterogeneous list like [D1,D0] so I tried to define data Digit = forall a b.(Digits a, Digits (b a)) => Digit (a -> b a) Loading this into ghci yields: :t Digit D0 :1:0: Ambiguous type variable `a' in the constraint: `Digits a' arising from a use of `Digit' at :1:0-7 Probable fix: add a type signature that fixes these type variable(s) Removing the type constraints in the definition of "Digit": data Digit = forall a b.Digit (a -> b a) makes it work like this: :t Digit D0 Digit D0 :: Digit :t [Digit D0, Digit D1] [Digit D0, Digit D1] :: [Digit] "Digit", however, is far too general (it also includes e.g. \x -> [x]), but I would like it to be restricted to the Digit class. Any help is appreciated. Thanks Harald. CODE: module Test where data D0 a = D0 a data D1 a = D1 a data D2 a = D2 a data D3 a = D3 a data D4 a = D4 a data D5 a = D5 a data D6 a = D6 a data D7 a = D7 a data D8 a = D8 a data D9 a = D9 a class Digits ds where d2num :: Num a => ds -> a -> a data Sz = Sz -- zero size instance Digits Sz where d2num _ acc = acc instance Digits ds => Digits (D0 ds) where d2num dds acc = d2num (t22 dds) (10*acc) instance Digits ds => Digits (D1 ds) where d2num dds acc = d2num (t22 dds) (10*acc+1) instance Digits ds => Digits (D2 ds) where d2num dds acc = d2num (t22 dds) (10*acc+2) instance Digits ds => Digits (D3 ds) where d2num dds acc = d2num (t22 dds) (10*acc+3) instance Digits ds => Digits (D4 ds) where d2num dds acc = d2num (t22 dds) (10*acc+4) instance Digits ds => Digits (D5 ds) where d2num dds acc = d2num (t22 dds) (10*acc+5) instance Digits ds => Digits (D6 ds) where d2num dds acc = d2num (t22 dds) (10*acc+6) instance Digits ds => Digits (D7 ds) where d2num dds acc = d2num (t22 dds) (10*acc+7) instance Digits ds => Digits (D8 ds) where d2num dds acc = d2num (t22 dds) (10*acc+8) instance Digits ds => Digits (D9 ds) where d2num dds acc = d2num (t22 dds) (10*acc+9) t22 :: f x -> x t22 = undefined --data Digit = forall a b.(Digits a, Digits (b a)) => Digit (a -> b a) data Digit = forall a b.Digit (a -> b a) ------------------------------------------------------------------------------------------------- " Ce courriel et les documents qui y sont attaches peuvent contenir des informations confidentielles. Si vous n'etes pas le destinataire escompte, merci d'en informer l'expediteur immediatement et de detruire ce courriel ainsi que tous les documents attaches de votre systeme informatique. Toute divulgation, distribution ou copie du present courriel et des documents attaches sans autorisation prealable de son emetteur est interdite." " This e-mail and any attached documents may contain confidential or proprietary information. If you are not the intended recipient, please advise the sender immediately and delete this e-mail and all attached documents from your computer system. Any unauthorised disclosure, distribution or copying hereof is prohibited." From anton.tayanovskyy at gmail.com Fri Jun 20 09:19:01 2008 From: anton.tayanovskyy at gmail.com (Anton Tayanovskyy) Date: Fri Jun 20 09:10:47 2008 Subject: [Haskell-cafe] number-parameterized types and heterogeneous lists In-Reply-To: References: Message-ID: Hi Harald, Can you give a link to the paper? Interesting stuff. Thanks. This is stretching my abilities a bit, but is this what you are after? data Digit = forall b.(Digits (b Sz)) => Digit (Sz -> b Sz) instance Digits [Digit] where d2num [] acc = acc d2num (Digit x:xs) acc = d2num xs (10*acc + d2num (x Sz) 0) I assumed you only want D0..D9 as digits, maybe this is too narrow. I've put this up on hpaste: http://hpaste.org/8437#a1 Bests, Anton On Fri, Jun 20, 2008 at 3:01 PM, Harald ROTTER wrote: > > Dear Haskellers, > > after reading Oleg Kiselyov's paper on number-parameterized types I started > to play around with > the class Digits that encodes decimal numbers in types. The "typed number" > 10 would e.g. be defined as > > D1 $ D0 $ Sz > > I wondered if it would be possible replace the expression above by a > heterogeneous list like > > [D1,D0] > > so I tried to define > > data Digit = forall a b.(Digits a, Digits (b a)) => Digit (a -> b a) > > Loading this into ghci yields: > > :t Digit D0 > > :1:0: > Ambiguous type variable `a' in the constraint: > `Digits a' arising from a use of `Digit' at :1:0-7 > Probable fix: add a type signature that fixes these type variable(s) > > Removing the type constraints in the definition of "Digit": > > data Digit = forall a b.Digit (a -> b a) > > makes it work like this: > > :t Digit D0 > Digit D0 :: Digit > > :t [Digit D0, Digit D1] > [Digit D0, Digit D1] :: [Digit] > > "Digit", however, is far too general (it also includes e.g. \x -> [x]), but > I would like it to be restricted to the Digit class. > > Any help is appreciated. > > Thanks > > Harald. > > > CODE: > > module Test where > > data D0 a = D0 a > data D1 a = D1 a > data D2 a = D2 a > data D3 a = D3 a > data D4 a = D4 a > data D5 a = D5 a > data D6 a = D6 a > data D7 a = D7 a > data D8 a = D8 a > data D9 a = D9 a > > class Digits ds where > d2num :: Num a => ds -> a -> a > > data Sz = Sz -- zero size > instance Digits Sz where > d2num _ acc = acc > > instance Digits ds => Digits (D0 ds) where > d2num dds acc = d2num (t22 dds) (10*acc) > instance Digits ds => Digits (D1 ds) where > d2num dds acc = d2num (t22 dds) (10*acc+1) > instance Digits ds => Digits (D2 ds) where > d2num dds acc = d2num (t22 dds) (10*acc+2) > instance Digits ds => Digits (D3 ds) where > d2num dds acc = d2num (t22 dds) (10*acc+3) > instance Digits ds => Digits (D4 ds) where > d2num dds acc = d2num (t22 dds) (10*acc+4) > instance Digits ds => Digits (D5 ds) where > d2num dds acc = d2num (t22 dds) (10*acc+5) > instance Digits ds => Digits (D6 ds) where > d2num dds acc = d2num (t22 dds) (10*acc+6) > instance Digits ds => Digits (D7 ds) where > d2num dds acc = d2num (t22 dds) (10*acc+7) > instance Digits ds => Digits (D8 ds) where > d2num dds acc = d2num (t22 dds) (10*acc+8) > instance Digits ds => Digits (D9 ds) where > d2num dds acc = d2num (t22 dds) (10*acc+9) > > t22 :: f x -> x > t22 = undefined > > --data Digit = forall a b.(Digits a, Digits (b a)) => Digit (a -> b a) > data Digit = forall a b.Digit (a -> b a) > > ------------------------------------------------------------------------------------------------- > > > > " Ce courriel et les documents qui y sont attaches peuvent contenir des informations confidentielles. Si vous n'etes pas le destinataire escompte, merci d'en informer l'expediteur immediatement et de detruire ce courriel ainsi que tous les documents attaches de votre systeme informatique. Toute divulgation, distribution ou copie du present courriel et des documents attaches sans autorisation prealable de son emetteur est interdite." > > " This e-mail and any attached documents may contain confidential or proprietary information. If you are not the intended recipient, please advise the sender immediately and delete this e-mail and all attached documents from your computer system. Any unauthorised disclosure, distribution or copying hereof is prohibited." > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From neil.mehra at hutchinhill.com Fri Jun 20 09:26:13 2008 From: neil.mehra at hutchinhill.com (Neil Mehra) Date: Fri Jun 20 09:17:59 2008 Subject: [Haskell-cafe] Quantitative Trading Developer Position at Hutchin Hill Capital Message-ID: <63D404D21F135440BFF6186D9059C6C1252A5071AC@EVS-PURPLE.coloflorida.com> Job Description: Quantitative Trading Developer Description: * Newly formed multi-strategy hedge fund, Hutchin Hill Capital, located in midtown Manhattan, seeks a Quantitative Trading Developer; * Focus on building infrastructure, applications, and technical support for quantitative equity trading business; * Candidate should have demonstrated interest or passion for functional programming-with experience using Haskell, F#, Kdb+/q, OCaml, ML, and related technologies; * Position reports directly to portfolio manager, and will work closely with other technology and research professionals. Responsibilities Include: * Developing data management, quant research, and analytical tools for model-driven equity trading strategies; * Building production environment for real-time content capture, trade generation, and risk management; * Deploying equity trading technology, methods, and protocols, including electronic execution algorithms and market impact analysis; * Conducting quantitative portfolio research using cutting-edge tools and techniques. Required Experience/Education: * 2 - 5 years in IT development or quantitative analytics; * Advanced degree or equivalent experience in a technical field such as computer science, mathematics, physics, or engineering; Other Requirements: * Exceptional technical and analytical problem-solving; * Desire to master the latest technology, hardware, and quantitative methods; * Willingness to work in a fast-paced, high pressure environment; * Team-oriented and highly resourceful; * Entrepreneurial drive. Please contact quant2@hutchinhill.com with resume if interested. __________ This communication, including any attachment(s), may contain confidential and/or privileged information. If you are not the intended recipient or have received this communication in error, please destroy/delete this email and any attachments. We do not waive confidentiality or privilege by mistransmission. This communication does not constitute an offer of employment, or an offer, or the solicitation of an offer, to buy or sell any security or investment advisory services, and is not an official confirmation of any transaction. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080620/0c9de848/attachment.htm From george.moschovitis at gmail.com Fri Jun 20 09:44:38 2008 From: george.moschovitis at gmail.com (George Moschovitis) Date: Fri Jun 20 09:36:24 2008 Subject: [Haskell-cafe] Re: HDBC converting a date sql value to UTCTime In-Reply-To: References: Message-ID: Alternatively is there a way to create a UTCTime value from an epoch integer (no of seconds since epoch). I can't find a suitable constructor with Hoogle. thank you in advance, George. On Thu, Jun 19, 2008 at 10:08 PM, George Moschovitis < george.moschovitis@gmail.com> wrote: > Hello, > > I am HDBC with the Postgres driver. I am trying to read a simple date > column from the DB: > > stmt <- DB.prepare conn "SELECT date FROM my_table ORDER BY date DESC LIMIT > 1" > DB.execute stmt [] > DB.commit conn > rows <- fetchAllRows' stmt > let ((d:_):_) = rows > > the d variable is of type: > > SqlEpochTime 1213736400 > > I am wondering how to convert this value to an UTCTime value. > > Any help appreciated (I am a newbie). > > -g. > > > > -- > http://gmosx.me.gr > http://joy.gr > http://cull.gr > http://nitroproject.org > http://phidz.com > http://joyerz.com -- Walt Disney - "I love Mickey Mouse more than any woman I have ever known." -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080620/382bbbd4/attachment.htm From lemming at henning-thielemann.de Fri Jun 20 11:43:04 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri Jun 20 11:34:51 2008 Subject: [Haskell-cafe] Checking packages before upload to Hackage Message-ID: Is there some command which tests a tar.gz created by 'Setup.lhs sdist' by unpacking the archive to say /tmp and compiling and documenting the sources? Hackage should recommend this tool before package upload. From gwern0 at gmail.com Fri Jun 20 12:12:05 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Fri Jun 20 12:03:49 2008 Subject: [Haskell-cafe] Checking packages before upload to Hackage In-Reply-To: References: Message-ID: On Fri, Jun 20, 2008 at 11:43 AM, Henning Thielemann wrote: > > Is there some command which tests a tar.gz created by 'Setup.lhs sdist' by > unpacking the archive to say /tmp and compiling and documenting the sources? > Hackage should recommend this tool before package upload. There isn't. However, I do have some shell scripts which I use to the same effect. They go like this: function rh { nice runhaskell Setup "$@" --verbose; } function build { rh build "$@"; } function build_clean { rh clean && rh build "$@"; } function build_sdist { clean_configure && sdist && cd dist/ && untar *.tar.gz && cd `ls -t ./ | grep "/" | head -n 1` && clean_configure && build && hinstall; haddock && hinstall; } function clean { rh clean "$@"; } function clean_configure { clean && configure; } function configurenop { rh configure --enable-split-objs --user --prefix=$HOME/bin "$@"; } function configure { configurenop --enable-executable-profiling -p "$@"; } function haddock { rh haddock --executables "$@"; } function hinstall { rh install --user "$@"; } function sdist { rh sdist "$@"; } function haskell { ( http_proxy="" pull ) & clean_configure && (build_sdist) & } (Obviously you would either run 'haskell' or 'build_sdist' to test things out.) If you're interested in a Haskell solution, there is an open Cabal bug for this: . -- gwern From duncan.coutts at worc.ox.ac.uk Fri Jun 20 14:25:44 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Fri Jun 20 14:12:42 2008 Subject: [Haskell-cafe] Checking packages before upload to Hackage In-Reply-To: References: Message-ID: <1213986344.15010.980.camel@localhost> On Fri, 2008-06-20 at 12:12 -0400, Gwern Branwen wrote: > On Fri, Jun 20, 2008 at 11:43 AM, Henning Thielemann > wrote: > > > > Is there some command which tests a tar.gz created by 'Setup.lhs sdist' by > > unpacking the archive to say /tmp and compiling and documenting the sources? > > Hackage should recommend this tool before package upload. > If you're interested in a Haskell solution, there is an open Cabal bug > for this: . This would indeed be a very useful feature. If anyone wants to have a go at implementing it that would be great. They can ask on cabal-devel for pointers and advice. Duncan From jefferson.r.heard at gmail.com Fri Jun 20 14:25:42 2008 From: jefferson.r.heard at gmail.com (Jefferson Heard) Date: Fri Jun 20 14:17:28 2008 Subject: [Haskell-cafe] Re: Wrapping FTGL in FFI calls In-Reply-To: <20080620071612.12d7e6c2@solaris> References: <4165d3a70806191104h5b8105cfo222058cba5518bc6@mail.gmail.com> <20080620071612.12d7e6c2@solaris> Message-ID: <4165d3a70806201125r59da2dfcla9467e61e9ae7876@mail.gmail.com> Well, Achim you were almost exactly correct. I have a functional function interface in about half an hour's worth of work. I have one question, which is how to create a Ptr to four CFloats on the fly, pass them to the bounding box functions, and then come back out with a [Float] My prototype looks like this: foreign import ccall unsafe "ftglGetFontBBox" fgetFontBBox :: Font -> CString -> Ptr CFloat -> IO () the ptr to cfloat should be a float[4], which is modified inside the original C function. On Fri, Jun 20, 2008 at 1:16 AM, Achim Schneider wrote: > "Jefferson Heard" wrote: > > > I've been looking for awhile now for a simple way to get truetype > > fonts into my visualizations so I can abandon the hideous GLUT fonts > > and make things that look like they were developed in the 1990s > > instead of back in the days of TRON. I found FTGL, but I'm mostly a > > Haskell developer these days, and resent having to go back to C just > > to write a simple application. > > > > So I was wondering if anyone had ever wrapped the FTGL library in > > Haskel FFI or whether those out there who are experts on the FFI > > think at first glance it should be readily wrappable by a rank > > amateur at FFI such as myself. > > > > http://ftgl.sourceforge.net/docs/html/ > > > Using the FFI is generally straight forward, as long as you can live > with using the IO monad and the C code uses objects (well, > pointers to structs passed as first argument, where's the > difference...). > > Things only depend on the purity of the C code and how high-level you > want your interface to be. In this case, I estimate half an hour if > you're a fast typist. That includes the time needed to read the FFI > docs. > > -- > (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 > -- I try to take things like a crow; war and chaos don't always ruin a picnic, they just mean you have to be careful what you swallow. -- Jessica Edwards -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080620/39775a64/attachment.htm From jefferson.r.heard at gmail.com Fri Jun 20 14:31:43 2008 From: jefferson.r.heard at gmail.com (Jefferson Heard) Date: Fri Jun 20 14:23:30 2008 Subject: [Haskell-cafe] Re: Wrapping FTGL in FFI calls In-Reply-To: <4165d3a70806201125r59da2dfcla9467e61e9ae7876@mail.gmail.com> References: <4165d3a70806191104h5b8105cfo222058cba5518bc6@mail.gmail.com> <20080620071612.12d7e6c2@solaris> <4165d3a70806201125r59da2dfcla9467e61e9ae7876@mail.gmail.com> Message-ID: <4165d3a70806201131o4370aee7kd63d20cad5caab9@mail.gmail.com> Oh, and I should say the function I want to implement is getFontBBox :: Font -> String -> IO [Float] I do know how to marhsal/unmarshal the String. Just not the CFloat array to Haskell [Float] On Fri, Jun 20, 2008 at 2:25 PM, Jefferson Heard < jefferson.r.heard@gmail.com> wrote: > Well, Achim you were almost exactly correct. I have a functional function > interface in about half an hour's worth of work. I have one question, which > is how to create a Ptr to four CFloats on the fly, pass them to the bounding > box functions, and then come back out with a [Float] > > My prototype looks like this: > foreign import ccall unsafe "ftglGetFontBBox" fgetFontBBox :: Font -> > CString -> Ptr CFloat -> IO () > > the ptr to cfloat should be a float[4], which is modified inside the > original C function. > > > On Fri, Jun 20, 2008 at 1:16 AM, Achim Schneider wrote: > >> "Jefferson Heard" wrote: >> >> > I've been looking for awhile now for a simple way to get truetype >> > fonts into my visualizations so I can abandon the hideous GLUT fonts >> > and make things that look like they were developed in the 1990s >> > instead of back in the days of TRON. I found FTGL, but I'm mostly a >> > Haskell developer these days, and resent having to go back to C just >> > to write a simple application. >> > >> > So I was wondering if anyone had ever wrapped the FTGL library in >> > Haskel FFI or whether those out there who are experts on the FFI >> > think at first glance it should be readily wrappable by a rank >> > amateur at FFI such as myself. >> > >> > http://ftgl.sourceforge.net/docs/html/ >> > >> Using the FFI is generally straight forward, as long as you can live >> with using the IO monad and the C code uses objects (well, >> pointers to structs passed as first argument, where's the >> difference...). >> >> Things only depend on the purity of the C code and how high-level you >> want your interface to be. In this case, I estimate half an hour if >> you're a fast typist. That includes the time needed to read the FFI >> docs. >> >> -- >> (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 >> > > > > -- > I try to take things like a crow; war and chaos don't always ruin a picnic, > they just mean you have to be careful what you swallow. > > -- Jessica Edwards -- I try to take things like a crow; war and chaos don't always ruin a picnic, they just mean you have to be careful what you swallow. -- Jessica Edwards -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080620/0194ac54/attachment.htm From matti.niemenmaa+news at iki.fi Fri Jun 20 14:56:47 2008 From: matti.niemenmaa+news at iki.fi (Matti Niemenmaa) Date: Fri Jun 20 14:56:47 2008 Subject: [Haskell-cafe] Re: Haddock compilation problem In-Reply-To: <62728db30806191945n6e8d8835pd8bef91a658c2b7b@mail.gmail.com> References: <62728db30806191945n6e8d8835pd8bef91a658c2b7b@mail.gmail.com> Message-ID: Ronald Guida wrote: > I just upgraded to ghc-6.8.3, using a linux binary, and I am having a > problem compiling Haddock. Haddock 2.1.0 and Haddock 2.0.0.0 both > fail to build under ghc-6.8.3, but they both build successfully with > ghc-6.8.2. I don't know if this is a Haddock problem, or a GHC > problem, or perhaps something else entirely? > > Here is the error I'm getting. It is the same error for either > version of Haddock. > > [15 of 24] Compiling Haddock.GHC.Typecheck ( > src/Haddock/GHC/Typecheck.hs, > dist/build/haddock/haddock-tmp/Haddock/GHC/Typecheck.o ) > > src/Haddock/GHC/Typecheck.hs:82:4: > Constructor `HsModule' should have 7 arguments, but has been given 8 > In the pattern: HsModule _ _ _ _ _ mbOpts _ _ > In a pattern binding: HsModule _ _ _ _ _ mbOpts _ _ = unLoc parsed I managed to fix this with a bit of hacking: 1) add "import FastString" to the top of the file 2) remove one of the _'s before mbOpts on that line that gives the error 3) on line 72 of the original file (probably 73 after step 1), insert 'fmap unpackFS' before 'mbOpts'. I now get some sort of System.Process-related link error, though. YMMV. libHSghc.a(SysTools.o)(.text+0x7200):fake: undefined reference to `processzm1zi0zi0zi1_SystemziProcess_a6_closure' libHSghc.a(SysTools.o)(.text+0x75c5):fake: undefined reference to `processzm1zi0zi0zi1_SystemziProcess_lvl1_closure' libHSghc.a(SysTools.o)(.text+0xa6df):fake: undefined reference to `__stginit_processzm1zi0zi0zi1_SystemziProcess_' libHSghc.a(SysTools.o)(.text+0x7215):fake: undefined reference to `processzm1zi0zi0zi1_SystemziProcessziInternals_a3_info' libHSghc.a(SysTools.o)(.text+0x75d4):fake: undefined reference to `processzm1zi0zi0zi1_SystemziProcess_a8_info' libHSghc.a(SysTools.o)(.data+0xcf8):fake: undefined reference to `processzm1zi0zi0zi1_SystemziProcess_lvl1_closure' libHSghc.a(SysTools.o)(.data+0xcfc):fake: undefined reference to `processzm1zi0zi0zi1_SystemziProcess_a8_closure' libHSghc.a(SysTools.o)(.data+0xd00):fake: undefined reference to `processzm1zi0zi0zi1_SystemziProcess_a6_closure' From matti.niemenmaa+news at iki.fi Fri Jun 20 15:19:54 2008 From: matti.niemenmaa+news at iki.fi (Matti Niemenmaa) Date: Fri Jun 20 15:11:50 2008 Subject: [Haskell-cafe] Re: Haddock compilation problem In-Reply-To: References: <62728db30806191945n6e8d8835pd8bef91a658c2b7b@mail.gmail.com> Message-ID: Matti Niemenmaa wrote: > I now get some sort of System.Process-related link error, though. YMMV. Audrey Tang gave me the fix for this on the IRC channel: passing --ghc-option="-package process-1.0.0.1" dealt with that. It appears that it was all for naught, though: running the haddock binary on pretty much anything results in "Segmentation fault/access violation in generated code" or a downright crash. I suppose I'll leave this to the Haddock developers, then. From vigalchin at gmail.com Fri Jun 20 15:51:11 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Fri Jun 20 15:42:55 2008 Subject: [Haskell-cafe] another FFI question Message-ID: <5ae4f2ba0806201251v3a11188cq9ab71d44d9d996da@mail.gmail.com> Hello, I am reading the FFI spec. The following is unclear to me. Say I have data Bonzo = A | B |C and I want to "poke" Bonzo to an Int A -> 0 B -> 1 C -> 4 I have made Bonzo an instance of Storable. How do I write the poke functions and call them? Thanks, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080620/2eae9718/attachment.htm From bulat.ziganshin at gmail.com Fri Jun 20 16:20:16 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Fri Jun 20 16:13:33 2008 Subject: [Haskell-cafe] another FFI question In-Reply-To: <5ae4f2ba0806201251v3a11188cq9ab71d44d9d996da@mail.gmail.com> References: <5ae4f2ba0806201251v3a11188cq9ab71d44d9d996da@mail.gmail.com> Message-ID: <1662913902.20080621002016@gmail.com> Hello Vasili, Friday, June 20, 2008, 11:51:11 PM, you wrote: > data Bonzo = A | B |C > How do I write the poke functions and call them? instance Storable Bonzo poke A = poke 0 poke B = poke 1 poke C = poke 4 call as "poke x" probably, you don't understand differences between OOP classes and type classes. look at http://haskell.org/haskellwiki/OOP_vs_type_classes and papers mentioned there -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From jules at jellybean.co.uk Fri Jun 20 16:26:07 2008 From: jules at jellybean.co.uk (Jules Bean) Date: Fri Jun 20 16:17:53 2008 Subject: [Haskell-cafe] Re: Wrapping FTGL in FFI calls In-Reply-To: <4165d3a70806201131o4370aee7kd63d20cad5caab9@mail.gmail.com> References: <4165d3a70806191104h5b8105cfo222058cba5518bc6@mail.gmail.com> <20080620071612.12d7e6c2@solaris> <4165d3a70806201125r59da2dfcla9467e61e9ae7876@mail.gmail.com> <4165d3a70806201131o4370aee7kd63d20cad5caab9@mail.gmail.com> Message-ID: <485C125F.3010401@jellybean.co.uk> Jefferson Heard wrote: > Oh, and I should say the function I want to implement is > > getFontBBox :: Font -> String -> IO [Float] > > I do know how to marhsal/unmarshal the String. Just not the CFloat > array to Haskell [Float] import Foreign.C import Foreign.Ptr import Foreign.Marshal.Array import Control.Applicative((<$>)) oneway :: Ptr CFloat -> IO [Float] oneway p = map real2Frac <$> peekArray 4 p the other way you would probably want withArray, but I think this is the way you need? From oddron at gmail.com Fri Jun 20 16:39:15 2008 From: oddron at gmail.com (Ronald Guida) Date: Fri Jun 20 16:31:06 2008 Subject: [Haskell-cafe] Re: Haddock compilation problem In-Reply-To: References: <62728db30806191945n6e8d8835pd8bef91a658c2b7b@mail.gmail.com> Message-ID: <62728db30806201339v61706ff0v73260092b371c8b4@mail.gmail.com> I have added ticket #18 to the Haddock Trac. http://trac.haskell.org/haddock/wiki From jefferson.r.heard at gmail.com Fri Jun 20 16:42:43 2008 From: jefferson.r.heard at gmail.com (Jefferson Heard) Date: Fri Jun 20 16:34:29 2008 Subject: [Haskell-cafe] Re: Wrapping FTGL in FFI calls In-Reply-To: <485C125F.3010401@jellybean.co.uk> References: <4165d3a70806191104h5b8105cfo222058cba5518bc6@mail.gmail.com> <20080620071612.12d7e6c2@solaris> <4165d3a70806201125r59da2dfcla9467e61e9ae7876@mail.gmail.com> <4165d3a70806201131o4370aee7kd63d20cad5caab9@mail.gmail.com> <485C125F.3010401@jellybean.co.uk> Message-ID: <4165d3a70806201342n41b745e4t81051089dce38fbf@mail.gmail.com> Exactly. thanks! On Fri, Jun 20, 2008 at 4:26 PM, Jules Bean wrote: > Jefferson Heard wrote: > >> Oh, and I should say the function I want to implement is >> >> getFontBBox :: Font -> String -> IO [Float] >> >> I do know how to marhsal/unmarshal the String. Just not the CFloat array >> to Haskell [Float] >> > > import Foreign.C > import Foreign.Ptr > import Foreign.Marshal.Array > > import Control.Applicative((<$>)) > > oneway :: Ptr CFloat -> IO [Float] > oneway p = map real2Frac <$> peekArray 4 p > > the other way you would probably want withArray, but I think this is the > way you need? > > > -- I try to take things like a crow; war and chaos don't always ruin a picnic, they just mean you have to be careful what you swallow. -- Jessica Edwards -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080620/433cb556/attachment.htm From jules at jellybean.co.uk Fri Jun 20 16:43:51 2008 From: jules at jellybean.co.uk (Jules Bean) Date: Fri Jun 20 16:35:35 2008 Subject: [Haskell-cafe] Re: Wrapping FTGL in FFI calls In-Reply-To: <4165d3a70806201342n41b745e4t81051089dce38fbf@mail.gmail.com> References: <4165d3a70806191104h5b8105cfo222058cba5518bc6@mail.gmail.com> <20080620071612.12d7e6c2@solaris> <4165d3a70806201125r59da2dfcla9467e61e9ae7876@mail.gmail.com> <4165d3a70806201131o4370aee7kd63d20cad5caab9@mail.gmail.com> <485C125F.3010401@jellybean.co.uk> <4165d3a70806201342n41b745e4t81051089dce38fbf@mail.gmail.com> Message-ID: <485C1687.3070707@jellybean.co.uk> Sorry, it's "realToFrac". Typo! Jefferson Heard wrote: > Exactly. thanks! > > On Fri, Jun 20, 2008 at 4:26 PM, Jules Bean > wrote: > > Jefferson Heard wrote: > > Oh, and I should say the function I want to implement is > > getFontBBox :: Font -> String -> IO [Float] > > I do know how to marhsal/unmarshal the String. Just not the > CFloat array to Haskell [Float] > > > import Foreign.C > import Foreign.Ptr > import Foreign.Marshal.Array > > import Control.Applicative((<$>)) > > oneway :: Ptr CFloat -> IO [Float] > oneway p = map real2Frac <$> peekArray 4 p > > the other way you would probably want withArray, but I think this is > the way you need? > > > > > > -- > I try to take things like a crow; war and chaos don't always ruin a > picnic, they just mean you have to be careful what you swallow. > > -- Jessica Edwards > > > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From vigalchin at gmail.com Fri Jun 20 17:55:00 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Fri Jun 20 17:46:45 2008 Subject: [Haskell-cafe] another FFI question In-Reply-To: <1662913902.20080621002016@gmail.com> References: <5ae4f2ba0806201251v3a11188cq9ab71d44d9d996da@mail.gmail.com> <1662913902.20080621002016@gmail.com> Message-ID: <5ae4f2ba0806201455n20f6af46pa65adb664b2e78c8@mail.gmail.com> Thanks Bulat! Vasili On Fri, Jun 20, 2008 at 3:20 PM, Bulat Ziganshin wrote: > Hello Vasili, > > Friday, June 20, 2008, 11:51:11 PM, you wrote: > > data Bonzo = A | B |C > > > How do I write the poke functions and call them? > > instance Storable Bonzo > poke A = poke 0 > poke B = poke 1 > poke C = poke 4 > > call as "poke x" > > probably, you don't understand differences between OOP classes and > type classes. look at http://haskell.org/haskellwiki/OOP_vs_type_classes > and papers mentioned there > > > -- > Best regards, > Bulat mailto:Bulat.Ziganshin@gmail.com > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080620/5f873a75/attachment.htm From pieter at laeremans.org Fri Jun 20 18:04:10 2008 From: pieter at laeremans.org (Pieter Laeremans) Date: Fri Jun 20 17:55:54 2008 Subject: [Haskell-cafe] What's wrong with the classes/insances? Message-ID: HI, What 's wrong with this: type Id = String class Catalog a where listItems :: a -> IO [String] getItem :: a -> Id -> IO (Maybe String) class Item a where getCatalog :: Catalog catalog => a -> catalog data Catalog c => Content c = Content {auteur :: String, inhoud:: String, catalog::c} instance Catalog c => Item (Content c) where getCatalog (Content _ _ c) = c I get this as error from ghci: Couldn't match expected type `catalog' against inferred type `c' `catalog' is a rigid type variable bound by the type signature for `getCatalog' at ../Sites/liberaleswebsite/www.liberales.be/cgi-bin/Test.hs:16:26 `c' is a rigid type variable bound by the instance declaration at ../Sites/liberaleswebsite/www.liberales.be/cgi-bin/Test.hs:20:17 In the expression: c In the definition of `getCatalog': getCatalog (Content _ _ c) = c In the definition for method `getCatalog' Failed, modules loaded: none. thanks in advance, P -- Pieter Laeremans "The future is here. It's just not evenly distributed yet." W. Gibson From bulat.ziganshin at gmail.com Fri Jun 20 18:22:45 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Fri Jun 20 18:15:29 2008 Subject: [Haskell-cafe] What's wrong with the classes/insances? In-Reply-To: References: Message-ID: <1617672145.20080621022245@gmail.com> Hello Pieter, Saturday, June 21, 2008, 2:04:10 AM, you wrote: for me, it seems just like you directly translated OOP classes into Haskell that is the wrong way. you may look into http://haskell.org/haskellwiki/OOP_vs_type_classes and ghc user manual which discuss functional dependencies on the example of collection classes > HI, > What 's wrong with this: > type Id = String > class Catalog a where > listItems :: a -> IO [String] > getItem :: a -> Id -> IO (Maybe String) > class Item a where > getCatalog :: Catalog catalog => a -> catalog data Catalog c =>> Content c = Content {auteur :: String, inhoud:: > String, catalog::c} > instance Catalog c => Item (Content c) where > getCatalog (Content _ _ c) = c > I get this as error from ghci: > Couldn't match expected type `catalog' against inferred type `c' > `catalog' is a rigid type variable bound by > the type signature for `getCatalog' > at > ../Sites/liberaleswebsite/www.liberales.be/cgi-bin/Test.hs:16:26 > `c' is a rigid type variable bound by > the instance declaration > at > ../Sites/liberaleswebsite/www.liberales.be/cgi-bin/Test.hs:20:17 > In the expression: c > In the definition of `getCatalog': getCatalog (Content _ _ c) = c > In the definition for method `getCatalog' > Failed, modules loaded: none. > thanks in advance, > P -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From westondan at imageworks.com Fri Jun 20 18:25:48 2008 From: westondan at imageworks.com (Dan Weston) Date: Fri Jun 20 18:17:35 2008 Subject: [Haskell-cafe] What's wrong with the classes/insances? In-Reply-To: References: Message-ID: <485C2E6C.5060709@imageworks.com> I think the problem is here: > getCatalog :: Catalog catalog => a -> catalog This wants to constrain the result of getCatalog to be an instance of Catalog, but this only works for function arguments, not results. The following code does typecheck, though I have no idea what is does or if it is what you want: type Id = String class Catalog a where listItems :: a -> IO [String] getItem :: a -> Id -> IO (Maybe String) class Catalog q => Item q a where getCatalog :: a -> q data Content d = MkContent {auteur :: String, inhoud :: String, catalog :: d} instance Catalog c => Item c (Content c) where getCatalog (MkContent _ _ e) = e Pieter Laeremans wrote: > HI, > > What 's wrong with this: > > type Id = String > > class Catalog a where > listItems :: a -> IO [String] > getItem :: a -> Id -> IO (Maybe String) > > class Item a where > getCatalog :: Catalog catalog => a -> catalog > > data Catalog c => Content c = Content {auteur :: String, inhoud:: > String, catalog::c} > > instance Catalog c => Item (Content c) where > getCatalog (Content _ _ c) = c > > I get this as error from ghci: > > Couldn't match expected type `catalog' against inferred type `c' > `catalog' is a rigid type variable bound by > the type signature for `getCatalog' > at > ../Sites/liberaleswebsite/www.liberales.be/cgi-bin/Test.hs:16:26 > `c' is a rigid type variable bound by > the instance declaration > at ../Sites/liberaleswebsite/www.liberales.be/cgi-bin/Test.hs:20:17 > In the expression: c > In the definition of `getCatalog': getCatalog (Content _ _ c) = c > In the definition for method `getCatalog' > Failed, modules loaded: none. > > thanks in advance, > > P > From dan.doel at gmail.com Fri Jun 20 18:26:32 2008 From: dan.doel at gmail.com (Dan Doel) Date: Fri Jun 20 18:18:26 2008 Subject: [Haskell-cafe] What's wrong with the classes/insances? In-Reply-To: References: Message-ID: <200806201826.33689.dan.doel@gmail.com> On Friday 20 June 2008, Pieter Laeremans wrote: > type Id = String > > class Catalog a where > listItems :: a -> IO [String] > getItem :: a -> Id -> IO (Maybe String) > > class Item a where > getCatalog :: Catalog catalog => a -> catalog > > data Catalog c => Content c = Content {auteur :: String, inhoud:: > String, catalog::c} > > instance Catalog c => Item (Content c) where > getCatalog (Content _ _ c) = c > > I get this as error from ghci: > > Couldn't match expected type `catalog' against inferred type `c' > `catalog' is a rigid type variable bound by > the type signature for `getCatalog' > at > ../Sites/liberaleswebsite/www.liberales.be/cgi-bin/Test.hs:16:26 > `c' is a rigid type variable bound by > the instance declaration > at > ../Sites/liberaleswebsite/www.liberales.be/cgi-bin/Test.hs:20:17 In the > expression: c > In the definition of `getCatalog': getCatalog (Content _ _ c) = c > In the definition for method `getCatalog' > Failed, modules loaded: none. The problem is in the type of getCatalog: (Item a, Catalog catalog) => a -> catalog That type says that given the a, you can produce a value of any type 'catalog' so long as that type is an instance of Catalog. What you probably meant it to say is that you can produce *some particular* type that belongs to catalog. There are a couple ways you could express this. For instance, using functional dependencies: class Catalog cat => HasCatalog a cat | a -> cat where getCatalog :: a -> cat or the new type families: class (Catalog (Cat a)) => Item a where type Cat a :: * getCatalog :: a -> Cat a Or you could wrap catalogues in an existential type: data SomeCatalog = forall c. Catalog c => Cat c class Item a where getCatalog :: a -> SomeCatalog However, as just a word of warning, I'd say that when you run into something like this, it's probably an indication that you're structuring your program from an object oriented mindset, and that may not be the best fit for programming in Haskell (of course, it's possible an existential type or some such is the appropriate way to do things). Cheers, -- Dan From derek.a.elkins at gmail.com Fri Jun 20 18:37:23 2008 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Fri Jun 20 18:29:16 2008 Subject: [Haskell-cafe] What's wrong with the classes/insances? In-Reply-To: References: Message-ID: <1214001443.26144.10.camel@derek-laptop> On Sat, 2008-06-21 at 00:04 +0200, Pieter Laeremans wrote: > HI, > > What 's wrong with this: It looks like you think Haskell is an OO language or want it to be. It is not. > > type Id = String > > class Catalog a where > listItems :: a -> IO [String] > getItem :: a -> Id -> IO (Maybe String) > > class Item a where > getCatalog :: Catalog catalog => a -> catalog This means class Item a where getCatalog :: forall catalog. Catalog catalog => a -> catalog That means, given some Item a, I can create a value of -any- type that is an instance of Catalog. There is no well-defined function that could do that. > > data Catalog c => Content c = Content {auteur :: String, inhoud:: > String, catalog::c} > > instance Catalog c => Item (Content c) where > getCatalog (Content _ _ c) = c > > I get this as error from ghci: > > Couldn't match expected type `catalog' against inferred type `c' > `catalog' is a rigid type variable bound by > the type signature for `getCatalog' > at > ../Sites/liberaleswebsite/www.liberales.be/cgi-bin/Test.hs:16:26 > `c' is a rigid type variable bound by > the instance declaration > at ../Sites/liberaleswebsite/www.liberales.be/cgi-bin/Test.hs:20:17 > In the expression: c > In the definition of `getCatalog': getCatalog (Content _ _ c) = c > In the definition for method `getCatalog' > Failed, modules loaded: none. > > thanks in advance, > > P > From pieter at laeremans.org Fri Jun 20 18:44:13 2008 From: pieter at laeremans.org (Pieter Laeremans) Date: Fri Jun 20 18:35:57 2008 Subject: [Haskell-cafe] What's wrong with the classes/insances? In-Reply-To: <200806201826.33689.dan.doel@gmail.com> References: <200806201826.33689.dan.doel@gmail.com> Message-ID: Thanks all! I have to admit, I have an OO mndset :-). I think I have found a more "functional design" : import Text.StringTemplate.Classes import Text.StringTemplate data (ToSElem a) => Item a b = Item {cargo::a , catalog :: (Catalog a b)} instance (ToSElem a) => ToSElem (Item a b) where toSElem = (toSElem . cargo) type Id = String type ItemToSelem a b = Item a b -> SElem b type ItemParser a b = String -> Item a b type AllItemReader a b = IO [Item a b] type SingleItemReader a b = Id -> IO (Item a b) data Catalog a b = Catalog {reader:: (AllItemReader a b), singleReader ::( SingleItemReader a b)} data Content = Content {authort :: String, text:: String} type ContentItem = Item Content String What I want to express is that there exists differnet kinds of catalogs which, depending on how they are configured can read from a file system or a database. And each catalog can contain a specific type of Item. For each Item I have to be able to produce the toSELem representation that subsequently can be used by HStringTemplate I thik that means I could declare On Sat, Jun 21, 2008 at 12:26 AM, Dan Doel wrote: > On Friday 20 June 2008, Pieter Laeremans wrote: >> type Id = String >> >> class Catalog a where >> listItems :: a -> IO [String] >> getItem :: a -> Id -> IO (Maybe String) >> >> class Item a where >> getCatalog :: Catalog catalog => a -> catalog >> >> data Catalog c => Content c = Content {auteur :: String, inhoud:: >> String, catalog::c} >> >> instance Catalog c => Item (Content c) where >> getCatalog (Content _ _ c) = c >> >> I get this as error from ghci: >> >> Couldn't match expected type `catalog' against inferred type `c' >> `catalog' is a rigid type variable bound by >> the type signature for `getCatalog' >> at >> ../Sites/liberaleswebsite/www.liberales.be/cgi-bin/Test.hs:16:26 >> `c' is a rigid type variable bound by >> the instance declaration >> at >> ../Sites/liberaleswebsite/www.liberales.be/cgi-bin/Test.hs:20:17 In the >> expression: c >> In the definition of `getCatalog': getCatalog (Content _ _ c) = c >> In the definition for method `getCatalog' >> Failed, modules loaded: none. > > The problem is in the type of getCatalog: > > (Item a, Catalog catalog) => a -> catalog > > That type says that given the a, you can produce a value of any type 'catalog' > so long as that type is an instance of Catalog. > > What you probably meant it to say is that you can produce *some particular* > type that belongs to catalog. There are a couple ways you could express this. > For instance, using functional dependencies: > > class Catalog cat => HasCatalog a cat | a -> cat where > getCatalog :: a -> cat > > or the new type families: > > class (Catalog (Cat a)) => Item a where > type Cat a :: * > getCatalog :: a -> Cat a > > Or you could wrap catalogues in an existential type: > > data SomeCatalog = forall c. Catalog c => Cat c > > class Item a where > getCatalog :: a -> SomeCatalog > > However, as just a word of warning, I'd say that when you run into something > like this, it's probably an indication that you're structuring your program > from an object oriented mindset, and that may not be the best fit for > programming in Haskell (of course, it's possible an existential type or some > such is the appropriate way to do things). > > Cheers, > -- Dan > -- Pieter Laeremans "The future is here. It's just not evenly distributed yet." W. Gibson From wren at freegeek.org Fri Jun 20 18:49:17 2008 From: wren at freegeek.org (wren ng thornton) Date: Fri Jun 20 18:41:04 2008 Subject: [Haskell-cafe] What's wrong with the classes/insances? In-Reply-To: References: Message-ID: <485C33ED.8010301@freegeek.org> Pieter Laeremans wrote: > HI, > > What 's wrong with this: > > [...] > > class Item a where > getCatalog :: Catalog catalog => a -> catalog This is a shorthand for > class Item a where > getCatalog :: forall c. (Catalog c) => a -> c That is, the class provides the contract that given some value of type a it will be able to return *any* type c which adheres to the contract of the class Catalog. This function is polymorphic in the return type. > instance Catalog c => Item (Content c) where > getCatalog (Content _ _ c) = c The problem is, here you're returning a *specific* type c which adheres to Catalog. What happens if the caller of getCatalog is expecting some other type (Catalog c') => c' or (Catalog c'') => c'' etc? There are a few different solutions you could take. The easiest one is to use multi-parameter type classes and functional dependencies to define Item like so: > class Item a c | a -> c where > getCatalog :: (Catalog c) => a -> c This says that for any given type a there is one particular type c which getCatalog returns. Depending on your goals this may be enough, but if you really want getCatalog to be polymorphic in c then it won't work. (If you only want to be, er, multimorphic in c then you can leave out the fundep and define instances for each a*c type pair. This can lead to needing to declare excessively many type signatures however.) If you really want to be able to return any c then there are a couple of approaches you could take. First is to add a conversion function to the Catalog class: > class Catalog c where > ... > convertCatalog:: forall c'. (Catalog c') => c -> c' Given the rest of the definition for Catalog, this looks to be eminently doable-- at least in as far as people don't try to access any other fiddly bits inside the value c'. Of course this gives no way of preventing them from trying to do that fiddling, which leads to... The other common approach is to use existential types to wrap values up with their class dictionaries like so: > data CatalogWrapper = forall c. (Catalog c) => CatalogWrapper c In this case you'd have getCatalog return a CatalogWrapper instead of a (Catalog c) => c. If you're not familiar with existential types they can be harder to think about since they loose information about what type you actually have inside; once wrapped they're only ever accessible by the methods of type classes restricting what we can wrap. But if you want to restrict people to only ever using the Catalog interface to manipulate them, then this is exactly what you want. -- Live well, ~wren From kangas at math.ku.edu Fri Jun 20 19:15:20 2008 From: kangas at math.ku.edu (George Kangas) Date: Fri Jun 20 19:07:03 2008 Subject: [Haskell-cafe] Pretty little definitions of left and right folds Message-ID: <485C3A08.8070302@math.ku.edu> Hi, Cafe, For no practical purpose, I wrote new definitions of list folds as chains of partially applied functions, joined by composition. I took the liberty of rearranging the type signature. > foldright :: (a -> b -> b)) -> [a] -> b -> b > foldright f = chain where > chain (a:as) = (f a).(chain as) > chain _ = id > foldleft :: (a -> b -> b) -> [a] -> b -> b > foldleft f = chain where > chain (a:as) = (chain as).(f a) > chain _ = id These definitions are point free, with respect to the "initializer" argument (which is now the last argument). Also, you can see how similar they are to each other, with the difference boiling down to the order of the composition, e.g.: foldright (+) [1, 2, 3] 0 == ( (1 +).(2 +).(3 +).id ) 0 foldleft (+) [1, 2, 3] 0 == ( id.(3 +).(2 +).(1 +) ) 0 We can also see the following identities: foldright f as == foldright (.) (map f as) id foldleft f as == foldright (flip (.)) (map f as) id I like that second one, after trying to read another definition of left fold in terms of right fold (in the web book "Real World Haskell"). The type signature, which could be written (a -> (b -> b)) -> ([a] -> (b -> b)), suggests generalization to another type constructor C: (a -> (b -> b)) -> (C a -> (b -> b)). Would a "foldable" typeclass make any sense? Okay, it goes without saying that this is useless dabbling, but have I entertained anyone? Or have I just wasted your time? I eagerly await comments on this, my first posting. very truly yours, George Kangas From allbery at ece.cmu.edu Fri Jun 20 19:21:25 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Fri Jun 20 19:13:14 2008 Subject: [Haskell-cafe] Pretty little definitions of left and right folds In-Reply-To: <485C3A08.8070302@math.ku.edu> References: <485C3A08.8070302@math.ku.edu> Message-ID: <555BB226-AF91-4EEA-B109-90702F3769D2@ece.cmu.edu> On 2008 Jun 20, at 19:15, George Kangas wrote: > The type signature, which could be written (a -> (b -> b)) -> ([a] - > > (b -> b)), suggests generalization to another type constructor C: > (a -> (b -> b)) -> (C a -> (b -> b)). Would a "foldable" typeclass > make any sense? http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data-Foldable.html -- 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 stevelihn at gmail.com Fri Jun 20 20:44:16 2008 From: stevelihn at gmail.com (Steve Lihn) Date: Fri Jun 20 20:36:00 2008 Subject: [Haskell-cafe] Access to Oracle database from Haskell In-Reply-To: References: Message-ID: You may want to check this out. http://www.orafaq.com/wiki/ODBC_FAQ#Where_can_one_get_ODBC_drivers_for_Oracle_and_Rdb.3F As Oracle is a commercial company who is not interested in open source historically, it is little chance that you will get robust software for free -- from someone with many years of Oracle DBA experience :-) On 6/19/08, Henning Thielemann wrote: > > Is there a way of accessing a remote Oracle database by one of the common > Haskell database interfaces (HaskellDB, Takusen, etc.) ? I tried to get > unixODBC and Oracle's Instant Client running on a Linux machine, but I'm > trapped in the notorious error: > > $ isql USER -v > [IM004][unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV > failed > [ISQL]ERROR: Could not SQLConnect > > This error message is discussed in various web forums, but there seems to be > no systematic way to track down the problem. So I wonder whether there is > another way to access the Oracle data base from Haskell. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From byorgey at seas.upenn.edu Fri Jun 20 22:31:17 2008 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Fri Jun 20 22:22:59 2008 Subject: [Haskell-cafe] Pretty little definitions of left and right folds In-Reply-To: <485C3A08.8070302@math.ku.edu> References: <485C3A08.8070302@math.ku.edu> Message-ID: <20080621023117.GA2741@minus.seas.upenn.edu> On Fri, Jun 20, 2008 at 06:15:20PM -0500, George Kangas wrote: > > foldright (+) [1, 2, 3] 0 == ( (1 +).(2 +).(3 +).id ) 0 > foldleft (+) [1, 2, 3] 0 == ( id.(3 +).(2 +).(1 +) ) 0 > Hi George, This is very cool! I have never thought of folds in quite this way before. It makes a lot of things (such as the identities you point out) obvious and elegant. > We can also see the following identities: > > foldright f as == foldright (.) (map f as) id > foldleft f as == foldright (flip (.)) (map f as) id > > I like that second one, after trying to read another definition of > left fold in terms of right fold (in the web book "Real World Haskell"). > > The type signature, which could be written (a -> (b -> b)) -> ([a] -> > (b -> b)), suggests generalization to another type constructor C: (a -> > (b -> b)) -> (C a -> (b -> b)). Would a "foldable" typeclass make any > sense? As Brandon points out, you have rediscovered Data.Foldable. =) There's nothing wrong with that, congratulations on discovering it for yourself! But again, I like this way of organizing the type signature: I had never thought of a fold as a sort of 'lift' before. If f :: a -> b -> b, then foldright 'lifts' f to foldright f :: [a] -> b -> b (or C a -> b -> b, more generally). > Okay, it goes without saying that this is useless dabbling, but have > I entertained anyone? Or have I just wasted your time? I eagerly await > comments on this, my first posting. Not at all! Welcome, and thanks for posting. -Brent From derek.a.elkins at gmail.com Fri Jun 20 22:52:36 2008 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Fri Jun 20 22:44:23 2008 Subject: [Haskell-cafe] Pretty little definitions of left and right folds In-Reply-To: <20080621023117.GA2741@minus.seas.upenn.edu> References: <485C3A08.8070302@math.ku.edu> <20080621023117.GA2741@minus.seas.upenn.edu> Message-ID: <1214016756.26144.15.camel@derek-laptop> On Fri, 2008-06-20 at 22:31 -0400, Brent Yorgey wrote: > On Fri, Jun 20, 2008 at 06:15:20PM -0500, George Kangas wrote: > > > > foldright (+) [1, 2, 3] 0 == ( (1 +).(2 +).(3 +).id ) 0 > > foldleft (+) [1, 2, 3] 0 == ( id.(3 +).(2 +).(1 +) ) 0 > > > > Hi George, > > This is very cool! I have never thought of folds in quite this way > before. It makes a lot of things (such as the identities you point > out) obvious and elegant. > > > We can also see the following identities: > > > > foldright f as == foldright (.) (map f as) id > > foldleft f as == foldright (flip (.)) (map f as) id > > > > I like that second one, after trying to read another definition of > > left fold in terms of right fold (in the web book "Real World Haskell"). > > > > The type signature, which could be written (a -> (b -> b)) -> ([a] -> > > (b -> b)), suggests generalization to another type constructor C: (a -> > > (b -> b)) -> (C a -> (b -> b)). Would a "foldable" typeclass make any > > sense? > > As Brandon points out, you have rediscovered Data.Foldable. =) There's > nothing wrong with that, congratulations on discovering it for > yourself! But again, I like this way of organizing the type > signature: I had never thought of a fold as a sort of 'lift' before. > If f :: a -> b -> b, then foldright 'lifts' f to foldright f :: [a] -> > b -> b (or C a -> b -> b, more generally). > > > Okay, it goes without saying that this is useless dabbling, but have > > I entertained anyone? Or have I just wasted your time? I eagerly await > > comments on this, my first posting. > > Not at all! Welcome, and thanks for posting. Look into the theory of monoids, monoid homomorphisms, M-sets and free monoids. From vigalchin at gmail.com Fri Jun 20 23:52:06 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Fri Jun 20 23:43:50 2008 Subject: [Haskell-cafe] another FFI question In-Reply-To: <1662913902.20080621002016@gmail.com> References: <5ae4f2ba0806201251v3a11188cq9ab71d44d9d996da@mail.gmail.com> <1662913902.20080621002016@gmail.com> Message-ID: <5ae4f2ba0806202052w143dc215x281a1faa4884ec@mail.gmail.com> I am still reading the web pages. Here is what I tried: data SigNotify = Signal | None | Thread | ThreadId instance Storable SigNotify where sizeOf _ = (#const sizeof (int)) alignment _ = 1 poke Signal = (#const SIGEV_SIGNAL) poke None = poke (#const SIGEV_NONE) poke Thread = poke (#const SIGEV_THREAD) poke ThreadId = poke (#const SIGEV_THREAD_ID) but I got ... Couldn't match expected type `Ptr SigNotify' against inferred type `SigNotify' In the pattern: Signal In the definition of `poke': poke Signal = poke (0) In the definition for method `poke' Basically I want to marshall SigInfo constructors to CInt values. ?? Regards, Vasili On Fri, Jun 20, 2008 at 3:20 PM, Bulat Ziganshin wrote: > Hello Vasili, > > Friday, June 20, 2008, 11:51:11 PM, you wrote: > > data Bonzo = A | B |C > > > How do I write the poke functions and call them? > > instance Storable Bonzo > poke A = poke 0 > poke B = poke 1 > poke C = poke 4 > > call as "poke x" > > probably, you don't understand differences between OOP classes and > type classes. look at http://haskell.org/haskellwiki/OOP_vs_type_classes > and papers mentioned there > > > -- > Best regards, > Bulat mailto:Bulat.Ziganshin@gmail.com > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080620/8c4ab5dd/attachment.htm From lanny at cisco.com Sat Jun 21 01:42:25 2008 From: lanny at cisco.com (Lanny Ripple) Date: Sat Jun 21 01:33:48 2008 Subject: [Haskell-cafe] Access to Oracle database from Haskell In-Reply-To: References: Message-ID: <485C94C1.6030006@cisco.com> I had luck with this the other day using Database.HDBC.ODBC. For Ubuntu's Hardy I found that Oracle's 10.2.0.3 worked best. (10.2.0.4 and 11 seemed to have problems for me at least.) http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html Grab the basic (not basic-lite), odbc, and sqlplus (to test) zips. The odbc_update_ini.sh should be run from inside the instantclient_10_2 directory as root sudo /bin/sh odbc_update_ini.sh / (assuming a standard unixODBC install.) You'll also need a tnsnames.ora file to describe your connection(s) to the DB(s). You'll also need to define some environment variables to run against all this. I use a small script: #!/bin/sh oracle_home=/opt/lib/oracle/instantclient_10_2 export TNS_ADMIN=$oracle_home export LD_LIBRARY_PATH=$oracle_home [ $# = 0 ] && exit 1 exec "$@" Best of luck, -ljr Steve Lihn wrote: > You may want to check this out. > > http://www.orafaq.com/wiki/ODBC_FAQ#Where_can_one_get_ODBC_drivers_for_Oracle_and_Rdb.3F > > As Oracle is a commercial company who is not interested in open source > historically, it is little chance that you will get robust software > for free -- from someone with many years of Oracle DBA experience :-) > > > On 6/19/08, Henning Thielemann wrote: >> Is there a way of accessing a remote Oracle database by one of the common >> Haskell database interfaces (HaskellDB, Takusen, etc.) ? I tried to get >> unixODBC and Oracle's Instant Client running on a Linux machine, but I'm >> trapped in the notorious error: >> >> $ isql USER -v >> [IM004][unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV >> failed >> [ISQL]ERROR: Could not SQLConnect >> >> This error message is discussed in various web forums, but there seems to be >> no systematic way to track down the problem. So I wonder whether there is >> another way to access the Oracle data base from Haskell. >> _______________________________________________ >> 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 jules at jellybean.co.uk Sat Jun 21 04:47:14 2008 From: jules at jellybean.co.uk (Jules Bean) Date: Sat Jun 21 04:38:57 2008 Subject: [Haskell-cafe] Re: HDBC converting a date sql value to UTCTime In-Reply-To: References: Message-ID: <485CC012.4080906@jellybean.co.uk> George Moschovitis wrote: > Alternatively is there a way to create a UTCTime value from an epoch > integer (no of seconds since epoch). > I can't find a suitable constructor with Hoogle. http://www.haskell.org/ghc/docs/latest/html/libraries/time/Data-Time-Clock-POSIX.html posixSecondsToUTCTime probably in combination with fromIntegral Jules From p.f.moore at gmail.com Sat Jun 21 07:18:29 2008 From: p.f.moore at gmail.com (Paul Moore) Date: Sat Jun 21 07:10:11 2008 Subject: [Haskell-cafe] Access to Oracle database from Haskell In-Reply-To: <79d7c4980806200251o6e74e409mbd993a09c835014@mail.gmail.com> References: <79d7c4980806192210j11796038sc5008d669df926b5@mail.gmail.com> <79d7c4980806200251o6e74e409mbd993a09c835014@mail.gmail.com> Message-ID: <79990c6b0806210418r5376fc80j8eceef9f9663468d@mail.gmail.com> 2008/6/20 Alistair Bayley : > Having just taken a closer took at what Oracle Instant Client is, I > suspect that you might have some trouble getting Takusen to compile > against it. The Instant Client lacks header files, while Takusen's FFI > imports specify oci.h. I don't know what happens if ghc can't find the > header files. Oracle do state that the Instant Client is for > deployment only; developers (that means you) will need the full client > installation. There's an additional download for the Instant Client which includes the OCI headers. Paul. From stevelihn at gmail.com Sat Jun 21 09:49:25 2008 From: stevelihn at gmail.com (Steve Lihn) Date: Sat Jun 21 09:41:07 2008 Subject: [Haskell-cafe] Access to Oracle database from Haskell In-Reply-To: <79990c6b0806210418r5376fc80j8eceef9f9663468d@mail.gmail.com> References: <79d7c4980806192210j11796038sc5008d669df926b5@mail.gmail.com> <79d7c4980806200251o6e74e409mbd993a09c835014@mail.gmail.com> <79990c6b0806210418r5376fc80j8eceef9f9663468d@mail.gmail.com> Message-ID: Oracle OCI interface is quite different between 7/8 and 9/10. And 10 is different from 9 in some respect. I don't know much about 11. Oracle 10.2.0.3 is a stable release, but there are some major server bugs in it, that Oracle had to release 10.2.0.4. I'd recommend Haskell community to focus on 10.2.0.x release. It should be good for another 2-3 years. It is too risky to venture into 11. That said, there is a large enterprise user base that will find Haskell useful if it works with Oracle DB (particularly on linux). On 6/21/08, Paul Moore wrote: > 2008/6/20 Alistair Bayley : > > Having just taken a closer took at what Oracle Instant Client is, I > > suspect that you might have some trouble getting Takusen to compile > > against it. The Instant Client lacks header files, while Takusen's FFI > > imports specify oci.h. I don't know what happens if ghc can't find the > > header files. Oracle do state that the Instant Client is for > > deployment only; developers (that means you) will need the full client > > installation. > > There's an additional download for the Instant Client which includes > the OCI headers. > > Paul. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From trifod at gmail.com Sat Jun 21 11:38:37 2008 From: trifod at gmail.com (trifod@gmail.com) Date: Sat Jun 21 11:30:19 2008 Subject: [Haskell-cafe] an example from YAHT doesn't run In-Reply-To: <1e8d59210806181227x1e6f5d8and846421a9164b6dc@mail.gmail.com> References: <1e8d59210806181227x1e6f5d8and846421a9164b6dc@mail.gmail.com> Message-ID: <1e8d59210806210838i579bdfcfh789571b0089d1499@mail.gmail.com> Hello, On pdf page 43 of YAHT it provides a code example. I typed this into a file named "Guess.hs" and tried unsuccessfully to load it into ghci. I am running ghci version 6.8.2 This is the output it gave me: " [1 of 1] Compiling Main ( Guess.hs, interpreted ) Guess.hs:19:12: parse error on input `doGuessing' Failed, modules loaded: none. " I've attached the code module. As far as I can tell it is identical to the example in YAHT. Did I type it wrong, is the tutorial wrong, or something else? thanks again, Jared Langson -------------- next part -------------- A non-text attachment was scrubbed... Name: Guess.hs Type: application/octet-stream Size: 543 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080621/289f0d7a/Guess.obj From tanimoto at arizona.edu Sat Jun 21 11:48:41 2008 From: tanimoto at arizona.edu (Paulo Tanimoto) Date: Sat Jun 21 11:40:23 2008 Subject: [Haskell-cafe] an example from YAHT doesn't run In-Reply-To: <1e8d59210806210838i579bdfcfh789571b0089d1499@mail.gmail.com> References: <1e8d59210806181227x1e6f5d8and846421a9164b6dc@mail.gmail.com> <1e8d59210806210838i579bdfcfh789571b0089d1499@mail.gmail.com> Message-ID: Hi Jared, 2008/6/21 : > Guess.hs:19:12: parse error on input `doGuessing' > > Failed, modules loaded: none. " That says there's something wrong at line 19. In this case, 'doGuessing' is not properly aligned with 'putStrLn' of the previous line. The same happens at line 22. See if that helps and double-check the rules of indentation. : ) Paulo From matti.niemenmaa+news at iki.fi Sat Jun 21 12:08:57 2008 From: matti.niemenmaa+news at iki.fi (Matti Niemenmaa) Date: Sat Jun 21 12:00:55 2008 Subject: [Haskell-cafe] ANNOUNCE: Pipe 1.0 Message-ID: Greetings, I hereby announce the release of the Pipe library, a library for piping data through a pipeline of processes. A web page with (hopefully) all the necessary info and a simple example can be found at http://iki.fi/matti.niemenmaa/pipe/ The package is at Hackage: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Pipe Feel free to comment on any part of it, either here or straight to my e-mail address. I've tested it on Windows XP and Linux (Gentoo) and GHC 6.8.2 and 6.8.3. Since the code is rather low-level it'd be interesting to hear whether it works on other systems, say the BSDs or OS X. -- Matti Niemenmaa From igloo at earth.li Sat Jun 21 13:10:28 2008 From: igloo at earth.li (Ian Lynagh) Date: Sat Jun 21 13:02:13 2008 Subject: [Haskell-cafe] message passing style like in Haskell? In-Reply-To: <874p7ops0p.fsf@malde.org> References: <81ea7d400806182033h40885ac5l96b415849f2d9d11@mail.gmail.com> <878wx1khcj.fsf@malde.org> <20080619171812.GA25606@dell> <485AE4CB.4080708@vex.net> <874p7ops0p.fsf@malde.org> Message-ID: <20080621171028.GA1077@matrix.chaos.earth.li> On Fri, Jun 20, 2008 at 07:57:58AM +0200, Ketil Malde wrote: > "Albert Y. C. Lai" writes: > > >> While we are kind of on this topic, what makes the characters ? ? > >> prefix operator by default, while ? and most other odd ones infix? > > > alphanumeric vs non-alphanumeric > > Testing this, I find that isAlpha is True also for '?', but as the OP > claims, Haskell will use it as a(n infix) symbol. This is a bug in GHC. The characters <= '\255' were done specially, but incorrectly for many of those >= '\128'. I'll fix it, probably by just removing the specialisation for them. Thanks Ian From blais at furius.ca Sat Jun 21 14:18:54 2008 From: blais at furius.ca (Martin Blais) Date: Sat Jun 21 13:18:13 2008 Subject: [Haskell-cafe] Literal programming in Haskell with rst-literals Message-ID: <20080621181854.184193C8002@banane.furius.ca> Hello Haskell community! I just did a marginally cool thing and I wanted to share it with you. "rst-literals" is a small program I wrote a while ago in order to write documents in reStructuredText format that would embed SQL code for data models in them, a form of literal programming for SQL if you will; I would describe my needs for the schema in prose, and reST literal-blocks were used to embed SQL code, blocks that look like this:: CLASS Employee ( firstname VARCHAR, lastname VARCHAR ) I wrote the script to be entirely generic: it parses the reST documents using the docutils code and outputs only the literal-blocks, with indentation removed; you can then run your favourite interpreter/compiler on the result (in that case, psql to initialize a database). Recently, while experimenting with Haskell, I started using both the literal (.lhs) and non-literal (.hs) styles of Haskell input, and I found the literal style a bit unpleasant to use, in particular, I don't like to have to prefix every line of code I write, despite the help that Emacs' haskell-mode provides. So I tried pulling a similar trick and embedding Haskell code in literal-blocks within reST documents, extracting that code using rst-literals, and it turns out that it works like a charm. Here is an example makefile for doing this:: .SUFFIXES: .rst .hs all: chap6 .rst.hs: rst-literals $< > $@ chap6: chap6.hs ghc --make chap6.hs An example reST document with some embedded Haskell code follows this email. Note that since rst-literals is using the docutils parser, you can make use of all of the recursive reST syntax, sections, bulleted items and much more. Only the literal-blocks are extracted, anywhere they appear. You can also easily process the reST source into HTML pages or LaTeX documents using the tools that come with docutils. You can find rst-literals here: http://furius.ca/pubcode/ Enjoy, -- Martin P.S. If there is a way to output cpp-like directives for GHC, like "#line ", it would be easy to modify rst-literals to generate those, so that compilation errors could refer to the source reST document instead of the extracted source. chap6.hs: ---------------------------------------------------------------------- =========================================== Exercises from Hutton book, Chapter 6 =========================================== .. contents:: .. 1 Introduction 2 Exercise 1 3 Exercise 2 4 Exercise 3 5 Exercise 4 6 Exercise 5 7 Exercise 6 Introduction ============ Bla bla bla blablablablablabla bla bla blabla. Bla bla bla blablablablablabla bla bla blabla. Bla bla bla blablablablablabla bla bla blabla. Bla bla bla blablablablablabla bla bla blabla. Bla bla bla blablablablablabla bla bla blabla. Bla bla bla blablablablablabla bla bla blabla. Exercise 1 ========== :: myexp :: Int -> Int -> Int myexp b 0 = 1 myexp b (n+1) = b * (myexp b n) Exercise 2 ========== (Exercise 2 consisted in derivations, so we mark the literal blocks as another type of block with "#!example", so that they don't get included in the output when only the "default" literal blocks get extracted. See rst-literals docstring for details.) Length:: #!example 1 + (length [2, 3]) 1 + 1 + (length [3]) 1 + 1 + (1) 3 Drop:: #!example drop 3 [1, 2, 3, 4, 5] [] ++ drop 3 [2, 3, 4, 5] [] ++ [] ++ drop 3 [3, 4, 5] [] ++ [] ++ [] ++ [4, 5] [4, 5] Init:: #!example init [1, 2, 3] [1] ++ init [2, 3] [1] ++ [2] ++ init [3] [1] ++ [2] ++ [] [1, 2] Exercise 3 ========== These are alternate versions of the example functions defined in the text:: and' :: [Bool] -> Bool and' [x] = x and' (x:xs) = x && and' xs concat' :: [[a]] -> [a] concat' [] = [] concat' (x:xs) = x ++ concat' xs replicate' :: Int -> a -> [a] replicate' 0 x = [] replicate' (n+1) x = (x : replicate' n x) select' :: [a] -> Int -> a select' (x:xs) 0 = x select' (x:xs) (n+1) = select' xs n elem' :: Eq a => a -> [a] -> Bool elem' _ [] = False elem' y (x:xs) | x == y = True | otherwise = elem' y xs Exercise 4 ========== The exercise asked to implement a function to merge two lists:: merge :: Ord a => [a] -> [a] -> [a] merge xs [] = xs merge [] xs = xs merge (x:xs) (y:ys) | x < y = (x : merge xs (y:ys)) | otherwise = (y : merge (x:xs) ys) Exercise 5 ========== :: msort :: Ord a => [a] -> [a] msort [] = [] msort [x] = [x] -- This is necessary to end the recursion. msort xs = merge (msort (fst hh)) (msort (snd hh)) where hh = halve xs halve :: [a] -> ([a], [a]) halve xs = (take n xs, drop n xs) where n = (length xs) `div` 2 Some main program:: main = (putStrLn . show) (halve [1..17]) Exercise 6 ========== (Too basic, I didn't bother.) ---------------------------------------------------------------------- From ryani.spam at gmail.com Sat Jun 21 14:28:47 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Sat Jun 21 14:20:31 2008 Subject: [Haskell-cafe] another FFI question In-Reply-To: <5ae4f2ba0806202052w143dc215x281a1faa4884ec@mail.gmail.com> References: <5ae4f2ba0806201251v3a11188cq9ab71d44d9d996da@mail.gmail.com> <1662913902.20080621002016@gmail.com> <5ae4f2ba0806202052w143dc215x281a1faa4884ec@mail.gmail.com> Message-ID: <2f9b2d30806211128u2646e8aen3a830b5b27ebd834@mail.gmail.com> You just have the arguments to "poke" wrong: poke :: Storable a => Ptr a -> a -> IO () So you are missing the pointer argument poke p Signal = poke p signal_int_value I didn't know about the (#const) syntax. Interesting. Also, alignment of signal should match the alignment of the underlying type (although I think that isn't really used at the moment). -- ryan 2008/6/20 Galchin, Vasili : > I am still reading the web pages. Here is what I tried: > > data SigNotify = Signal | None | Thread | ThreadId > > > instance Storable SigNotify where > > sizeOf _ = (#const sizeof (int)) > > alignment _ = 1 > > poke Signal = (#const SIGEV_SIGNAL) > > poke None = poke (#const SIGEV_NONE) > > poke Thread = poke (#const SIGEV_THREAD) > > poke ThreadId = poke (#const SIGEV_THREAD_ID) > > > but I got ... > > Couldn't match expected type `Ptr SigNotify' > against inferred type `SigNotify' > In the pattern: Signal > In the definition of `poke': poke Signal = poke (0) > In the definition for method `poke' > > Basically I want to marshall SigInfo constructors to CInt values. ?? > > Regards, Vasili > > > On Fri, Jun 20, 2008 at 3:20 PM, Bulat Ziganshin > wrote: >> >> Hello Vasili, >> >> Friday, June 20, 2008, 11:51:11 PM, you wrote: >> > data Bonzo = A | B |C >> >> > How do I write the poke functions and call them? >> >> instance Storable Bonzo >> poke A = poke 0 >> poke B = poke 1 >> poke C = poke 4 >> >> call as "poke x" >> >> probably, you don't understand differences between OOP classes and >> type classes. look at http://haskell.org/haskellwiki/OOP_vs_type_classes >> and papers mentioned there >> >> >> -- >> Best regards, >> Bulat mailto:Bulat.Ziganshin@gmail.com >> > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From dons at galois.com Sat Jun 21 15:12:55 2008 From: dons at galois.com (Don Stewart) Date: Sat Jun 21 15:04:41 2008 Subject: [Haskell-cafe] ANNOUNCE: Pipe 1.0 In-Reply-To: References: Message-ID: <20080621191255.GA2361@scytale.galois.com> matti.niemenmaa+news: > Greetings, > > I hereby announce the release of the Pipe library, a library for piping > data through a pipeline of processes. > > A web page with (hopefully) all the necessary info and a simple example can > be found at http://iki.fi/matti.niemenmaa/pipe/ > > The package is at Hackage: > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Pipe > > Feel free to comment on any part of it, either here or straight to my > e-mail address. > > I've tested it on Windows XP and Linux (Gentoo) and GHC 6.8.2 and 6.8.3. > Since the code is rather low-level it'd be interesting to hear whether it > works on other systems, say the BSDs or OS X. Interesting. Does it depend on an unreleased version of the process library? -- Don From xj2106 at columbia.edu Sat Jun 21 15:12:38 2008 From: xj2106 at columbia.edu (Xiao-Yong Jin) Date: Sat Jun 21 15:04:49 2008 Subject: [Haskell-cafe] Safe way to parse arguments? Message-ID: <87tzfmtxeh.fsf@columbia.edu> Hi, I'm wondering how usually you parse command line arguments list safely. If the given argument is wrong, the program can still print out some error information instead of giving something like Prelude.read: no parse Let's make the discussion concrete. Suppose we have the following code. -->8----------8<-- import System.Environment data Conf = Conf { number :: Int } parseArgs [] = error "need at least one argument" parseArgs (x:_) = Conf { number = read x } work (Conf { number = n }) = n * (n-1) `div` 2 main = print . work . parseArgs =<< getArgs -->8----------8<-- If the "read x" fails in line 8, the program dies with Prelude.read: no parse What is the standard way to make the error message useful? Xiao-Yong -- c/* __o/* <\ * (__ */\ < From ndmitchell at gmail.com Sat Jun 21 15:19:31 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Sat Jun 21 15:11:13 2008 Subject: [Haskell-cafe] Safe way to parse arguments? In-Reply-To: <87tzfmtxeh.fsf@columbia.edu> References: <87tzfmtxeh.fsf@columbia.edu> Message-ID: <404396ef0806211219u2130911k619d0ce9dc5ac31@mail.gmail.com> Hi > I'm wondering how usually you parse command line arguments > list safely. If the given argument is wrong, the program > can still print out some error information instead of giving > something like Either use reads instead, and deal with the case where there is no parse. Or use the safe library, on hackage, and something like: import Safe readNote "please enter a number" x Where if x is "test", you'll get: Program error: Prelude.read: no parse, please enter a number, on "test" Or use readDef: readDef (error "Please enter a number") x Which will just give you: Program error: Please enter a number Or, readMay, which will return a Nothing if you fail, which you can deal with as you wish. Thanks Neil From dons at galois.com Sat Jun 21 15:19:32 2008 From: dons at galois.com (Don Stewart) Date: Sat Jun 21 15:11:23 2008 Subject: [Haskell-cafe] Safe way to parse arguments? In-Reply-To: <87tzfmtxeh.fsf@columbia.edu> References: <87tzfmtxeh.fsf@columbia.edu> Message-ID: <20080621191932.GC2361@scytale.galois.com> xj2106: > Hi, > > I'm wondering how usually you parse command line arguments > list safely. If the given argument is wrong, the program > can still print out some error information instead of giving > something like > > Prelude.read: no parse > > Let's make the discussion concrete. Suppose we have the > following code. > > -->8----------8<-- > import System.Environment > > data Conf = Conf { number :: Int } > > parseArgs [] = error "need at least one argument" > parseArgs (x:_) = Conf { number = read x } > > work (Conf { number = n }) = n * (n-1) `div` 2 > > main = print . work . parseArgs =<< getArgs > -->8----------8<-- > > If the "read x" fails in line 8, the program dies with > > Prelude.read: no parse > > What is the standard way to make the error message useful? > > Xiao-Yong > -- The main thing is to define a safe read. This will be in the base library soon, maybeRead :: Read a => String -> Maybe a maybeRead s = case reads s of [(x, "")] -> Just x _ -> Nothing Then you can pattern match on the failure case as Nothing. Cheers, Don From vigalchin at gmail.com Sat Jun 21 15:27:59 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Sat Jun 21 15:19:41 2008 Subject: [Haskell-cafe] another FFI question In-Reply-To: <2f9b2d30806211128u2646e8aen3a830b5b27ebd834@mail.gmail.com> References: <5ae4f2ba0806201251v3a11188cq9ab71d44d9d996da@mail.gmail.com> <1662913902.20080621002016@gmail.com> <5ae4f2ba0806202052w143dc215x281a1faa4884ec@mail.gmail.com> <2f9b2d30806211128u2646e8aen3a830b5b27ebd834@mail.gmail.com> Message-ID: <5ae4f2ba0806211227v668a9941ycde85314793afab7@mail.gmail.com> On Sat, Jun 21, 2008 at 1:28 PM, Ryan Ingram wrote: > You just have the arguments to "poke" wrong: > poke :: Storable a => Ptr a -> a -> IO () > > So you are missing the pointer argument > poke p Signal = poke p signal_int_value ^^ what is "signal_int_value"? > > > I didn't know about the (#const) syntax. Interesting. > > Also, alignment of signal should match the alignment of the underlying > type (although I think that isn't really used at the moment). > > -- ryan > > 2008/6/20 Galchin, Vasili : > > I am still reading the web pages. Here is what I tried: > > > > data SigNotify = Signal | None | Thread | ThreadId > > > > > > instance Storable SigNotify where > > > > sizeOf _ = (#const sizeof (int)) > > > > alignment _ = 1 > > > > poke Signal = (#const SIGEV_SIGNAL) > > > > poke None = poke (#const SIGEV_NONE) > > > > poke Thread = poke (#const SIGEV_THREAD) > > > > poke ThreadId = poke (#const SIGEV_THREAD_ID) > > > > > > but I got ... > > > > Couldn't match expected type `Ptr SigNotify' > > against inferred type `SigNotify' > > In the pattern: Signal > > In the definition of `poke': poke Signal = poke (0) > > In the definition for method `poke' > > > > Basically I want to marshall SigInfo constructors to CInt values. ?? > > > > Regards, Vasili > > > > > > On Fri, Jun 20, 2008 at 3:20 PM, Bulat Ziganshin < > bulat.ziganshin@gmail.com> > > wrote: > >> > >> Hello Vasili, > >> > >> Friday, June 20, 2008, 11:51:11 PM, you wrote: > >> > data Bonzo = A | B |C > >> > >> > How do I write the poke functions and call them? > >> > >> instance Storable Bonzo > >> poke A = poke 0 > >> poke B = poke 1 > >> poke C = poke 4 > >> > >> call as "poke x" > >> > >> probably, you don't understand differences between OOP classes and > >> type classes. look at > http://haskell.org/haskellwiki/OOP_vs_type_classes > >> and papers mentioned there > >> > >> > >> -- > >> Best regards, > >> Bulat mailto:Bulat.Ziganshin@gmail.com > >> > > > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080621/21e40c43/attachment.htm From matti.niemenmaa+news at iki.fi Sat Jun 21 15:33:56 2008 From: matti.niemenmaa+news at iki.fi (Matti Niemenmaa) Date: Sat Jun 21 15:25:49 2008 Subject: [Haskell-cafe] Re: ANNOUNCE: Pipe 1.0 In-Reply-To: <20080621191255.GA2361@scytale.galois.com> References: <20080621191255.GA2361@scytale.galois.com> Message-ID: Don Stewart wrote: > Interesting. > Does it depend on an unreleased version of the process library? Indeed it does. Actually most of the code was written using the current released version, I just jumped the gun a bit when I saw how nice the new interface was. I'm hoping that the release of the new process library (GHC ticket #2233) isn't that far off, which is why I figured I'd shove Pipe out in this state. If that's not the case and it turns out that people want to use Pipe without the hassle, I might be persuaded to release a version that doesn't need it. The only 'real' dependency that can't be worked around is the handlePipe function, which is only a non-exported optimization that gets applied via RULES. From xj2106 at columbia.edu Sat Jun 21 15:46:57 2008 From: xj2106 at columbia.edu (Xiao-Yong Jin) Date: Sat Jun 21 15:39:01 2008 Subject: [Haskell-cafe] Safe way to parse arguments? In-Reply-To: <20080621191932.GC2361@scytale.galois.com> (Don Stewart's message of "Sat, 21 Jun 2008 12:19:32 -0700") References: <87tzfmtxeh.fsf@columbia.edu> <20080621191932.GC2361@scytale.galois.com> Message-ID: <87lk0ytvta.fsf@columbia.edu> Don Stewart writes: > The main thing is to define a safe read. This will be in the base > library soon, > > maybeRead :: Read a => String -> Maybe a > maybeRead s = case reads s of > [(x, "")] -> Just x > _ -> Nothing > > Then you can pattern match on the failure case as Nothing. When will it be in the base library? X-Y -- c/* __o/* <\ * (__ */\ < From lanny at cisco.com Sat Jun 21 17:06:31 2008 From: lanny at cisco.com (Lanny Ripple) Date: Sat Jun 21 16:58:29 2008 Subject: [Haskell-cafe] Access to Oracle database from Haskell In-Reply-To: <485C94C1.6030006@cisco.com> References: <485C94C1.6030006@cisco.com> Message-ID: <485D6D57.10606@cisco.com> Lanny Ripple wrote: > I had luck with this the other day using Database.HDBC.ODBC. For > Ubuntu's Hardy I found that Oracle's 10.2.0.3 worked best. > (10.2.0.4 and 11 seemed to have problems for me at least.) > > http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html > > Grab the basic (not basic-lite), odbc, and sqlplus (to test) zips. Oops. And the sdk zip. > The odbc_update_ini.sh should be run from inside the > instantclient_10_2 directory as root > > sudo /bin/sh odbc_update_ini.sh / > > (assuming a standard unixODBC install.) You'll also need a > tnsnames.ora file to describe your connection(s) to the DB(s). > You'll also need to define some environment variables to run against > all this. I use a small script: > > #!/bin/sh > oracle_home=/opt/lib/oracle/instantclient_10_2 > export TNS_ADMIN=$oracle_home > export LD_LIBRARY_PATH=$oracle_home > [ $# = 0 ] && exit 1 > exec "$@" > > Best of luck, > -ljr > > > Steve Lihn wrote: >> You may want to check this out. >> >> http://www.orafaq.com/wiki/ODBC_FAQ#Where_can_one_get_ODBC_drivers_for_Oracle_and_Rdb.3F >> >> As Oracle is a commercial company who is not interested in open source >> historically, it is little chance that you will get robust software >> for free -- from someone with many years of Oracle DBA experience :-) >> >> >> On 6/19/08, Henning Thielemann wrote: >>> Is there a way of accessing a remote Oracle database by one of the common >>> Haskell database interfaces (HaskellDB, Takusen, etc.) ? I tried to get >>> unixODBC and Oracle's Instant Client running on a Linux machine, but I'm >>> trapped in the notorious error: >>> >>> $ isql USER -v >>> [IM004][unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV >>> failed >>> [ISQL]ERROR: Could not SQLConnect >>> >>> This error message is discussed in various web forums, but there seems to be >>> no systematic way to track down the problem. So I wonder whether there is >>> another way to access the Oracle data base from Haskell. >>> _______________________________________________ >>> 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 dan.doel at gmail.com Sat Jun 21 17:37:24 2008 From: dan.doel at gmail.com (Dan Doel) Date: Sat Jun 21 17:29:09 2008 Subject: [Haskell-cafe] Safe way to parse arguments? In-Reply-To: <20080621191932.GC2361@scytale.galois.com> References: <87tzfmtxeh.fsf@columbia.edu> <20080621191932.GC2361@scytale.galois.com> Message-ID: <200806211737.24484.dan.doel@gmail.com> On Saturday 21 June 2008, Don Stewart wrote: > maybeRead :: Read a => String -> Maybe a > maybeRead s = case reads s of > [(x, "")] -> Just x > _ -> Nothing Note, if you want to match the behavior of read, you'll probably want something like: maybeRead :: Read a => String -> Maybe a maybeRead s = case reads s of [(x, str)] | all isSpace str -> Just x _ -> Nothing Otherwise, trailing spaces will yield a bad parse. -- Dan From byorgey at seas.upenn.edu Sat Jun 21 21:11:10 2008 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Sat Jun 21 21:02:50 2008 Subject: [Haskell-cafe] Pretty little definitions of left and right folds In-Reply-To: <1214016756.26144.15.camel@derek-laptop> References: <485C3A08.8070302@math.ku.edu> <20080621023117.GA2741@minus.seas.upenn.edu> <1214016756.26144.15.camel@derek-laptop> Message-ID: <20080622011110.GA9877@minus.seas.upenn.edu> On Fri, Jun 20, 2008 at 09:52:36PM -0500, Derek Elkins wrote: > On Fri, 2008-06-20 at 22:31 -0400, Brent Yorgey wrote: > > On Fri, Jun 20, 2008 at 06:15:20PM -0500, George Kangas wrote: > > > > > > foldright (+) [1, 2, 3] 0 == ( (1 +).(2 +).(3 +).id ) 0 > > > foldleft (+) [1, 2, 3] 0 == ( id.(3 +).(2 +).(1 +) ) 0 > > > > > > > Hi George, > > > > This is very cool! I have never thought of folds in quite this way > > before. It makes a lot of things (such as the identities you point > > out) obvious and elegant. > > > > > We can also see the following identities: > > > > > > foldright f as == foldright (.) (map f as) id > > > foldleft f as == foldright (flip (.)) (map f as) id > > > > > > I like that second one, after trying to read another definition of > > > left fold in terms of right fold (in the web book "Real World Haskell"). > > > > > > The type signature, which could be written (a -> (b -> b)) -> ([a] -> > > > (b -> b)), suggests generalization to another type constructor C: (a -> > > > (b -> b)) -> (C a -> (b -> b)). Would a "foldable" typeclass make any > > > sense? > > > > As Brandon points out, you have rediscovered Data.Foldable. =) There's > > nothing wrong with that, congratulations on discovering it for > > yourself! But again, I like this way of organizing the type > > signature: I had never thought of a fold as a sort of 'lift' before. > > If f :: a -> b -> b, then foldright 'lifts' f to foldright f :: [a] -> > > b -> b (or C a -> b -> b, more generally). > > > > > Okay, it goes without saying that this is useless dabbling, but have > > > I entertained anyone? Or have I just wasted your time? I eagerly await > > > comments on this, my first posting. > > > > Not at all! Welcome, and thanks for posting. > > Look into the theory of monoids, monoid homomorphisms, M-sets and free > monoids. Thanks for the pointers! Here's what I've come up with, after re-reading some Barr-Wells lecture notes. First, given finite sets A (representing an 'alphabet') and S (representing 'states'), we can describe a finite state machine by a function phi : A x S -> S, which gives 'transition rules' giving a new state for each combination of alphabet character and state. If we squint and wave our hands and ignore the fact that types aren't exactly sets, and most of the types we care about have infinitely many values, this is very much like the Haskell type (a,s) -> s, or (curried) a -> s -> s, i.e. a -> (s -> s). So we can think of a Haskell function phi :: a -> (s -> s) as a sort of 'state machine'. Also, for a monoid M and set S, an action of M on S is given by a function f : M x S -> S for which (1) f(1,s) = s, and (2) f(mn,s) = f(m,f(n,s)). Of course, in Haskell we would write f :: m -> (s -> s), and we would write criteria (1) and (2) as (1) f mempty = id (2) f (m `mappend` n) = f m . f n Now look at the type of foldright: foldright :: (a -> (s -> s)) -> ([a] -> (s -> s)) We can see that foldright exactly corresponds to the observation that any state machine with alphabet a and states s induces a monoid action on s by the free monoid [a]. It's not hard to check that the function produced by foldright indeed satisfies the requirements to be a monoid action. First, recall that foldright f = chain where chain (a:as) = (f a).(chain as) chain _ = id Now, we can easily prove (1): (foldright f) [] = chain [] = id The proof of (2) is by induction on the length of m. The base case is obvious, given the proof of (1). (foldright f) (m ++ n) = { defn. of foldright, assume m = x:xs } chain ((x:xs) ++ n) = { defn. of (++) } chain (x:(xs ++ n)) = { defn. of chain } f x . chain (xs ++ n) = { inductive hypothesis } f x . chain xs . chain n = { defn. of chain, associativity of (.) } chain (x:xs) . chain n = { defn. of foldright, m } (foldright f) m . (foldright f) n How'd I do? I'm still trying to figure out how the generalization to Traversable fits in here. I'm guessing this is where the monoid homomorphisms come in. -Brent From lrpalmer at gmail.com Sat Jun 21 22:17:51 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Sat Jun 21 22:09:32 2008 Subject: [Haskell-cafe] Pretty little definitions of left and right folds In-Reply-To: <20080622011110.GA9877@minus.seas.upenn.edu> References: <485C3A08.8070302@math.ku.edu> <20080621023117.GA2741@minus.seas.upenn.edu> <1214016756.26144.15.camel@derek-laptop> <20080622011110.GA9877@minus.seas.upenn.edu> Message-ID: <7ca3f0160806211917h29cfd8edtd6fb6655823fd7bb@mail.gmail.com> On Sat, Jun 21, 2008 at 7:11 PM, Brent Yorgey wrote: > First, given finite sets A (representing an 'alphabet') and S > (representing 'states'), we can describe a finite state machine by a > function phi : A x S -> S, which gives 'transition rules' giving a new > state for each combination of alphabet character and state. If we > squint and wave our hands and ignore the fact that types aren't > exactly sets, and most of the types we care about have infinitely many > values, this is very much like the Haskell type (a,s) -> s, or > (curried) a -> s -> s, i.e. a -> (s -> s). So we can think of a > Haskell function phi :: a -> (s -> s) as a sort of 'state machine'. > > Also, for a monoid M and set S, an action of M on S is given by a > function f : M x S -> S for which > > (1) f(1,s) = s, and > (2) f(mn,s) = f(m,f(n,s)). > > Of course, in Haskell we would write f :: m -> (s -> s), and we would > write criteria (1) and (2) as > > (1) f mempty = id > (2) f (m `mappend` n) = f m . f n > > Now look at the type of foldright: > > foldright :: (a -> (s -> s)) -> ([a] -> (s -> s)) Wow! I commend you on this excellent, enlightening post! Luke > We can see that foldright exactly corresponds to the observation that > any state machine with alphabet a and states s induces a monoid action > on s by the free monoid [a]. It's not hard to check that the > function produced by foldright indeed satisfies the requirements to be > a monoid action. > > First, recall that > > foldright f = chain where > chain (a:as) = (f a).(chain as) > chain _ = id > > Now, we can easily prove (1): > > (foldright f) [] > = chain [] > = id > > The proof of (2) is by induction on the length of m. The base case is > obvious, given the proof of (1). > > (foldright f) (m ++ n) > = { defn. of foldright, assume m = x:xs } > chain ((x:xs) ++ n) > = { defn. of (++) } > chain (x:(xs ++ n)) > = { defn. of chain } > f x . chain (xs ++ n) > = { inductive hypothesis } > f x . chain xs . chain n > = { defn. of chain, associativity of (.) } > chain (x:xs) . chain n > = { defn. of foldright, m } > (foldright f) m . (foldright f) n > > > How'd I do? I'm still trying to figure out how the generalization to > Traversable fits in here. I'm guessing this is where the monoid > homomorphisms come in. > > -Brent > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From derek.a.elkins at gmail.com Sat Jun 21 22:36:06 2008 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Sat Jun 21 22:27:49 2008 Subject: [Haskell-cafe] Pretty little definitions of left and right folds In-Reply-To: <20080622011110.GA9877@minus.seas.upenn.edu> References: <485C3A08.8070302@math.ku.edu> <20080621023117.GA2741@minus.seas.upenn.edu> <1214016756.26144.15.camel@derek-laptop> <20080622011110.GA9877@minus.seas.upenn.edu> Message-ID: <1214102166.26144.19.camel@derek-laptop> On Sat, 2008-06-21 at 21:11 -0400, Brent Yorgey wrote: > On Fri, Jun 20, 2008 at 09:52:36PM -0500, Derek Elkins wrote: > > On Fri, 2008-06-20 at 22:31 -0400, Brent Yorgey wrote: > > > On Fri, Jun 20, 2008 at 06:15:20PM -0500, George Kangas wrote: > > > > > > > > foldright (+) [1, 2, 3] 0 == ( (1 +).(2 +).(3 +).id ) 0 > > > > foldleft (+) [1, 2, 3] 0 == ( id.(3 +).(2 +).(1 +) ) 0 > > > > > > > > > > Hi George, > > > > > > This is very cool! I have never thought of folds in quite this way > > > before. It makes a lot of things (such as the identities you point > > > out) obvious and elegant. > > > > > > > We can also see the following identities: > > > > > > > > foldright f as == foldright (.) (map f as) id > > > > foldleft f as == foldright (flip (.)) (map f as) id > > > > > > > > I like that second one, after trying to read another definition of > > > > left fold in terms of right fold (in the web book "Real World Haskell"). > > > > > > > > The type signature, which could be written (a -> (b -> b)) -> ([a] -> > > > > (b -> b)), suggests generalization to another type constructor C: (a -> > > > > (b -> b)) -> (C a -> (b -> b)). Would a "foldable" typeclass make any > > > > sense? > > > > > > As Brandon points out, you have rediscovered Data.Foldable. =) There's > > > nothing wrong with that, congratulations on discovering it for > > > yourself! But again, I like this way of organizing the type > > > signature: I had never thought of a fold as a sort of 'lift' before. > > > If f :: a -> b -> b, then foldright 'lifts' f to foldright f :: [a] -> > > > b -> b (or C a -> b -> b, more generally). > > > > > > > Okay, it goes without saying that this is useless dabbling, but have > > > > I entertained anyone? Or have I just wasted your time? I eagerly await > > > > comments on this, my first posting. > > > > > > Not at all! Welcome, and thanks for posting. > > > > Look into the theory of monoids, monoid homomorphisms, M-sets and free > > monoids. > > Thanks for the pointers! Here's what I've come up with, after > re-reading some Barr-Wells lecture notes. > > First, given finite sets A (representing an 'alphabet') and S > (representing 'states'), we can describe a finite state machine by a > function phi : A x S -> S, which gives 'transition rules' giving a new > state for each combination of alphabet character and state. If we > squint and wave our hands and ignore the fact that types aren't > exactly sets, and most of the types we care about have infinitely many > values, this is very much like the Haskell type (a,s) -> s, or > (curried) a -> s -> s, i.e. a -> (s -> s). So we can think of a > Haskell function phi :: a -> (s -> s) as a sort of 'state machine'. > > Also, for a monoid M and set S, an action of M on S is given by a > function f : M x S -> S for which > > (1) f(1,s) = s, and > (2) f(mn,s) = f(m,f(n,s)). > > Of course, in Haskell we would write f :: m -> (s -> s), This change is not completely trivial. > and we would > write criteria (1) and (2) as > > (1) f mempty = id > (2) f (m `mappend` n) = f m . f n So what does this make f? Hint: What is (s -> s)? From byorgey at seas.upenn.edu Sat Jun 21 22:48:59 2008 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Sat Jun 21 22:40:38 2008 Subject: [Haskell-cafe] Pretty little definitions of left and right folds In-Reply-To: <1214102166.26144.19.camel@derek-laptop> References: <485C3A08.8070302@math.ku.edu> <20080621023117.GA2741@minus.seas.upenn.edu> <1214016756.26144.15.camel@derek-laptop> <20080622011110.GA9877@minus.seas.upenn.edu> <1214102166.26144.19.camel@derek-laptop> Message-ID: <20080622024859.GA23472@minus.seas.upenn.edu> On Sat, Jun 21, 2008 at 09:36:06PM -0500, Derek Elkins wrote: > On Sat, 2008-06-21 at 21:11 -0400, Brent Yorgey wrote: > > On Fri, Jun 20, 2008 at 09:52:36PM -0500, Derek Elkins wrote: > > > On Fri, 2008-06-20 at 22:31 -0400, Brent Yorgey wrote: > > > > On Fri, Jun 20, 2008 at 06:15:20PM -0500, George Kangas wrote: > > > > > > > > > > foldright (+) [1, 2, 3] 0 == ( (1 +).(2 +).(3 +).id ) 0 > > > > > foldleft (+) [1, 2, 3] 0 == ( id.(3 +).(2 +).(1 +) ) 0 > > > > > > > > > > > > > Hi George, > > > > > > > > This is very cool! I have never thought of folds in quite this way > > > > before. It makes a lot of things (such as the identities you point > > > > out) obvious and elegant. > > > > > > > > > We can also see the following identities: > > > > > > > > > > foldright f as == foldright (.) (map f as) id > > > > > foldleft f as == foldright (flip (.)) (map f as) id > > > > > > > > > > I like that second one, after trying to read another definition of > > > > > left fold in terms of right fold (in the web book "Real World Haskell"). > > > > > > > > > > The type signature, which could be written (a -> (b -> b)) -> ([a] -> > > > > > (b -> b)), suggests generalization to another type constructor C: (a -> > > > > > (b -> b)) -> (C a -> (b -> b)). Would a "foldable" typeclass make any > > > > > sense? > > > > > > > > As Brandon points out, you have rediscovered Data.Foldable. =) There's > > > > nothing wrong with that, congratulations on discovering it for > > > > yourself! But again, I like this way of organizing the type > > > > signature: I had never thought of a fold as a sort of 'lift' before. > > > > If f :: a -> b -> b, then foldright 'lifts' f to foldright f :: [a] -> > > > > b -> b (or C a -> b -> b, more generally). > > > > > > > > > Okay, it goes without saying that this is useless dabbling, but have > > > > > I entertained anyone? Or have I just wasted your time? I eagerly await > > > > > comments on this, my first posting. > > > > > > > > Not at all! Welcome, and thanks for posting. > > > > > > Look into the theory of monoids, monoid homomorphisms, M-sets and free > > > monoids. > > > > Thanks for the pointers! Here's what I've come up with, after > > re-reading some Barr-Wells lecture notes. > > > > First, given finite sets A (representing an 'alphabet') and S > > (representing 'states'), we can describe a finite state machine by a > > function phi : A x S -> S, which gives 'transition rules' giving a new > > state for each combination of alphabet character and state. If we > > squint and wave our hands and ignore the fact that types aren't > > exactly sets, and most of the types we care about have infinitely many > > values, this is very much like the Haskell type (a,s) -> s, or > > (curried) a -> s -> s, i.e. a -> (s -> s). So we can think of a > > Haskell function phi :: a -> (s -> s) as a sort of 'state machine'. > > > > Also, for a monoid M and set S, an action of M on S is given by a > > function f : M x S -> S for which > > > > (1) f(1,s) = s, and > > (2) f(mn,s) = f(m,f(n,s)). > > > > Of course, in Haskell we would write f :: m -> (s -> s), > > This change is not completely trivial. Hmm... why is that? Is it because of the types-aren't-really-sets thing? Or are there other reasons as well? > > > and we would > > write criteria (1) and (2) as > > > > (1) f mempty = id > > (2) f (m `mappend` n) = f m . f n > > So what does this make f? Hint: What is (s -> s)? Aha! f is a monoid homomorphism to the monoid of endomorphisms on s! Right? -Brent From derek.a.elkins at gmail.com Sat Jun 21 23:32:21 2008 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Sat Jun 21 23:24:03 2008 Subject: [Haskell-cafe] Pretty little definitions of left and right folds In-Reply-To: <20080622024859.GA23472@minus.seas.upenn.edu> References: <485C3A08.8070302@math.ku.edu> <20080621023117.GA2741@minus.seas.upenn.edu> <1214016756.26144.15.camel@derek-laptop> <20080622011110.GA9877@minus.seas.upenn.edu> <1214102166.26144.19.camel@derek-laptop> <20080622024859.GA23472@minus.seas.upenn.edu> Message-ID: <1214105541.26144.27.camel@derek-laptop> On Sat, 2008-06-21 at 22:48 -0400, Brent Yorgey wrote: > On Sat, Jun 21, 2008 at 09:36:06PM -0500, Derek Elkins wrote: > > On Sat, 2008-06-21 at 21:11 -0400, Brent Yorgey wrote: > > > On Fri, Jun 20, 2008 at 09:52:36PM -0500, Derek Elkins wrote: > > > > On Fri, 2008-06-20 at 22:31 -0400, Brent Yorgey wrote: > > > > > On Fri, Jun 20, 2008 at 06:15:20PM -0500, George Kangas wrote: > > > > > > > > > > > > foldright (+) [1, 2, 3] 0 == ( (1 +).(2 +).(3 +).id ) 0 > > > > > > foldleft (+) [1, 2, 3] 0 == ( id.(3 +).(2 +).(1 +) ) 0 > > > > > > > > > > > > > > > > Hi George, > > > > > > > > > > This is very cool! I have never thought of folds in quite this way > > > > > before. It makes a lot of things (such as the identities you point > > > > > out) obvious and elegant. > > > > > > > > > > > We can also see the following identities: > > > > > > > > > > > > foldright f as == foldright (.) (map f as) id > > > > > > foldleft f as == foldright (flip (.)) (map f as) id > > > > > > > > > > > > I like that second one, after trying to read another definition of > > > > > > left fold in terms of right fold (in the web book "Real World Haskell"). > > > > > > > > > > > > The type signature, which could be written (a -> (b -> b)) -> ([a] -> > > > > > > (b -> b)), suggests generalization to another type constructor C: (a -> > > > > > > (b -> b)) -> (C a -> (b -> b)). Would a "foldable" typeclass make any > > > > > > sense? > > > > > > > > > > As Brandon points out, you have rediscovered Data.Foldable. =) There's > > > > > nothing wrong with that, congratulations on discovering it for > > > > > yourself! But again, I like this way of organizing the type > > > > > signature: I had never thought of a fold as a sort of 'lift' before. > > > > > If f :: a -> b -> b, then foldright 'lifts' f to foldright f :: [a] -> > > > > > b -> b (or C a -> b -> b, more generally). > > > > > > > > > > > Okay, it goes without saying that this is useless dabbling, but have > > > > > > I entertained anyone? Or have I just wasted your time? I eagerly await > > > > > > comments on this, my first posting. > > > > > > > > > > Not at all! Welcome, and thanks for posting. > > > > > > > > Look into the theory of monoids, monoid homomorphisms, M-sets and free > > > > monoids. > > > > > > Thanks for the pointers! Here's what I've come up with, after > > > re-reading some Barr-Wells lecture notes. > > > > > > First, given finite sets A (representing an 'alphabet') and S > > > (representing 'states'), we can describe a finite state machine by a > > > function phi : A x S -> S, which gives 'transition rules' giving a new > > > state for each combination of alphabet character and state. If we > > > squint and wave our hands and ignore the fact that types aren't > > > exactly sets, and most of the types we care about have infinitely many > > > values, this is very much like the Haskell type (a,s) -> s, or > > > (curried) a -> s -> s, i.e. a -> (s -> s). So we can think of a > > > Haskell function phi :: a -> (s -> s) as a sort of 'state machine'. > > > > > > Also, for a monoid M and set S, an action of M on S is given by a > > > function f : M x S -> S for which > > > > > > (1) f(1,s) = s, and > > > (2) f(mn,s) = f(m,f(n,s)). > > > > > > Of course, in Haskell we would write f :: m -> (s -> s), > > > > This change is not completely trivial. > > Hmm... why is that? Is it because of the types-aren't-really-sets > thing? Or are there other reasons as well? No, it's just that though these types are isomorphic (in our squinted vision), they are still not identical and each is different way of viewing the same thing. > > > > > > and we would > > > write criteria (1) and (2) as > > > > > > (1) f mempty = id > > > (2) f (m `mappend` n) = f m . f n > > > > So what does this make f? Hint: What is (s -> s)? > > Aha! f is a monoid homomorphism to the monoid of endomorphisms on s! > Right? Yep. So the monoid action, MxS -> S can be curried to give M -> (S->S), a monoid homomorphism, or further we can swap the arguments and curry giving S -> (M->S); one name for this last form, connected to a totally different field, is a flow. In this case, let M be the monoid of time (the non-negative reals under addition) and S be points in space (R^3 say). Usually, in this case, the "monoid action" will be the solution of a differential equation. From nfjinjing at gmail.com Sun Jun 22 00:19:30 2008 From: nfjinjing at gmail.com (jinjing) Date: Sun Jun 22 00:11:28 2008 Subject: [Haskell-cafe] message passing style like in Haskell? In-Reply-To: <20080621171028.GA1077@matrix.chaos.earth.li> References: <81ea7d400806182033h40885ac5l96b415849f2d9d11@mail.gmail.com> <878wx1khcj.fsf@malde.org> <20080619171812.GA25606@dell> <485AE4CB.4080708@vex.net> <874p7ops0p.fsf@malde.org> <20080621171028.GA1077@matrix.chaos.earth.li> Message-ID: <81ea7d400806212119o657a1e94v4b60b7c638652026@mail.gmail.com> After some fiddling with this style, here is what I came up with for the 8 queens problem in the 99 problem set. It's quite entertaining ... ( note: it's brute force and requires a combination library ) queens2 n = n.permutations.filter all_satisfied where all_satisfied queens = queens.diff_col && queens.diff_diag diff_col queens = queens.unique.is queens diff_diag queens = n .combinations 2 .map (map (subtract 1)) .map (id &&& flip cherry_pick queens) .any same_dist.not where same_dist (row_pair, col_pair) = row_pair.foldl1 (-).abs == col_pair.foldl1 (-).abs -- generic helper cherry_pick ids xs = ids.map (xs !!) is a b = a == b unique xs = nub xs Guess this can conclude this experiment :) jinjing On Sun, Jun 22, 2008 at 1:10 AM, Ian Lynagh wrote: > On Fri, Jun 20, 2008 at 07:57:58AM +0200, Ketil Malde wrote: >> "Albert Y. C. Lai" writes: >> >> >> While we are kind of on this topic, what makes the characters ? ? >> >> prefix operator by default, while ? and most other odd ones infix? >> >> > alphanumeric vs non-alphanumeric >> >> Testing this, I find that isAlpha is True also for '?', but as the OP >> claims, Haskell will use it as a(n infix) symbol. > > This is a bug in GHC. The characters <= '\255' were done specially, but > incorrectly for many of those >= '\128'. I'll fix it, probably by just > removing the specialisation for them. > > > Thanks > Ian > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From briqueabraque at yahoo.com Sun Jun 22 01:52:33 2008 From: briqueabraque at yahoo.com (=?ISO-8859-1?Q?Maur=ED=ADcio?=) Date: Sun Jun 22 01:44:22 2008 Subject: [Haskell-cafe] IMAP and NNTP libraries Message-ID: Hi, Are there mature libraries for IMAP and NNTP available to Haskell? Thanks, Maur?cio From vigalchin at gmail.com Sun Jun 22 02:47:35 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Sun Jun 22 02:39:15 2008 Subject: [Haskell-cafe] "C" buffer suggestions?? Message-ID: <5ae4f2ba0806212347r56df45fdu962fccc1bd532ac9@mail.gmail.com> Hello, I want to model an I/O read/write buffer in Haskell and marshall down into ANSI C. 1) ByteString? Or Ptr Word8? 2) What are example values of the types in 1)? Kind regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080622/9c21c9b1/attachment.htm From seanmcl at gmail.com Sun Jun 22 11:37:03 2008 From: seanmcl at gmail.com (Sean McLaughlin) Date: Sun Jun 22 11:28:43 2008 Subject: [Haskell-cafe] ieee 754 Message-ID: <6579f8680806220837i9fe85e2ya161609d63eb4568@mail.gmail.com> Hello, I'm considering using Haskell for a numerical application. However, I need to rely on IEEE 754 standards being implemented correctly. What is the current state of 754 in Haskell? The definition has this paragraph, which makes me suspect Haskell is not appropriate for this application: "The default floating point operations defined by the Haskell Prelude do not conform to current language independent arithmetic (LIA) standards. These standards require considerably more complexity in the numeric structure and have thus been relegated to a library. Some, but not all, aspects of the IEEE floating point standard have been accounted for in Prelude class RealFloat." Thank you, Sean From lennart at augustsson.net Sun Jun 22 12:21:34 2008 From: lennart at augustsson.net (Lennart Augustsson) Date: Sun Jun 22 12:13:13 2008 Subject: [Haskell-cafe] ieee 754 In-Reply-To: <6579f8680806220837i9fe85e2ya161609d63eb4568@mail.gmail.com> References: <6579f8680806220837i9fe85e2ya161609d63eb4568@mail.gmail.com> Message-ID: Haskell does not allow you to change rounding mode, NaN signallng mode, etc. But otherwise Haskell on modern platforms conforms to IEEE 754. -- Lennart On Sun, Jun 22, 2008 at 9:37 AM, Sean McLaughlin wrote: > Hello, > > I'm considering using Haskell for a numerical application. However, > I need to rely > on IEEE 754 standards being implemented correctly. What is the > current state of 754 in Haskell? > The definition has this paragraph, which makes me suspect Haskell is > not appropriate for this > application: > > "The default floating point operations defined by the Haskell Prelude > do not conform to current language independent arithmetic (LIA) > standards. These standards require considerably more complexity in the > numeric structure and have thus been relegated to a library. Some, but > not all, aspects of the IEEE floating point standard have been > accounted for in Prelude class RealFloat." > > Thank you, > > Sean > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From lemming at henning-thielemann.de Sun Jun 22 15:56:05 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sun Jun 22 15:47:46 2008 Subject: [Haskell-cafe] Scripting OpenOffice with Haskell Message-ID: Has someone already tried to communicate with OpenOffice via Haskell? An interface seems to exist: http://framework.openoffice.org/scripting/index.html For instance, I like to mark some cells in oocalc, preprocess them and write them to a database. From haskell.hall at live.com Sun Jun 22 15:58:44 2008 From: haskell.hall at live.com (Haskell Hall) Date: Sun Jun 22 15:50:24 2008 Subject: [Haskell-cafe] Testing Message-ID: Testing Testing _________________________________________________________________ Need to know now? Get instant answers with Windows Live Messenger. http://www.windowslive.com/messenger/connect_your_way.html?ocid=TXT_TAGLM_WL_Refresh_messenger_062008 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080622/58aa3b11/attachment.htm From haskell.hall at live.com Sun Jun 22 16:08:26 2008 From: haskell.hall at live.com (Haskell Hall) Date: Sun Jun 22 16:00:04 2008 Subject: [Haskell-cafe] INVITATION Message-ID: Haskell Hall is up and running. Haskell Hall is a mailing list, a forum, where you can discuss Haskell, functional programming and anything related, freely and openly with fellow enthusiasts. We welcome people of all abilities and know-how. So, if you fancy a change from what you get on Haskell Cafe send an email to haskell-request@freelists.org with the word subscribe in the subject field.The first 10 members will have access to the wine cellar. :-) _________________________________________________________________ The i?m Talkathon starts 6/24/08.? For now, give amongst yourselves. http://www.imtalkathon.com?source=TXT_EML_WLH_LearnMore_GiveAmongst -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080622/68f62bcc/attachment.htm From lemming at henning-thielemann.de Sun Jun 22 16:32:21 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sun Jun 22 16:23:58 2008 Subject: [Haskell-cafe] ieee 754 In-Reply-To: References: <6579f8680806220837i9fe85e2ya161609d63eb4568@mail.gmail.com> Message-ID: On Sun, 22 Jun 2008, Lennart Augustsson wrote: > Haskell does not allow you to change rounding mode, NaN signallng mode, etc. > But otherwise Haskell on modern platforms conforms to IEEE 754. It just uses the machine floating point implementation, which is most oftenly IEEE. However the good news are - if someone manually writes functions for IEEE number representation, they could be used exactly the same way as Float and Double, and chances are good that with some optimizer RULES the operations can be replaced by efficient FPU operations on IEEE compliant FPUs. From nielsadb at gmail.com Sun Jun 22 16:39:57 2008 From: nielsadb at gmail.com (Niels Aan de Brugh) Date: Sun Jun 22 16:31:36 2008 Subject: [Haskell-cafe] another FFI question In-Reply-To: <1662913902.20080621002016@gmail.com> References: <5ae4f2ba0806201251v3a11188cq9ab71d44d9d996da@mail.gmail.com> <1662913902.20080621002016@gmail.com> Message-ID: <1214167197.12672.46.camel@porcupine> On Sat, 2008-06-21 at 00:20 +0400, Bulat Ziganshin wrote: > > probably, you don't understand differences between OOP classes and > type classes. look at http://haskell.org/haskellwiki/OOP_vs_type_classes > and papers mentioned there I took the liberty to update some of the C++ code on that page so that the code will compile and work as expected. Reading the rest of the page I have a question regarding section 4.2, Type classes correspond to parameterized abstract classes (Gabriel Dos Reis). This is probably more related to C++ than Haskell, so not all readers might find it of interest. --- off topic --- Looking at 4.2, it's interesting to see how type classes are translated into C++. Admittedly C++ isn't the prettiest language to look at, but I feel one must be fair, and the code presented at the Wiki is too complex, using virtuals and templates where they're not needed. Normal overloading suffices. Operator definitions can already be placed outside of a class scope, e.g. the many overloads of << to print something to a stream. By default these definitions cannot access private members of their operands but the code at the Wiki has the same problem. Just a small example: // --- somewhere in a file --- struct Aap { int x; explicit Aap(int x) : x(x) {} Aap add(Aap const& other) const { return Aap(x + other.x); } }; // --- somewhere in another file --- Aap operator+(Aap const& lhs, Aap const& rhs) { return lhs.add(rhs); } Overloading functions is not different. I've omitted some other (more complex) ways you can achieve the same (aside from normal overloads it's also allowed to introduce new specializations later). At the time of writing it's not possible in C++ to restrict a type to allow a certain operation (concepts[1] will hopefully fill that gap some day, but I think it'll be a long time before tool support is ready for prime-time). Rather, it's common to just use the operation and let the compiler generate a (sometimes very cryptic) error message if it cannot find the right code. [1]: http://www.generic-programming.org/software/ConceptGCC/ A very poor man's solution to see if an operation is defined would be: template struct has_add; template<> struct has_add {}; int main() { (void)sizeof(has_add); // okay ? (void)sizeof(has_add); // fails to compile, put useful comment here } It's not hard to add some primitive predicate logic (at compile time) to resemble type classes in some sense, but I think this is off-topic enough as it is. Regards, Niels From lemming at henning-thielemann.de Sun Jun 22 16:45:51 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sun Jun 22 16:37:29 2008 Subject: [Haskell-cafe] Safe way to parse arguments? In-Reply-To: <87tzfmtxeh.fsf@columbia.edu> References: <87tzfmtxeh.fsf@columbia.edu> Message-ID: On Sat, 21 Jun 2008, Xiao-Yong Jin wrote: > Hi, > > I'm wondering how usually you parse command line arguments > list safely. If the given argument is wrong, the program > can still print out some error information instead of giving > something like > > Prelude.read: no parse It's generally not a good idea to call 'read' on user data. 'read' expects well-formed input. Calling 'read' with other input is a programming _error_. If the user enters garbage, this is an _exception_ and this must be handled with 'reads' or 'maybeRead' as others suggested. http://www.haskell.org/haskellwiki/Error http://www.haskell.org/haskellwiki/Exception From james at neurogami.com Sun Jun 22 19:05:50 2008 From: james at neurogami.com (James Britt) Date: Sun Jun 22 18:57:36 2008 Subject: [Haskell-cafe] INVITATION In-Reply-To: References: Message-ID: <485EDACE.1080009@neurogami.com> Haskell Hall wrote: > Haskell Hall is up and running. Haskell Hall is a mailing list, a forum, where you can discuss Haskell, functional programming and anything related, freely and openly with fellow enthusiasts. We welcome people of all abilities and know-how. So, if you fancy a change from what you get on Haskell Cafe send an email to haskell-request@freelists.org with the word subscribe in the subject field.The first 10 members will have access to the wine cellar. :-) How does or will Haskell Hall differ? I.e., why would I want to join another list? James From dons at galois.com Sun Jun 22 19:16:22 2008 From: dons at galois.com (Don Stewart) Date: Sun Jun 22 19:08:03 2008 Subject: [Haskell-cafe] INVITATION In-Reply-To: <485EDACE.1080009@neurogami.com> References: <485EDACE.1080009@neurogami.com> Message-ID: <20080622231622.GD7178@scytale.galois.com> james: > Haskell Hall wrote: > > Haskell Hall is up and running. Haskell Hall is a mailing list, a > forum, where you can discuss Haskell, functional programming and > anything related, freely and openly with fellow enthusiasts. We welcome > people of all abilities and know-how. So, if you fancy a change from > what you get on Haskell Cafe send an email to > haskell-request@freelists.org with the word subscribe in the subject > field.The first 10 members will have access to the wine cellar. :-) > > > How does or will Haskell Hall differ? > > I.e., why would I want to join another list? This is a list set up by PR Stanley after he was moderated last week, during a flame war in this channel. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/41413/focus=41444 Make of that what you will. -- Don From ok at cs.otago.ac.nz Sun Jun 22 22:23:26 2008 From: ok at cs.otago.ac.nz (Richard A. O'Keefe) Date: Sun Jun 22 22:15:10 2008 Subject: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment? In-Reply-To: <485B95A9.2090002@jellybean.co.uk> References: <7e270cea0806170945l50f68d35p4761e6a0ee131104@mail.gmail.com> <1213755981.3338.15.camel@jonathans-macbook> <7e270cea0806172136m67f5eb22o6fda46db93b49053@mail.gmail.com> <4859F46B.5060602@jellybean.co.uk> <279D0571-7E22-41C1-8F46-8FF40E12506A@cs.otago.ac.nz> <4859FBC1.2070102@jellybean.co.uk> <1213896576.5557.55.camel@derek-laptop> <485B95A9.2090002@jellybean.co.uk> Message-ID: <0B58BD73-20F8-4845-BCFF-92C6C85D88AE@cs.otago.ac.nz> This is increasingly less relevant to Haskell, except of course to demonstrate what a nice language Haskell is. On 20 Jun 2008, at 11:34 pm, Jules Bean wrote: > I think where I differ on you is how to map the semantics of a C- > like language to explicit references. > > I would argue that the glyph "c" in a C-like language denotes the > value of C, not the reference to it. C-like languages have, for the > most part, value semantics, and call-by-value. > > The exception of course is what C-like languages called "lvalues", > but lvalues are only really on the left of the = sign and a few > other special positions. I think that's the exception and not the > rule. No, this is back to front. C basically follows the Algol 68 idea that the lvalue is the normative thing, and that there is an IMPLICIT COERCION from a variable to its value in certain contexts. C is full of implicit coercions: perhaps the most famous is the one that says that in almost all contexts an array is quietly coerced to a pointer to its first element. The key observation is that an implicit coercion from a variable to its contents is possible, whereas an implicit coercion from a value to "the" variable that holds it is not. Only the "a variable really stands for its address" view is coherent. > In C, of course, if you want to capture the reference you do it > explicitly with "&c". If we can use evidence from a relative to probe such questions, the fact that you *don't* need an explicit "&" in C++ (when you find a 'reference' to a variable, you use "c", not "&c") strongly suggests that the "variable stands for location" view is the more useful one. Thankfully, Haskell saves us these perplexities. (And replaces them with other perplexities...) From xj2106 at columbia.edu Sun Jun 22 23:26:58 2008 From: xj2106 at columbia.edu (Xiao-Yong Jin) Date: Sun Jun 22 23:19:16 2008 Subject: [Haskell-cafe] What is a rigid type variable? Message-ID: <87r6aokf0d.fsf@columbia.edu> Hi all, I'm writing a short function as follows, but I'm not able to find a suitable type signature for `go'. It uses Numeric.LinearAlgebra from hmatrix. -- | Map each element in a vector to vectors and thus form a matrix -- | row by row mapVecToMat :: (Element a, Element b) => (a -> Vector b) -> Vector a -> Matrix b mapVecToMat f v = fromRows $ go (d - 1) [] where d = dim v go :: Element b => Int -> [Vector b] -> [Vector b] go 0 vs = f (v @> 0) : vs go !j !vs = go (j - 1) (f (v @> j) : vs) If I give the type signature to go as this, I got the following error Couldn't match expected type `b1' against inferred type `b' `b1' is a rigid type variable bound by the type signature for `go' at test.hs:36:20 `b' is a rigid type variable bound by the type signature for `mapVecToMat' at test.hs:31:35 Expected type: Vector b1 Inferred type: Vector b In the first argument of `(:)', namely `f (v @> 0)' In the expression: f (v @> 0) : vs So what is this rigid type variable all about and what is correct type of the function `go'? Thanks in advance, X-Y -- c/* __o/* <\ * (__ */\ < From jamiiecb at googlemail.com Mon Jun 23 01:51:09 2008 From: jamiiecb at googlemail.com (Jamie Brandon) Date: Mon Jun 23 01:42:47 2008 Subject: [Haskell-cafe] Planet haskell Message-ID: <10ed1a750806222251s6a276fd4ha6a5f77195fd663c@mail.gmail.com> I was hoping to have my summer of code blog added to planet haskell but planet@community.haskell.org no longer seems to exist. Hopefully the owner is subscribed to this list? Jamie From lrpalmer at gmail.com Mon Jun 23 01:58:50 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Mon Jun 23 01:50:26 2008 Subject: [Haskell-cafe] What is a rigid type variable? In-Reply-To: <87r6aokf0d.fsf@columbia.edu> References: <87r6aokf0d.fsf@columbia.edu> Message-ID: <7ca3f0160806222258t1e08397etb6a98d8566665c0e@mail.gmail.com> On Mon, Jun 23, 2008 at 3:26 AM, Xiao-Yong Jin wrote: > Hi all, > > I'm writing a short function as follows, but I'm not able to > find a suitable type signature for `go'. It uses > Numeric.LinearAlgebra from hmatrix. > > > -- | Map each element in a vector to vectors and thus form a matrix > -- | row by row > mapVecToMat :: (Element a, Element b) => > (a -> Vector b) -> Vector a -> Matrix b > mapVecToMat f v = fromRows $ go (d - 1) [] > where > d = dim v > go :: Element b => Int -> [Vector b] -> [Vector b] > go 0 vs = f (v @> 0) : vs > go !j !vs = go (j - 1) (f (v @> j) : vs) If you want to give a type signature for 'go', you need a GHC extension called ScopeTypeVariables (IIRC). The problem is that the 'b' in the signature of mapVecToMat is not the same b as the one in 'go'. With this extension, you can put those variables into scope for the body of the definition using explicit 'forall' quantifiers: mapVecToMat :: forall a b. (Element a, Element b) => (a -> Vector b) -> Vector a -> Matrix b -- rest as before But the Element b constraint is redundant in the signature of 'go', since that constraint is already in place by the above signature. As far as I can tell, giving an explicit signature for 'go' is not possible without this extension. Luke From lrpalmer at gmail.com Mon Jun 23 02:02:13 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Mon Jun 23 01:53:51 2008 Subject: [Haskell-cafe] What is a rigid type variable? In-Reply-To: <7ca3f0160806222258t1e08397etb6a98d8566665c0e@mail.gmail.com> References: <87r6aokf0d.fsf@columbia.edu> <7ca3f0160806222258t1e08397etb6a98d8566665c0e@mail.gmail.com> Message-ID: <7ca3f0160806222302i3bf31925ke5c23dc4cbe0f3b9@mail.gmail.com> On Mon, Jun 23, 2008 at 5:58 AM, Luke Palmer wrote: > On Mon, Jun 23, 2008 at 3:26 AM, Xiao-Yong Jin wrote: >> Hi all, >> >> I'm writing a short function as follows, but I'm not able to >> find a suitable type signature for `go'. It uses >> Numeric.LinearAlgebra from hmatrix. >> >> >> -- | Map each element in a vector to vectors and thus form a matrix >> -- | row by row >> mapVecToMat :: (Element a, Element b) => >> (a -> Vector b) -> Vector a -> Matrix b >> mapVecToMat f v = fromRows $ go (d - 1) [] >> where >> d = dim v >> go :: Element b => Int -> [Vector b] -> [Vector b] >> go 0 vs = f (v @> 0) : vs >> go !j !vs = go (j - 1) (f (v @> j) : vs) > > If you want to give a type signature for 'go', you need a GHC > extension called ScopeTypeVariables (IIRC). I was indeed correct on the name of this extension, but it would be no help to you to know this since I made a typo :-) The extension is called ScopedTypeVaraibles. You probably already know that this can be enabled with: {-# LANGUAGE ScopedTypeVariables #-} Luke From leledumbo_cool at yahoo.co.id Mon Jun 23 02:30:51 2008 From: leledumbo_cool at yahoo.co.id (leledumbo) Date: Mon Jun 23 02:23:31 2008 Subject: [Haskell-cafe] Help with generalizing function Message-ID: <18063291.post@talk.nabble.com> I've successfully create a function to return lists of N-ple that satisfy the following function: x1 + x2 + x3 + ... + xN = C But unfortunately, it's not generic. The N is supposed to be an input, too. I don't know how to make a dynamic N-ple (is it possible anyway?). Currently, here's the implementation: [code] findAllAns c = [ (x1,x2,x3,x4,x5) | x1 <- [0..c], x2 <- [0..c], x3 <- [0..c], x4 <- [0..c], x5 <- [0..c], x1 + x2 + x3 + x4 + x5 == c ] [/code] I tried using lists of lists, like this: [code] findAllAns c n = [ [x] | x <- [0..c], length [x] == n ] [/code] but [x] doesn't mean "a list of x", instead it's "a list that contains an x, where x in [0..c]". Can anyone help me? -- View this message in context: http://www.nabble.com/Help-with-generalizing-function-tp18063291p18063291.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From ryani.spam at gmail.com Mon Jun 23 02:37:25 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Mon Jun 23 02:29:02 2008 Subject: [Haskell-cafe] What is a rigid type variable? In-Reply-To: <87r6aokf0d.fsf@columbia.edu> References: <87r6aokf0d.fsf@columbia.edu> Message-ID: <2f9b2d30806222337r7f462c9el89a3e8c58986ec8d@mail.gmail.com> To answer the question in the subject: >From "Simple unification-based type inference for GADTs", Peyton-Jones, et al. ICFP 2006. http://research.microsoft.com/users/simonpj/papers/gadt/ "Instead of "user-specified type", we use the briefer term rigid type to describe a type that is completely specified, in some direct fashion, by a programmer-supplied type annotation." So a rigid type is any type specified by a programmer type signature. All other types are "wobbly". Does anyone know what is going to change about the terminology with the new "boxy types" paper? http://research.microsoft.com/users/simonpj/papers/boxy/ -- ryan -- ryan On Sun, Jun 22, 2008 at 8:26 PM, Xiao-Yong Jin wrote: > Hi all, > > I'm writing a short function as follows, but I'm not able to > find a suitable type signature for `go'. It uses > Numeric.LinearAlgebra from hmatrix. > > > -- | Map each element in a vector to vectors and thus form a matrix > -- | row by row > mapVecToMat :: (Element a, Element b) => > (a -> Vector b) -> Vector a -> Matrix b > mapVecToMat f v = fromRows $ go (d - 1) [] > where > d = dim v > go :: Element b => Int -> [Vector b] -> [Vector b] > go 0 vs = f (v @> 0) : vs > go !j !vs = go (j - 1) (f (v @> j) : vs) > > > If I give the type signature to go as this, I got the > following error > > Couldn't match expected type `b1' against inferred type `b' > `b1' is a rigid type variable bound by > the type signature for `go' at test.hs:36:20 > `b' is a rigid type variable bound by > the type signature for `mapVecToMat' at test.hs:31:35 > Expected type: Vector b1 > Inferred type: Vector b > In the first argument of `(:)', namely `f (v @> 0)' > In the expression: f (v @> 0) : vs > > So what is this rigid type variable all about and what is > correct type of the function `go'? > > Thanks in advance, > X-Y > -- > c/* __o/* > <\ * (__ > */\ < > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ryani.spam at gmail.com Mon Jun 23 02:42:43 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Mon Jun 23 02:34:20 2008 Subject: [Haskell-cafe] Help with generalizing function In-Reply-To: <18063291.post@talk.nabble.com> References: <18063291.post@talk.nabble.com> Message-ID: <2f9b2d30806222342i300d6a3s5006eb6eb485e6a3@mail.gmail.com> Hint: use recursion. Hint 2: You can use <- in a list comprehension or list "do"-block to select a single list from a list of lists. -- ryan On Sun, Jun 22, 2008 at 11:30 PM, leledumbo wrote: > > I've successfully create a function to return lists of N-ple that satisfy the > following function: > x1 + x2 + x3 + ... + xN = C > But unfortunately, it's not generic. The N is supposed to be an input, too. > I don't know how to make a dynamic N-ple (is it possible anyway?). > Currently, here's the implementation: > [code] > findAllAns c = [ (x1,x2,x3,x4,x5) | > x1 <- [0..c], > x2 <- [0..c], > x3 <- [0..c], > x4 <- [0..c], > x5 <- [0..c], > x1 + x2 + x3 + x4 + x5 == c > ] > [/code] > I tried using lists of lists, like this: > [code] > findAllAns c n = [ [x] | x <- [0..c], length [x] == n ] > [/code] > but [x] doesn't mean "a list of x", instead it's "a list that contains an x, > where x in [0..c]". Can anyone help me? > -- > View this message in context: http://www.nabble.com/Help-with-generalizing-function-tp18063291p18063291.html > Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From bulat.ziganshin at gmail.com Mon Jun 23 02:42:33 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Jun 23 02:35:53 2008 Subject: [Haskell-cafe] Help with generalizing function In-Reply-To: <18063291.post@talk.nabble.com> References: <18063291.post@talk.nabble.com> Message-ID: <1038886043.20080623104233@gmail.com> Hello leledumbo, Monday, June 23, 2008, 10:30:51 AM, you wrote: > I've successfully create a function to return lists of N-ple that satisfy the tuples may contain any combination of types, use lists instead -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From harald.rotter at sagem.com Mon Jun 23 02:50:33 2008 From: harald.rotter at sagem.com (Harald ROTTER) Date: Mon Jun 23 02:42:44 2008 Subject: [Haskell-cafe] number-parameterized types and heterogeneous lists Message-ID: Hello, sorry for the late answer, I was off for the weekend :-) The paper "Number-parameterized types" by Oleg Kielyov is located at http://okmij.org/ftp/papers/number-parameterized-types.pdf It impressively shows what one can do with Haskell's type system. What I am after is the replacement of a "chain" of digits, like e.g. D1 $ D0 $ D0 $ Sz by a list [D1,D0,D0] so I can effectively use list operations on those "typed numbers". I also wonder if there is some kind of "generalized" foldr such that, e.g. D1 $ D0 $ D0 $ Sz = specialFoldr ($) Sz [D1,D0,D0] I think that this foldr must be some "special" foldr that augments the data type of the result in each foldr step. Would this be possible or am I just chasing phantoms ? Thanks Harald. " Ce courriel et les documents qui y sont attaches peuvent contenir des informations confidentielles. Si vous n'etes pas le destinataire escompte, merci d'en informer l'expediteur immediatement et de detruire ce courriel ainsi que tous les documents attaches de votre systeme informatique. Toute divulgation, distribution ou copie du present courriel et des documents attaches sans autorisation prealable de son emetteur est interdite." " This e-mail and any attached documents may contain confidential or proprietary information. If you are not the intended recipient, please advise the sender immediately and delete this e-mail and all attached documents from your computer system. Any unauthorised disclosure, distribution or copying hereof is prohibited." From leledumbo_cool at yahoo.co.id Mon Jun 23 04:04:58 2008 From: leledumbo_cool at yahoo.co.id (leledumbo) Date: Mon Jun 23 03:56:35 2008 Subject: [Haskell-cafe] Help with generalizing function In-Reply-To: <2f9b2d30806222342i300d6a3s5006eb6eb485e6a3@mail.gmail.com> References: <18063291.post@talk.nabble.com> <2f9b2d30806222342i300d6a3s5006eb6eb485e6a3@mail.gmail.com> Message-ID: <18064396.post@talk.nabble.com> >> tuples may contain any combination of types, use lists instead I think so, too. >> You can use <- in a list comprehension or list "do"-block to select a >> single list from a list of lists. Is it related with my question? I mean, instead of extracting, I need to construct lists. -- View this message in context: http://www.nabble.com/Help-with-generalizing-function-tp18063291p18064396.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From lrpalmer at gmail.com Mon Jun 23 04:05:33 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Mon Jun 23 03:57:08 2008 Subject: [Haskell-cafe] number-parameterized types and heterogeneous lists In-Reply-To: References: Message-ID: <7ca3f0160806230105h56fa14b7g1acc3201be6f06f8@mail.gmail.com> On Mon, Jun 23, 2008 at 6:50 AM, Harald ROTTER wrote: > Hello, > > sorry for the late answer, I was off for the weekend :-) > > The paper "Number-parameterized types" by Oleg Kielyov is located at > > http://okmij.org/ftp/papers/number-parameterized-types.pdf > > It impressively shows what one can do with Haskell's type system. > What I am after is the replacement of a "chain" of digits, like e.g. > D1 $ D0 $ D0 $ Sz > by a list > [D1,D0,D0] > so I can effectively use list operations on those "typed numbers". I also > wonder if there is some kind of > "generalized" foldr such that, e.g. > D1 $ D0 $ D0 $ Sz = specialFoldr ($) Sz [D1,D0,D0] > I think that this foldr must be some "special" foldr that augments the data > type of the result in each foldr step. > Would this be possible or am I just chasing phantoms ? Mostly I believe you are. What you are describing is firmly in the realm of dependent types, far beyond Haskell's type system. See Epigram or Agda for languages which have attempted to tackle this problem. Luke From antti-juhani at kaijanaho.fi Mon Jun 23 04:08:50 2008 From: antti-juhani at kaijanaho.fi (Antti-Juhani Kaijanaho) Date: Mon Jun 23 04:00:27 2008 Subject: [Haskell-cafe] Planet haskell In-Reply-To: <10ed1a750806222251s6a276fd4ha6a5f77195fd663c@mail.gmail.com> References: <10ed1a750806222251s6a276fd4ha6a5f77195fd663c@mail.gmail.com> Message-ID: <20080623080849.GE4901@kukkaseppele.kaijanaho.fi> On Mon, Jun 23, 2008 at 06:51:09AM +0100, Jamie Brandon wrote: > I was hoping to have my summer of code blog added to planet haskell > but planet@community.haskell.org no longer seems to exist. Hopefully > the owner is subscribed to this list? It exists but seems to be broken. Thank you for letting me know. In the mean time, just contact myself or Don Stewart. -- Antti-Juhani Kaijanaho, Jyv?skyl?, Finland http://antti-juhani.kaijanaho.fi/newblog/ http://www.flickr.com/photos/antti-juhani/ From lrpalmer at gmail.com Mon Jun 23 04:11:46 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Mon Jun 23 04:03:22 2008 Subject: [Haskell-cafe] Help with generalizing function In-Reply-To: <18063291.post@talk.nabble.com> References: <18063291.post@talk.nabble.com> Message-ID: <7ca3f0160806230111o36adb13cl96ebd67773718924@mail.gmail.com> On Mon, Jun 23, 2008 at 6:30 AM, leledumbo wrote: > I've successfully create a function to return lists of N-ple that satisfy the > following function: > x1 + x2 + x3 + ... + xN = C > But unfortunately, it's not generic. The N is supposed to be an input, too. > I don't know how to make a dynamic N-ple (is it possible anyway?). > Currently, here's the implementation: > [code] > findAllAns c = [ (x1,x2,x3,x4,x5) | > x1 <- [0..c], > x2 <- [0..c], > x3 <- [0..c], > x4 <- [0..c], > x5 <- [0..c], > x1 + x2 + x3 + x4 + x5 == c > ] > [/code] You will not be able to do this with a straight list comprehension without using recursion. It may help you to know that: [ e | x <- as, y <- bs ] -- for any expression e Is equivalent to concat [ [ e | y <- bs ] | x <- as ] That is a way commas in list comprehensions can be factored out. Luke From alfonso.acosta at gmail.com Mon Jun 23 04:26:30 2008 From: alfonso.acosta at gmail.com (Alfonso Acosta) Date: Mon Jun 23 04:18:12 2008 Subject: [Haskell-cafe] number-parameterized types and heterogeneous lists In-Reply-To: References: Message-ID: <6a7c66fc0806230126w6886a427j50265ad60389b0f3@mail.gmail.com> Inspired in Oleg's ideas, I implemented the packages type-level and parameterized-data (which includes number-parameterized vectors). To get an idea about how they work you might want to read their haddock documentation in hackage: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/type-level http://hackage.haskell.org/cgi-bin/hackage-scripts/package/parameterized-data You can get their darcs repositories (including some minor updates) from: darcs get http://code.haskell.org/type-level darcs get http://code.haskell.org/parameterized-data On Fri, Jun 20, 2008 at 8:01 AM, Harald ROTTER wrote: > > Dear Haskellers, > > after reading Oleg Kiselyov's paper on number-parameterized types I started > to play around with > the class Digits that encodes decimal numbers in types. The "typed number" > 10 would e.g. be defined as > > D1 $ D0 $ Sz > > I wondered if it would be possible replace the expression above by a > heterogeneous list like > > [D1,D0] > > so I tried to define > > data Digit = forall a b.(Digits a, Digits (b a)) => Digit (a -> b a) > > Loading this into ghci yields: > > :t Digit D0 > > :1:0: > Ambiguous type variable `a' in the constraint: > `Digits a' arising from a use of `Digit' at :1:0-7 > Probable fix: add a type signature that fixes these type variable(s) > > Removing the type constraints in the definition of "Digit": > > data Digit = forall a b.Digit (a -> b a) > > makes it work like this: > > :t Digit D0 > Digit D0 :: Digit > > :t [Digit D0, Digit D1] > [Digit D0, Digit D1] :: [Digit] > > "Digit", however, is far too general (it also includes e.g. \x -> [x]), but > I would like it to be restricted to the Digit class. > > Any help is appreciated. > > Thanks > > Harald. > > > CODE: > > module Test where > > data D0 a = D0 a > data D1 a = D1 a > data D2 a = D2 a > data D3 a = D3 a > data D4 a = D4 a > data D5 a = D5 a > data D6 a = D6 a > data D7 a = D7 a > data D8 a = D8 a > data D9 a = D9 a > > class Digits ds where > d2num :: Num a => ds -> a -> a > > data Sz = Sz -- zero size > instance Digits Sz where > d2num _ acc = acc > > instance Digits ds => Digits (D0 ds) where > d2num dds acc = d2num (t22 dds) (10*acc) > instance Digits ds => Digits (D1 ds) where > d2num dds acc = d2num (t22 dds) (10*acc+1) > instance Digits ds => Digits (D2 ds) where > d2num dds acc = d2num (t22 dds) (10*acc+2) > instance Digits ds => Digits (D3 ds) where > d2num dds acc = d2num (t22 dds) (10*acc+3) > instance Digits ds => Digits (D4 ds) where > d2num dds acc = d2num (t22 dds) (10*acc+4) > instance Digits ds => Digits (D5 ds) where > d2num dds acc = d2num (t22 dds) (10*acc+5) > instance Digits ds => Digits (D6 ds) where > d2num dds acc = d2num (t22 dds) (10*acc+6) > instance Digits ds => Digits (D7 ds) where > d2num dds acc = d2num (t22 dds) (10*acc+7) > instance Digits ds => Digits (D8 ds) where > d2num dds acc = d2num (t22 dds) (10*acc+8) > instance Digits ds => Digits (D9 ds) where > d2num dds acc = d2num (t22 dds) (10*acc+9) > > t22 :: f x -> x > t22 = undefined > > --data Digit = forall a b.(Digits a, Digits (b a)) => Digit (a -> b a) > data Digit = forall a b.Digit (a -> b a) > > ------------------------------------------------------------------------------------------------- > > > > " Ce courriel et les documents qui y sont attaches peuvent contenir des informations confidentielles. Si vous n'etes pas le destinataire escompte, merci d'en informer l'expediteur immediatement et de detruire ce courriel ainsi que tous les documents attaches de votre systeme informatique. Toute divulgation, distribution ou copie du present courriel et des documents attaches sans autorisation prealable de son emetteur est interdite." > > " This e-mail and any attached documents may contain confidential or proprietary information. If you are not the intended recipient, please advise the sender immediately and delete this e-mail and all attached documents from your computer system. Any unauthorised disclosure, distribution or copying hereof is prohibited." > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From leledumbo_cool at yahoo.co.id Mon Jun 23 05:00:51 2008 From: leledumbo_cool at yahoo.co.id (leledumbo) Date: Mon Jun 23 04:52:28 2008 Subject: [Haskell-cafe] Help with generalizing function In-Reply-To: <7ca3f0160806230111o36adb13cl96ebd67773718924@mail.gmail.com> References: <18063291.post@talk.nabble.com> <7ca3f0160806230111o36adb13cl96ebd67773718924@mail.gmail.com> Message-ID: <18065206.post@talk.nabble.com> I give up %-|, I'll go back to Pascal instead. Thanks for your answers. -- View this message in context: http://www.nabble.com/Help-with-generalizing-function-tp18063291p18065206.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From Malcolm.Wallace at cs.york.ac.uk Mon Jun 23 05:04:14 2008 From: Malcolm.Wallace at cs.york.ac.uk (Malcolm Wallace) Date: Mon Jun 23 05:00:22 2008 Subject: [Haskell-cafe] Safe way to parse arguments? In-Reply-To: References: <87tzfmtxeh.fsf@columbia.edu> Message-ID: <20080623100414.2b530b10.Malcolm.Wallace@cs.york.ac.uk> > > I'm wondering how usually you parse command line arguments > > list safely. > > > > Prelude.read: no parse > > It's generally not a good idea to call 'read' on user data. There is (at least one) proper parsing library intended as a direct replacement for Read: http://www.cs.york.ac.uk/fp/polyparse/haddock/Text-Parse.html The basic idea is that the function 'parse' replaces 'read', and to use it at any specific type T: (runParser parse) :: String -> (Either String T, String) You get back either an error message or the value, along with the remaining unparsed text. Instances of the Parse class are defined for all Prelude types, and you can easily derive instances for any of your own types, using the DrIFT tool. Parse is assumed to be an inverse of Show, that is, the derived instances of Parse will read back a canonically derived Show value. Another benefit of using a real parser library is that you can plumb together several parsers quickly if you need to. e.g. runParser (exactly 3 parse) :: String -> (Either String [T], String) Regards, Malcolm From vigalchin at gmail.com Mon Jun 23 05:10:33 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Mon Jun 23 05:02:10 2008 Subject: [Haskell-cafe] Re: "C" buffer suggestions?? In-Reply-To: <5ae4f2ba0806212347r56df45fdu962fccc1bd532ac9@mail.gmail.com> References: <5ae4f2ba0806212347r56df45fdu962fccc1bd532ac9@mail.gmail.com> Message-ID: <5ae4f2ba0806230210m6453be5aqfbeaecf342291291@mail.gmail.com> Basically I want to model POSIX async io "aiocb"( http://uw714doc.sco.com/en/man/html.5/aiocb.5.html) in Haskell .. in particular the aiocb field "aio_buf"! Kind regards, Vasili On Sun, Jun 22, 2008 at 1:47 AM, Galchin, Vasili wrote: > Hello, > > I want to model an I/O read/write buffer in Haskell and marshall down > into ANSI C. > > 1) ByteString? Or Ptr Word8? > > 2) What are example values of the types in 1)? > > > Kind regards, Vasili > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080623/bd6ba040/attachment.htm From chaddai.fouche at gmail.com Mon Jun 23 05:42:25 2008 From: chaddai.fouche at gmail.com (=?ISO-8859-1?Q?Chadda=EF_Fouch=E9?=) Date: Mon Jun 23 05:34:01 2008 Subject: [Haskell-cafe] Help with generalizing function In-Reply-To: <18065206.post@talk.nabble.com> References: <18063291.post@talk.nabble.com> <7ca3f0160806230111o36adb13cl96ebd67773718924@mail.gmail.com> <18065206.post@talk.nabble.com> Message-ID: 2008/6/23 leledumbo : > > I give up %-|, I'll go back to Pascal instead. Thanks for your answers. Don't give up so fast !! (Note that you can't do what you asked for in Pascal either, in fact Pascal don't support n-uplet) A recursive way to do it is : findAllAns 0 0 = [[]] findAllAns 0 s = [] findAllAns n s = [ x:xs | x <- [0..s], xs <- findAllAns (n - 1) (s - x) ] For all those little questions that bug you, you'll get your answers faster by asking on the #haskell channel on irc.freenode.org . -- Jeda? From bulat.ziganshin at gmail.com Mon Jun 23 05:45:30 2008 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Jun 23 05:38:48 2008 Subject: [Haskell-cafe] Help with generalizing function In-Reply-To: References: <18063291.post@talk.nabble.com> <7ca3f0160806230111o36adb13cl96ebd67773718924@mail.gmail.com> <18065206.post@talk.nabble.com> Message-ID: <1316971110.20080623134530@gmail.com> Hello Chaddai, Monday, June 23, 2008, 1:42:25 PM, you wrote: >> I give up %-|, I'll go back to Pascal instead. Thanks for your answers. > findAllAns 0 0 = [[]] > findAllAns 0 s = [] > findAllAns n s = [ x:xs | x <- [0..s], xs <- findAllAns (n - 1) (s - x) ] seems that leledumbo found a new way to force us give the answers to those homeworks LOL -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From isaacdupree at charter.net Mon Jun 23 06:56:12 2008 From: isaacdupree at charter.net (Isaac Dupree) Date: Mon Jun 23 06:47:51 2008 Subject: [Haskell-cafe] ANNOUNCE: Pipe 1.0 In-Reply-To: <20080621191255.GA2361@scytale.galois.com> References: <20080621191255.GA2361@scytale.galois.com> Message-ID: <485F814C.7090105@charter.net> Don Stewart wrote: > Interesting. > Does it depend on an unreleased version of the process library? by the way, is there a policy for when new versions of packages maintained by libraries@h.o are *released*? Or do patches just collect in the darcs repository until they're picked up by some major release like GHC's? I would tend to think that for any change nontrivial enough to be discussed on libraries@, why not quickly release the newer version with an appropriately incremented version number? -Isaac From leledumbo_cool at yahoo.co.id Mon Jun 23 07:03:18 2008 From: leledumbo_cool at yahoo.co.id (leledumbo) Date: Mon Jun 23 06:54:55 2008 Subject: Re[Haskell-cafe] [2]: Help with generalizing function In-Reply-To: <1316971110.20080623134530@gmail.com> References: <18063291.post@talk.nabble.com> <7ca3f0160806230111o36adb13cl96ebd67773718924@mail.gmail.com> <18065206.post@talk.nabble.com> <1316971110.20080623134530@gmail.com> Message-ID: <18066860.post@talk.nabble.com> >> Don't give up so fast !! (Note that you can't do what you asked for in >> Pascal either, in fact Pascal don't support n-uplet) I'm not going to use n-uplet, dynamic array of array of Byte is enough. Though not very optimizing, I can use 2 step process: 1. Generate all lists (array of Byte) of length N which each element ranges from 0 to C. 2. Filter which has sum=C. >> seems that leledumbo found a new way to force us give the answers to >> those homeworks LOL Don't worry, I'm not gonna use it because it has to be done in procedural way (I haven't taken Functional Programming class yet). The reason why I ask is I'm HOPING that if I can understand how it works, implementing the procedural form would be easy. I've read somewhere that functional language can be implemented in procedural one. In fact, GHC outputs C code. Thanks for the answer. I'll use it to learn, it's quite difficult to switch from procedural to functional. I mean, in procedural it's easy to find the fastest solution using brute force. This can't be done in functional. -- View this message in context: http://www.nabble.com/Help-with-generalizing-function-tp18063291p18066860.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From leledumbo_cool at yahoo.co.id Mon Jun 23 07:04:18 2008 From: leledumbo_cool at yahoo.co.id (leledumbo) Date: Mon Jun 23 06:55:54 2008 Subject: Re[Haskell-cafe] [2]: Help with generalizing function In-Reply-To: <1316971110.20080623134530@gmail.com> References: <18063291.post@talk.nabble.com> <7ca3f0160806230111o36adb13cl96ebd67773718924@mail.gmail.com> <18065206.post@talk.nabble.com> <1316971110.20080623134530@gmail.com> Message-ID: <18066861.post@talk.nabble.com> >> Don't give up so fast !! (Note that you can't do what you asked for in >> Pascal either, in fact Pascal don't support n-uplet) I'm not going to use n-uplet, dynamic array of array of Byte is enough. Though not very optimizing, I can use 2 step process: 1. Generate all lists (array of Byte) of length N which each element ranges from 0 to C. 2. Filter which has sum=C. >> seems that leledumbo found a new way to force us give the answers to >> those homeworks LOL Don't worry, I'm not gonna use it because it has to be done in procedural way (I haven't taken Functional Programming class yet). The reason why I ask is I'm HOPING that if I can understand how it works, implementing the procedural form would be easy. I've read somewhere that functional language can be implemented in procedural one. In fact, GHC outputs C code. Thanks for the answer. I'll use it to learn, it's quite difficult to switch from procedural to functional. I mean, in procedural it's easy to find the fastest solution using brute force. This can't be done in functional. -- View this message in context: http://www.nabble.com/Help-with-generalizing-function-tp18063291p18066861.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From abhay.parvate at gmail.com Mon Jun 23 07:20:30 2008 From: abhay.parvate at gmail.com (Abhay Parvate) Date: Mon Jun 23 07:12:06 2008 Subject: [Haskell-cafe] Literal programming in Haskell with rst-literals In-Reply-To: <20080621181854.184193C8002@banane.furius.ca> References: <20080621181854.184193C8002@banane.furius.ca> Message-ID: <3c4d5adf0806230420w56198d39n4027f00341f90b17@mail.gmail.com> Hello, You might already know this, but in case you don't: there is another literate style: ... non-code ... \begin{code} ... code ... \end{code} ... non-code ... in which you do not put prefixes to each line. (In fact the standard says somewhere it is not recommended to mix the two styles if I remember right.) I hope I am not being redundant! Abhay On Sat, Jun 21, 2008 at 11:48 PM, Martin Blais wrote: > > Hello Haskell community! > > I just did a marginally cool thing and I wanted to share it > with you. > > "rst-literals" is a small program I wrote a while ago in > order to write documents in reStructuredText format that > would embed SQL code for data models in them, a form of > literal programming for SQL if you will; I would describe my > needs for the schema in prose, and reST literal-blocks were > used to embed SQL code, blocks that look like this:: > > CLASS Employee ( > firstname VARCHAR, > lastname VARCHAR > ) > > I wrote the script to be entirely generic: it parses the > reST documents using the docutils code and outputs only the > literal-blocks, with indentation removed; you can then run > your favourite interpreter/compiler on the result (in that > case, psql to initialize a database). > > Recently, while experimenting with Haskell, I started using > both the literal (.lhs) and non-literal (.hs) styles of > Haskell input, and I found the literal style a bit > unpleasant to use, in particular, I don't like to have to > prefix every line of code I write, despite the help that > Emacs' haskell-mode provides. > > So I tried pulling a similar trick and embedding Haskell > code in literal-blocks within reST documents, extracting > that code using rst-literals, and it turns out that it works > like a charm. Here is an example makefile for doing this:: > > .SUFFIXES: .rst .hs > > all: chap6 > > .rst.hs: > rst-literals $< > $@ > > chap6: chap6.hs > ghc --make chap6.hs > > An example reST document with some embedded Haskell code > follows this email. Note that since rst-literals is using > the docutils parser, you can make use of all of the > recursive reST syntax, sections, bulleted items and much > more. Only the literal-blocks are extracted, anywhere they > appear. You can also easily process the reST source into > HTML pages or LaTeX documents using the tools that come with > docutils. > > You can find rst-literals here: > http://furius.ca/pubcode/ > > Enjoy, > > > > > -- > Martin > > P.S. If there is a way to output cpp-like directives for > GHC, like "#line ", it would be easy to > modify rst-literals to generate those, so that compilation > errors could refer to the source reST document instead of > the extracted source. > > > > chap6.hs: > ---------------------------------------------------------------------- > > =========================================== > Exercises from Hutton book, Chapter 6 > =========================================== > > .. contents:: > .. > 1 Introduction > 2 Exercise 1 > 3 Exercise 2 > 4 Exercise 3 > 5 Exercise 4 > 6 Exercise 5 > 7 Exercise 6 > > > Introduction > ============ > > Bla bla bla blablablablablabla bla bla blabla. Bla bla bla > blablablablablabla bla bla blabla. Bla bla bla blablablablablabla bla > bla blabla. Bla bla bla blablablablablabla bla bla blabla. Bla bla bla > blablablablablabla bla bla blabla. Bla bla bla blablablablablabla bla > bla blabla. > > > Exercise 1 > ========== > :: > > myexp :: Int -> Int -> Int > myexp b 0 = 1 > myexp b (n+1) = b * (myexp b n) > > > Exercise 2 > ========== > > (Exercise 2 consisted in derivations, so we mark the literal > blocks as another type of block with "#!example", so that > they don't get included in the output when only the > "default" literal blocks get extracted. See rst-literals > docstring for details.) > > Length:: > > #!example > 1 + (length [2, 3]) > 1 + 1 + (length [3]) > 1 + 1 + (1) > 3 > > Drop:: > > #!example > drop 3 [1, 2, 3, 4, 5] > [] ++ drop 3 [2, 3, 4, 5] > [] ++ [] ++ drop 3 [3, 4, 5] > [] ++ [] ++ [] ++ [4, 5] > [4, 5] > > Init:: > > #!example > init [1, 2, 3] > [1] ++ init [2, 3] > [1] ++ [2] ++ init [3] > [1] ++ [2] ++ [] > [1, 2] > > > Exercise 3 > ========== > > These are alternate versions of the example functions defined in the > text:: > > and' :: [Bool] -> Bool > and' [x] = x > and' (x:xs) = x && and' xs > > concat' :: [[a]] -> [a] > concat' [] = [] > concat' (x:xs) = x ++ concat' xs > > replicate' :: Int -> a -> [a] > replicate' 0 x = [] > replicate' (n+1) x = (x : replicate' n x) > > select' :: [a] -> Int -> a > select' (x:xs) 0 = x > select' (x:xs) (n+1) = select' xs n > > elem' :: Eq a => a -> [a] -> Bool > elem' _ [] = False > elem' y (x:xs) | x == y = True > | otherwise = elem' y xs > > Exercise 4 > ========== > > The exercise asked to implement a function to merge two lists:: > > merge :: Ord a => [a] -> [a] -> [a] > merge xs [] = xs > merge [] xs = xs > merge (x:xs) (y:ys) | x < y = (x : merge xs (y:ys)) > | otherwise = (y : merge (x:xs) ys) > > > Exercise 5 > ========== > :: > > msort :: Ord a => [a] -> [a] > msort [] = [] > msort [x] = [x] -- This is necessary to end the recursion. > msort xs = merge (msort (fst hh)) (msort (snd hh)) > where hh = halve xs > > halve :: [a] -> ([a], [a]) > halve xs = (take n xs, drop n xs) > where n = (length xs) `div` 2 > > Some main program:: > > main = (putStrLn . show) (halve [1..17]) > > > Exercise 6 > ========== > > (Too basic, I didn't bother.) > > ---------------------------------------------------------------------- > _______________________________________________ > 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/20080623/ccdd921a/attachment.htm From marlowsd at gmail.com Mon Jun 23 09:14:14 2008 From: marlowsd at gmail.com (Simon Marlow) Date: Mon Jun 23 09:05:56 2008 Subject: [Haskell-cafe] Re: ANNOUNCE: Pipe 1.0 In-Reply-To: <485F814C.7090105@charter.net> References: <20080621191255.GA2361@scytale.galois.com> <485F814C.7090105@charter.net> Message-ID: <485FA1A6.9040208@gmail.com> Isaac Dupree wrote: > Don Stewart wrote: >> Interesting. >> Does it depend on an unreleased version of the process library? > > by the way, is there a policy for when new versions of packages > maintained by libraries@h.o are *released*? Or do patches just collect > in the darcs repository until they're picked up by some major release > like GHC's? I would tend to think that for any change nontrivial enough > to be discussed on libraries@, why not quickly release the newer version > with an appropriately incremented version number? There are some further changes we've been discussing, see Duncan's message here: http://www.haskell.org/pipermail/libraries/2008-May/009695.html and I'd like to batch all these together in one release. Cheers, Simon From xj2106 at columbia.edu Mon Jun 23 09:31:59 2008 From: xj2106 at columbia.edu (Xiao-Yong Jin) Date: Mon Jun 23 09:24:18 2008 Subject: [Haskell-cafe] What is a rigid type variable? In-Reply-To: <7ca3f0160806222302i3bf31925ke5c23dc4cbe0f3b9@mail.gmail.com> (Luke Palmer's message of "Mon, 23 Jun 2008 06:02:13 +0000") References: <87r6aokf0d.fsf@columbia.edu> <7ca3f0160806222258t1e08397etb6a98d8566665c0e@mail.gmail.com> <7ca3f0160806222302i3bf31925ke5c23dc4cbe0f3b9@mail.gmail.com> Message-ID: <87ej6ojn00.fsf@columbia.edu> "Luke Palmer" writes: > On Mon, Jun 23, 2008 at 5:58 AM, Luke Palmer wrote: >> On Mon, Jun 23, 2008 at 3:26 AM, Xiao-Yong Jin wrote: >>> Hi all, >>> >>> I'm writing a short function as follows, but I'm not able to >>> find a suitable type signature for `go'. It uses >>> Numeric.LinearAlgebra from hmatrix. >>> >>> >>> -- | Map each element in a vector to vectors and thus form a matrix >>> -- | row by row >>> mapVecToMat :: (Element a, Element b) => >>> (a -> Vector b) -> Vector a -> Matrix b >>> mapVecToMat f v = fromRows $ go (d - 1) [] >>> where >>> d = dim v >>> go :: Element b => Int -> [Vector b] -> [Vector b] >>> go 0 vs = f (v @> 0) : vs >>> go !j !vs = go (j - 1) (f (v @> j) : vs) >> >> If you want to give a type signature for 'go', you need a GHC >> extension called ScopeTypeVariables (IIRC). > > I was indeed correct on the name of this extension, but it would be no > help to you to know this since I made a typo :-) > > The extension is called ScopedTypeVaraibles. > > You probably already know that this can be enabled with: > > {-# LANGUAGE ScopedTypeVariables #-} > > Luke Thanks for the explanation. I guess it's just easier for me not to give any type signature to `go', since ghc should do the type inference quite nicely and reliably. X-Y -- c/* __o/* <\ * (__ */\ < From claus.reinke at talk21.com Mon Jun 23 09:40:27 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Mon Jun 23 09:32:10 2008 Subject: GSoC project blogs? (Re: [Haskell-cafe] Planet haskell) References: <10ed1a750806222251s6a276fd4ha6a5f77195fd663c@mail.gmail.com> <20080623080849.GE4901@kukkaseppele.kaijanaho.fi> Message-ID: <00c901c8d536$b5fac540$ea038351@cr3lt> It would be nice to have blogs for all Haskell GSoC projects on Planet Haskell. Infrequent updates (such as Neil's weekly summaries) would be quite okay - details can always be followed up in email, provided that interested parties are aware of them in the first place;-) Otherwise, we end up with little community involvement, and questions like "wasn't there a GSoC project on X last year? What ever happened to that?" Claus > On Mon, Jun 23, 2008 at 06:51:09AM +0100, Jamie Brandon wrote: >> I was hoping to have my summer of code blog added to planet haskell >> but planet@community.haskell.org no longer seems to exist. Hopefully >> the owner is subscribed to this list? > > It exists but seems to be broken. Thank you for letting me know. > > In the mean time, just contact myself or Don Stewart. > > -- > Antti-Juhani Kaijanaho, Jyv?skyl?, Finland > http://antti-juhani.kaijanaho.fi/newblog/ > http://www.flickr.com/photos/antti-juhani/ > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From antti-juhani at kaijanaho.fi Mon Jun 23 09:57:58 2008 From: antti-juhani at kaijanaho.fi (Antti-Juhani Kaijanaho) Date: Mon Jun 23 09:49:34 2008 Subject: GSoC project blogs? (Re: [Haskell-cafe] Planet haskell) In-Reply-To: <00c901c8d536$b5fac540$ea038351@cr3lt> References: <10ed1a750806222251s6a276fd4ha6a5f77195fd663c@mail.gmail.com> <20080623080849.GE4901@kukkaseppele.kaijanaho.fi> <00c901c8d536$b5fac540$ea038351@cr3lt> Message-ID: <20080623135757.GF4901@kukkaseppele.kaijanaho.fi> (I'd rather people did not send me copies of list posts.) On Mon, Jun 23, 2008 at 02:40:27PM +0100, Claus Reinke wrote: > It would be nice to have blogs for all Haskell GSoC projects > on Planet Haskell. Any such blogs would certainly qualify. Authors should read http://planet.haskell.org/policy.html - and while our alias address is out of commission, send addition requests to me or Don Stewart. -- Antti-Juhani Kaijanaho, Jyv?skyl?, Finland http://antti-juhani.kaijanaho.fi/newblog/ http://www.flickr.com/photos/antti-juhani/ From jonathanccast at fastmail.fm Mon Jun 23 10:06:29 2008 From: jonathanccast at fastmail.fm (Jonathan Cast) Date: Mon Jun 23 09:58:05 2008 Subject: Re[Haskell-cafe] [2]: Help with generalizing function In-Reply-To: <18066860.post@talk.nabble.com> References: <18063291.post@talk.nabble.com> <7ca3f0160806230111o36adb13cl96ebd67773718924@mail.gmail.com> <18065206.post@talk.nabble.com> <1316971110.20080623134530@gmail.com> <18066860.post@talk.nabble.com> Message-ID: <1214229989.6302.7.camel@jonathans-macbook> On Mon, 2008-06-23 at 04:03 -0700, leledumbo wrote: > >> Don't give up so fast !! (Note that you can't do what you asked for in > >> Pascal either, in fact Pascal don't support n-uplet) > I'm not going to use n-uplet, dynamic array of array of Byte is enough. > Though not very optimizing, I can use 2 step process: > 1. Generate all lists (array of Byte) of length N which each element ranges > from 0 to C. Come now, you really think this is harder in Haskell than in Pascal? Understanding Haskell takes a little work, granted, but then I always thought the same was true of Pascal... > 2. Filter which has sum=C. Come now. Try your browser's search engine on the standard prelude, word by word. You can't really expect this to be just given to you, but you must realise that sometimes it is... > > >> seems that leledumbo found a new way to force us give the answers to > >> those homeworks LOL > Don't worry, I'm not gonna use it because it has to be done in procedural > way (I haven't taken Functional Programming class yet). The reason why I ask > is I'm HOPING that if I can understand how it works, implementing the > procedural form would be easy. I've read somewhere that functional language > can be implemented in procedural one. In fact, GHC outputs C code. > > Thanks for the answer. I'll use it to learn, it's quite difficult to switch > from procedural to functional. I mean, in procedural it's easy to find the > fastest solution using brute force. Huh? The brute force solution is usually the /slowest/ solution, even in imperative languages. Consider bubble sort (bogo sort if you want to push it) vs. quick sort. > This can't be done in functional. If you mean `find a brute-force solution quickly', getting to the brute force solution is indeed usually /faster/ in a functional language (it's usually shorter, too), because of the higher level of abstraction. (The same is true for other modern languages, such as Perl, Ruby, to a certain extent Python, and soon enough (hopefully) PHP, but then it's questionable in what way the languages (as opposed to their programming cultures) fail to be functional in the first place). jcc From Malcolm.Wallace at cs.york.ac.uk Mon Jun 23 11:10:16 2008 From: Malcolm.Wallace at cs.york.ac.uk (Malcolm Wallace) Date: Mon Jun 23 11:06:36 2008 Subject: GSoC project blogs? (Re: [Haskell-cafe] Planet haskell) In-Reply-To: <00c901c8d536$b5fac540$ea038351@cr3lt> References: <10ed1a750806222251s6a276fd4ha6a5f77195fd663c@mail.gmail.com> <20080623080849.GE4901@kukkaseppele.kaijanaho.fi> <00c901c8d536$b5fac540$ea038351@cr3lt> Message-ID: <20080623161016.5dec64a8.Malcolm.Wallace@cs.york.ac.uk> > It would be nice to have blogs for all Haskell GSoC projects > on Planet Haskell. See also http://hackage.haskell.org/trac/summer-of-code/wiki/progress2008 Regards, Malcolm From stephen at enterity.com Mon Jun 23 11:16:10 2008 From: stephen at enterity.com (Stephen Howard) Date: Mon Jun 23 11:07:01 2008 Subject: [Haskell-cafe] expected vs inferred type confusion Message-ID: <485FBE3A.70806@enterity.com> I am having issues with type signatures for the resourceHandler action below. I haven't figured out what I'm doing wrong to cause the wrong type to be returned. It looks like Haskell is inferring that I'm returning a function from this action, when from the type signature I've specified, that is not what I'm wanting. The gist of the code is based on the request_method of the passed in HttpRequest, choose an action to run and pass it the needed parameters. the error: renao.hs:6:4: Couldn't match `HttpResponse' against `IO HttpResponse' Expected type: IO HttpResponse Inferred type: IO (IO HttpResponse) In the expression: return $ (handler session request) In the result of a 'do' expression: return $ (handler session request) the code: import HttpMessage import HttpSession resourceHandler :: HttpSession -> HttpRequest -> IO HttpResponse resourceHandler session request = do return $ handler session request where handler = which_handler request which_handler r = case request_method r of Get -> get_resources Head -> last_modified Post -> update_resources Put -> create_resources Delete -> delete_resources get_resources :: HttpSession -> HttpRequest -> IO HttpResponse get_resources session request = undefined -- ... the same stubbed definition for the other handlers (last_modified, etc) From Alistair.Bayley at invesco.com Mon Jun 23 11:19:04 2008 From: Alistair.Bayley at invesco.com (Bayley, Alistair) Date: Mon Jun 23 11:10:43 2008 Subject: [Haskell-cafe] expected vs inferred type confusion In-Reply-To: <485FBE3A.70806@enterity.com> References: <485FBE3A.70806@enterity.com> Message-ID: <125EACD0CAE4D24ABDB4D148C4593DA9049E9432@GBLONXMB02.corp.amvescap.net> > From: haskell-cafe-bounces@haskell.org > [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Stephen Howard > > the error: > > renao.hs:6:4: > Couldn't match `HttpResponse' against `IO HttpResponse' > Expected type: IO HttpResponse > Inferred type: IO (IO HttpResponse) > In the expression: return $ (handler session request) > In the result of a 'do' expression: return $ (handler > session request) > > the code: > > import HttpMessage > import HttpSession > > resourceHandler :: HttpSession -> HttpRequest -> IO HttpResponse > resourceHandler session request = do > return $ handler session request > where > handler = which_handler request > which_handler r = case request_method r of > Get -> get_resources > Head -> last_modified > Post -> update_resources > Put -> create_resources > Delete -> delete_resources > > > get_resources :: HttpSession -> HttpRequest -> IO HttpResponse > get_resources session request = undefined > > -- ... the same stubbed definition for the other handlers > (last_modified, etc) Try removing the do ... return $ e.g. > resourceHandler session request = > handler session request > where Alistair ***************************************************************** Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. ***************************************************************** From lemming at henning-thielemann.de Mon Jun 23 11:22:10 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon Jun 23 11:13:47 2008 Subject: [Haskell-cafe] What is a rigid type variable? In-Reply-To: <87ej6ojn00.fsf@columbia.edu> References: <87r6aokf0d.fsf@columbia.edu> <7ca3f0160806222258t1e08397etb6a98d8566665c0e@mail.gmail.com> <7ca3f0160806222302i3bf31925ke5c23dc4cbe0f3b9@mail.gmail.com> <87ej6ojn00.fsf@columbia.edu> Message-ID: On Mon, 23 Jun 2008, Xiao-Yong Jin wrote: > Thanks for the explanation. I guess it's just easier for me > not to give any type signature to `go', since ghc should do > the type inference quite nicely and reliably. If you want to stay Haskell98 'asTypeOf' can help you in similar cases. From darrinth at gmail.com Mon Jun 23 12:16:43 2008 From: darrinth at gmail.com (Darrin Thompson) Date: Mon Jun 23 12:08:18 2008 Subject: [Haskell-cafe] Literal programming in Haskell with rst-literals In-Reply-To: <3c4d5adf0806230420w56198d39n4027f00341f90b17@mail.gmail.com> References: <20080621181854.184193C8002@banane.furius.ca> <3c4d5adf0806230420w56198d39n4027f00341f90b17@mail.gmail.com> Message-ID: 2008/6/23 Abhay Parvate : > Hello, > > You might already know this, but in case you don't: there is another > literate style: > I had trouble finding the docs on this, as I expected them to be in the ghc user guide. For the record, the relevant docs are in the h98 report: http://www.haskell.org/onlinereport/literate.html And the wiki: http://www.haskell.org/haskellwiki/Literate_programming -- Darrin From anton.tayanovskyy at gmail.com Mon Jun 23 12:17:01 2008 From: anton.tayanovskyy at gmail.com (Anton Tayanovskyy) Date: Mon Jun 23 12:08:37 2008 Subject: [Haskell-cafe] number-parameterized types and heterogeneous lists In-Reply-To: <6a7c66fc0806230126w6886a427j50265ad60389b0f3@mail.gmail.com> References: <6a7c66fc0806230126w6886a427j50265ad60389b0f3@mail.gmail.com> Message-ID: Alfonso, Thanks! For didactic purposes I will defer looking into your code. It does not always help to know the correct solution :) Bests, --A On Mon, Jun 23, 2008 at 11:26 AM, Alfonso Acosta wrote: > Inspired in Oleg's ideas, I implemented the packages type-level and > parameterized-data (which includes number-parameterized vectors). > > > To get an idea about how they work you might want to read their > haddock documentation in hackage: > > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/type-level > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/parameterized-data > > You can get their darcs repositories (including some minor updates) from: > > darcs get http://code.haskell.org/type-level > darcs get http://code.haskell.org/parameterized-data > > On Fri, Jun 20, 2008 at 8:01 AM, Harald ROTTER wrote: >> >> Dear Haskellers, >> >> after reading Oleg Kiselyov's paper on number-parameterized types I started >> to play around with >> the class Digits that encodes decimal numbers in types. The "typed number" >> 10 would e.g. be defined as >> >> D1 $ D0 $ Sz >> >> I wondered if it would be possible replace the expression above by a >> heterogeneous list like >> >> [D1,D0] >> >> so I tried to define >> >> data Digit = forall a b.(Digits a, Digits (b a)) => Digit (a -> b a) >> >> Loading this into ghci yields: >> >> :t Digit D0 >> >> :1:0: >> Ambiguous type variable `a' in the constraint: >> `Digits a' arising from a use of `Digit' at :1:0-7 >> Probable fix: add a type signature that fixes these type variable(s) >> >> Removing the type constraints in the definition of "Digit": >> >> data Digit = forall a b.Digit (a -> b a) >> >> makes it work like this: >> >> :t Digit D0 >> Digit D0 :: Digit >> >> :t [Digit D0, Digit D1] >> [Digit D0, Digit D1] :: [Digit] >> >> "Digit", however, is far too general (it also includes e.g. \x -> [x]), but >> I would like it to be restricted to the Digit class. >> >> Any help is appreciated. >> >> Thanks >> >> Harald. >> >> >> CODE: >> >> module Test where >> >> data D0 a = D0 a >> data D1 a = D1 a >> data D2 a = D2 a >> data D3 a = D3 a >> data D4 a = D4 a >> data D5 a = D5 a >> data D6 a = D6 a >> data D7 a = D7 a >> data D8 a = D8 a >> data D9 a = D9 a >> >> class Digits ds where >> d2num :: Num a => ds -> a -> a >> >> data Sz = Sz -- zero size >> instance Digits Sz where >> d2num _ acc = acc >> >> instance Digits ds => Digits (D0 ds) where >> d2num dds acc = d2num (t22 dds) (10*acc) >> instance Digits ds => Digits (D1 ds) where >> d2num dds acc = d2num (t22 dds) (10*acc+1) >> instance Digits ds => Digits (D2 ds) where >> d2num dds acc = d2num (t22 dds) (10*acc+2) >> instance Digits ds => Digits (D3 ds) where >> d2num dds acc = d2num (t22 dds) (10*acc+3) >> instance Digits ds => Digits (D4 ds) where >> d2num dds acc = d2num (t22 dds) (10*acc+4) >> instance Digits ds => Digits (D5 ds) where >> d2num dds acc = d2num (t22 dds) (10*acc+5) >> instance Digits ds => Digits (D6 ds) where >> d2num dds acc = d2num (t22 dds) (10*acc+6) >> instance Digits ds => Digits (D7 ds) where >> d2num dds acc = d2num (t22 dds) (10*acc+7) >> instance Digits ds => Digits (D8 ds) where >> d2num dds acc = d2num (t22 dds) (10*acc+8) >> instance Digits ds => Digits (D9 ds) where >> d2num dds acc = d2num (t22 dds) (10*acc+9) >> >> t22 :: f x -> x >> t22 = undefined >> >> --data Digit = forall a b.(Digits a, Digits (b a)) => Digit (a -> b a) >> data Digit = forall a b.Digit (a -> b a) >> >> ------------------------------------------------------------------------------------------------- >> >> >> >> " Ce courriel et les documents qui y sont attaches peuvent contenir des informations confidentielles. Si vous n'etes pas le destinataire escompte, merci d'en informer l'expediteur immediatement et de detruire ce courriel ainsi que tous les documents attaches de votre systeme informatique. Toute divulgation, distribution ou copie du present courriel et des documents attaches sans autorisation prealable de son emetteur est interdite." >> >> " This e-mail and any attached documents may contain confidential or proprietary information. If you are not the intended recipient, please advise the sender immediately and delete this e-mail and all attached documents from your computer system. Any unauthorised disclosure, distribution or copying hereof is 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 agl at imperialviolet.org Mon Jun 23 13:07:25 2008 From: agl at imperialviolet.org (Adam Langley) Date: Mon Jun 23 12:59:01 2008 Subject: [Haskell-cafe] Re: "C" buffer suggestions?? In-Reply-To: <5ae4f2ba0806230210m6453be5aqfbeaecf342291291@mail.gmail.com> References: <5ae4f2ba0806212347r56df45fdu962fccc1bd532ac9@mail.gmail.com> <5ae4f2ba0806230210m6453be5aqfbeaecf342291291@mail.gmail.com> Message-ID: <396556a20806231007j3c1446dev1f1c83c887c32e08@mail.gmail.com> 2008/6/23 Galchin, Vasili : > Basically I want to model POSIX async io "aiocb"( > http://uw714doc.sco.com/en/man/html.5/aiocb.5.html) in Haskell .. in > particular the aiocb field "aio_buf"! That's a mutable buffer, so this has to be pretty low level in your wrapping of the AIO interface. I would keep it as a Ptr Word8 at that point. ByteStrings are probably the correct type for the user visible interface, but I would guess not here. Plus, ByteString data lives in the Haskell heap so could get moved about by the collector. Since an AIO interface is probably going to return while the IO is still in progress, you don't want to stop the collector, but nor do you want the data moving because the kernel's pointer isn't going to move with it. AGL -- Adam Langley agl@imperialviolet.org http://www.imperialviolet.org From agl at imperialviolet.org Mon Jun 23 13:09:50 2008 From: agl at imperialviolet.org (Adam Langley) Date: Mon Jun 23 13:01:50 2008 Subject: [Haskell-cafe] IMAP and NNTP libraries In-Reply-To: References: Message-ID: <396556a20806231009k3d3352d4yebe4883168357d60@mail.gmail.com> On Sat, Jun 21, 2008 at 10:52 PM, Maur??cio wrote: > Are there mature libraries for IMAP and NNTP > available to Haskell? Pretty much, if a Haskell library exist it will be listed at [1]. Since I don't see anything for IMAP, nor NNTP I can be pretty sure that the answer is "no" I'm afraid. Perhaps you would care to write such libraries if you have a need? [1] http://hackage.haskell.org/packages/archive/pkg-list.html -- Adam Langley agl@imperialviolet.org http://www.imperialviolet.org From vigalchin at gmail.com Mon Jun 23 16:15:42 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Mon Jun 23 16:07:17 2008 Subject: [Haskell-cafe] Re: "C" buffer suggestions?? In-Reply-To: <396556a20806231007j3c1446dev1f1c83c887c32e08@mail.gmail.com> References: <5ae4f2ba0806212347r56df45fdu962fccc1bd532ac9@mail.gmail.com> <5ae4f2ba0806230210m6453be5aqfbeaecf342291291@mail.gmail.com> <396556a20806231007j3c1446dev1f1c83c887c32e08@mail.gmail.com> Message-ID: <5ae4f2ba0806231315h6406e004tcccc092a5088d059@mail.gmail.com> On Mon, Jun 23, 2008 at 12:07 PM, Adam Langley wrote: > 2008/6/23 Galchin, Vasili : > > Basically I want to model POSIX async io "aiocb"( > > http://uw714doc.sco.com/en/man/html.5/aiocb.5.html) in Haskell .. in > > particular the aiocb field "aio_buf"! > > That's a mutable buffer, so this has to be pretty low level in your > wrapping of the AIO interface. I would keep it as a Ptr Word8 at that > point. ByteStrings are probably the correct type for the user visible > interface, but I would guess not here. I tried to write a test value of Word8 without success. Can you give an example? > > > Plus, ByteString data lives in the Haskell heap so could get moved > about by the collector. Since an AIO interface is probably going to > return while the IO is still in progress, you don't want to stop the > collector, but nor do you want the data moving because the kernel's > pointer isn't going to move with it. ^^ Interesting about moving around in the heap. I cannot use it for AIO. > > > AGL > > -- > Adam Langley agl@imperialviolet.org http://www.imperialviolet.org > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080623/b76e650c/attachment.htm From sjanssen at cse.unl.edu Mon Jun 23 16:26:12 2008 From: sjanssen at cse.unl.edu (Spencer Janssen) Date: Mon Jun 23 16:17:55 2008 Subject: [Haskell-cafe] IMAP and NNTP libraries In-Reply-To: References: Message-ID: <20080623202612.GA29551@celeborn> On Sun, Jun 22, 2008 at 02:52:33AM -0300, Maur??cio wrote: > Hi, > > Are there mature libraries for IMAP and NNTP > available to Haskell? > > Thanks, > Maur?cio There is the haskellnet project: http://darcs.haskell.org/SoC/haskellnet/ I'm not sure whether it is mature or maintained. Cheers, Spencer Janssen From agl at imperialviolet.org Mon Jun 23 17:00:34 2008 From: agl at imperialviolet.org (Adam Langley) Date: Mon Jun 23 16:52:09 2008 Subject: [Haskell-cafe] Re: "C" buffer suggestions?? In-Reply-To: <5ae4f2ba0806231315h6406e004tcccc092a5088d059@mail.gmail.com> References: <5ae4f2ba0806212347r56df45fdu962fccc1bd532ac9@mail.gmail.com> <5ae4f2ba0806230210m6453be5aqfbeaecf342291291@mail.gmail.com> <396556a20806231007j3c1446dev1f1c83c887c32e08@mail.gmail.com> <5ae4f2ba0806231315h6406e004tcccc092a5088d059@mail.gmail.com> Message-ID: <396556a20806231400q6a2cd3b6t4935ebd17c9b447b@mail.gmail.com> On Mon, Jun 23, 2008 at 1:15 PM, Galchin, Vasili wrote: > I tried to write a test value of Word8 without success. Can you give an example? I'm not quite sure what you would want in such an example. See [1] for the malloc function. Then you take the result and wrap it with [2]: fp <- mallocBytes nbytes >>= newForeignPtr finalizerFree When you want to use it, use [3] to unwrap fp and get a raw Ptr Word8. You can pass these to foreign functions any place they expect a uint8_t *, char * etc. [1] http://www.haskell.org/hoogle/hoodoc.cgi?module=Foreign.Marshal.Alloc&name=mallocBytes&mode=func [2] http://www.haskell.org/hoogle/hoodoc.cgi?module=Foreign.ForeignPtr&name=newForeignPtr&mode=func [3] http://www.haskell.org/hoogle/hoodoc.cgi?module=Foreign.ForeignPtr&name=withForeignPtr&mode=func -- Adam Langley agl@imperialviolet.org http://www.imperialviolet.org From chris at eidhof.nl Mon Jun 23 17:02:20 2008 From: chris at eidhof.nl (Chris Eidhof) Date: Mon Jun 23 16:53:56 2008 Subject: [Haskell-cafe] IMAP and NNTP libraries In-Reply-To: <20080623202612.GA29551@celeborn> References: <20080623202612.GA29551@celeborn> Message-ID: <950583A7-37B3-411E-BCF8-2330F67C3339@eidhof.nl> On 23 jun 2008, at 22:26, Spencer Janssen wrote: > On Sun, Jun 22, 2008 at 02:52:33AM -0300, Maur? cio wrote: >> Hi, >> >> Are there mature libraries for IMAP and NNTP >> available to Haskell? >> >> Thanks, >> Maur?cio > > There is the haskellnet project: > > http://darcs.haskell.org/SoC/haskellnet/ > > I'm not sure whether it is mature or maintained. I don't think it's maintained or mature: last time I checked, I couldn't get it to work (probably due to library changes), and there is not a lot of documentation nor comments. I was actually thinking of writing a binding myself, to libEtPan!, which seems to have a well-documented and clean interface. I'm not sure how hard this is though. I've also looked a bit at the UW c- client, but I haven't seen any good examples of how to use it. -chris From dons at galois.com Mon Jun 23 17:27:03 2008 From: dons at galois.com (Don Stewart) Date: Mon Jun 23 17:18:43 2008 Subject: [Haskell-cafe] Re: "C" buffer suggestions?? In-Reply-To: <396556a20806231007j3c1446dev1f1c83c887c32e08@mail.gmail.com> References: <5ae4f2ba0806212347r56df45fdu962fccc1bd532ac9@mail.gmail.com> <5ae4f2ba0806230210m6453be5aqfbeaecf342291291@mail.gmail.com> <396556a20806231007j3c1446dev1f1c83c887c32e08@mail.gmail.com> Message-ID: <20080623212703.GE10144@scytale.galois.com> agl: > 2008/6/23 Galchin, Vasili : > > Basically I want to model POSIX async io "aiocb"( > > http://uw714doc.sco.com/en/man/html.5/aiocb.5.html) in Haskell .. in > > particular the aiocb field "aio_buf"! > > That's a mutable buffer, so this has to be pretty low level in your > wrapping of the AIO interface. I would keep it as a Ptr Word8 at that > point. ByteStrings are probably the correct type for the user visible > interface, but I would guess not here. > > Plus, ByteString data lives in the Haskell heap so could get moved > about by the collector. Since an AIO interface is probably going to ByteStrings are allocated into pinned memory, so they're easy to pass to C and back. It uses the fast 'mallocPlainForeignPtr' api, -- GHC notes: 'mallocPlainForeignPtr' has a heavily optimised -- implementation in GHC. It uses pinned memory in the garbage -- collected heap, as for mallocForeignPtr. So heap allocated and collected, but not moved. > return while the IO is still in progress, you don't want to stop the > collector, but nor do you want the data moving because the kernel's > pointer isn't going to move with it. -- Don From dons at galois.com Mon Jun 23 17:35:13 2008 From: dons at galois.com (Don Stewart) Date: Mon Jun 23 17:26:48 2008 Subject: [Haskell-cafe] IMAP and NNTP libraries In-Reply-To: <396556a20806231009k3d3352d4yebe4883168357d60@mail.gmail.com> References: <396556a20806231009k3d3352d4yebe4883168357d60@mail.gmail.com> Message-ID: <20080623213513.GF10144@scytale.galois.com> agl: > On Sat, Jun 21, 2008 at 10:52 PM, Maur??cio wrote: > > Are there mature libraries for IMAP and NNTP > > available to Haskell? > > Pretty much, if a Haskell library exist it will be listed at [1]. > Since I don't see anything for IMAP, nor NNTP I can be pretty sure > that the answer is "no" I'm afraid. Perhaps you would care to write > such libraries if you have a need? > > > [1] http://hackage.haskell.org/packages/archive/pkg-list.html Or FFI bind to some existing library. cabal-install will take care of the rest. From jgoerzen at complete.org Mon Jun 23 17:43:31 2008 From: jgoerzen at complete.org (John Goerzen) Date: Mon Jun 23 17:35:09 2008 Subject: [Haskell-cafe] IMAP and NNTP libraries In-Reply-To: <396556a20806231009k3d3352d4yebe4883168357d60@mail.gmail.com> References: <396556a20806231009k3d3352d4yebe4883168357d60@mail.gmail.com> Message-ID: <48601903.6020600@complete.org> Adam Langley wrote: > On Sat, Jun 21, 2008 at 10:52 PM, Maur??cio wrote: >> Are there mature libraries for IMAP and NNTP >> available to Haskell? > > Pretty much, if a Haskell library exist it will be listed at [1]. > Since I don't see anything for IMAP, nor NNTP I can be pretty sure > that the answer is "no" I'm afraid. Perhaps you would care to write > such libraries if you have a need? I'm aware of neither. NNTP is a pretty trivial protocol, and should be trivial to implement. IMAP is more complex. I may write such a library someday, if I ever port OfflineIMAP to Haskell, but it will not be real soon now by any means. From ryani.spam at gmail.com Mon Jun 23 18:21:28 2008 From: ryani.spam at gmail.com (Ryan Ingram) Date: Mon Jun 23 18:13:04 2008 Subject: [Haskell-cafe] number-parameterized types and heterogeneous lists In-Reply-To: <7ca3f0160806230105h56fa14b7g1acc3201be6f06f8@mail.gmail.com> References: <7ca3f0160806230105h56fa14b7g1acc3201be6f06f8@mail.gmail.com> Message-ID: <2f9b2d30806231521m7eb2f92fp25dd8b7ce18098b4@mail.gmail.com> Literate haskell response: > {-# LANGUAGE GADTs, RankNTypes #-} > module Digits where > {- On 6/23/08, Luke Palmer wrote: > > I also wonder if there is some kind of "generalized" foldr such that, e.g. > > D1 $ D0 $ D0 $ Sz = specialFoldr ($) Sz [D1,D0,D0] > > I think that this foldr must be some "special" foldr that augments the data > > type of the result in each foldr step. > > Would this be possible or am I just chasing phantoms ? > Mostly I believe you are. What you are describing is firmly in the > realm of dependent types, far beyond Haskell's type system. See > Epigram or Agda for languages which have attempted to tackle this > problem. > -} I'm not so sure, as long as you are willing to live with the result being existentially quantified. Here's an example: ghci> mkNat [x1, x0, x3, x2] (reifyInt 1032) ghci> :t mkNat [x1, x0, x3, x2] mkNat [x1, x0, x3, x2] :: AnyNat I slightly specialize the constructors to wrap them in existential types: d0 = AnyNat . D0 -- and so on for d1..d9 x0 = NatFn d0 -- and so on for x1..x9 Full code: > data Sz = Sz > data D0 a = D0 a > data D1 a = D1 a > data D2 a = D2 a > data D3 a = D3 a > data D4 a = D4 a > data D5 a = D5 a > data D6 a = D6 a > data D7 a = D7 a > data D8 a = D8 a > data D9 a = D9 a > class Nat n where > toIntAccum :: n -> Integer -> Integer > toInt :: Nat n => n -> Integer > toInt n = toIntAccum n 0 > instance Nat Sz where toIntAccum _ acc = acc > instance Nat a => Nat (D0 a) where > toIntAccum (D0 n) acc = toIntAccum n (10 * acc + 0) > instance Nat a => Nat (D1 a) where > toIntAccum (D1 n) acc = toIntAccum n (10 * acc + 1) > instance Nat a => Nat (D2 a) where > toIntAccum (D2 n) acc = toIntAccum n (10 * acc + 2) > instance Nat a => Nat (D3 a) where > toIntAccum (D3 n) acc = toIntAccum n (10 * acc + 3) > instance Nat a => Nat (D4 a) where > toIntAccum (D4 n) acc = toIntAccum n (10 * acc + 4) > instance Nat a => Nat (D5 a) where > toIntAccum (D5 n) acc = toIntAccum n (10 * acc + 5) > instance Nat a => Nat (D6 a) where > toIntAccum (D6 n) acc = toIntAccum n (10 * acc + 6) > instance Nat a => Nat (D7 a) where > toIntAccum (D7 n) acc = toIntAccum n (10 * acc + 7) > instance Nat a => Nat (D8 a) where > toIntAccum (D8 n) acc = toIntAccum n (10 * acc + 8) > instance Nat a => Nat (D9 a) where > toIntAccum (D9 n) acc = toIntAccum n (10 * acc + 9) > data AnyNat where AnyNat :: Nat n => n -> AnyNat > d0, d1, d2, d3, d4, d5, d6, d7, d8, d9 :: Nat n => n -> AnyNat > d0 = AnyNat . D0 > d1 = AnyNat . D1 > d2 = AnyNat . D2 > d3 = AnyNat . D3 > d4 = AnyNat . D4 > d5 = AnyNat . D5 > d6 = AnyNat . D6 > d7 = AnyNat . D7 > d8 = AnyNat . D8 > d9 = AnyNat . D9 > reifyDigit :: Integer -> (forall n. Nat n => n -> AnyNat) > reifyDigit 0 = d0 > reifyDigit 1 = d1 > reifyDigit 2 = d2 > reifyDigit 3 = d3 > reifyDigit 4 = d4 > reifyDigit 5 = d5 > reifyDigit 6 = d6 > reifyDigit 7 = d7 > reifyDigit 8 = d8 > reifyDigit 9 = d9 > reifyDigit _ = error "not a digit" > reifyIntAccum :: Integer -> AnyNat -> AnyNat > reifyIntAccum 0 acc = acc > reifyIntAccum n (AnyNat rhs) = let (l, r) = divMod n 10 in > reifyIntAccum l (reifyDigit r rhs) > reifyInt :: Integer -> AnyNat > reifyInt n | n < 0 = error "negative" > reifyInt n = reifyIntAccum n (AnyNat Sz) > instance Show AnyNat where > show (AnyNat n) = "(reifyInt " ++ show (toInt n) ++ ")" > data NatFn where NatFn :: (forall n. Nat n => n -> AnyNat) -> NatFn > x0, x1, x2, x3, x4, x5, x6, x7, x8, x9 :: NatFn > x0 = NatFn d0 > x1 = NatFn d1 > x2 = NatFn d2 > x3 = NatFn d3 > x4 = NatFn d4 > x5 = NatFn d5 > x6 = NatFn d6 > x7 = NatFn d7 > x8 = NatFn d8 > x9 = NatFn d9 > foldNat :: [NatFn] -> AnyNat -> AnyNat > foldNat [] z = z > foldNat (NatFn f:xs) z = case foldNat xs z of AnyNat n -> f n > mkNat :: [NatFn] -> AnyNat > mkNat xs = foldNat xs (AnyNat Sz) -- ryan From agl at imperialviolet.org Mon Jun 23 19:13:15 2008 From: agl at imperialviolet.org (Adam Langley) Date: Mon Jun 23 19:04:49 2008 Subject: [Haskell-cafe] Re: "C" buffer suggestions?? In-Reply-To: <20080623212703.GE10144@scytale.galois.com> References: <5ae4f2ba0806212347r56df45fdu962fccc1bd532ac9@mail.gmail.com> <5ae4f2ba0806230210m6453be5aqfbeaecf342291291@mail.gmail.com> <396556a20806231007j3c1446dev1f1c83c887c32e08@mail.gmail.com> <20080623212703.GE10144@scytale.galois.com> Message-ID: <396556a20806231613x483aa2e1ree26d5690b558854@mail.gmail.com> On Mon, Jun 23, 2008 at 2:27 PM, Don Stewart wrote: > So heap allocated and collected, but not moved. My bad. In that case, you might want to work with ByteStrings all the way since it might make building the visible interface (which probably should use ByteStrings) easier. AGL -- Adam Langley agl@imperialviolet.org http://www.imperialviolet.org From ok at cs.otago.ac.nz Mon Jun 23 19:46:25 2008 From: ok at cs.otago.ac.nz (Richard A. O'Keefe) Date: Mon Jun 23 19:38:02 2008 Subject: [Haskell-cafe] Help with generalizing function In-Reply-To: <18063291.post@talk.nabble.com> References: <18063291.post@talk.nabble.com> Message-ID: <7DE61A0C-B403-42C5-A1CC-2A0D53F1CFA3@cs.otago.ac.nz> On 23 Jun 2008, at 6:30 pm, leledumbo wrote: > I've successfully create a function to return lists of N-ple that > satisfy the > following function: > x1 + x2 + x3 + ... + xN = C > But unfortunately, it's not generic. Why do you want it to be a tuple? All the elements are the same type, so it might as well be a list. part 0 c | c == 0 = [[]] part (n+1) c | c >= 0 = [(x:xs) | x <- [0..c], xs <- part n (c-x)] (WARNING: UNTESTED CODE!) Knuth TAOCP Volume 4 has some stuff on enumerating partitions. From vigalchin at gmail.com Mon Jun 23 21:13:39 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Mon Jun 23 21:05:12 2008 Subject: [Haskell-cafe] Re: "C" buffer suggestions?? In-Reply-To: <396556a20806231613x483aa2e1ree26d5690b558854@mail.gmail.com> References: <5ae4f2ba0806212347r56df45fdu962fccc1bd532ac9@mail.gmail.com> <5ae4f2ba0806230210m6453be5aqfbeaecf342291291@mail.gmail.com> <396556a20806231007j3c1446dev1f1c83c887c32e08@mail.gmail.com> <20080623212703.GE10144@scytale.galois.com> <396556a20806231613x483aa2e1ree26d5690b558854@mail.gmail.com> Message-ID: <5ae4f2ba0806231813w227992bdub3a0cc5af11e5b50@mail.gmail.com> ok ..... 1) how do I marshall from ByteString to char * (poke)?? 2) how do I write let x =??? :: Word8 3) how do I write let y = ??? ::ByteString Kind regards, Vasili On Mon, Jun 23, 2008 at 6:13 PM, Adam Langley wrote: > On Mon, Jun 23, 2008 at 2:27 PM, Don Stewart wrote: > > So heap allocated and collected, but not moved. > > My bad. In that case, you might want to work with ByteStrings all the > way since it might make building the visible interface (which probably > should use ByteStrings) easier. > > > AGL > > -- > Adam Langley agl@imperialviolet.org http://www.imperialviolet.org > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080623/d5ce56cb/attachment.htm From vigalchin at gmail.com Mon Jun 23 21:18:23 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Mon Jun 23 21:09:58 2008 Subject: [Haskell-cafe] Re: "C" buffer suggestions?? In-Reply-To: <5ae4f2ba0806231813w227992bdub3a0cc5af11e5b50@mail.gmail.com> References: <5ae4f2ba0806212347r56df45fdu962fccc1bd532ac9@mail.gmail.com> <5ae4f2ba0806230210m6453be5aqfbeaecf342291291@mail.gmail.com> <396556a20806231007j3c1446dev1f1c83c887c32e08@mail.gmail.com> <20080623212703.GE10144@scytale.galois.com> <396556a20806231613x483aa2e1ree26d5690b558854@mail.gmail.com> <5ae4f2ba0806231813w227992bdub3a0cc5af11e5b50@mail.gmail.com> Message-ID: <5ae4f2ba0806231818p4ef26615q3c6724c20d7a4011@mail.gmail.com> e.g. on Word8 ..... let aiocb = AIOCB{ aioFd=fd, aioLioOpcode=0, aioReqPrio=0, aioOffset=0, aioBuf=??, <<<<<<<<<<<<<<<<<<<<< Ptr Word8 aioBytes=128, aioSigevent=event} ??? Kind regards, Vasili On Mon, Jun 23, 2008 at 8:13 PM, Galchin, Vasili wrote: > ok ..... > > 1) how do I marshall from ByteString to char * (poke)?? > > 2) how do I write > > let x =??? :: Word8 > > 3) how do I write > > let y = ??? ::ByteString > > Kind regards, Vasili > > > > On Mon, Jun 23, 2008 at 6:13 PM, Adam Langley > wrote: > >> On Mon, Jun 23, 2008 at 2:27 PM, Don Stewart wrote: >> > So heap allocated and collected, but not moved. >> >> My bad. In that case, you might want to work with ByteStrings all the >> way since it might make building the visible interface (which probably >> should use ByteStrings) easier. >> >> >> AGL >> >> -- >> Adam Langley agl@imperialviolet.org http://www.imperialviolet.org >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080623/fa062590/attachment.htm From droundy at darcs.net Mon Jun 23 21:32:57 2008 From: droundy at darcs.net (David Roundy) Date: Mon Jun 23 21:24:31 2008 Subject: [Haskell-cafe] Re: "C" buffer suggestions?? In-Reply-To: <5ae4f2ba0806231818p4ef26615q3c6724c20d7a4011@mail.gmail.com> References: <5ae4f2ba0806212347r56df45fdu962fccc1bd532ac9@mail.gmail.com> <5ae4f2ba0806230210m6453be5aqfbeaecf342291291@mail.gmail.com> <396556a20806231007j3c1446dev1f1c83c887c32e08@mail.gmail.com> <20080623212703.GE10144@scytale.galois.com> <396556a20806231613x483aa2e1ree26d5690b558854@mail.gmail.com> <5ae4f2ba0806231813w227992bdub3a0cc5af11e5b50@mail.gmail.com> <5ae4f2ba0806231818p4ef26615q3c6724c20d7a4011@mail.gmail.com> Message-ID: <20080624013256.GG32397@darcs.net> See the Data.ByteString.Internal docs: http://www.haskell.org/ghc/docs/latest/html/libraries/bytestring/Data-ByteString-Internal.html#v%3AtoForeignPtr Of course, you'd better not write to the contents of that pointer, or bad things could happen... David On Mon, Jun 23, 2008 at 08:18:23PM -0500, Galchin, Vasili wrote: > e.g. on Word8 ..... > > let aiocb = AIOCB{ > aioFd=fd, > aioLioOpcode=0, > aioReqPrio=0, > aioOffset=0, > aioBuf=??, <<<<<<<<<<<<<<<<<<<<< Ptr Word8 > aioBytes=128, > aioSigevent=event} > > ??? > > Kind regards, Vasili > > On Mon, Jun 23, 2008 at 8:13 PM, Galchin, Vasili > wrote: > > > ok ..... > > > > 1) how do I marshall from ByteString to char * (poke)?? > > > > 2) how do I write > > > > let x =??? :: Word8 > > > > 3) how do I write > > > > let y = ??? ::ByteString > > > > Kind regards, Vasili > > > > > > > > On Mon, Jun 23, 2008 at 6:13 PM, Adam Langley > > wrote: > > > >> On Mon, Jun 23, 2008 at 2:27 PM, Don Stewart wrote: > >> > So heap allocated and collected, but not moved. > >> > >> My bad. In that case, you might want to work with ByteStrings all the > >> way since it might make building the visible interface (which probably > >> should use ByteStrings) easier. > >> > >> > >> AGL From oleg at okmij.org Tue Jun 24 01:03:43 2008 From: oleg at okmij.org (oleg@okmij.org) Date: Tue Jun 24 00:57:39 2008 Subject: [Haskell-cafe] Re: number-parameterized types and heterogeneous lists In-Reply-To: Message-ID: <20080624050343.A8D6CAA92@Adric.metnet.fnmoc.navy.mil> Luke Palmer wrote in response to Harald ROTTER > > I also wonder if there is some kind of "generalized" foldr such that, e.g. > > D1 $ D0 $ D0 $ Sz = specialFoldr ($) Sz [D1,D0,D0] > > I think that this foldr must be some "special" foldr that augments the data > > type of the result in each foldr step. > > Would this be possible or am I just chasing phantoms ? > Mostly I believe you are. What you are describing is firmly in the > realm of dependent types, far beyond Haskell's type system. See > Epigram or Agda for languages which have attempted to tackle this > problem. First of all, Haskell (as implemented by released versions of GHC for at least two years) already permits dependent types, in the strict sense of a type of an expression being determined by the value of one argument of that expression: http://okmij.org/ftp/Computation/tagless-typed.html#tc-GADT-tc Second, (values of) types like D0 and D1 can be collected in a heterogenous list (HList), which does have the corresponding fold operator, called HFoldr in http://darcs.haskell.org/HList/Data/HList/HListPrelude.hs From vigalchin at gmail.com Tue Jun 24 01:36:51 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Tue Jun 24 01:28:24 2008 Subject: [Haskell-cafe] safe vs unsafe Message-ID: <5ae4f2ba0806232236q2e9b95d5kd1d1eafbf0e12b61@mail.gmail.com> Hello, At runtime, I am getting .... aio: schedule: re-entered unsafely. Perhaps a 'foreign import unsafe' should be 'safe'? I want to understand from an implementation viewpoint .. deeper. This is a GC issue yes? Kind regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080624/32a0ba7e/attachment.htm From lemming at henning-thielemann.de Tue Jun 24 10:17:12 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Tue Jun 24 10:08:47 2008 Subject: [Haskell-cafe] Access to Oracle database from Haskell In-Reply-To: <79d7c4980806200251o6e74e409mbd993a09c835014@mail.gmail.com> References: <79d7c4980806192210j11796038sc5008d669df926b5@mail.gmail.com> <79d7c4980806200251o6e74e409mbd993a09c835014@mail.gmail.com> Message-ID: On Fri, 20 Jun 2008, Alistair Bayley wrote: > Another problem is that the Oracle installation process assumes that, > for all platforms, the library is called oci i.e. the linker option > -loci is used. For Unix clients, the OCI library seems to be > libclnstsh.so, so I guess it should pass -lclnstsh. This highlights > the lack of testing on non-Windows platforms. If you'd like to help > get this working better, perhaps we can discuss off-list. (I remain on the list in order to fill the archive with information, others may need, too.) I have now installed the OCI SDK http://download.oracle.com/otn/linux/instantclient/10204/oracle-instantclient-devel-10.2.0.4-1.i386.rpm and Cabal-1.4 in order to get Takusen from Darcs repository running. I configure the package with -f oracle and the package gets compiled (and emits several warnings from Haddock-2.0). (Btw. Takusen should be split into several packages for all database backends because Cabal flags must not influence the package interface.) But on installation Cabal complains about missing /usr/oci directory. I assume that this must be the include dir of OCI include files. For me this is /usr/include/oracle/10.2.0.4/client/ I can add this path with runhaskell Setup.hs configure --extra-include-dirs=/usr/include/oracle/10.2.0.4/client but I cannot replace /usr/oci. If I remove /usr/oci manually from dist/installed-pkg-config then the path /usr/oci is again added by runhaskell Setup.hs install . I'm lost. Am I on the right track? Once I will get Takusen running with OCI - how would I use it? Is there a minimal example which connects to an Oracle database, performing a very simple query? From alistair at abayley.org Tue Jun 24 10:55:09 2008 From: alistair at abayley.org (Alistair Bayley) Date: Tue Jun 24 10:46:41 2008 Subject: [Haskell-cafe] Access to Oracle database from Haskell In-Reply-To: References: <79d7c4980806192210j11796038sc5008d669df926b5@mail.gmail.com> <79d7c4980806200251o6e74e409mbd993a09c835014@mail.gmail.com> Message-ID: <79d7c4980806240755p724777e3i9240067c3c050ccb@mail.gmail.com> 2008/6/24 Henning Thielemann : > > (I remain on the list in order to fill the archive with information, others > may need, too.) As you wish. > (Btw. Takusen should be split into > several packages for all database backends because Cabal flags must not > influence the package interface.) I don't understand this (cabal flags must not influence package interface). I thought that was the point of cabal flags? I wanted to have a single package installation, and this seems like the best way. > But on installation Cabal complains about missing /usr/oci directory. When you run configure, you should get output that says: Using Oracle: What is ? The Setup.hs assumes the entire Oracle installation is under a single root folder ($ORACLE_HOME); is this not true on Linux? If not, then we will have to find some other way of locating the bin and include folders. Perhaps we can do something like the Postgres installation, where there is a program you can run which will print the include and lib folders. That may mean a little hacking on Setup.hs, but there's already a good example there for Postgres. > Once I will get Takusen running with OCI - how would I use it? Is there a > minimal example which connects to an Oracle database, performing a very > simple query? There's an example in the README.txt, which I've tweaked here for Oracle: {-# OPTIONS -fglasgow-exts #-} {-# OPTIONS -fallow-overlapping-instances #-} module Main where import Database.Oracle.Enumerator import Control.Monad.Trans (liftIO) main = flip catchDB reportRethrow $ withSession (connect "user" "pswd" "dbname") (do let iter (s::String) (_::String) = result s result <- doQuery (sql "select 'Hello world.' from dual") iter "" liftIO (putStrLn result) ) Alistair From agl at imperialviolet.org Tue Jun 24 13:03:04 2008 From: agl at imperialviolet.org (Adam Langley) Date: Tue Jun 24 12:54:36 2008 Subject: [Haskell-cafe] safe vs unsafe In-Reply-To: <5ae4f2ba0806232236q2e9b95d5kd1d1eafbf0e12b61@mail.gmail.com> References: <5ae4f2ba0806232236q2e9b95d5kd1d1eafbf0e12b61@mail.gmail.com> Message-ID: <396556a20806241003t5f32194aqd629d2933ba03538@mail.gmail.com> 2008/6/23 Galchin, Vasili : > aio: schedule: re-entered unsafely. > Perhaps a 'foreign import unsafe' should be 'safe'? > > I want to understand from an implementation viewpoint .. deeper. This is a > GC issue yes? Are you reentering Haskell on a path which involves an unsafe FFI call? e.g. you enter C land via an unsafe FFI call and, on the same call path, reenter Haskell with a callback? http://www.cse.unsw.edu.au/~chak/haskell/ffi/ffi/ffise3.html#x6-130003.3 says: "Optionally, an import declaration can specify, after the calling convention, the safety level that should be used when invoking an external entity. A safe call is less efficient, but guarantees to leave the Haskell system in a state that allows callbacks from the external code. In contrast, an unsafe call, while carrying less overhead, must not trigger a callback into the Haskell system. If it does, the system behaviour is undefined. The default for an invocation is to be safe. Note that a callback into the Haskell system implies that a garbage collection might be triggered after an external entity was called, but before this call returns. Consequently, objects other than stable pointers (cf. Section 5.6) may be moved or garbage collected by the storage manager." -- Adam Langley agl@imperialviolet.org http://www.imperialviolet.org From lgreg.meredith at biosimilarity.com Tue Jun 24 13:18:17 2008 From: lgreg.meredith at biosimilarity.com (Greg Meredith) Date: Tue Jun 24 13:09:50 2008 Subject: [Haskell-cafe] NW Functional Programming Interest Group In-Reply-To: <5de3f5ca0802011155l771cc649wa0e671bbe3abe364@mail.gmail.com> References: <5de3f5ca0802011155l771cc649wa0e671bbe3abe364@mail.gmail.com> Message-ID: <5de3f5ca0806241018o5b582ebfufcfd4c1b371cdc12@mail.gmail.com> All, Apologies for multiple listings. A small cadre of us, collectively known as the Northwest Functional Programming Interest Group, have been meeting monthly to discuss all things functional. Our next meeting is at The Seattle Public Library 5009 Roosevelt Way N.E. * Seattle*, WA 98105 206-684-4063 from 18:30 - 19:50 on June 25th. We'd hoped to have Andrew Birkett talk on a Haskell implementation of an emacs-like editor, but sadly could not secure a meeting venue before Andrew's flight back to the UK. Maybe we can set up a skype session for a presentation by Andrew in future. Since it's so late in the game i will step in and offer a presentation on a compositional representation of graphs i've been tinkering with -- unless someone has something they'd like to talk about at a moment's notice. Hope to see you there. Monadically yours, --greg -- L.G. Meredith Managing Partner Biosimilarity LLC 806 55th St NE Seattle, WA 98105 +1 206.650.3740 http://biosimilarity.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080624/92adcdeb/attachment.htm From jeremy at n-heptane.com Tue Jun 24 14:27:03 2008 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Tue Jun 24 14:16:22 2008 Subject: Haskell on ARM (was Re: [Haskell-cafe] ANN: Topkata) In-Reply-To: <20080617201233.GD19304@scytale.galois.com> References: <87zlpoguqh.fsf@elefant.olsbruecken.local> <4B3E7353-F7F2-4D2D-A335-30D2D3883A4A@gmail.com> <200806170851.22718.valgarv@gmx.net> <87ej6ww9dy.fsf_-_@columbia.edu> <20080617201233.GD19304@scytale.galois.com> Message-ID: <871w2mit8o.wl%jeremy@n-heptane.com> Hello, I have, on two occasions made an *unregisterised* of GHC for the ARM (specifically the Maemo on Nokia 770). Mostly I just followed the unregisterised porting directions in the GHC user manual. I documented one attempt here: http://hackage.haskell.org/trac/ghc/wiki/ArmLinuxGhc Note: This procedure is for building a version of GHC that runs on ARM and generates ARM code. So, it is not build a cross-compiler, just a native ARM compiler. The unregisterised build is not that useful because: 1. no FFI 2. uses trampolining for tail calls 3. no threads I think 4. some other stuff I have forgotten So, the next step is to registerise the build. This is online a few lines a code. Basically stuff like: 1. add ARM support to the evil mangler (basically, a few regexps to strip prolog and epilogue stuff from the ASM) 2. #define which registers exist and what they should be used for 3. implement the tail call ASM 4. define some aspects of the C calling convention 5. (Optional), implement native assembly generation This is not a lot of code. However, it is very low-level code. I think that doing a registerised build is pretty easy, the *second* time you do it. The big problem is that there is pretty much no documentation on how to do it. (The porting guide does tell you, very generally, what needs to be done). Also, running GHC on an emulated ARM processor is slow. I think it took GHC 6.4 8+ hours to build. Now that many of the extra libs have been split out into the extra libs package, that should help significantly with the build time. If any does attempt to build for the ARM, please, please, please, document what you do in the wiki. And, if you do, edit the wiki as you go, you definitely won't be able to remember what you did after the fact. (Or, at the very least, use some program to capture everything you do so that you can refer to it later). And, finally, I heard vague rumors a while ago that made me think that GHC 6.10 might have a pure ANSI-C backend? Is there any truth to this? That would make porting much easier if it meant you did not have to do steps 1-4. j. ps. I would be happy to try to answer any questions if someone tries a port. I would still like to run GHC on my 770, and I hope to own an iPhone if they fix a few ommisions (bluetooth keyboard support, and similar stuff). At Tue, 17 Jun 2008 13:12:33 -0700, Don Stewart wrote: > > xj2106: > > "Ariel J. Birnbaum" writes: > > > > >> In the mean time -- who knows enough to make ghc target > > >> ARM, and get this to link against the iPhone libraries? > > >> This would be quite a coup if it could be made to run > > >> there! > > > For that matter, there's another ARM-based target in which > > > I'm interested: Nintendo DS. Has anyone got any Haskell > > > code to run on one of these? PS: Maybe this discussion > > > should be moved to a new "Haskell on ARM" thread? > > > > I would be interested to see ghc running on Nokia n8xx or > > iRex iliad. Both of them are quite open linux based > > systems. > > Jeremy Shaw had ghc targeting the nokia last year, iirc. > Perhaps he'll have more info. > > -- Don > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From vigalchin at gmail.com Tue Jun 24 15:08:00 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Tue Jun 24 14:59:32 2008 Subject: [Haskell-cafe] safe vs unsafe In-Reply-To: <396556a20806241003t5f32194aqd629d2933ba03538@mail.gmail.com> References: <5ae4f2ba0806232236q2e9b95d5kd1d1eafbf0e12b61@mail.gmail.com> <396556a20806241003t5f32194aqd629d2933ba03538@mail.gmail.com> Message-ID: <5ae4f2ba0806241208i2a0570c0i91f41bbfac8d91a5@mail.gmail.com> yes I am invoking a callback function written in Haskell. On Tue, Jun 24, 2008 at 12:03 PM, Adam Langley wrote: > 2008/6/23 Galchin, Vasili : > > aio: schedule: re-entered unsafely. > > Perhaps a 'foreign import unsafe' should be 'safe'? > > > > I want to understand from an implementation viewpoint .. deeper. This is > a > > GC issue yes? > > Are you reentering Haskell on a path which involves an unsafe FFI > call? e.g. you enter C land via an unsafe FFI call and, on the same > call path, reenter Haskell with a callback? > > http://www.cse.unsw.edu.au/~chak/haskell/ffi/ffi/ffise3.html#x6-130003.3says: > > "Optionally, an import declaration can specify, after the calling > convention, the safety level that should be used when invoking an > external entity. A safe call is less efficient, but guarantees to > leave the Haskell system in a state that allows callbacks from the > external code. In contrast, an unsafe call, while carrying less > overhead, must not trigger a callback into the Haskell system. If it > does, the system behaviour is undefined. The default for an invocation > is to be safe. Note that a callback into the Haskell system implies > that a garbage collection might be triggered after an external entity > was called, but before this call returns. Consequently, objects other > than stable pointers (cf. Section 5.6) may be moved or garbage > collected by the storage manager." > > -- > Adam Langley agl@imperialviolet.org http://www.imperialviolet.org > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080624/bba50bf1/attachment.htm From agl at imperialviolet.org Tue Jun 24 15:10:37 2008 From: agl at imperialviolet.org (Adam Langley) Date: Tue Jun 24 15:02:09 2008 Subject: [Haskell-cafe] safe vs unsafe In-Reply-To: <5ae4f2ba0806241208i2a0570c0i91f41bbfac8d91a5@mail.gmail.com> References: <5ae4f2ba0806232236q2e9b95d5kd1d1eafbf0e12b61@mail.gmail.com> <396556a20806241003t5f32194aqd629d2933ba03538@mail.gmail.com> <5ae4f2ba0806241208i2a0570c0i91f41bbfac8d91a5@mail.gmail.com> Message-ID: <396556a20806241210o1f513f11pb162c75e0ab51ee7@mail.gmail.com> On Tue, Jun 24, 2008 at 12:08 PM, Galchin, Vasili wrote: > yes I am invoking a callback function written in Haskell. Then you should just need to remove the "unsafe" from the foreign import decl which leads to the callback getting called. AGL -- Adam Langley agl@imperialviolet.org http://www.imperialviolet.org From robgreayer at yahoo.com Tue Jun 24 15:43:22 2008 From: robgreayer at yahoo.com (Robert Greayer) Date: Tue Jun 24 15:34:53 2008 Subject: [Haskell-cafe] Template Haskell ListT wrinkle Message-ID: <890508.88590.qm@web65709.mail.ac4.yahoo.com> In messing around with TH, I noticed (what I consider to be an) odd wrinkle in the handling of list types within TH's syntax meta-data. For example, given the program at the end of this email, which prints out the TH representation of the types 'Ints' and '[Int]', where 'Ints' is just a type-alias for '[Int]', the following results are generated: Ints is: AppT (ConT GHC.Base.[]) (ConT GHC.Base.Int) [Int] is: AppT ListT (ConT GHC.Base.Int) type0, 'Ints' resolves to the application of the named type constructor "GHC.Base.[]" to the named type constructor "GHC.Base.Int" (which makes perfect sense). type1, '[Int]' resolves to the application of the 'built-in' ListT type constructor to the named type constructor "GHC.Base.Int" (which also makes perfect sense). What's odd (to me) is that in one situation, the 'named' constructor 'GHC.Base.[]' appears, and in the other, the 'built-in' constructor appears. Does anyone have insight into why this might be? (These results were obtained with GHC 6.8.2, btw). > {-# OPTIONS_GHC -XTemplateHaskell #-} > module Main where > import Language.Haskell.TH > > type Ints = [Int] > > type0 = $( reify ''Ints >>= (\ (TyConI (TySynD _ _ t)) -> return $ show t) >>= \s -> [| s |]) > type1 = $( [t| [Int] |] >>= return . show >>= \s -> [| s |]) > > main = do > putStrLn ("Ints is: " ++ type0) > putStrLn ("[Int] is: " ++ type1) Thanks rcg From ndmitchell at gmail.com Tue Jun 24 15:50:32 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Tue Jun 24 15:42:05 2008 Subject: [Haskell-cafe] Template Haskell ListT wrinkle In-Reply-To: <890508.88590.qm@web65709.mail.ac4.yahoo.com> References: <890508.88590.qm@web65709.mail.ac4.yahoo.com> Message-ID: <404396ef0806241250k7c39c96eg1984a2823d78c9f6@mail.gmail.com> Hi Robert, The derive program [http://www.cs.york.ac.uk/~ndm/derive] works extensively with Template Haskell, and has come across loads of instances where you get either AppT or ListT, and similarly where you get either ListE or AppE - and I seem to remember ListP as well. I think the same also holds for TupT/TupE/TupP My advice is to treat them all the same, and if it matters to you, normalise them before you start work. I think the pretty printer may print them differently, but otherwise they are equivalent. For example derive has: peep (AppE (AppE cons x) nil) | cons ~= ":" && nil ~= "[]" = ListE [x] i.e. if you have a list using cons, change it to a list using the list notation. Thanks Neil On 6/24/08, Robert Greayer wrote: > > In messing around with TH, I noticed (what I consider > to be an) odd wrinkle in the handling of list types > within TH's syntax meta-data. For example, given the > program at the end of this email, which prints out the > TH representation of the types 'Ints' and '[Int]', > where 'Ints' is just a type-alias for '[Int]', the > following results are generated: > > Ints is: AppT (ConT GHC.Base.[]) (ConT GHC.Base.Int) > [Int] is: AppT ListT (ConT GHC.Base.Int) > > type0, 'Ints' resolves to the application of the named > type constructor "GHC.Base.[]" to the named type > constructor "GHC.Base.Int" (which makes perfect > sense). type1, '[Int]' resolves to the application of > the 'built-in' ListT type constructor to the named > type constructor "GHC.Base.Int" (which also makes > perfect sense). What's odd (to me) is that in one > situation, the 'named' constructor 'GHC.Base.[]' > appears, and in the other, the 'built-in' constructor > appears. > > Does anyone have insight into why this might be? > (These results were obtained with GHC 6.8.2, btw). > > > {-# OPTIONS_GHC -XTemplateHaskell #-} > > module Main where > > import Language.Haskell.TH > > > > type Ints = [Int] > > > > type0 = $( reify ''Ints >>= (\ (TyConI (TySynD _ _ > t)) -> return $ show t) >>= \s -> [| s |]) > > type1 = $( [t| [Int] |] >>= return . show >>= \s -> > [| s |]) > > > > main = do > > putStrLn ("Ints is: " ++ type0) > > putStrLn ("[Int] is: " ++ type1) > > Thanks > rcg > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From wojtowicz.norbert at gmail.com Tue Jun 24 15:57:46 2008 From: wojtowicz.norbert at gmail.com (Norbert Wojtowicz) Date: Tue Jun 24 15:49:18 2008 Subject: [Haskell-cafe] sdl-mixer loading issue Message-ID: Hello, I am trying to use the SDL-mixer bindings to play wav files. I've hit a wierd error and I can't figure out how to solve it: Prelude> import Graphics.UI.SDL.Mixer.Music Prelude Graphics.UI.SDL.Mixer.Music> loadMUS "test.wav" Loading package SDL-0.5.4 ... linking ... done. Loading package SDL-mixer-0.5.2 ... linking ... : /home/norbert/bin/lib/SDL-mixer-0.5.2/ghc-6.8.2/HSSDL-mixer-0.5.2.o: unknown symbol `Mix_LoadWAV' ghc-6.8.2: unable to load package `SDL-mixer-0.5.2' I've looked up the source code; Mix_LoadWAV seems to be #defined, so I suspect it's some kind of library path issue but I don't grok the whole system well enough to figure it out; maybe someone could point me in the right direction? Have the issue now on Ubuntu 8.04 and previously had the same issue when I tested it on a FreeBSD box. I did install all of the "libsdl-*-dev" in the Ubuntu repo. - Norbert From lemming at henning-thielemann.de Tue Jun 24 16:04:41 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Tue Jun 24 15:56:13 2008 Subject: [Haskell-cafe] sdl-mixer loading issue In-Reply-To: References: Message-ID: On Tue, 24 Jun 2008, Norbert Wojtowicz wrote: > Hello, > > I am trying to use the SDL-mixer bindings to play wav files. I've hit > a wierd error and I can't figure out how to solve it: > > Prelude> import Graphics.UI.SDL.Mixer.Music > Prelude Graphics.UI.SDL.Mixer.Music> loadMUS "test.wav" Is the package installed? Otherwise you may have to give an -lSDL_mixer option when starting ghci. From dons at galois.com Tue Jun 24 16:05:29 2008 From: dons at galois.com (Don Stewart) Date: Tue Jun 24 15:57:10 2008 Subject: [Haskell-cafe] sdl-mixer loading issue In-Reply-To: References: Message-ID: <20080624200529.GG17394@scytale.galois.com> wojtowicz.norbert: > Hello, > > I am trying to use the SDL-mixer bindings to play wav files. I've hit > a wierd error and I can't figure out how to solve it: > > Prelude> import Graphics.UI.SDL.Mixer.Music > Prelude Graphics.UI.SDL.Mixer.Music> loadMUS "test.wav" > Loading package SDL-0.5.4 ... linking ... done. > Loading package SDL-mixer-0.5.2 ... linking ... : > /home/norbert/bin/lib/SDL-mixer-0.5.2/ghc-6.8.2/HSSDL-mixer-0.5.2.o: > unknown symbol `Mix_LoadWAV' > ghc-6.8.2: unable to load package `SDL-mixer-0.5.2' > > I've looked up the source code; Mix_LoadWAV seems to be #defined, so I > suspect it's some kind of library path issue but I don't grok the > whole system well enough to figure it out; maybe someone could point > me in the right direction? > > Have the issue now on Ubuntu 8.04 and previously had the same issue > when I tested it on a FreeBSD box. I did install all of the > "libsdl-*-dev" in the Ubuntu repo. Ah, well spotted. I get the same issue on Arch, in ghci: Prelude> import Graphics.UI.SDL.Mixer.Music Prelude Graphics.UI.SDL.Mixer.Music> loadMUS "/usr/share/hback-0.0.3/sounds/t.wav" : /usr/lib/SDL-mixer-0.5.2/ghc-6.8.2/HSSDL-mixer-0.5.2.o: unknown symbol `Mix_LoadWAV' ghc-6.8.2: unable to load package `SDL-mixer-0.5.2' Looking in the source we see: foreign import ccall unsafe "Mix_LoadWAV" mixLoadWAV :: CString -> IO (Ptr ChunkStruct) Lemmih, any ideas? -lSDL and -lSDL_mixer seem to be there. -- Don From dons at galois.com Tue Jun 24 16:07:02 2008 From: dons at galois.com (Don Stewart) Date: Tue Jun 24 15:58:36 2008 Subject: [Haskell-cafe] sdl-mixer loading issue In-Reply-To: References: Message-ID: <20080624200702.GH17394@scytale.galois.com> lemming: > > On Tue, 24 Jun 2008, Norbert Wojtowicz wrote: > > >Hello, > > > >I am trying to use the SDL-mixer bindings to play wav files. I've hit > >a wierd error and I can't figure out how to solve it: > > > >Prelude> import Graphics.UI.SDL.Mixer.Music > >Prelude Graphics.UI.SDL.Mixer.Music> loadMUS "test.wav" > > Is the package installed? Otherwise you may have to give an -lSDL_mixer > option when starting ghci. That's not enough, for some reason: $ ghci -lSDL_mixer Prelude> import Graphics.UI.SDL.Mixer.Music Prelude Graphics.UI.SDL.Mixer.Music> loadMUS "test.wav" : /home/dons/.cabal/lib/SDL-mixer-0.5.2/ghc-6.8.2/HSSDL-mixer-0.5.2.o: unknown symbol `Mix_LoadWAV' ghc-6.8.2: unable to load package `SDL-mixer-0.5.2' Despite it being defined in $ grep Mix_LoadWAV /usr/lib/* Binary file /usr/lib/libSDL_mixer-1.2.so.0 matches Binary file /usr/lib/libSDL_mixer-1.2.so.0.2.6 matches Binary file /usr/lib/libSDL_mixer.a matches Binary file /usr/lib/libSDL_mixer.so matches Hmm. From marcot at riseup.net Tue Jun 24 16:13:47 2008 From: marcot at riseup.net (Marco =?ISO-8859-1?Q?T=FAlio?= Gontijo e Silva) Date: Tue Jun 24 16:04:58 2008 Subject: [Haskell-cafe] sdl-mixer loading issue In-Reply-To: References: Message-ID: <1214338427.2850.16.camel@quindinho.domain.invalid> Em Ter, 2008-06-24 ?s 14:57 -0500, Norbert Wojtowicz escreveu: > Prelude> import Graphics.UI.SDL.Mixer.Music > Prelude Graphics.UI.SDL.Mixer.Music> loadMUS "test.wav" > Loading package SDL-0.5.4 ... linking ... done. > Loading package SDL-mixer-0.5.2 ... linking ... : > /home/norbert/bin/lib/SDL-mixer-0.5.2/ghc-6.8.2/HSSDL-mixer-0.5.2.o: > unknown symbol `Mix_LoadWAV' > ghc-6.8.2: unable to load package `SDL-mixer-0.5.2' Hello. SDL-mixer does not support the most recent SDL version. The problem is that in SDL now Mix_LoadWAV is a macro. -- Marco T?lio Gontijo e Silva P?gina: http://marcotmarcot.googlepages.com/ Blog: http://marcotmarcot.wordpress.com/ Correio: marcot@riseup.net XMPP: marcot@jabber.org IRC: marcot@irc.freenode.net Telefone: 25151920 Celular: 98116720 Endere?o: Rua Turfa, 639/701 Prado 30410-370 Belo Horizonte/MG Brasil From dons at galois.com Tue Jun 24 16:14:53 2008 From: dons at galois.com (Don Stewart) Date: Tue Jun 24 16:06:26 2008 Subject: [Haskell-cafe] sdl-mixer loading issue In-Reply-To: <1214338427.2850.16.camel@quindinho.domain.invalid> References: <1214338427.2850.16.camel@quindinho.domain.invalid> Message-ID: <20080624201453.GI17394@scytale.galois.com> marcot: > Em Ter, 2008-06-24 ?s 14:57 -0500, Norbert Wojtowicz escreveu: > > Prelude> import Graphics.UI.SDL.Mixer.Music > > Prelude Graphics.UI.SDL.Mixer.Music> loadMUS "test.wav" > > Loading package SDL-0.5.4 ... linking ... done. > > Loading package SDL-mixer-0.5.2 ... linking ... : > > /home/norbert/bin/lib/SDL-mixer-0.5.2/ghc-6.8.2/HSSDL-mixer-0.5.2.o: > > unknown symbol `Mix_LoadWAV' > > ghc-6.8.2: unable to load package `SDL-mixer-0.5.2' > > Hello. > > SDL-mixer does not support the most recent SDL version. The problem is > that in SDL now Mix_LoadWAV is a macro. Ah ha, so it needs a cbits wrapper over the macro. From lemming at henning-thielemann.de Tue Jun 24 16:38:34 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Tue Jun 24 16:30:05 2008 Subject: [Haskell-cafe] Access to Oracle database from Haskell In-Reply-To: <79d7c4980806240755p724777e3i9240067c3c050ccb@mail.gmail.com> References: <79d7c4980806192210j11796038sc5008d669df926b5@mail.gmail.com> <79d7c4980806200251o6e74e409mbd993a09c835014@mail.gmail.com> <79d7c4980806240755p724777e3i9240067c3c050ccb@mail.gmail.com> Message-ID: On Tue, 24 Jun 2008, Alistair Bayley wrote: > 2008/6/24 Henning Thielemann : >> >> (Btw. Takusen should be split into >> several packages for all database backends because Cabal flags must not >> influence the package interface.) > > I don't understand this (cabal flags must not influence package > interface). I thought that was the point of cabal flags? I wanted to > have a single package installation, and this seems like the best way. No, if a package imports Takusen - how can it be assert that it can import the Oracle back-end? It can't because it can reference the Takusen package only by its name and a version. Flags are there to make a package appear consistent under different circumstances (e.g. Windows and Unix, or GHC-6.4 and GHC-6.8). If the back-end modules would not be exported, then the API would remain the same for different back-ends and that would be ok. >> But on installation Cabal complains about missing /usr/oci directory. > > When you run configure, you should get output that says: > Using Oracle: > > What is ? I don't get these questions. > The Setup.hs assumes the entire Oracle installation is under a single > root folder ($ORACLE_HOME); is this not true on Linux? Ah, I must have set ORACLE_HOME for the Takusen installation ... should be documented. However in my case, this doesn't change the path used by Takusen's Setup/install. $ echo $ORACLE_HOME /usr/lib/oracle/10.2.0.4/client $ ls $ORACLE_HOME bin lib $ ll $ORACLE_HOME/lib -rw-r--r-- 1 root root 1525 17. Feb 09:58 glogin.sql lrwxrwxrwx 1 root root 17 24. Jun 15:36 libclntsh.so -> libclntsh.so.10.1 -rw-r--r-- 1 root root 19076649 17. Feb 09:57 libclntsh.so.10.1 -rw-r--r-- 1 root root 5656445 17. Feb 09:57 libnnz10.so lrwxrwxrwx 1 root root 15 24. Jun 15:36 libocci.so -> libocci.so.10.1 -rw-r--r-- 1 root root 1398244 17. Feb 09:57 libocci.so.10.1 -rw-r--r-- 1 root root 72698427 17. Feb 09:57 libociei.so -rw-r--r-- 1 root root 120443 17. Feb 09:57 libocijdbc10.so -rw-r--r-- 1 root root 1434263 17. Feb 09:58 libsqlplusic.so -rw-r--r-- 1 root root 1069221 17. Feb 09:58 libsqlplus.so -rw-r--r-- 1 root root 781311 17. Feb 09:58 libsqora.so.10.1 -rw-r--r-- 1 root root 1555682 17. Feb 09:57 ojdbc14.jar I assume that libociei.so is the library I need. $ runhaskell Setup.hs configure --user -f oracle Configuring Takusen-0.8.2... $ runhaskell Setup.hs build && runhaskell Setup.hs haddock Preprocessing library Takusen-0.8.2... Building Takusen-0.8.2... /usr/bin/ar: creating dist/build/libHSTakusen-0.8.2.a Preprocessing library Takusen-0.8.2... Running Haddock for Takusen-0.8.2... Preprocessing library Takusen-0.8.2... ... Documentation created: dist/doc/html/Takusen/index.html $ runhaskell Setup.hs install Installing: [...]/lib/Takusen-0.8.2/ghc-6.8.2 Registering Takusen-0.8.2... Reading package info from "dist/installed-pkg-config" ... done. ghc-pkg: /usr/oci doesn't exist or isn't a directory (use --force to override) >> Once I will get Takusen running with OCI - how would I use it? Is there a >> minimal example which connects to an Oracle database, performing a very >> simple query? > > There's an example in the README.txt, which I've tweaked here for Oracle: > > {-# OPTIONS -fglasgow-exts #-} > {-# OPTIONS -fallow-overlapping-instances #-} > module Main where > import Database.Oracle.Enumerator > import Control.Monad.Trans (liftIO) > main = flip catchDB reportRethrow $ > withSession (connect "user" "pswd" "dbname") (do > let iter (s::String) (_::String) = result s > result <- doQuery (sql "select 'Hello world.' from dual") iter "" > liftIO (putStrLn result) > ) Thanks for the adapted example! From lemming at henning-thielemann.de Tue Jun 24 16:54:38 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Tue Jun 24 16:46:09 2008 Subject: [Haskell-cafe] Access to Oracle database from Haskell In-Reply-To: <485C94C1.6030006@cisco.com> References: <485C94C1.6030006@cisco.com> Message-ID: On Sat, 21 Jun 2008, Lanny Ripple wrote: > I had luck with this the other day using Database.HDBC.ODBC. For > Ubuntu's Hardy I found that Oracle's 10.2.0.3 worked best. > (10.2.0.4 and 11 seemed to have problems for me at least.) > > http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html > > Grab the basic (not basic-lite), odbc, and sqlplus (to test) zips. > The odbc_update_ini.sh should be run from inside the > instantclient_10_2 directory as root > > sudo /bin/sh odbc_update_ini.sh / > > (assuming a standard unixODBC install.) You'll also need a > tnsnames.ora file to describe your connection(s) to the DB(s). > You'll also need to define some environment variables to run against > all this. I use a small script: > > #!/bin/sh > oracle_home=/opt/lib/oracle/instantclient_10_2 > export TNS_ADMIN=$oracle_home > export LD_LIBRARY_PATH=$oracle_home > [ $# = 0 ] && exit 1 > exec "$@" Thank you for the detailed hints! However, I tried a lot of this and that, but without a possibility to track down what went wrong, the ways to fix the probable problems are unbounded. Finally I get 'Driver's SQLAllocHandle on SQL_HANDLE_HENV failed' when I start 'isql' and that's where systematic error analysis stops and wild guessing starts. Since OCI and sqlplus work on my machine, I'll try to follow this way. From nielsadb at gmail.com Tue Jun 24 17:04:42 2008 From: nielsadb at gmail.com (Niels Aan de Brugh) Date: Tue Jun 24 16:56:15 2008 Subject: [Haskell-cafe] Two questions regarding Alex/Parsec Message-ID: <1214341482.13477.26.camel@porcupine> Hello Haskellers, As an experiment I'm writing a parser for MediaWiki language. I'm using the Alex lexer and Parsec. I have novice two questions. (I've tried using Happy but I was unable to get a grammar file to compile, which must be because I have no real experience using Yacc and the like. I've also attempted to write an ad-hoc recursive descent parser, but that become too complex to be fun very quickly.) == SourcePos and AlexPosn == My first question is about Parsec's SourcePos. I have a definition like: type LexToken = (AlexPosn, Token) type MWP a = GenParser LexToken () a toSourcePos :: AlexPosn -> SourcePos toSourcePos (AlexPn _ line col) = undefined mwtok :: (Token -> Maybe a) -> MWP a mwtok test = token showToken posToken posTest where showToken = show . snd posToken = toSourcePos . fst posTest = test . snd The definition of ?toSourcePos isn't 100% satisfactory. The constructor SourcePos is hidden, so I cannot simply use (SourcePos line col). Is there a way to convert an AlexPosn value to a SourcePos? == Data Constructors as Parameters and Tags == Secondly, I frequently encounter the pattern where I try to match a token, return Just some result if it matches, and Nothing otherwise. So I tried to fix this pattern in a nice reusable function. onTok0 :: Token -> a -> MWP a onTok0 t x = mwtok (\tok -> if tok `isTok` t then Just x else Nothing) This seems to work, but I'd also like a definition for data constructors taking one parameter: onTok1 :: (a -> Token) -> (a -> b) -> MWP b onTok1 t f = mwtok (\tok -> case tok of (t n) = Just $ f n _ = Nothing) This doesn't work, the pattern match (t n) fails, which is understandable: n is used as a parameter to t and a matched result, which looks like a paradox. t is a function (constructor) but also a tag. Is it possible to pass a tag as an argument? Or is there another way to extract this pattern? Regards, Niels From dons at galois.com Tue Jun 24 17:08:29 2008 From: dons at galois.com (Don Stewart) Date: Tue Jun 24 17:00:05 2008 Subject: [Haskell-cafe] Two questions regarding Alex/Parsec In-Reply-To: <1214341482.13477.26.camel@porcupine> References: <1214341482.13477.26.camel@porcupine> Message-ID: <20080624210829.GL17394@scytale.galois.com> nielsadb: > Hello Haskellers, > > As an experiment I'm writing a parser for MediaWiki language. I'm using > the Alex lexer and Parsec. I have novice two questions. Just a quick question, did you try using the pandoc markdown parser? http://hackage.haskell.org/packages/archive/pandoc/0.46/doc/html/Text-Pandoc-Readers-Markdown.html It'd be useful to know if that was enough for printing and generation of wiki content. Though being GPLd, it'd also be nice to have a BSD-ish licensed wiki parser/pretty printer. -- Don From alistair at abayley.org Tue Jun 24 17:35:56 2008 From: alistair at abayley.org (Alistair Bayley) Date: Tue Jun 24 17:27:26 2008 Subject: [Haskell-cafe] Access to Oracle database from Haskell In-Reply-To: References: <79d7c4980806192210j11796038sc5008d669df926b5@mail.gmail.com> <79d7c4980806200251o6e74e409mbd993a09c835014@mail.gmail.com> <79d7c4980806240755p724777e3i9240067c3c050ccb@mail.gmail.com> Message-ID: <79d7c4980806241435y2d0f2054n714b1c8701c2eea@mail.gmail.com> >> 2008/6/24 Henning Thielemann : >>> >> When you run configure, you should get output that says: >> Using Oracle: >> >> What is ? > > I don't get these questions. Sorry. I was really asking (not very clearly): what is the output from "runhaskell Setup.hs configure -foracle" ? You've answered that below. > Ah, I must have set ORACLE_HOME for the Takusen installation ... should be > documented. However in my case, this doesn't change the path used by > Takusen's Setup/install. Well, you don't actually need it set for the Takusen install (it doesn''t use it). But $ORACLE_HOME/bin should be in your path. And it needs to contain the executable sqlplus. Can you run sqlplus? It looks as though you don't have it. If sqlplus is not in my path then I get this error in the configure step, because I have specified sqlplus as a buildtool in Takusen.cabal: > setup configure -foracle Configuring Takusen-0.8.2... setup: sqlplus is required but it could not be found. Note: sqlplus isn't really needed to build; this is just a validation step, to check you have $ORACLE_HOME/bin in your path. > $ echo $ORACLE_HOME > /usr/lib/oracle/10.2.0.4/client > $ ls $ORACLE_HOME > bin lib > $ ll $ORACLE_HOME/lib > ... > I assume that libociei.so is the library I need. Actually it's libclntsh.so. You need to change the oracle section in Takusen.cabal to this: If flag(oracle) Exposed-modules: Database.Oracle.Enumerator , Database.Oracle.OCIConstants , Database.Oracle.OCIFunctions Build-Tools: sqlplus If os(windows) Extra-Libraries: oci Else Extra-Libraries: clntsh Your $ORACLE_HOME installation looks fairly normal, if somewhat minimal. I would normally expect to see sqlplus, and maybe some other executables, like tnsping. And a folder $ORACLE_HOME/oci/include, which contains the OCI header files. Perhaps you could also install the sqplus and SDK packages, as Lanny Ripple suggested, although I suspect they may not be strictly necessary, as you can apparently successfully compile, as evidenced below. > $ runhaskell Setup.hs configure --user -f oracle > Configuring Takusen-0.8.2... Here, I would expect to see "Using Oracle: /usr/lib/oracle/10.2.0.4/client" After setup configure you can say: $ runhaskell Setup.hs register --gen-pkg-config and then take a look at the generated Takusen-0.8.2.conf. Check the library-dirs and include-dirs fields. Alistair From oddron at gmail.com Tue Jun 24 17:46:56 2008 From: oddron at gmail.com (Ronald Guida) Date: Tue Jun 24 17:38:27 2008 Subject: [Haskell-cafe] Bug in Emacs Haskell Mode Message-ID: <62728db30806241446m68799c4q95851f8b2bbb2b@mail.gmail.com> Emacs Haskell Mode has the following useful feature: when "Haskell -> Load File" is used to load a file into GHCi from Emacs, Haskell Mode automatically looks for a "*.cabal" file in an attempt to find the project directory. When Haskell Mode finds the *.cabal file, it fails to check whether it has found a file or a folder. As a result, if I want to load a Haskell file that has no corresponding .cabal file, then Haskell Mode locates my "~/.cabal" *folder* and assumes that it's my project directory. I have a "~/.cabal" folder because Cabal-Install puts it there. Cabal-Install is part of Haskell's new package management system. Now I don't know very much Emacs Lisp, but I figured out a fix for the problem. In Haskell-Mode-2.4, in the file haskell-cabal.el, I changed the function "haskell-cabal-find-file" so that it explicitly checks to make sure that any *.cabal file is in fact a file and not a folder. I don't know if comparing the first letter of the file mode string to 'd' is the right way to diferentiate a folder from a file, but so far it appears to work for me, so I thought I'd share it. (defun haskell-cabal-find-file () "Return a buffer visiting the cabal file of the current directory, or nil." (catch 'found (let ((user (nth 2 (file-attributes default-directory))) ;; Abbreviate, so as to stop when we cross ~/. (root (abbreviate-file-name default-directory)) files) (while (and root (equal user (nth 2 (file-attributes root)))) (let ((files (directory-files root 'full "\\.cabal\\'"))) (if (and files (not (equal 100 (aref (nth 8 (file-attributes (car files))) 0)))) (throw 'found (find-file-noselect (car files))) (if (equal root (setq root (file-name-directory (directory-file-name root)))) (setq root nil)))) nil)))) From daniil.elovkov at googlemail.com Tue Jun 24 17:51:10 2008 From: daniil.elovkov at googlemail.com (Daniil Elovkov) Date: Tue Jun 24 17:42:57 2008 Subject: [Haskell-cafe] Access to Oracle database from Haskell In-Reply-To: References: <485C94C1.6030006@cisco.com> Message-ID: <48616C4E.4000101@gmail.com> Henning Thielemann wrote: > > On Sat, 21 Jun 2008, Lanny Ripple wrote: > >> I had luck with this the other day using Database.HDBC.ODBC. For >> Ubuntu's Hardy I found that Oracle's 10.2.0.3 worked best. >> (10.2.0.4 and 11 seemed to have problems for me at least.) >> >> http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html >> >> >> Grab the basic (not basic-lite), odbc, and sqlplus (to test) zips. >> The odbc_update_ini.sh should be run from inside the >> instantclient_10_2 directory as root >> >> sudo /bin/sh odbc_update_ini.sh / >> >> (assuming a standard unixODBC install.) You'll also need a >> tnsnames.ora file to describe your connection(s) to the DB(s). >> You'll also need to define some environment variables to run against >> all this. I use a small script: >> >> #!/bin/sh >> oracle_home=/opt/lib/oracle/instantclient_10_2 >> export TNS_ADMIN=$oracle_home >> export LD_LIBRARY_PATH=$oracle_home >> [ $# = 0 ] && exit 1 >> exec "$@" > > Thank you for the detailed hints! However, I tried a lot of this and > that, but without a possibility to track down what went wrong, the ways > to fix the probable problems are unbounded. Finally I get 'Driver's > SQLAllocHandle on SQL_HANDLE_HENV failed' when I start 'isql' and that's > where systematic error analysis stops and wild guessing starts. Since > OCI and sqlplus work on my machine, I'll try to follow this way. There are also Database.HSQL Database.HSQL.Oracle It works through OCI as well. It's not clear (to me at least) if it is/will be supported. It has back-ends for multiple DBs (is Takusen only for Oracle?) It doesn't take the typeful approach, that Takusen takes (may be a plus in some situations) From wojtowicz.norbert at gmail.com Tue Jun 24 19:19:24 2008 From: wojtowicz.norbert at gmail.com (Norbert Wojtowicz) Date: Tue Jun 24 19:10:54 2008 Subject: [Haskell-cafe] sdl-mixer loading issue In-Reply-To: <20080624201453.GI17394@scytale.galois.com> References: <1214338427.2850.16.camel@quindinho.domain.invalid> <20080624201453.GI17394@scytale.galois.com> Message-ID: >> SDL-mixer does not support the most recent SDL version. The problem is >> that in SDL now Mix_LoadWAV is a macro. I've tried it with SDL-0.5.2 from hackage as well with the same problem. (Unless you mean an earlier version of the actual SDL library?) > Ah ha, so it needs a cbits wrapper over the macro. This is above my head. If we know what the problem is, will this by any chance hit someone's todo list soon or is this a big hurdle? Are there any other cross-platform (windows + linux at the minimum) ways of playing sounds that anyone can recommend? - Norbert From dons at galois.com Tue Jun 24 19:31:41 2008 From: dons at galois.com (Don Stewart) Date: Tue Jun 24 19:23:17 2008 Subject: [Haskell-cafe] sdl-mixer loading issue In-Reply-To: References: <1214338427.2850.16.camel@quindinho.domain.invalid> <20080624201453.GI17394@scytale.galois.com> Message-ID: <20080624233141.GU17394@scytale.galois.com> wojtowicz.norbert: > >> SDL-mixer does not support the most recent SDL version. The problem is > >> that in SDL now Mix_LoadWAV is a macro. > > I've tried it with SDL-0.5.2 from hackage as well with the same > problem. (Unless you mean an earlier version of the actual SDL > library?) > > > Ah ha, so it needs a cbits wrapper over the macro. > > This is above my head. If we know what the problem is, will this by > any chance hit someone's todo list soon or is this a big hurdle? > > Are there any other cross-platform (windows + linux at the minimum) > ways of playing sounds that anyone can recommend? Attached is a patched version of SDL_mixer 0.5.2 with a C wrapper for this macro. I'm now able to run loadWAV in ghci. We need to have the maintainer upload the amended version to Hackage, or to give me leave to do so. -- Don -------------- next part -------------- A non-text attachment was scrubbed... Name: SDL-mixer-0.5.2.1.tar.gz Type: application/x-gzip Size: 41107 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080624/94ad5acc/SDL-mixer-0.5.2.1.tar-0001.bin From wojtowicz.norbert at gmail.com Tue Jun 24 20:34:08 2008 From: wojtowicz.norbert at gmail.com (Norbert Wojtowicz) Date: Tue Jun 24 20:25:39 2008 Subject: [Haskell-cafe] sdl-mixer loading issue In-Reply-To: References: <1214338427.2850.16.camel@quindinho.domain.invalid> <20080624201453.GI17394@scytale.galois.com> <20080624233141.GU17394@scytale.galois.com> Message-ID: > Attached is a patched version of SDL_mixer 0.5.2 with a C wrapper > for this macro. I'm now able to run loadWAV in ghci. Works for me, thanks! Now I just need to learn how to make my WAVs sound not like computer-generated children voices. For example, using the hback wav files and this: import Control.Concurrent (threadDelay) import Graphics.UI.SDL.Mixer.General import Graphics.UI.SDL.Mixer.Music main = do openAudio 22050 AudioS16Sys 2 4096 w <- loadMUS "c.wav" playMusic w 1 threadDelay 2000000 freeMusic w closeAudio It plays (which is an immense improvement), but I can't get it to sound the way it does from eg. mplayer. I have almost no knowledge of the inner workings of computer sound drivers, so if there is something obvious I'm missing please do speak up. - Norbert From Braden.Shepherdson at gmail.com Tue Jun 24 20:43:45 2008 From: Braden.Shepherdson at gmail.com (Braden Shepherdson) Date: Tue Jun 24 20:37:26 2008 Subject: [Haskell-cafe] Re: Haskell on ARM (was Re: ANN: Topkata) In-Reply-To: <871w2mit8o.wl%jeremy@n-heptane.com> References: <87zlpoguqh.fsf@elefant.olsbruecken.local> <4B3E7353-F7F2-4D2D-A335-30D2D3883A4A@gmail.com> <200806170851.22718.valgarv@gmx.net> <87ej6ww9dy.fsf_-_@columbia.edu> <20080617201233.GD19304@scytale.galois.com> <871w2mit8o.wl%jeremy@n-heptane.com> Message-ID: Jeremy Shaw wrote: > If any does attempt to build for the ARM, please, please, please, > document what you do in the wiki. And, if you do, edit the wiki as you > go, you definitely won't be able to remember what you did after the > fact. (Or, at the very least, use some program to capture everything > you do so that you can refer to it later). > > And, finally, I heard vague rumors a while ago that made me think that > GHC 6.10 might have a pure ANSI-C backend? Is there any truth to this? > That would make porting much easier if it meant you did not have to do > steps 1-4. > > j. > > ps. I would be happy to try to answer any questions if someone tries a > port. I would still like to run GHC on my 770, and I hope to own an > iPhone if they fix a few ommisions (bluetooth keyboard support, and > similar stuff). > I recently acquired the ARM-based Nokia N810 (and <3 it), powered by Maemo. Running a uname -a on it: Linux Nokia-N810-42-19 2.6.21-omap1 #2 Fri Nov 16 16:24:58 EET 2007 armv6l unknown I would love a working GHC implementation on it, if for nothing else than how awesome it would be. Whether that means using a C back-end or native compilation doesn't matter to me so much. I might be one to attempt this, as I know C and ARM-ish asm decently well and have a powerful desktop to compile on. I have no familiarity with GHC internals, though. Lastly, I won't have anything like the time to attempt this seriously until mid-September or so. Braden Shepherdson shepheb From monnier at iro.umontreal.ca Tue Jun 24 21:39:00 2008 From: monnier at iro.umontreal.ca (Stefan Monnier) Date: Tue Jun 24 21:30:41 2008 Subject: [Haskell-cafe] Re: Bug in Emacs Haskell Mode In-Reply-To: <62728db30806241446m68799c4q95851f8b2bbb2b@mail.gmail.com> (Ronald Guida's message of "Tue, 24 Jun 2008 17:46:56 -0400") References: <62728db30806241446m68799c4q95851f8b2bbb2b@mail.gmail.com> Message-ID: > Emacs Haskell Mode has the following useful feature: when "Haskell -> > Load File" is used to load a file into GHCi from Emacs, Haskell Mode > automatically looks for a "*.cabal" file in an attempt to find the > project directory. I'm truly sorry about the fact that I only release new versions rather rarely. I recommend you use the CVS version, where this bug was fixed a few months ago. Stefan From thomas.dubuisson at gmail.com Tue Jun 24 21:52:48 2008 From: thomas.dubuisson at gmail.com (Thomas M. DuBuisson) Date: Tue Jun 24 21:44:21 2008 Subject: [Haskell-cafe] Why the exception? Message-ID: <1214358768.20040.9.camel@tom-laptop> Cafe I'm a bit lost on this exception and curious about what's going on. Is there a valid reason for this exception that I am missing? Note the hard-coded [0..100] could be any Word8 list you want (generated via arbitrary, [], or other) and it gives the same result. Load the module and perform: :break prop_LPS quickCheck prop_LPS :step :force ps *** Exception: Prelude.head: empty list > import qualified Data.ByteString as L > import Test.QuickCheck > > instance Arbitrary L.ByteString where > arbitrary = do > return $ L.pack [0..100] > > prop_LPS :: L.ByteString -> Bool > prop_LPS ps = ps `seq` True P.S. Same result with GHCi 6.8.2 and 6.8.3. From tphyahoo at gmail.com Tue Jun 24 22:32:56 2008 From: tphyahoo at gmail.com (tphyahoo) Date: Tue Jun 24 22:24:26 2008 Subject: [Haskell-cafe] Fwd: Cabalized, Self-Demoing, HStringTemplate-using HAppS Tutorial In-Reply-To: <0fb0a9bd-89fa-4001-b0a7-3dbaec828b87@z32g2000prh.googlegroups.com> References: <0fb0a9bd-89fa-4001-b0a7-3dbaec828b87@z32g2000prh.googlegroups.com> Message-ID: ---------- Forwarded message ---------- From: tphyahoo Date: Jun 24, 7:26?pm Subject: Cabalized, Self-Demoing, HStringTemplate-using HAppS Tutorial To: HAppS Hello HAppSers! I have created a self-demoing, HStringTemplate-using intro to HAppS. There is a live demo at http://rippledeals.com:5001 It is cabalized at http://hackage.haskell.org/cgi-bin/hackage-scripts/package/happs-tuto... and should install fine with sudo cabal install happs-tutorial. There is a darcs repo at http://code.haskell.org/happs-examples And a google project at http://code.google.com/p/happs-tutorial/ which currently isn't used, but who knows, maybe for the wiki or issue tracking. (I started at google hosting before migrating to darcs.) I have all kinds of additional lessons planned, but under the release early/release often motto I'm letting it out in its embryonic state. Enjoy! Thomas. From tphyahoo at gmail.com Tue Jun 24 23:08:46 2008 From: tphyahoo at gmail.com (tphyahoo) Date: Tue Jun 24 23:00:16 2008 Subject: [Haskell-cafe] Fwd: Cabalized, Self-Demoing, HStringTemplate-using HAppS Tutorial In-Reply-To: <00c66891-143a-4d1c-92ac-c2c3c22d7e16@w4g2000prd.googlegroups.com> References: <0fb0a9bd-89fa-4001-b0a7-3dbaec828b87@z32g2000prh.googlegroups.com> <00c66891-143a-4d1c-92ac-c2c3c22d7e16@w4g2000prd.googlegroups.com> Message-ID: <8398182c-f80e-4620-9f7b-be9d167823ca@y22g2000prd.googlegroups.com> ---------- Forwarded message ---------- From: tphyahoo Date: Jun 24, 7:46?pm Subject: Cabalized, Self-Demoing, HStringTemplate-using HAppS Tutorial To: HAppS There are some issues with the cabalized project -- templates are missing. Doh. Use darcs for now. Thomas. On Jun 24, 7:26?pm, tphyahoo wrote: > Hello HAppSers! > I have created a self-demoing, HStringTemplate-using intro to HAppS. > There is a live demo at >http://rippledeals.com:5001 > It is cabalized at >http://hackage.haskell.org/cgi-bin/hackage-scripts/package/happs-tuto... > and should install fine with sudo cabal install happs-tutorial. > There is a darcs repo at >http://code.haskell.org/happs-examples > And a google project at >http://code.google.com/p/happs-tutorial/ > which currently isn't used, but who knows, maybe for the wiki or issue > tracking. (I started at google hosting before migrating to darcs.) > I have all kinds of additional lessons planned, but under the release > early/release often motto I'm letting it out in its embryonic state. > Enjoy! > Thomas. From tphyahoo at gmail.com Tue Jun 24 23:40:21 2008 From: tphyahoo at gmail.com (Thomas Hartman) Date: Tue Jun 24 23:31:55 2008 Subject: [Haskell-cafe] Fwd: Cabalized, Self-Demoing, HStringTemplate-using HAppS Tutorial In-Reply-To: <8398182c-f80e-4620-9f7b-be9d167823ca@y22g2000prd.googlegroups.com> References: <0fb0a9bd-89fa-4001-b0a7-3dbaec828b87@z32g2000prh.googlegroups.com> <00c66891-143a-4d1c-92ac-c2c3c22d7e16@w4g2000prd.googlegroups.com> <8398182c-f80e-4620-9f7b-be9d167823ca@y22g2000prd.googlegroups.com> Message-ID: <910ddf450806242040r5bcbaacweec95cb2c7abc13c@mail.gmail.com> Uy. I think I got the cabal install version as well, but I had to specify a mess of files manually. So I'll probably be using darcs tag for future release if there are any ;) thomas. 2008/6/24 tphyahoo : > > > > ---------- Forwarded message ---------- > From: tphyahoo > Date: Jun 24, 7:46 pm > Subject: Cabalized, Self-Demoing, HStringTemplate-using HAppS Tutorial > To: HAppS > > > There are some issues with the cabalized project -- templates are > missing. Doh. > > Use darcs for now. > > Thomas. > > On Jun 24, 7:26 pm, tphyahoo wrote: > >> Hello HAppSers! > >> I have created a self-demoing, HStringTemplate-using intro to HAppS. > >> There is a live demo at > >>http://rippledeals.com:5001 > >> It is cabalized at > >>http://hackage.haskell.org/cgi-bin/hackage-scripts/package/happs-tuto... > >> and should install fine with sudo cabal install happs-tutorial. > >> There is a darcs repo at > >>http://code.haskell.org/happs-examples > >> And a google project at > >>http://code.google.com/p/happs-tutorial/ > >> which currently isn't used, but who knows, maybe for the wiki or issue >> tracking. (I started at google hosting before migrating to darcs.) > >> I have all kinds of additional lessons planned, but under the release >> early/release often motto I'm letting it out in its embryonic state. > >> Enjoy! > >> Thomas. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From tphyahoo at gmail.com Tue Jun 24 23:41:37 2008 From: tphyahoo at gmail.com (Thomas Hartman) Date: Tue Jun 24 23:33:08 2008 Subject: [Haskell-cafe] Fwd: Cabalized, Self-Demoing, HStringTemplate-using HAppS Tutorial In-Reply-To: <910ddf450806242040r5bcbaacweec95cb2c7abc13c@mail.gmail.com> References: <0fb0a9bd-89fa-4001-b0a7-3dbaec828b87@z32g2000prh.googlegroups.com> <00c66891-143a-4d1c-92ac-c2c3c22d7e16@w4g2000prd.googlegroups.com> <8398182c-f80e-4620-9f7b-be9d167823ca@y22g2000prd.googlegroups.com> <910ddf450806242040r5bcbaacweec95cb2c7abc13c@mail.gmail.com> Message-ID: <910ddf450806242041n25aa02b7s3fdd2fcc46ca9fa7@mail.gmail.com> ... cabal install version _working_ as well... (v0.2) 2008/6/24 Thomas Hartman : > Uy. > > I think I got the cabal install version as well, but I had to specify > a mess of files manually. > > So I'll probably be using darcs tag for future release if there are any ;) > > thomas. > > 2008/6/24 tphyahoo : >> >> >> >> ---------- Forwarded message ---------- >> From: tphyahoo >> Date: Jun 24, 7:46 pm >> Subject: Cabalized, Self-Demoing, HStringTemplate-using HAppS Tutorial >> To: HAppS >> >> >> There are some issues with the cabalized project -- templates are >> missing. Doh. >> >> Use darcs for now. >> >> Thomas. >> >> On Jun 24, 7:26 pm, tphyahoo wrote: >> >>> Hello HAppSers! >> >>> I have created a self-demoing, HStringTemplate-using intro to HAppS. >> >>> There is a live demo at >> >>>http://rippledeals.com:5001 >> >>> It is cabalized at >> >>>http://hackage.haskell.org/cgi-bin/hackage-scripts/package/happs-tuto... >> >>> and should install fine with sudo cabal install happs-tutorial. >> >>> There is a darcs repo at >> >>>http://code.haskell.org/happs-examples >> >>> And a google project at >> >>>http://code.google.com/p/happs-tutorial/ >> >>> which currently isn't used, but who knows, maybe for the wiki or issue >>> tracking. (I started at google hosting before migrating to darcs.) >> >>> I have all kinds of additional lessons planned, but under the release >>> early/release often motto I'm letting it out in its embryonic state. >> >>> Enjoy! >> >>> Thomas. >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > From skynare at gmail.com Tue Jun 24 23:58:01 2008 From: skynare at gmail.com (skynare@gmail.com) Date: Tue Jun 24 23:49:35 2008 Subject: [Haskell-cafe] Why the exception? In-Reply-To: <1214358768.20040.9.camel@tom-laptop> References: <1214358768.20040.9.camel@tom-laptop> Message-ID: <4e7aa0f80806242058j156b27e1w66accd7ebdaa718d@mail.gmail.com> Probably you need to implement coarbitrary, too. My ghci session for your code: $ ghci GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help Loading package base ... linking ... done. Prelude> :l t.hs [1 of 1] Compiling Main ( t.hs, interpreted ) t.hs:4:0: Warning: No explicit method nor default method for `coarbitrary' In the instance declaration for `Arbitrary L.ByteString' Ok, modules loaded: Main. *Main> quickCheck prop_LPS Loading package array-0.1.0.0 ... 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 random-1.0.0.0 ... linking ... done. Loading package QuickCheck-1.1.0.0 ... linking ... done. OK, passed 100 tests. On 6/24/08, Thomas M. DuBuisson wrote: > Cafe > I'm a bit lost on this exception and curious about what's going on. Is > there a valid reason for this exception that I am missing? Note the > hard-coded [0..100] could be any Word8 list you want (generated via > arbitrary, [], or other) and it gives the same result. > > Load the module and perform: > :break prop_LPS > quickCheck prop_LPS > :step > :force ps > *** Exception: Prelude.head: empty list > >> import qualified Data.ByteString as L >> import Test.QuickCheck >> >> instance Arbitrary L.ByteString where >> arbitrary = do >> return $ L.pack [0..100] >> >> prop_LPS :: L.ByteString -> Bool >> prop_LPS ps = ps `seq` True > > P.S. Same result with GHCi 6.8.2 and 6.8.3. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From lrpalmer at gmail.com Wed Jun 25 01:16:16 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Wed Jun 25 01:07:45 2008 Subject: [Haskell-cafe] sdl-mixer loading issue In-Reply-To: References: <1214338427.2850.16.camel@quindinho.domain.invalid> <20080624201453.GI17394@scytale.galois.com> <20080624233141.GU17394@scytale.galois.com> Message-ID: <7ca3f0160806242216y76b99d80x6e52a2b575829ce@mail.gmail.com> On Tue, Jun 24, 2008 at 6:34 PM, Norbert Wojtowicz wrote: >> Attached is a patched version of SDL_mixer 0.5.2 with a C wrapper >> for this macro. I'm now able to run loadWAV in ghci. > > Works for me, thanks! > > Now I just need to learn how to make my WAVs sound not like > computer-generated children voices. For example, using the hback wav > files and this: > > import Control.Concurrent (threadDelay) > import Graphics.UI.SDL.Mixer.General > import Graphics.UI.SDL.Mixer.Music > > main = do > openAudio 22050 AudioS16Sys 2 4096 This is probably the issue. Most wavs are sampled at 44100, not 22050, and I think you have to ask mplayer specifically to downsample. Changing this to openAudio 44100 AudioS16Sys 2 4096 should do the trick. Luke > w <- loadMUS "c.wav" > playMusic w 1 > threadDelay 2000000 > freeMusic w > closeAudio > > It plays (which is an immense improvement), but I can't get it to > sound the way it does from eg. mplayer. I have almost no knowledge of > the inner workings of computer sound drivers, so if there is something > obvious I'm missing please do speak up. > > - Norbert > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From lrpalmer at gmail.com Wed Jun 25 01:17:17 2008 From: lrpalmer at gmail.com (Luke Palmer) Date: Wed Jun 25 01:08:50 2008 Subject: [Haskell-cafe] sdl-mixer loading issue In-Reply-To: <7ca3f0160806242216y76b99d80x6e52a2b575829ce@mail.gmail.com> References: <1214338427.2850.16.camel@quindinho.domain.invalid> <20080624201453.GI17394@scytale.galois.com> <20080624233141.GU17394@scytale.galois.com> <7ca3f0160806242216y76b99d80x6e52a2b575829ce@mail.gmail.com> Message-ID: <7ca3f0160806242217v7a0fb25fpaa6aea42201547eb@mail.gmail.com> On Tue, Jun 24, 2008 at 11:16 PM, Luke Palmer wrote: > On Tue, Jun 24, 2008 at 6:34 PM, Norbert Wojtowicz > wrote: >>> Attached is a patched version of SDL_mixer 0.5.2 with a C wrapper >>> for this macro. I'm now able to run loadWAV in ghci. >> >> Works for me, thanks! >> >> Now I just need to learn how to make my WAVs sound not like >> computer-generated children voices. For example, using the hback wav >> files and this: >> >> import Control.Concurrent (threadDelay) >> import Graphics.UI.SDL.Mixer.General >> import Graphics.UI.SDL.Mixer.Music >> >> main = do >> openAudio 22050 AudioS16Sys 2 4096 > > This is probably the issue. Most wavs are sampled at 44100, not > 22050, and I think you have to ask mplayer specifically to downsample. Er, ask sdl-mixer specifically... you knew what I meant. > Changing this to > > openAudio 44100 AudioS16Sys 2 4096 > > should do the trick. > > Luke > >> w <- loadMUS "c.wav" >> playMusic w 1 >> threadDelay 2000000 >> freeMusic w >> closeAudio >> >> It plays (which is an immense improvement), but I can't get it to >> sound the way it does from eg. mplayer. I have almost no knowledge of >> the inner workings of computer sound drivers, so if there is something >> obvious I'm missing please do speak up. >> >> - Norbert >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > From harald.rotter at sagem.com Wed Jun 25 02:33:34 2008 From: harald.rotter at sagem.com (Harald ROTTER) Date: Wed Jun 25 02:26:52 2008 Subject: [Haskell-cafe] number-parameterized types and heterogeneous lists Message-ID: Hello Anton, thanks for your enlightening piece of code. "foldD" does exactly what I was hoping for. Now it becomes very obvious to me that the positions of the forall's in the Digit definition are crucial. Thanks a lot to Alfonso, Luke and Ryan as well. Haskell Cafe is a really good place to learn new things :-) Harald. " Ce courriel et les documents qui y sont attaches peuvent contenir des informations confidentielles. Si vous n'etes pas le destinataire escompte, merci d'en informer l'expediteur immediatement et de detruire ce courriel ainsi que tous les documents attaches de votre systeme informatique. Toute divulgation, distribution ou copie du present courriel et des documents attaches sans autorisation prealable de son emetteur est interdite." " This e-mail and any attached documents may contain confidential or proprietary information. If you are not the intended recipient, please advise the sender immediately and delete this e-mail and all attached documents from your computer system. Any unauthorised disclosure, distribution or copying hereof is prohibited." From leledumbo_cool at yahoo.co.id Wed Jun 25 04:05:12 2008 From: leledumbo_cool at yahoo.co.id (leledumbo) Date: Wed Jun 25 03:56:42 2008 Subject: [Haskell-cafe] Help with generalizing function In-Reply-To: References: <18063291.post@talk.nabble.com> <7ca3f0160806230111o36adb13cl96ebd67773718924@mail.gmail.com> <18065206.post@talk.nabble.com> Message-ID: <18106999.post@talk.nabble.com> Hi, I'm back. I have some troubles understanding your code: Chadda? Fouch?-2 wrote: > > findAllAns 0 0 = [[]] > findAllAns 0 s = [] > findAllAns n s = [ x:xs | x <- [0..s], xs <- findAllAns (n - 1) (s - x) ] > Let's try a test case (CMIIW) for findAllAns 2 1: findAllAns 2 1 = [ 0:(findAllAns 1 1) ] = [ 0:0:(findAllAns 0 1) ] = [ 0:0:[] ] // Not a solution = [ 0:(findAllAns 1 1) ] = [ 0:1:(findAllAns 0 0) ] = [ 0:1:[[]] ] // A solution = [ 1:(findAllAns 1 0) ] = [ 1:0:(findAllAns 0 0) ] = [ 1:0:[[]] ] // A solution ( 1:1:? is never reached. ) I don't understand why if the last element is [[]] then it's included in the result and not if it's []. -- View this message in context: http://www.nabble.com/Help-with-generalizing-function-tp18063291p18106999.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From alistair at abayley.org Wed Jun 25 04:10:56 2008 From: alistair at abayley.org (Alistair Bayley) Date: Wed Jun 25 04:02:26 2008 Subject: [Haskell-cafe] Access to Oracle database from Haskell In-Reply-To: <79d7c4980806241435y2d0f2054n714b1c8701c2eea@mail.gmail.com> References: <79d7c4980806192210j11796038sc5008d669df926b5@mail.gmail.com> <79d7c4980806200251o6e74e409mbd993a09c835014@mail.gmail.com> <79d7c4980806240755p724777e3i9240067c3c050ccb@mail.gmail.com> <79d7c4980806241435y2d0f2054n714b1c8701c2eea@mail.gmail.com> Message-ID: <79d7c4980806250110m38c8da33h790c2b3da22f9d2c@mail.gmail.com> >> $ ll $ORACLE_HOME/lib >> ... >> I assume that libociei.so is the library I need. > > Actually it's libclntsh.so. You need to change the oracle section in > Takusen.cabal to this: Another difference between Windows and Linux Oracle installations is that the client libs are in $ORACLE_HOME/lib on Linux, but in $ORACLE_HOME/bin on Windows. The Setup.hs script has the Windows case baked in. You should change the configOracle function like so: configOracle verbose buildtools = createConfigByFindingExe verbose buildtools "Oracle" sqlplusProgram parentFolder oracleLibDir "oci/include" -- location of OCI client library differs between Windows and Unix where oracleLibDir = if isWindows then "bin" else "lib" Alistair From sasko.mateski at gmail.com Wed Jun 25 04:15:03 2008 From: sasko.mateski at gmail.com (Sasko Mateski) Date: Wed Jun 25 04:06:33 2008 Subject: [Haskell-cafe] Problem installing Cabal-1.4.0.1 with ghc-6.8.3 Message-ID: <110ac8380806250115i7f628013xd45982f5c7112ca5@mail.gmail.com> Hi, After reading the latest article on the Haskell Hacking blog (Daily Haskell: Download and analyse logs, then generate sparklines) I wanted to install cabal-install to check it out. Soon I found out that it has a dependency on Cabal (>=1.4&&<1.5), so next thing to do was getting and installing Cabal-1.4.0.1 (since the version coming with ghc-6.8.3 is 1.2.4.0). But during the configuration part of the installation I got the following error: During interactive linking, GHCi couldn't find the following symbol: SHGetFolderPathA@20 This may be due to you not asking GHCi to load extra object files, archives or DLLs needed by your current session. Restart GHCi, specifying the missing library using the -L/path/to/object/dir and -lmissinglibname flags, or simply by naming the relevant files on the GHCi command line. Alternatively, this link failure might indicate a bug in GHCi. If you suspect the latter, please send a bug report to: glasgow-haskell-bugs@haskell.org After some googling, I couldn't find anything on the web related to the problem, so posting to a Haskell mailing list seemed like an obvious next step. Since I'm a novice Haskell any help would be very much appreciated, indeed. I'm using *ghc-6.8.3* on a *Windows XP Professional SP3*. Regards *Sasko* -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080625/b8b0084c/attachment.htm From lemming at henning-thielemann.de Wed Jun 25 04:59:38 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Wed Jun 25 04:51:08 2008 Subject: [Haskell-cafe] Access to Oracle database from Haskell In-Reply-To: <79d7c4980806241435y2d0f2054n714b1c8701c2eea@mail.gmail.com> References: <79d7c4980806192210j11796038sc5008d669df926b5@mail.gmail.com> <79d7c4980806200251o6e74e409mbd993a09c835014@mail.gmail.com> <79d7c4980806240755p724777e3i9240067c3c050ccb@mail.gmail.com> <79d7c4980806241435y2d0f2054n714b1c8701c2eea@mail.gmail.com> Message-ID: On Tue, 24 Jun 2008, Alistair Bayley wrote: >>> 2008/6/24 Henning Thielemann : >>>> >>> When you run configure, you should get output that says: >>> Using Oracle: >>> >>> What is ? >> >> I don't get these questions. > > Sorry. I was really asking (not very clearly): what is the output from > "runhaskell Setup.hs configure -foracle" ? It doesn't output the Oracle path. :-( >> Ah, I must have set ORACLE_HOME for the Takusen installation ... should be >> documented. However in my case, this doesn't change the path used by >> Takusen's Setup/install. > > Well, you don't actually need it set for the Takusen install (it > doesn''t use it). But $ORACLE_HOME/bin should be in your path. And it > needs to contain the executable sqlplus. Can you run sqlplus? Yes, I have successfully connected to a database with sqlplus, already. > If sqlplus is not in my path then I get this error in the configure > step, because I have specified sqlplus as a buildtool in > Takusen.cabal: > > > setup configure -foracle > Configuring Takusen-0.8.2... > setup: sqlplus is required but it could not be found. > > Note: sqlplus isn't really needed to build; this is just a validation > step, to check you have $ORACLE_HOME/bin in your path. I don't get an error. sqlplus is in $ORACLE_HOME/bin, but the RPM package also sets a link from /usr/bin/sqlplus to $ORACLE_HOME/bin, thus 'sqlplus' is in the $PATH also without $ORACLE_HOME. (But sqlplus cannot be started until the LD_LIBRARY_PATH is extended to Oracles libraries.) >> $ echo $ORACLE_HOME >> /usr/lib/oracle/10.2.0.4/client >> $ ls $ORACLE_HOME >> bin lib >> $ ll $ORACLE_HOME/lib >> ... >> I assume that libociei.so is the library I need. > > Actually it's libclntsh.so. You need to change the oracle section in > Takusen.cabal to this: > > If flag(oracle) > Exposed-modules: > Database.Oracle.Enumerator > , Database.Oracle.OCIConstants > , Database.Oracle.OCIFunctions > Build-Tools: sqlplus > If os(windows) > Extra-Libraries: oci > Else > Extra-Libraries: clntsh > > Your $ORACLE_HOME installation looks fairly normal, if somewhat > minimal. I would normally expect to see sqlplus, and maybe some other > executables, like tnsping. And a folder $ORACLE_HOME/oci/include, > which contains the OCI header files. They got installed to: /usr/include/oracle/10.2.0.4/client/ That is, they are not in $ORACLE_HOME. :-( >> $ runhaskell Setup.hs configure --user -f oracle >> Configuring Takusen-0.8.2... > > Here, I would expect to see "Using Oracle: /usr/lib/oracle/10.2.0.4/client" It does not tell me. :-( > After setup configure you can say: > $ runhaskell Setup.hs register --gen-pkg-config > > and then take a look at the generated Takusen-0.8.2.conf. Check the > library-dirs and include-dirs fields. Takusen-0.8.2.conf and dist/installed-pkg-config contain the same. They contain include-dirs: /usr/oci independent from my setting of ORACLE_HOME. As I said, I cannot manually fix dist/installed-pkg-config, because it gets overwritten by 'Setup install'. From Alistair.Bayley at invesco.com Wed Jun 25 05:24:14 2008 From: Alistair.Bayley at invesco.com (Bayley, Alistair) Date: Wed Jun 25 05:16:44 2008 Subject: [Haskell-cafe] Access to Oracle database from Haskell In-Reply-To: References: <79d7c4980806192210j11796038sc5008d669df926b5@mail.gmail.com><79d7c4980806200251o6e74e409mbd993a09c835014@mail.gmail.com><79d7c4980806240755p724777e3i9240067c3c050ccb@mail.gmail.com><79d7c4980806241435y2d0f2054n714b1c8701c2eea@mail.gmail.com> Message-ID: <125EACD0CAE4D24ABDB4D148C4593DA9049E943F@GBLONXMB02.corp.amvescap.net> > From: haskell-cafe-bounces@haskell.org > [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of > Henning Thielemann > > I don't get an error. sqlplus is in $ORACLE_HOME/bin, but the > RPM package > also sets a link from /usr/bin/sqlplus to $ORACLE_HOME/bin, > thus 'sqlplus' > is in the $PATH also without $ORACLE_HOME. (But sqlplus > cannot be started > until the LD_LIBRARY_PATH is extended to Oracles libraries.) Ahhh... so Setup.hs thinks sqlplus is in /usr/bin, rather than $ORACLE_HOME/bin. That explains: include-dirs: /usr/oci I'll have to change the way that Setup.hs tries to find $ORACLE_HOME. Using getEnv would be a much better idea. I don't recall why I didn't use it before; perhaps it's not always set on Windows installations. > > Your $ORACLE_HOME installation looks fairly normal, if somewhat > > minimal. I would normally expect to see sqlplus, and maybe > some other > > executables, like tnsping. And a folder $ORACLE_HOME/oci/include, > > which contains the OCI header files. > > They got installed to: > /usr/include/oracle/10.2.0.4/client/ > That is, they are not in $ORACLE_HOME. :-( I'm not sure how Setup.hs would find out where these are installed. Any ideas? It may not matter, as I think you can compile without them. I'd expect problems if you compile -fvia-C, though. > >> $ runhaskell Setup.hs configure --user -f oracle > >> Configuring Takusen-0.8.2... > > > > Here, I would expect to see "Using Oracle: > /usr/lib/oracle/10.2.0.4/client" > > It does not tell me. :-( That is odd. Alistair ***************************************************************** Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. ***************************************************************** From duncan.coutts at worc.ox.ac.uk Wed Jun 25 05:33:46 2008 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Jun 25 05:20:05 2008 Subject: [Haskell-cafe] Problem installing Cabal-1.4.0.1 with ghc-6.8.3 In-Reply-To: <110ac8380806250115i7f628013xd45982f5c7112ca5@mail.gmail.com> References: <110ac8380806250115i7f628013xd45982f5c7112ca5@mail.gmail.com> Message-ID: <1214386426.15010.1135.camel@localhost> On Wed, 2008-06-25 at 10:15 +0200, Sasko Mateski wrote: > I wanted to install cabal-install to check it out. Soon I found out > that it has a dependency on Cabal (>=1.4&&<1.5), so next thing to do > was getting and installing Cabal-1.4.0.1 (since the version coming > with ghc-6.8.3 is 1.2.4.0). But during the configuration part of the > installation I got the following error: > > During interactive linking, GHCi couldn't find the following symbol: > SHGetFolderPathA@20 > This may be due to you not asking GHCi to load extra object files, Instead of using runghc Setup.hs configure, use: ghc --make Setup.hs Setup.exe configure Setup.exe build Setup.exe install (This is documented in the README in the Cabal package tarball) That way you are compiling Setup.hs using ghc rather than running it using ghci. The problem is that on Windows Cabal needs to use some Win32 FFI calls and ghci doesn't know about the libs we are linking to. You only have to use this workaround when installing Cabal itself (and only on Windows). Once it's installed the runghc method works for all other packages. Even better, once you've got cabal-install working there'll be no need for this kind of fiddling at all as cabal-install will compile Setup.hs automatically (if that's necessary, often it can do it directly without compiling Setup.hs at all). Duncan From chaddai.fouche at gmail.com Wed Jun 25 05:55:13 2008 From: chaddai.fouche at gmail.com (=?ISO-8859-1?Q?Chadda=EF_Fouch=E9?=) Date: Wed Jun 25 05:46:43 2008 Subject: [Haskell-cafe] Help with generalizing function In-Reply-To: <18106999.post@talk.nabble.com> References: <18063291.post@talk.nabble.com> <7ca3f0160806230111o36adb13cl96ebd67773718924@mail.gmail.com> <18065206.post@talk.nabble.com> <18106999.post@talk.nabble.com> Message-ID: 2008/6/25 leledumbo : > > Hi, I'm back. I have some troubles understanding your code: > > ( 1:1:? is never reached. ) Why would 1:1 be reached when we search for lists with a sum of 1 ?? Your derivation is incorrect, when you're reading a list comprehension you must see it as imbricated loops, let's see a correct derivation : findAllAns 2 1 ==> [ x:xs | x <- [0..1], xs <- findAllAns 1 (1 - x) ] ==> concat [ [ 0 : xs | xs <- findAllAns 1 1 ], [ 1 : xs | xs <- findAllAns 1 0 ] ] findAllAns 1 1 ==> [ concat [ [ [ 0 : xs | xs <- findAllAns 0 1 ], [ 1 : xs | xs <- findAllAns 0 0 ] ] ==> concat [ [], [[1]] ] ==> [ [ 1 ] ] In reality, all list comprehensions are translated to ordinary functions under the hood, the translation is the following : [ x:xs | x <- [0..s], xs <- findAllAns (n - 1) (s - x) ] == concatMap (x -> concatMap (\xs -> x : xs) (findAllAns (n - 1) (s - x)) [0..s] which is then easier to derive. > I don't understand why if the last element is [[]] then it's included in the > result and not if it's []. I think with the concatMap above you'll understand better what's going on : "concatMap (\xs -> 0 : xs) (findAllAns 0 1)" returns the empty list because "findAllAns 0 1" is an empty list while "concatMap (\xs -> 1 : xs) (findAllAns 0 0)" returns [[1]] because "findAllAns 0 0" is a list that contains the empty list. But you don't have to think so hard to find the good response, just think of the edge cases logically : faire une somme de 0 avec 0 ?l?ments c'est possible (parce que 0 est l'?l?ment neutre de l'addition), tandis que faire une somme diff?rente de 0 avec 0 ?l?ments est impossible. (The sum of 0 elements is always 0, and the product of 0 elements is always 1) -- Jeda? From alistair at abayley.org Wed Jun 25 06:07:49 2008 From: alistair at abayley.org (Alistair Bayley) Date: Wed Jun 25 05:59:21 2008 Subject: [Haskell-cafe] Access to Oracle database from Haskell In-Reply-To: <125EACD0CAE4D24ABDB4D148C4593DA9049E943F@GBLONXMB02.corp.amvescap.net> References: <79d7c4980806192210j11796038sc5008d669df926b5@mail.gmail.com> <79d7c4980806200251o6e74e409mbd993a09c835014@mail.gmail.com> <79d7c4980806240755p724777e3i9240067c3c050ccb@mail.gmail.com> <79d7c4980806241435y2d0f2054n714b1c8701c2eea@mail.gmail.com> <125EACD0CAE4D24ABDB4D148C4593DA9049E943F@GBLONXMB02.corp.amvescap.net> Message-ID: <79d7c4980806250307h64bfba7dh95b518967c171384@mail.gmail.com> > I'll have to change the way that Setup.hs tries to find $ORACLE_HOME. > Using getEnv would be a much better idea. I don't recall why I didn't > use it before; perhaps it's not always set on Windows installations. Try this version of configOracle in Setup.hs: configOracle verbose buildtools = do if not (sqlplusProgram `isElem` buildtools) then return Nothing else do path <- getEnv "ORACLE_HOME" info verbose ("Using Oracle: " ++ path) makeConfig path libDir "oci/include" where libDir = if isWindows then "bin" else "lib" You'll also need to add this import: import System.Environment (getEnv) I always used to get the "Using..." messages, but now it seems I need to say: $ setup configure -v -foracle Alistair From jgoerzen at complete.org Wed Jun 25 09:25:34 2008 From: jgoerzen at complete.org (John Goerzen) Date: Wed Jun 25 09:17:11 2008 Subject: [Haskell-cafe] Access to Oracle database from Haskell In-Reply-To: References: <79d7c4980806192210j11796038sc5008d669df926b5@mail.gmail.com> <79d7c4980806200251o6e74e409mbd993a09c835014@mail.gmail.com> <79d7c4980806240755p724777e3i9240067c3c050ccb@mail.gmail.com> Message-ID: <4862474E.8070801@complete.org> Henning Thielemann wrote: > On Tue, 24 Jun 2008, Alistair Bayley wrote: > >> 2008/6/24 Henning Thielemann : >>> (Btw. Takusen should be split into >>> several packages for all database backends because Cabal flags must not >>> influence the package interface.) >> I don't understand this (cabal flags must not influence package >> interface). I thought that was the point of cabal flags? I wanted to >> have a single package installation, and this seems like the best way. > > No, if a package imports Takusen - how can it be assert that it can import I haven't read this entire thread, but I might also just interject here that HDBC supports ODBC (on Windows, and on Linux/Posix platforms via unixODBC, iODBC, or similar), which may be another avenue for you to try. I'm sure there are ODBC Oracle drivers out there, and so if you have your ODBC layer working, you get Haskell support easily. -- John From lemming at henning-thielemann.de Wed Jun 25 09:31:27 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Wed Jun 25 09:23:02 2008 Subject: [Haskell-cafe] Access to Oracle database from Haskell In-Reply-To: <4862474E.8070801@complete.org> References: <79d7c4980806192210j11796038sc5008d669df926b5@mail.gmail.com> <79d7c4980806200251o6e74e409mbd993a09c835014@mail.gmail.com> <79d7c4980806240755p724777e3i9240067c3c050ccb@mail.gmail.com> <4862474E.8070801@complete.org> Message-ID: On Wed, 25 Jun 2008, John Goerzen wrote: > I haven't read this entire thread, but I might also just interject here > that HDBC supports ODBC (on Windows, and on Linux/Posix platforms via > unixODBC, iODBC, or similar), which may be another avenue for you to > try. I'm sure there are ODBC Oracle drivers out there, and so if you > have your ODBC layer working, you get Haskell support easily. This was actually how the thread started: I don't get ODBC for Oracle working on Linux. :-( Maybe this is an unixODBC issue - is iODBC an API-compatible replacement? From icfp.publicity at googlemail.com Wed Jun 25 10:01:03 2008 From: icfp.publicity at googlemail.com (Matthew Fluet (ICFP Publicity Chair)) Date: Wed Jun 25 09:52:37 2008 Subject: [Haskell-cafe] ICFP08 Final Call for posters Message-ID: <53ff55480806250701u79d6fba1lcd089c69de68691d@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 conal at conal.net Wed Jun 25 10:50:59 2008 From: conal at conal.net (Conal Elliott) Date: Wed Jun 25 10:42:29 2008 Subject: [Haskell-cafe] history of tuples vs pairs Message-ID: I have a foggy memory that early ML had only binary pairing, nesting for n-tuples. Can anyone confirm this memory. If so, does anyone remember the rationale for going to n-tuples? Performance, perhaps? Similarly, did the Haskell designers consider pairs as an alternative to n-ary tuples? The reason I ask is that while ghc and libraries suppors n-tuples for some values of n, the support is generally incomplete and inconsistent. And some abstractions are very heavily biased toward pairing, particularly Arrow and the pair instances of Monad and Applicative. And of course, inclusion of fst and snd in the prelude but lack of similar standard functions for n-tuples with n>2. - Conal -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080625/1da9f710/attachment.htm From dcespin at fastmail.fm Wed Jun 25 11:37:30 2008 From: dcespin at fastmail.fm (Dominic Espinosa) Date: Wed Jun 25 11:28:59 2008 Subject: [Haskell-cafe] Simple question about processing XML with HaXml Message-ID: <20080625153729.GD2960@argivia.columbus.rr.com> Hello, I'm trying to learn how to use HaXml, but I'm having trouble getting off the ground. I can see from the documentation how to process XML using the combinators and processXmlWith, but processXmlWith seems to "hide" the actual process of reading and parsing the XML. Suppose that processXmlWith isn't suitable for a program. How then do you load the XML and apply filters to it? I guess what I'm asking is, given the following code: load filename = do handle <- IO.openFile filename IO.ReadMode contents <- IO.getContents handle IO.hclose handle return $ xmlParse filename contents myTest fname = do -- read file d <- load fname --- ?? now what? I'm sure the answer to this is quite simple, but I'm coming from a background of OO and SAX, and the HaXml docs are a bit cryptic as yet. Additionally, if anyone knows of any tutorials pertaining to HaXml, other than the papers on the HaXml website and the blog entries on cleaning legacy HTML, I'd appreciate some pointers. Thanks. From Christian.Maeder at dfki.de Wed Jun 25 11:49:20 2008 From: Christian.Maeder at dfki.de (Christian Maeder) Date: Wed Jun 25 11:40:50 2008 Subject: [Haskell-cafe] Re: history of tuples vs pairs In-Reply-To: References: Message-ID: <48626900.5090809@dfki.de> Conal Elliott wrote: > I have a foggy memory that early ML had only binary pairing, nesting for > n-tuples. Can anyone confirm this memory. If so, does anyone remember > the rationale for going to n-tuples? Performance, perhaps? In Isabelle HOL "*" is a right-associative (pair) type constructor. So "T1 * T2 * T3" is the same as "T1 * (T2 * T3)". Although the concept is minimal it is sort of asymmetric (wrt. associativity). Cheers Christian From dave at zednenem.com Wed Jun 25 13:29:53 2008 From: dave at zednenem.com (David Menendez) Date: Wed Jun 25 13:21:26 2008 Subject: [Haskell-cafe] history of tuples vs pairs In-Reply-To: References: Message-ID: <49a77b7a0806251029s7fc1ad3bj8535a8d9d9217474@mail.gmail.com> 2008/6/25 Conal Elliott : > I have a foggy memory that early ML had only binary pairing, nesting for > n-tuples. Can anyone confirm this memory. If so, does anyone remember the > rationale for going to n-tuples? Performance, perhaps? > > Similarly, did the Haskell designers consider pairs as an alternative to > n-ary tuples? I think performance was part of it: accessing the nth element of a tuple is O(1), but the nth element of a nested pair is O(n). On the other hand, you can't internally represent nested pairs as n-tuples because of laziness. (a,(b,c)) has elements of the form (x,_|_) that don't correspond to any triple. -- Dave Menendez From nielsadb at gmail.com Wed Jun 25 13:42:16 2008 From: nielsadb at gmail.com (Niels Aan de Brugh) Date: Wed Jun 25 13:33:47 2008 Subject: [Haskell-cafe] Two questions regarding Alex/Parsec In-Reply-To: <20080624210829.GL17394@scytale.galois.com> References: <1214341482.13477.26.camel@porcupine> <20080624210829.GL17394@scytale.galois.com> Message-ID: <1214415736.8450.16.camel@porcupine> On Tue, 2008-06-24 at 14:08 -0700, Don Stewart wrote: > Just a quick question, did you try using the pandoc markdown parser? > > http://hackage.haskell.org/packages/archive/pandoc/0.46/doc/html/Text-Pandoc-Readers-Markdown.html > > It'd be useful to know if that was enough for printing and generation > of wiki content. Though being GPLd, it'd also be nice to have a BSD-ish > licensed wiki parser/pretty printer. No, I did not. In fact I didn't know about this project, but it looks very interesting. I'll definitely go and look at the code. One of the reasons I started worked on a MediaWikiParser was because I wanted to use the Haskell language and some of its tools rather than just read about them. I'm not really interested in making a clone of something that already exists just for the sake of ideology (although personally I'm much more fond of BSD-style licenses than of GPL). On a side note: are there any lexer/parser generators out there I should be aware of? As mentioned in my original post I've tried using Happy, but I was unable to understand its very concise error message 'parE'. It would be really nice to have a tool that generates an AST automatically (e.g. something like ANTLR). Regards, Niels From dons at galois.com Wed Jun 25 13:46:30 2008 From: dons at galois.com (Don Stewart) Date: Wed Jun 25 13:38:04 2008 Subject: [Haskell-cafe] Two questions regarding Alex/Parsec In-Reply-To: <1214415736.8450.16.camel@porcupine> References: <1214341482.13477.26.camel@porcupine> <20080624210829.GL17394@scytale.galois.com> <1214415736.8450.16.camel@porcupine> Message-ID: <20080625174630.GA21487@scytale.galois.com> nielsadb: > On Tue, 2008-06-24 at 14:08 -0700, Don Stewart wrote: > > > Just a quick question, did you try using the pandoc markdown parser? > > > > http://hackage.haskell.org/packages/archive/pandoc/0.46/doc/html/Text-Pandoc-Readers-Markdown.html > > > > It'd be useful to know if that was enough for printing and generation > > of wiki content. Though being GPLd, it'd also be nice to have a BSD-ish > > licensed wiki parser/pretty printer. > > No, I did not. In fact I didn't know about this project, but it looks > very interesting. I'll definitely go and look at the code. > One of the reasons I started worked on a MediaWikiParser was because I > wanted to use the Haskell language and some of its tools rather than just > read about them. I'm not really interested in making a clone of something > that already exists just for the sake of ideology (although personally > I'm much more fond of BSD-style licenses than of GPL). Personally, I'd find a MediaWiki parser/pretty printer quite useful! > On a side note: are there any lexer/parser generators out there I should > be aware of? As mentioned in my original post I've tried using Happy, but > I was unable to understand its very concise error message 'parE'. > It would be really nice to have a tool that generates an AST automatically > (e.g. something like ANTLR). There's lots, but probably Alex (lexer) and Happy (parser) or Parsec are the most widely used. -- Don From nielsadb at gmail.com Wed Jun 25 13:50:08 2008 From: nielsadb at gmail.com (Niels Aan de Brugh) Date: Wed Jun 25 13:41:37 2008 Subject: [Haskell-cafe] history of tuples vs pairs In-Reply-To: References: Message-ID: <1214416208.8450.22.camel@porcupine> On Wed, 2008-06-25 at 16:50 +0200, Conal Elliott wrote: > I have a foggy memory that early ML had only binary pairing, nesting > for n-tuples. Can anyone confirm this memory. If so, does anyone > remember the rationale for going to n-tuples? Performance, perhaps? ?What is the difference between a list build up of Cons and a "tuple" made out of pairs? I think the latter wouldn't really add anything new. A question of my own: is there much difference between e.g. data MyData = MyData Int Bool Char and type MyData = (Int, Bool, Char) other than the syntax of course? Regards, Niels From jgoerzen at complete.org Wed Jun 25 14:09:35 2008 From: jgoerzen at complete.org (John Goerzen) Date: Wed Jun 25 14:01:09 2008 Subject: [Haskell-cafe] Access to Oracle database from Haskell In-Reply-To: References: <79d7c4980806192210j11796038sc5008d669df926b5@mail.gmail.com> <79d7c4980806200251o6e74e409mbd993a09c835014@mail.gmail.com> <79d7c4980806240755p724777e3i9240067c3c050ccb@mail.gmail.com> <4862474E.8070801@complete.org> Message-ID: <486289DF.70107@complete.org> Henning Thielemann wrote: > On Wed, 25 Jun 2008, John Goerzen wrote: > >> I haven't read this entire thread, but I might also just interject here >> that HDBC supports ODBC (on Windows, and on Linux/Posix platforms via >> unixODBC, iODBC, or similar), which may be another avenue for you to >> try. I'm sure there are ODBC Oracle drivers out there, and so if you >> have your ODBC layer working, you get Haskell support easily. > > This was actually how the thread started: I don't get ODBC for Oracle > working on Linux. :-( > Maybe this is an unixODBC issue - is iODBC an API-compatible replacement? > Yes, iODBC is. There are also proprietary ODBC implementations. At work, we have to deal with Progress databases. Their ODBC library, presumably due to being a rather ancient shared library, doesn't work with unixODBC -- but they ship their entire own ODBC framework, Merant ODBC. HDBC compiles against it (though must be modified to not support wide characters, which Merant ODBC doesn't support). -- John From nielsadb at gmail.com Wed Jun 25 14:17:09 2008 From: nielsadb at gmail.com (Niels Aan de Brugh) Date: Wed Jun 25 14:08:38 2008 Subject: [Haskell-cafe] Two questions regarding Alex/Parsec In-Reply-To: <20080625174630.GA21487@scytale.galois.com> References: <1214341482.13477.26.camel@porcupine> <20080624210829.GL17394@scytale.galois.com> <1214415736.8450.16.camel@porcupine> <20080625174630.GA21487@scytale.galois.com> Message-ID: <1214417829.8450.44.camel@porcupine> On Wed, 2008-06-25 at 10:46 -0700, Don Stewart wrote: > > One of the reasons I started worked on a MediaWikiParser was because I > > wanted to use the Haskell language and some of its tools rather than just > > read about them. I'm not really interested in making a clone of something > > that already exists just for the sake of ideology (although personally > > I'm much more fond of BSD-style licenses than of GPL). > > Personally, I'd find a MediaWiki parser/pretty printer quite useful! Oh yes, don't yet me wrong, this isn't just a study project for me; I really want to have a working parser. I'm just saying that if there was such a parser for Haskell already under the GPL I wouldn't be bothered rewriting it just so I could license it under MIT/BSD. > > On a side note: are there any lexer/parser generators out there I should > > be aware of? As mentioned in my original post I've tried using Happy, but > > I was unable to understand its very concise error message 'parE'. > > It would be really nice to have a tool that generates an AST automatically > > (e.g. something like ANTLR). > > There's lots, but probably Alex (lexer) and Happy (parser) or Parsec are > the most widely used. Okay, in that case I'll stick to Alex + Parsec, it's quite comfortable so far. By the way, does anyone know the answer to my original question? Especially the first one (Alex' AlexPosn vs. Parsec's SourcePos) is worrying me somewhat. Regards, Niels From byorgey at seas.upenn.edu Wed Jun 25 14:24:57 2008 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Wed Jun 25 14:16:25 2008 Subject: [Haskell-cafe] history of tuples vs pairs In-Reply-To: <1214416208.8450.22.camel@porcupine> References: <1214416208.8450.22.camel@porcupine> Message-ID: <20080625182456.GA12376@minus.seas.upenn.edu> On Wed, Jun 25, 2008 at 07:50:08PM +0200, Niels Aan de Brugh wrote: > On Wed, 2008-06-25 at 16:50 +0200, Conal Elliott wrote: > > I have a foggy memory that early ML had only binary pairing, nesting > > for n-tuples. Can anyone confirm this memory. If so, does anyone > > remember the rationale for going to n-tuples? Performance, perhaps? > > ???What is the difference between a list build up of Cons and a "tuple" > made out of pairs? I think the latter wouldn't really add anything new. The difference is that all the elements of a list must be the same type, whereas nested tuples could have elements of any type. For example, (True, (6, 'c')) :: (Bool, (Int, Char)) and there is no corresponding three-element list. However, you're right in noting the similarity between lists and nested tuples -- in fact, this is exactly how lists are implemented in lisp (which is where we get the tern 'cons'). > > A question of my own: is there much difference between e.g. > data MyData = MyData Int Bool Char > and > type MyData = (Int, Bool, Char) > other than the syntax of course? Conceptually, there is not much difference; these types are clearly isomorphic. Practically speaking, there are differences other than just the syntax. For example, in Haskell 98 you are not allowed to make class instances for type synonyms. Another big difference is that this: type MyData = (Int, Bool, MyData) is illegal, whereas this: data MyData = MyData Int Bool MyData is perfectly fine. -Brent From nielsadb at gmail.com Wed Jun 25 14:58:18 2008 From: nielsadb at gmail.com (Niels Aan de Brugh) Date: Wed Jun 25 14:49:46 2008 Subject: [Haskell-cafe] Two questions regarding Alex/Parsec In-Reply-To: <1214417829.8450.44.camel@porcupine> References: <1214341482.13477.26.camel@porcupine> <20080624210829.GL17394@scytale.galois.com> <1214415736.8450.16.camel@porcupine> <20080625174630.GA21487@scytale.galois.com> <1214417829.8450.44.camel@porcupine> Message-ID: <1214420298.8450.48.camel@porcupine> On Wed, 2008-06-25 at 20:17 +0200, Niels Aan de Brugh wrote: > By the way, does anyone know the answer to my original question? > Especially the first one (Alex' AlexPosn vs. Parsec's SourcePos) is > worrying me somewhat. To answer my own question: as it turns out I was using an old version of Parsec (2.1.0, the one that comes with Ubuntu Linux). A newer version of Parsec (3.0.0) adds a newPos function in ?Text.Parsec.Pos that trivially constructs a new SourcePos. Regards, Niels From wagner.andrew at gmail.com Wed Jun 25 16:14:21 2008 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Wed Jun 25 16:05:50 2008 Subject: [Haskell-cafe] Haskell, Microsoft, and interview questions Message-ID: This post borders on being off-topic, but it seems like people on this list would be interested. First, some of you know that I had the distinct privilege of flying out to Microsoft this week to interview for a Software Development Engineer position on their Live Search team. So I want to first tell you about their reaction to my Haskell experience, and then give you some interesting coding problems that they asked me to solve, which could be good practice to tackle in Haskell. So the first task I was given to do, long before my in-person interview, was to complete a technical assessment. This consisted of two fairly simple algorithms to write. I chose to do so in Haskell. On the basis of this assessment, they decided I was worth a phone interview. When I got on that interview, one of the first things the interviewer said was "So, one thing that jumped out immediately was that you did the assessment in Haskell. Tell me a little bit about that." It led to a good discussion about why I like Haskell and functional programming. When I actually flew out there, several people made comments about me being "that guy who writes Haskell". The recruiter even said something along the lines of "anyone who knows haskell is certainly worth our time to talk to." Moral of the story: Haskell rocks, and even Microsoft knows it! That said, here are some interesting problems to work through in Haskell, if you'd like: 1.) A "rotated array" is an array of integers in ascending order, after which for every element i, it has been moved to element (i + n) mod sizeOfList. Write a function that takes a rotated array and, in less-than-linear time, returns n (the amount of rotation). 2.) You are given a list of Ball objects. Each Ball is either Red or Blue. Write a function that partitions these balls so that all of the balls of each color are contiguous. Return the index of the first ball of the second color (your result can be Red balls, then Blue balls, or the other way around). In haskell, you'll probably want to return a ([Ball],Int). 3.) Live Search is a search engine. Suppose it was to be tied into an online store. Now you're given two lists. One is a [(SessionId, NormalizedQuery)]. That is, when a particular user performs a query, it is turned into some consistent format, based on their apparent intent, and stored in this logfile. The second list is a [(SessionId, ProductId)]. This indicates the product bought by a particular user. Now, you want to take these two (potentially very long) lists, and return some structure that will make it easy to take a query and return a list of the most popular resulting purchases. That is, of people who have run this query in the past, what are the most common products they've wound up buying? The interviewer said that this is an instance of a well-known problem, but I didn't catch the name of it. 4.) You're given an array which contains the numbers from 1 to n, in random order, except there is one missing. Write a function to return the missing number. 5.) Write a function to reconstruct a binary tree from its preorder traversal and inorder traversal. Take into account that the traversals could be invalid. 6.) You have a [(WeatherStationId, Latitude, Longitude)]. Similar to #3, write a function which will, off-line, turn this into a data structure from which you can easily determine the nearest Weather Station, given an arbitrary Latitude and Longitude. 7.) Write a function for scoring a mastermind guess. That is, in a game of mastermind (http://en.wikipedia.org/wiki/Mastermind_(board_game)), given a guess, and the actual answer, determine the number correct, the number wrong, and the number out of place. 8.) Implement a trie (http://en.wikipedia.org/wiki/Trie) data structure. Write a function add, which takes a word, and a trie, and adds the word to the trie. Write another function lookup, which takes a prefix and a trie, and returns all the words in the trie that start with that prefix. 9.) Write an algorithm to shuffle a deck of cards. Now write a function to perform some kind of evaluation of "how shuffled" a deck of cards is. Hope you enjoy! From droundy at darcs.net Wed Jun 25 16:35:34 2008 From: droundy at darcs.net (David Roundy) Date: Wed Jun 25 16:27:03 2008 Subject: [Haskell-cafe] history of tuples vs pairs In-Reply-To: <20080625182456.GA12376@minus.seas.upenn.edu> References: <1214416208.8450.22.camel@porcupine> <20080625182456.GA12376@minus.seas.upenn.edu> Message-ID: <20080625203533.GA19738@darcs.net> On Wed, Jun 25, 2008 at 02:24:57PM -0400, Brent Yorgey wrote: > On Wed, Jun 25, 2008 at 07:50:08PM +0200, Niels Aan de Brugh wrote: > > On Wed, 2008-06-25 at 16:50 +0200, Conal Elliott wrote: > > > I have a foggy memory that early ML had only binary pairing, nesting > > > for n-tuples. Can anyone confirm this memory. If so, does anyone > > > remember the rationale for going to n-tuples? Performance, perhaps? > > > > ???What is the difference between a list build up of Cons and a "tuple" > > made out of pairs? I think the latter wouldn't really add anything new. > > The difference is that all the elements of a list must be the same > type, whereas nested tuples could have elements of any type. For > example, > > (True, (6, 'c')) :: (Bool, (Int, Char)) > > and there is no corresponding three-element list. However, you're > right in noting the similarity between lists and nested tuples -- in > fact, this is exactly how lists are implemented in lisp (which is > where we get the tern 'cons'). The other difference is that nested tuples have the number of elements specified in the type, while lists do not. -- David Roundy Department of Physics Oregon State University From lemming at henning-thielemann.de Wed Jun 25 16:49:43 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Wed Jun 25 16:41:12 2008 Subject: [Haskell-cafe] Haskell, Microsoft, and interview questions In-Reply-To: References: Message-ID: On Wed, 25 Jun 2008, Andrew Wagner wrote: > The recruiter even said something along the lines of "anyone who knows > haskell is certainly worth our time to talk to." Moral of the story: > Haskell rocks, and even Microsoft knows it! Interesting. That is they are aware what they support in Cambridge for years? From wagner.andrew at gmail.com Wed Jun 25 16:54:45 2008 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Wed Jun 25 16:46:14 2008 Subject: [Haskell-cafe] Haskell, Microsoft, and interview questions In-Reply-To: References: Message-ID: I would guess that there are a lot of things their research department does that doesn't get used or thought about on a daily basis by the implementation teams. Either way, the sarcasm is not necessary. On Wed, Jun 25, 2008 at 4:49 PM, Henning Thielemann wrote: > > On Wed, 25 Jun 2008, Andrew Wagner wrote: > >> The recruiter even said something along the lines of "anyone who knows >> haskell is certainly worth our time to talk to." Moral of the story: Haskell >> rocks, and even Microsoft knows it! > > Interesting. That is they are aware what they support in Cambridge for > years? > > From byorgey at seas.upenn.edu Wed Jun 25 17:10:31 2008 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Wed Jun 25 17:01:59 2008 Subject: [Haskell-cafe] Haskell Weekly News: Issue 74 - June 25, 2008 Message-ID: <20080625211031.GA31043@minus.seas.upenn.edu> --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20080625 Issue 74 - June 25, 2008 --------------------------------------------------------------------------- Welcome to issue 74 of HWN, a newsletter covering developments in the [1]Haskell community. This week, you'll notice a bit more detail in the 'Blogs' section. I've added summaries to some of the posts, to help you decide which you might be interested to read (only a few this week, since I added them at the last minute). I've also >>> highlighted blogs not syndicated on Planet Haskell---mostly people who have just begun learning Haskell and decided to blog about it. Go show them some comment love, and invite them into the community! Community News Andrew Wagner (chessguy) recently flew out to Microsoft for an interview with their Live Search team. In [2]an email to the cafe, he shares some stories from his experience and some interesting coding challenges. Announcements HAppS self-demoing tutorial. Thomas Hartman [3]announced a self-demoing, HStringTemplate-using intro to HAppS. Check out the [4]live demo or obtain it [5]from Hackage. NWFP Interest Group. Greg Meredith [6]announced the next monthly meeting of the NW Functional Programmers Interest group, 6:30 on June 25 at the Seattle Public Library. Greg will talk about a very cool [7]compositional representation of graphs he's been tinkering with recently. ICFP final call for posters. Matthew Fluet [8]announced the final call for proposals for the ICFP 2008 poster session, which should be [9]submitted by June 30. Let people know what you're working on! type-level and parameterized-data packages. Alfonso Acosta [10]announced the release of the [11]type-level and parameterized-data packages, which provide type-level computation and parameterized types a la a dependently-typed system. Lambda in the sun. James Iry [12]announced the creation of [13]Southern California Functional Programmers (SoCalFP), a group for people in LA, Orange County, and San Diego to meet to discuss, debate, present, and learn about functional programming concepts and techniques in various languages. Real World Haskell. Bryan O'Sullivan [14]announced the availability of ten new draft chapters of [15]Real World Haskell, the upcoming O'Reilly book being written by Bryan, John Goerzen, and Don Stewart. In case you were worried, yes, you'll be able to have one in your Christmas stocking! Pugs on hackage!. Audrey Tang has uploaded to Hackage [16]version 6.2.13.2 of [17]Pugs, an implementation of Perl 6 in Haskell. Literal programming with rst-literals. Martin Blais [18]described a neat use of his utility [19]rst-literals to extract Haskell code from ReST documents, enabling a different style of literate programming. Pipe 1.0. Matti Niemenmaa [20]announced the release of [21]Pipe, a library for piping data through a pipeline of processes. HUnit. Richard Giraud [22]announced that he has improved the HUnit documentation and published the changes in a [23]darcs repository. hback. Norbert Wojtowicz [24]announced a new release of [25]hback, a Haskell implementation of the [26]dual n-back memory game using [27]gtk2hs. Google Summer of Code Progress updates from participants in the 2008 [28]Google Summer of Code. Hoogle 4. Neil Mitchell (ndm) is working on Hoogle 4, and recently [29]added two new features, multi-word search and intelligent suggestions. DPH physics engine. Roman Cheplyaka (Feuerbach) is working on a physics engine using [30]Data Parallel Haskell. [31]This week he intended to implement simple ad-hoc cubic collision geometry to test collisions with rotation, but the code became too cumbersome and non-extensible. He took a break to read some papers, and found [32]a better solution. GHC plugins. Max Bolingbroke is working on dynamically loaded plugins for GHC. [33]This week he worked on adding arbitrary user-specified phases to GHC, implementing a control system, pipeline generation, and [34]Template Haskell integration. Next he plans to work on a plugin annotation system. Cabal dependency framework. Andrea Vezzosi (Saizan) is working on a make-like dependency analysis framework for Cabal. He has posted [35]a detailed explanation of his project, some of the issues involved, and his progress so far. Language.C. Benedikt Huber (visq) is working on Language.C, a standalone parser/pretty printer library for C99. This week he worked on AST documentation and improvements, prepared to port the AST analysis from c2hs, and worked on the pretty printer's internals. Generic tries. Jamie Brandon is working on a library for efficient maps using generalized tries. Recently he has worked on implementing some [36]bitpacking tools to save memory. GHC API. Thomas Schilling (nominolo) is supposedly working on [37]improvements to the GHC API. However, officials at HWN headquarters have begun privately speculating that Thomas does not, in fact, exist. Discussion history of tuples vs pairs. Conal Elliott [38]asked about the history of support for n-tuples in Haskell and ML. hackageDB maintainer policy. Ross Paterson began a lengthy [39]discussion towards agreeing on a policy for uploading packages to Hackage, specifying whether the package is maintained and who is maintaining it, and other related issues. What is a rigid type variable?. Xiao-Yong Jin [40]asked what the 'rigid type variables' are that are sometimes referred to in GHC error messages. Read the thread for a concise discussion and the solution to the original problem. Map interface. Jamie Brandon started a [41]thread asking for feedback on his proposed API for generic tries, and the discussion is still ongoing. Left and right folds. George Kangas [42]exhibited a pair of very elegant alternate definitions for left and right fold, and showed how this alternate viewpoint makes obvious several algebraic identities as well as the generalization to [43]Data.Foldable. A must-read for the aspiring functional programmer. ribbonsPerLine. Alfonso Acosta asked an interesting [44]question about "ribbonsPerLine" in the Text.PrettyPrint.HughesPJ library. Do you know what it does? The answer can be found in the [45]original paper describing the library. Jobs PhD position at University of Strathclyde, Glasgow. Simon Marlow [46]announced, on behalf of Patricia Johann, an open PhD position in operational and categorical approaches to parametricity. The funded position is in the newly-formed Mathematically Structured Programming group at the University of Strathclyde, comprising Neil Ghani, Patricia Johann, and Conor McBride. Quantitative Trading Developer Position at Hutchin Hill Capital. Neil Mehra [47]announced an open position for a Quantitative Trading Developer at Hutchin Hill Capital, a newly formed multi-strategy hedge fund located in midtown Manhattan. Blog noise [48]Haskell news from the [49]blogosphere. * >>> Blockcipher: [50]Converting Geospatial Coordinates. Blockcipher has had enough of reading Haskell tutorials, and is itching to actually create something useful! * Roman Cheplyaka: [51]V-Clip algorithm (status update). An update on Roman's Google Summer of Code project. * Andy Gill: [52]Memo class using type families. * >>> blueapple: [53]Project Euler. blueapple is hooked on [54]Project Euler and has been using it as an opportunity to learn Haskell. * >>> Dinesh Pillay: [55]Haskell & Type Inference. Dinesh has been learning Haskell for just a few days now and is really enjoying it. In this post he shares a problem he was having with types and its solution. * Don Stewart (dons): [56]Daily Haskell: Download and analyse logs, then generate sparklines. A new series on gluing Hackage libraries together to get things done. * Max Bolingbroke: [57]Compiler Plugins For GHC: Week Two. An update on Max's Google Summer of Code project. * Edward Kmett: [58]Paramorphism. * Edward Kmett: [59]Catamorphism. * Edward Kmett: [60]Recursion Schemes: A Field Guide. Edward is writing up a 'field guide' to all those 'foomorphism' recursion schemes. * Neil Mitchell: [61]GSoC Hoogle: Week 4. * Real World Haskell: [62]Ten new draft chapters. * Jamie Brandon: [63]Bitpacking. Updates on Jamie's Google Summer of Code project. * Jamie Brandon: [64]Finally!. * Brent Yorgey: [65]ZipEdit. Brent describes a new library for creating simple interactive list editors. * Real-World Haskell: [66]Video of my concurrent/multicore Haskell talk is up. * Roman Cheplyaka: [67]Status report: week 4. An update on Roman's Google Summer of Code project. * Osfameron: [68]More Countdown: laziness, Scheme, and German frogs. * Andrea Vezzosi (Saizan): [69]a dependency analysis framework for Cabal. * Osfameron: [70]Schwartzian transform in Haskell. * Neil Mitchell: [71]Hoogle 4 New Features. * Thomas M. DuBuisson: [72]Past and Future libraries. * >>> codeflow: [73]Haskell + a grain of Python. codeflow talks about his experience learning Haskell and functional programming. * >>> Peter Christensen: [74]Hey Language Snobs: Don't Pinch Pennies. * >>> Micah Elliott: [75]1983-96: The Golden Age of Programming Languages. Quotes of the Week * povman: when does ghc6.10 plan to release itself? * Baughn: So I just rewrote a fairly complex text extraction/indexing system to pipeline its work across several processors - painlessly, in less than five minutes. Bravo, haskell! * monochrom: We need to cabalise Cale. * Botje: h0t (monoid `mappend` monoid) action? * quicksilver: the only tool we have in haskell98 for performing an action is the magic sigil 'main =' * solrize: haskell has a very steep unlearning curve :) * Botje: drug users pass around needles, haskell users pass around Oleg papers * qwe1234: i know haskell, ocaml, scheme and prolog better than you ever will. About the Haskell Weekly News New editions are posted to [76]the Haskell mailing list as well as to [77]the Haskell Sequence and [78]Planet Haskell. [79]RSS is also available, and headlines appear on [80]haskell.org. Headlines are available as [81]PDF. To help create new editions of this newsletter, please see the information on [82]how to contribute. Send stories to byorgey at seas dot upenn dot edu. The darcs repository is available at darcs get [83]http://code.haskell.org/~byorgey/code/hwn/ . References 1. http://haskell.org/ 2. http://article.gmane.org/gmane.comp.lang.haskell.cafe/41760 3. http://www.haskell.org/pipermail/haskell-cafe/2008-June/044696.html 4. http://rippledeals.com:5001/ 5. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/happs-tutorial 6. http://www.haskell.org/pipermail/haskell-cafe/2008-June/044671.html 7. http://biosimilarity.blogspot.com/2008/06/algebra-of-graphs-individually-and.html 8. http://article.gmane.org/gmane.comp.lang.haskell.general/16263 9. https://www.softconf.com/s08/icfp08-posters/submit.html 10. http://www.haskell.org/pipermail/haskell-cafe/2008-June/044630.html 11. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/type-level 12. http://article.gmane.org/gmane.comp.lang.haskell.general/16260 13. http://socalfp.blogspot.com/ 14. http://www.realworldhaskell.org/blog/2008/06/22/ten-new-draft-chapters/ 15. http://www.realworldhaskell.org/blog/ 16. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Pugs-6.2.13.2 17. http://pugscode.org/ 18. http://article.gmane.org/gmane.comp.lang.haskell.cafe/41621 19. http://furius.ca/pubcode/pub/conf/common/bin/rst-literals.html 20. http://article.gmane.org/gmane.comp.lang.haskell.cafe/41619 21. http://iki.fi/matti.niemenmaa/pipe/ 22. http://article.gmane.org/gmane.comp.lang.haskell.glasgow.user/14661 23. http://richardg.name/ 24. http://article.gmane.org/gmane.comp.lang.haskell.general/16252 25. http://code.google.com/p/hback/ 26. http://www.pnas.org/cgi/content/abstract/0801268105v1 27. http://www.haskell.org/gtk2hs/ 28. http://hackage.haskell.org/trac/summer-of-code/wiki/SoC2008 29. http://neilmitchell.blogspot.com/2008/06/hoogle-4-new-features.html 30. http://www.haskell.org/haskellwiki/GHC/Data_Parallel_Haskell 31. http://physics-dph.blogspot.com/2008/06/status-report-week-4.html 32. http://physics-dph.blogspot.com/2008/06/v-clip-algorithm-status-update.html 33. http://blog.omega-prime.co.uk/2008/06/23/compiler-plugins-for-ghc-week-two/ 34. http://www.haskell.org/haskellwiki/Template_Haskell 35. http://vezzosi.blogspot.com/2008/06/my-summer-of-code-project-dependency.html 36. http://jamiiecb.blogspot.com/2008/06/gsoc-week-1.html 37. http://hackage.haskell.org/trac/ghc/wiki/GhcApiStatus 38. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/41749 39. http://article.gmane.org/gmane.comp.lang.haskell.libraries/9334 40. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/41651 41. http://thread.gmane.org/gmane.comp.lang.haskell.libraries/9259 42. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/41607 43. http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data-Foldable.html 44. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/41506 45. http://www.cs.chalmers.se/~rjmh/Papers/pretty.ps 46. http://article.gmane.org/gmane.comp.lang.haskell.general/16253 47. http://article.gmane.org/gmane.comp.lang.haskell.cafe/41584 48. http://planet.haskell.org/ 49. http://haskell.org/haskellwiki/Blog_articles 50. http://idea-guy.blogspot.com/2008/06/converting-geosptial-coordinates.html 51. http://physics-dph.blogspot.com/2008/06/v-clip-algorithm-status-update.html 52. http://blog.unsafeperformio.com/?p=30 53. http://blueappledev.wordpress.com/2008/06/24/project-euler/ 54. http://projecteuler.net/ 55. http://dpillay.blogspot.com/2008/06/haskell-type-inference.html 56. http://www.cse.unsw.edu.au/~dons/blog/2008/06/24#daily-haskell-one 57. http://blog.omega-prime.co.uk/2008/06/23/compiler-plugins-for-ghc-week-two/ 58. http://comonad.com/reader/2008/paramorphism/ 59. http://comonad.com/reader/2008/catamorphism/ 60. http://comonad.com/reader/2008/recursion-schemes/ 61. http://neilmitchell.blogspot.com/2008/06/gsoc-hoogle-week-4.html 62. http://www.realworldhaskell.org/blog/2008/06/22/ten-new-draft-chapters/ 63. http://jamiiecb.blogspot.com/2008/06/bitpacking.html 64. http://jamiiecb.blogspot.com/2008/06/finally.html 65. http://byorgey.wordpress.com/2008/06/21/zipedit/ 66. http://www.realworldhaskell.org/blog/2008/06/20/video-of-my-concurrentmulticore-haskell-talk-is-up/ 67. http://physics-dph.blogspot.com/2008/06/status-report-week-4.html 68. http://osfameron.vox.com/library/post/more-countdown-laziness-scheme-and-german-frogs.html?_c=feed-atom 69. http://vezzosi.blogspot.com/2008/06/my-summer-of-code-project-dependency.html 70. http://osfameron.vox.com/library/post/schwartzian-transform-in-haskell.html?_c=feed-atom 71. http://neilmitchell.blogspot.com/2008/06/hoogle-4-new-features.html 72. http://tommd.wordpress.com/2008/06/18/past-and-future-libraries/ 73. http://codeflow.wordpress.com/2008/06/18/haskell-a-grain-of-python/ 74. http://www.pchristensen.com/blog/articles/hey-language-snobs-dont-pinch-pennies/ 75. http://micahelliott.blogspot.com/2008/06/1983-96-golden-age-of-programming.html 76. http://www.haskell.org/mailman/listinfo/haskell 77. http://sequence.complete.org/ 78. http://planet.haskell.org/ 79. http://sequence.complete.org/node/feed 80. http://haskell.org/ 81. http://code.haskell.org/~byorgey/code/hwn/archives/20080625.pdf 82. http://haskell.org/haskellwiki/HWN 83. http://code.haskell.org/~byorgey/code/hwn/ From allbery at ece.cmu.edu Wed Jun 25 17:47:10 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Wed Jun 25 17:38:41 2008 Subject: [Haskell-cafe] Haskell, Microsoft, and interview questions In-Reply-To: References: Message-ID: <8E854EDE-43AC-4D3D-959C-6F6EF509DF2C@ece.cmu.edu> On 2008 Jun 25, at 16:49, Henning Thielemann wrote: > > On Wed, 25 Jun 2008, Andrew Wagner wrote: > >> The recruiter even said something along the lines of "anyone who >> knows haskell is certainly worth our time to talk to." Moral of the >> story: Haskell rocks, and even Microsoft knows it! > > Interesting. That is they are aware what they support in Cambridge > for years? The sales office doesn't always pay attention to MSR. -- 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 lennart at augustsson.net Wed Jun 25 20:50:23 2008 From: lennart at augustsson.net (Lennart Augustsson) Date: Wed Jun 25 20:41:50 2008 Subject: [Haskell-cafe] history of tuples vs pairs In-Reply-To: References: Message-ID: Yes, early ML had nested pairs. We introduced n-tuples in Lazy ML because in a lazy language n-tuples are not isomorphic to nested pairs (whereas they are in a strict language). So n-tuples are nasty because they are not inductive, but they are in many ways much more reasonable than lazy nested pairs. BTW, early ML also had binary sums. Again, they are not isomorphic to n-ary sums. -- Lennart 2008/6/25 Conal Elliott : > I have a foggy memory that early ML had only binary pairing, nesting for > n-tuples. Can anyone confirm this memory. If so, does anyone remember the > rationale for going to n-tuples? Performance, perhaps? > > Similarly, did the Haskell designers consider pairs as an alternative to > n-ary tuples? > > The reason I ask is that while ghc and libraries suppors n-tuples for some > values of n, the support is generally incomplete and inconsistent. And some > abstractions are very heavily biased toward pairing, particularly Arrow and > the pair instances of Monad and Applicative. And of course, inclusion of > fst and snd in the prelude but lack of similar standard functions for > n-tuples with n>2. > > - Conal > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From ok at cs.otago.ac.nz Thu Jun 26 00:23:27 2008 From: ok at cs.otago.ac.nz (Richard A. O'Keefe) Date: Thu Jun 26 00:15:02 2008 Subject: [Haskell-cafe] Haskell, Microsoft, and interview questions In-Reply-To: References: Message-ID: On 26 Jun 2008, at 8:14 am, Andrew Wagner wrote: > 6.) You have a [(WeatherStationId, Latitude, Longitude)]. Similar to > #3, write a function which will, off-line, turn this into a data > structure from which you can easily determine the nearest Weather > Station, given an arbitrary Latitude and Longitude. I actually set something not entirely unlike this as a problem in a 4th year OO class. Despite telling them over and over and over again that the Earth is not flat, and despite telling them how to convert (Latitude, Longitude) to 3-dimensional coordinates on the unit sphere, and despite telling them that greatest circle distance between two points on the surface of the Earth is a monotone function of Euclidean distance between points on the unit sphere, so that all they had to do was to glue these pieces together, EVERY SINGLE ONE used Euclidean distance between (Latitude, Longitude) pairs as if they were co-ordinates on a flat 2-d plane. And we even live near the International Date Line, which is where this mistake goes horribly wrong. Did they score you on coding or on geometry? For what it's worth, a 3-dimensional kd tree really flew on this problem. From vigalchin at gmail.com Thu Jun 26 02:00:23 2008 From: vigalchin at gmail.com (Galchin, Vasili) Date: Thu Jun 26 01:51:51 2008 Subject: [Haskell-cafe] looking for advice on "lifting" and FFI Message-ID: <5ae4f2ba0806252300l5d22b275tb1293e3b553cddb6@mail.gmail.com> Hello, I am thinking about "glue"/"binding" code for POSIX listio and aio_suspend. E.g. http://docs.hp.com/en/B9106-90009/lio_listio.2.html 1) It seems to me that this is a "lifting" problem where we lift to a Haskell list of "aiocb's" to a C array of pointers?? An example of the "C array of pointers" is described by http://docs.hp.com/en/B9106-90009/lio_listio.2.html 2) Is it reasonable for the domain of the 1) mapping to be a Haskell list of "aiocb's"?? Kind regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080626/8fa264b4/attachment.htm From rwbarton at math.harvard.edu Thu Jun 26 03:00:27 2008 From: rwbarton at math.harvard.edu (Reid Barton) Date: Thu Jun 26 02:50:40 2008 Subject: [Haskell-cafe] ghc-HEAD: build succeeds, but install fails with linker errors? Message-ID: <20080626070027.GD8867@rwbarton.mit.edu> I'm trying to install GHC from the darcs repository for the first time, so I'm hoping someone here can tell me if I'm doing something wrong before I bother cvs-ghc. I'm currently running ghc 6.8.2 on Debian x86 Linux. Following the instructions on the wiki, I put the following in a file and ran it: #!/bin/bash darcs get --partial http://darcs.haskell.org/ghc cd ghc chmod +x darcs-all ./darcs-all get sh boot ./configure --prefix=$HOME/ghc-HEAD make make install but during the "make install" step I get the error ../../compiler/stage1/ghc-inplace -no-user-package-conf -o ghc-pkg.bin -H32m -O -cpp -Wall -fno-warn-name-shadowing -fno-warn-unused-matches -package Cabal -Rghc-timing -package unix -package containers Main.o Version.o CRT_noglob.o Main.o: In function `s7AP_info': (.text+0x1d): undefined reference to `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_Str_con_info' {- hundreds of similar errors (not all from the pretty package, some from base and others as well) -} collect2: ld returned 1 exit status <> make[2]: *** [ghc-pkg.bin] Error 1 Failed making install in ghc-pkg: 1 make[1]: *** [install] Error 1 make: *** [install] Error 1 Have I got some of the steps wrong? Regards, Reid Barton From eeoam at ukfsn.org Thu Jun 26 06:40:41 2008 From: eeoam at ukfsn.org (Eric) Date: Thu Jun 26 06:32:13 2008 Subject: [Haskell-cafe] Parsing problem Message-ID: <48637229.7000904@ukfsn.org> Hi all, I'm using the Parsec library to parse the following grammar expr = atom+ atom = integer | var | (expr) The input to the parser is a list of (Token, SourcePos). I have the following code for atom: atom = try variable <|> try integerr <|> do{sat(== Reserved "("); (e,pos) <- expression; sat(==Reserved ")"); return (e,pos)} sat p = do (t,pos) <- item if p t then return(t,pos) else pzero When I run the code on the input "(_ineg_ 0)" the parser fails, but removing sat(==Reserved ")") and it succeeds. Can any one see why? E. From isaacdupree at charter.net Thu Jun 26 06:54:05 2008 From: isaacdupree at charter.net (Isaac Dupree) Date: Thu Jun 26 06:45:46 2008 Subject: [Haskell-cafe] history of tuples vs pairs In-Reply-To: References: Message-ID: <4863754D.8000903@charter.net> Lennart Augustsson wrote: > Yes, early ML had nested pairs. We introduced n-tuples in Lazy ML > because in a lazy language n-tuples are not isomorphic to nested pairs > (whereas they are in a strict language). So n-tuples are nasty > because they are not inductive, but they are in many ways much more > reasonable than lazy nested pairs. although it is possible in a slightly different (and less left-right symmetric) way in Haskell: data P a b = P a !b pair: P Int (P Bool ()) triple: P Char (P Int (P Bool ()) single: P Bool () unit: () > BTW, early ML also had binary sums. Again, they are not isomorphic to > n-ary sums. data E a b = L a | R !b data Z --since Haskell Prelude provides us with the unit type () but not the uninhabited "zero" type, I'll use GHC's EmptyDataDecls syntax for this. either: E Int (E Bool Z) 3: E Char (E Int (E Bool Z) 1: E Bool Z 0: Z Still, these don't have isomorphic *representations*: the efficiency is lacking. I wonder if it would be possible to allow {-#UNPACK#-} for those polymorphic arguments in such a way that either/both of the above were actually equivalent to n-tuple/sums. -Isaac From quarantedeux42 at yahoo.fr Thu Jun 26 08:01:49 2008 From: quarantedeux42 at yahoo.fr (Fernand) Date: Thu Jun 26 07:53:18 2008 Subject: [Haskell-cafe] Stupid question about Cabal file Message-ID: <4863852D.60104@yahoo.fr> Hi, Excuse me in advance if this is a trivial question, but I have been unable to find (understand?) the answer in Cabal's documentation. My issue is simple : I build a Cabal package named, let's say, "foo". That package is a library (libHSfoo.a, something like that), which exposes its Foo.Bar and Foobar modules. I wrote the cabal file, register it, everything seems fine. The issue comes when I try to use that package when compiling a main program, like this : ghc -package foo MyMain.hs [other options] I get an error about the compiler not finding the interface files Foobar.hi and Bar.hi, as I have "import Bar" and "import Foo.Bar" in my "MyMain.hs" file. Of course, I could add "-l" flags to point to the ".hi" files that I used to compile my package, but I get the well-known issue about the fact that the package's names of the interface files (which were compiled with the "-package-name foo" option) are not the correct ones ("Bad interface file: ../foo/Foobar.hi, Something is amiss; requested module main:Foobar differs from name found in the interface file foo:Foobar") ; and that solution is ugly anyway. So far, I found some Cabal documentation talking about the import-dirs property, but I did not manage to "make it work", I mean, my package does not seems to "include" the interface files. I am sure, on the other hand, that it is possible :) Sincerely yours, Fernand From gwern0 at gmail.com Thu Jun 26 08:20:43 2008 From: gwern0 at gmail.com (Gwern Branwen) Date: Thu Jun 26 08:12:54 2008 Subject: [Haskell-cafe] ghc-HEAD: build succeeds, but install fails with linker errors? In-Reply-To: <20080626070027.GD8867@rwbarton.mit.edu> References: <20080626070027.GD8867@rwbarton.mit.edu> Message-ID: <20080626122043.GA3598@craft> On 2008.06.26 03:00:27 -0400, Reid Barton scribbled 1.4K characters: > I'm trying to install GHC from the darcs repository for the first > time, so I'm hoping someone here can tell me if I'm doing something > wrong before I bother cvs-ghc. > > I'm currently running ghc 6.8.2 on Debian x86 Linux. Following the > instructions on the wiki, I put the following in a file and ran it: > > #!/bin/bash > darcs get --partial http://darcs.haskell.org/ghc > cd ghc > chmod +x darcs-all > ./darcs-all get > sh boot > ./configure --prefix=$HOME/ghc-HEAD > make > make install > > but during the "make install" step I get the error > > ../../compiler/stage1/ghc-inplace -no-user-package-conf -o ghc-pkg.bin -H32m -O -cpp -Wall -fno-warn-name-shadowing -fno-warn-unused-matches -package Cabal -Rghc-timing -package unix -package containers Main.o Version.o CRT_noglob.o > Main.o: In function `s7AP_info': > (.text+0x1d): undefined reference to `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_Str_con_info' > {- hundreds of similar errors (not all from the pretty package, some from base and others as well) -} > collect2: ld returned 1 exit status > <> > make[2]: *** [ghc-pkg.bin] Error 1 > Failed making install in ghc-pkg: 1 > make[1]: *** [install] Error 1 > make: *** [install] Error 1 > > Have I got some of the steps wrong? > > Regards, > Reid Barton For what it's worth, I've gotten the same exact problem building darcs GHC - innumerable link errors during make install. I haven't figured out what the problem was yet (hadn't gotten around to reporting it yet either). This was on a Hardy Heron Ubuntu/GHC 6.8.2 etc. -- gwern football Pine UXO SASCOM Comirex shelter ARDA/DTO industrial NSES Mace -------------- 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/20080626/e93ea8e0/attachment.bin From daniel.is.fischer at web.de Thu Jun 26 08:41:36 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Jun 26 08:31:03 2008 Subject: [Haskell-cafe] Stupid question about Cabal file In-Reply-To: <4863852D.60104@yahoo.fr> References: <4863852D.60104@yahoo.fr> Message-ID: <200806261441.36077.daniel.is.fischer@web.de> Am Donnerstag, 26. Juni 2008 14:01 schrieb Fernand: > Hi, > > Excuse me in advance if this is a trivial question, but I have been > unable to find (understand?) the answer in Cabal's documentation. > My issue is simple : I build a Cabal package named, let's say, "foo". > That package is a library (libHSfoo.a, something like that), which > exposes its Foo.Bar and Foobar modules. I wrote the cabal file, register > it, everything seems fine. > The issue comes when I try to use that package when compiling a main > program, like this : > > ghc -package foo MyMain.hs [other options] > > I get an error about the compiler not finding the interface files > Foobar.hi and Bar.hi, as I have "import Bar" and "import Foo.Bar" in my > "MyMain.hs" file. Of course, I could add "-l" flags to point to the > ".hi" files that I used to compile my package, but I get the well-known > issue about the fact that the package's names of the interface files > (which were compiled with the "-package-name foo" option) are not the > correct ones ("Bad interface file: ../foo/Foobar.hi, Something is amiss; > requested module main:Foobar differs from name found in the interface > file foo:Foobar") ; and that solution is ugly anyway. > > So far, I found some Cabal documentation talking about the import-dirs > property, but I did not manage to "make it work", I mean, my package > does not seems to "include" the interface files. I am sure, on the other > hand, that it is possible :) > > Sincerely yours, > > Fernand Did you create your package using Cabal, i.e. have a module Setup.(l)hs in the same directory as the .cabal file and then runhaskell Setup.hs configure --prefix=WhereYouWantIt runhaskell Setup.hs build runhaskell Setup.hs haddock (optionally) runhaskell Setup.hs install ? Then you shouldn't even need the -package option to use it, ghc-pkg would know where to find the interface files. Cheers, Daniel From lemming at henning-thielemann.de Thu Jun 26 08:40:18 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Jun 26 08:31:49 2008 Subject: [Haskell-cafe] Access to Oracle database from Haskell In-Reply-To: <79d7c4980806260142m41baeab4m2a13dde21b83cefc@mail.gmail.com> References: <79d7c4980806192210j11796038sc5008d669df926b5@mail.gmail.com> <79d7c4980806200251o6e74e409mbd993a09c835014@mail.gmail.com> <79d7c4980806240755p724777e3i9240067c3c050ccb@mail.gmail.com> <79d7c4980806241435y2d0f2054n714b1c8701c2eea@mail.gmail.com> <125EACD0CAE4D24ABDB4D148C4593DA9049E943F@GBLONXMB02.corp.amvescap.net> <79d7c4980806250307h64bfba7dh95b518967c171384@mail.gmail.com> <79d7c4980806260142m41baeab4m2a13dde21b83cefc@mail.gmail.com> Message-ID: On Thu, 26 Jun 2008, Alistair Bayley wrote: >> Try this version of configOracle in Setup.hs: >> >> configOracle verbose buildtools = do >> if not (sqlplusProgram `isElem` buildtools) >> then return Nothing >> else do >> path <- getEnv "ORACLE_HOME" >> info verbose ("Using Oracle: " ++ path) >> makeConfig path libDir "oci/include" >> where libDir = if isWindows then "bin" else "lib" >> >> >> You'll also need to add this import: >> >> import System.Environment (getEnv) > > Did you get a chance to try this? I'm quite keen to fix the > non-Windows parts of the installation process, if I can. I have replaced configOracle by configOracle verbose buildtools = do if not (sqlplusProgram `isElem` buildtools) then return Nothing else do path <- getEnv "ORACLE_HOME" info verbose ("Using Oracle: " ++ path) let (libDir, includeDir) = if isWindows then ("bin", "oci/include") else ("lib", "/usr/include/oracle/10.2.0.4/client") makeConfig path libDir includeDir This is obviously a hack. We should get the Oracle include path from the user, maybe via another environment variable or a custom Cabal option. Now I can start GHCi with the example program you gave me. However I have to start with -lclntsh, otherwise symbol OCIEnvCreate cannot by found. I thought I do not need this option, because the installed Takusen package contains the library name: $ grep clntsh dist/installed-pkg-config extra-libraries: clntsh clntsh I wonder why it appears twice, because in dist/setup-config it exists only once: extraLibs = ["clntsh"] Nevertheless I can start GHCi with the example program and I can see 'hello world'! Great - many thanks for the hints that led me to that state! Next step is to fetch real data from the database. But now I encounter new problems. If I write a real 'select' statement I get at best: Unexpected null in row 1, column 1. *** Exception: (unknown) and at worst: 50001752 *** glibc detected *** /usr/lib/ghc-6.8.2/ghc-6.8.2: free(): invalid pointer: 0x08d10065 *** ======= Backtrace: ========= /lib/libc.so.6[0xb7dba4b6] /lib/libc.so.6(cfree+0x89)[0xb7dbc179] /usr/lib/oracle/10.2.0.4/client/lib/libclntsh.so(lfvclose+0x1c)[0xb5df9c1e] /usr/lib/oracle/10.2.0.4/client/lib/libclntsh.so(SlfMunmap+0x3f)[0xb5e70c3b] /usr/lib/oracle/10.2.0.4/client/lib/libclntsh.so(ldiutzd+0x37)[0xb5e49e7b] /usr/lib/oracle/10.2.0.4/client/lib/libclntsh.so(kputerm+0x51)[0xb54c96b9] /usr/lib/oracle/10.2.0.4/client/lib/libclntsh.so(OCITerminate+0x1c)[0xb5596888] [0xb6a33801] /usr/lib/ghc-6.8.2/ghc-6.8.2[0x8a600de] ======= Memory map: ======== ... then GHCi quits. > BTW, the location of your header files is still a puzzle. Oracle's docs: > http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14250/ociabdem.htm#i459676 > > state that the header files shoulld be in $ORACLE_HOME/rdbms/public. > But perhaps things are different for the Instant Client. I don't know. I have just installed the RPMs and I expect that others will do so as well. From alistair at abayley.org Thu Jun 26 08:54:06 2008 From: alistair at abayley.org (Alistair Bayley) Date: Thu Jun 26 08:45:34 2008 Subject: [Haskell-cafe] Access to Oracle database from Haskell In-Reply-To: References: <79d7c4980806240755p724777e3i9240067c3c050ccb@mail.gmail.com> <79d7c4980806241435y2d0f2054n714b1c8701c2eea@mail.gmail.com> <125EACD0CAE4D24ABDB4D148C4593DA9049E943F@GBLONXMB02.corp.amvescap.net> <79d7c4980806250307h64bfba7dh95b518967c171384@mail.gmail.com> <79d7c4980806260142m41baeab4m2a13dde21b83cefc@mail.gmail.com> Message-ID: <79d7c4980806260554w3698f3d3p624dde7f16b6b06d@mail.gmail.com> > Now I can start GHCi with the example program you gave me. However I have to > start with -lclntsh, otherwise symbol OCIEnvCreate cannot by found. > I thought I do not need this option, because the installed Takusen package > contains the library name: > > $ grep clntsh dist/installed-pkg-config > extra-libraries: clntsh clntsh > > I wonder why it appears twice, because in dist/setup-config it exists > only once: > extraLibs = ["clntsh"] Yes, puzzling. I don't know why you need to say -lclntsh, because that's the point of all of this Setup shenanigans: to get things set up so that ghci works nicely. That's why we have flags that expose/hide modules in the API: ghci has a custom linker, and this tries to link everything in the library, and of course this fails if you don't have the .ddl/.so installed for a particular backend. ghc uses gnu ld to link, and this does not try to link unused modules, so this works fine with the entire library API compiled. Do you need to say -lclntsh when you use ghc to compile? > Next step is to fetch real data from the database. But now I encounter new > problems. If I write a real 'select' statement I get at best: > > Unexpected null in row 1, column 1. > *** Exception: (unknown) This looks like you are fetching a null value back with an iteratee that does not expect nulls. We use Maybe to specify that a column in the result-set can be null e.g. iter :: Int -> Maybe Int -> Maybe String -> IterAct [(Int, Maybe Int, Maybe String)] The first column must never contain null. If it does then you get the "Unexpected null" exception. > and at worst: > > 50001752 > *** glibc detected *** /usr/lib/ghc-6.8.2/ghc-6.8.2: free(): invalid > pointer: 0x08d10065 *** > ======= Backtrace: ========= If this continues, can you provide a test case for me? Alistair From quarantedeux42 at yahoo.fr Thu Jun 26 08:56:41 2008 From: quarantedeux42 at yahoo.fr (Fernand) Date: Thu Jun 26 08:48:11 2008 Subject: [Haskell-cafe] Stupid question about Cabal file In-Reply-To: <200806261441.36077.daniel.is.fischer@web.de> References: <4863852D.60104@yahoo.fr> <200806261441.36077.daniel.is.fischer@web.de> Message-ID: <48639209.9040300@yahoo.fr> Daniel Fischer ?????: > Did you create your package using Cabal, i.e. have a module Setup.(l)hs in the > same directory as the .cabal file and then > > runhaskell Setup.hs configure --prefix=WhereYouWantIt > runhaskell Setup.hs build > runhaskell Setup.hs haddock (optionally) > runhaskell Setup.hs install > ? > > Then you shouldn't even need the -package option to use it, ghc-pkg would know > where to find the interface files. > > Cheers, > Daniel > No, I did not, because I actually inherited a large Makefile with huge dependencies and twisted built options. If using Setup is the right (and only) way to create the package, I will then try it. thank you, Fernand From daniel.is.fischer at web.de Thu Jun 26 09:12:06 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Jun 26 09:02:05 2008 Subject: [Haskell-cafe] Stupid question about Cabal file In-Reply-To: <48639209.9040300@yahoo.fr> References: <4863852D.60104@yahoo.fr> <200806261441.36077.daniel.is.fischer@web.de> <48639209.9040300@yahoo.fr> Message-ID: <200806261512.06175.daniel.is.fischer@web.de> Am Donnerstag, 26. Juni 2008 14:56 schrieb Fernand: > Daniel Fischer ?????: > > Did you create your package using Cabal, i.e. have a module Setup.(l)hs > > in the same directory as the .cabal file and then > > > > runhaskell Setup.hs configure --prefix=WhereYouWantIt > > runhaskell Setup.hs build > > runhaskell Setup.hs haddock (optionally) > > runhaskell Setup.hs install > > ? > > > > Then you shouldn't even need the -package option to use it, ghc-pkg would > > know where to find the interface files. > > > > Cheers, > > Daniel > > No, I did not, because I actually inherited a large Makefile with huge > dependencies and twisted built options. > If using Setup is the right (and only) way to create the package, I will > then try it. > > thank you, > > Fernand If it's a complicated build, you should certainly take a close look at the Cabal user guide, because then you will probably need more than main = defaultMain in your Setup.hs. On the other hand, the GHC user's guide should also contain some sections on building and registering packages. The Cabal / Setup way is intended to be the simplest and standard way to build packages, but it's not the only one and won't be for a long time. Cheers, Daniel From quarantedeux42 at yahoo.fr Thu Jun 26 09:50:35 2008 From: quarantedeux42 at yahoo.fr (Fernand) Date: Thu Jun 26 09:42:03 2008 Subject: [Haskell-cafe] Stupid question about Cabal file In-Reply-To: <200806261512.06175.daniel.is.fischer@web.de> References: <4863852D.60104@yahoo.fr> <200806261441.36077.daniel.is.fischer@web.de> <48639209.9040300@yahoo.fr> <200806261512.06175.daniel.is.fischer@web.de> Message-ID: <48639EAB.7020401@yahoo.fr> I had a look at the Distribution.Make import, which may be the answer. Thank you for pointing the GHC documentation : I found a way to have the build process work, but after having patched my local package.conf file by hand, and installed manually the interfaces files accordingly. I now just need to understand how to obtain the same result using make, I think. Haskelly yours, Fernand Daniel Fischer ?????: > > > If it's a complicated build, you should certainly take a close look at the > Cabal user guide, because then you will probably need more than > main = defaultMain > in your Setup.hs. On the other hand, the GHC user's guide should also contain > some sections on building and registering packages. > > The Cabal / Setup way is intended to be the simplest and standard way to build > packages, but it's not the only one and won't be for a long time. > > Cheers, > Daniel > > > From daniel.is.fischer at web.de Thu Jun 26 09:54:50 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Jun 26 09:44:17 2008 Subject: [Haskell-cafe] Parsing problem In-Reply-To: <48637229.7000904@ukfsn.org> References: <48637229.7000904@ukfsn.org> Message-ID: <200806261554.50830.daniel.is.fischer@web.de> Am Donnerstag, 26. Juni 2008 12:40 schrieb Eric: > Hi all, > > I'm using the Parsec library to parse the following grammar > > expr = atom+ > atom = integer | var | (expr) > > The input to the parser is a list of (Token, SourcePos). I have the > following code for atom: > > atom > = try variable <|> try integerr <|> > do{sat(== Reserved "("); (e,pos) <- expression; sat(==Reserved > ")"); return (e,pos)} > > sat p = do (t,pos) <- item > if p t then return(t,pos) else pzero > > When I run the code on the input "(_ineg_ 0)" the parser fails, but > removing > > sat(==Reserved ")") > > and it succeeds. Can any one see why? > > E. > What does the tokeniser return? I would have to see more of the code to diagnose it. Cheers, Daniel From lemming at henning-thielemann.de Thu Jun 26 09:59:23 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Jun 26 09:50:50 2008 Subject: [Haskell-cafe] Access to Oracle database from Haskell In-Reply-To: <79d7c4980806260554w3698f3d3p624dde7f16b6b06d@mail.gmail.com> References: <79d7c4980806240755p724777e3i9240067c3c050ccb@mail.gmail.com> <79d7c4980806241435y2d0f2054n714b1c8701c2eea@mail.gmail.com> <125EACD0CAE4D24ABDB4D148C4593DA9049E943F@GBLONXMB02.corp.amvescap.net> <79d7c4980806250307h64bfba7dh95b518967c171384@mail.gmail.com> <79d7c4980806260142m41baeab4m2a13dde21b83cefc@mail.gmail.com> <79d7c4980806260554w3698f3d3p624dde7f16b6b06d@mail.gmail.com> Message-ID: On Thu, 26 Jun 2008, Alistair Bayley wrote: > Yes, puzzling. I don't know why you need to say -lclntsh, because > that's the point of all of this Setup shenanigans: to get things set > up so that ghci works nicely. > > That's why we have flags that expose/hide modules in the API: ghci has > a custom linker, and this tries to link everything in the library, and > of course this fails if you don't have the .ddl/.so installed for a > particular backend. ghc uses gnu ld to link, and this does not try to > link unused modules, so this works fine with the entire library API > compiled. > > Do you need to say -lclntsh when you use ghc to compile? Ah, I see, I must run both GHCi and GHC with -package Takusen and everything is fine. >> Next step is to fetch real data from the database. But now I encounter new >> problems. If I write a real 'select' statement I get at best: >> >> Unexpected null in row 1, column 1. >> *** Exception: (unknown) > > This looks like you are fetching a null value back with an iteratee > that does not expect nulls. We use Maybe to specify that a column in > the result-set can be null e.g. > > iter :: Int -> Maybe Int -> Maybe String -> IterAct [(Int, Maybe Int, Maybe String)] Indeed, using Maybe as type solves that problem. >> and at worst: >> >> 50001752 >> *** glibc detected *** /usr/lib/ghc-6.8.2/ghc-6.8.2: free(): invalid >> pointer: 0x08d10065 *** >> ======= Backtrace: ========= > > If this continues, can you provide a test case for me? I cannot reliably reproduce this. Sometimes it seems that the first run of 'main' succeeds, and the second one crashes in GHCi. So, many thanks for the help! From mailing_list at istitutocolli.org Thu Jun 26 10:11:58 2008 From: mailing_list at istitutocolli.org (Andrea Rossato) Date: Thu Jun 26 10:03:32 2008 Subject: [Haskell-cafe] hxt and pickler combinations Message-ID: <20080626141157.GM27924@laptop.nowhere.net> Hello, I'm using HXT for writing a Citation Style Language (http://xbiblio.sourceforge.net) implementation in Haskell and I'm trying to use the hxt pickler library to parse XML data contained in elements that can be interleaved, that is to say, elements that can appear in any order within other elements. For instance: ciao 2 or 2 ciao are both permitted. I'm not able to write picklers able to parse such kind of data. I indeed noticed that this is not possible with interleaved elements, but it is possible with attributes. To make myself hopefully clearer I included some code below. Suppose we have a data structure like: data Term = T Int String deriving ( Show ) If encoded in XML without respecting the ordering (first the Int and then the String), picklers seem to fail. But if I use attributes to store the values, this doesn't happen. In other word, the xp1 pickler (taken from the example below) will fail with such an xml doc: ciao 2 since it requires the 'int' element to appear before the 'string' element. To test this behaviour, run the code below and see that: - test doc1 xp1 will fail - test doc2 xp1 will succeed while: - test doc3 xp2 will succeed - test doc4 xp2 will succeed What am I getting wrong? It's just a matter of wrong combinator I'm choosing or I'm getting wrong something more fundamental? TIA. Andrea The code: import Text.XML.HXT.Arrow test :: String -> PU Term -> IO () test t xp = do p <- runX ( constA t >>> xread >>> xunpickleVal xp ) putStrLn (show p) data Term = T Int String deriving ( Show ) xp1, xp2 :: PU Term xp1 = xpElem "data" $ xpWrap (uncurry T, \(T i s) -> (i, s)) $ xpPair (xpElem "int" xpickle) (xpElem "string" xpText ) xp2 = xpElem "data" $ xpWrap (uncurry T, \(T i s) -> (i, s)) $ xpPair (xpAttr "int" xpickle) (xpAttr "string" xpText ) doc1, doc2, doc3, doc4 :: String doc1 = "ciao2" doc2 = "2ciao" doc3 = "" doc4 = "" From igloo at earth.li Thu Jun 26 10:26:19 2008 From: igloo at earth.li (Ian Lynagh) Date: Thu Jun 26 10:17:47 2008 Subject: Haskell on ARM (was Re: [Haskell-cafe] ANN: Topkata) In-Reply-To: <871w2mit8o.wl%jeremy@n-heptane.com> References: <87zlpoguqh.fsf@elefant.olsbruecken.local> <4B3E7353-F7F2-4D2D-A335-30D2D3883A4A@gmail.com> <200806170851.22718.valgarv@gmx.net> <87ej6ww9dy.fsf_-_@columbia.edu> <20080617201233.GD19304@scytale.galois.com> <871w2mit8o.wl%jeremy@n-heptane.com> Message-ID: <20080626142619.GA4743@matrix.chaos.earth.li> On Tue, Jun 24, 2008 at 11:27:03AM -0700, Jeremy Shaw wrote: > > The unregisterised build is not that useful because: > > 1. no FFI If libffi supports it then this should now work. > 1. add ARM support to the evil mangler (basically, a few regexps to > strip prolog and epilogue stuff from the ASM) Note that the mangler is on the way out for 6.10: http://www.haskell.org/pipermail/cvs-ghc/2008-June/042979.html > 5. (Optional), implement native assembly generation You'll need to do this instead. Thanks Ian From lemming at henning-thielemann.de Thu Jun 26 11:04:41 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Jun 26 10:56:17 2008 Subject: [Haskell-cafe] Access to Oracle database from Haskell In-Reply-To: <486289DF.70107@complete.org> References: <79d7c4980806192210j11796038sc5008d669df926b5@mail.gmail.com> <79d7c4980806200251o6e74e409mbd993a09c835014@mail.gmail.com> <79d7c4980806240755p724777e3i9240067c3c050ccb@mail.gmail.com> <4862474E.8070801@complete.org> <486289DF.70107@complete.org> Message-ID: On Wed, 25 Jun 2008, John Goerzen wrote: > Henning Thielemann wrote: >> On Wed, 25 Jun 2008, John Goerzen wrote: >> >>> I haven't read this entire thread, but I might also just interject here >>> that HDBC supports ODBC (on Windows, and on Linux/Posix platforms via >>> unixODBC, iODBC, or similar), which may be another avenue for you to >>> try. I'm sure there are ODBC Oracle drivers out there, and so if you >>> have your ODBC layer working, you get Haskell support easily. >> >> This was actually how the thread started: I don't get ODBC for Oracle >> working on Linux. :-( >> Maybe this is an unixODBC issue - is iODBC an API-compatible replacement? > > Yes, iODBC is. Ok, I gave also iODBC a try and installed libiodbc-3.52.6-1.i386.rpm libiodbc-admin-3.52.6-1.i386.rpm libiodbc-devel-3.52.6-1.i386.rpm After a bit of configuration I called: $ iodbctest NMR2 iODBC Demonstration program This program shows an interactive SQL processor Driver Manager: 03.52.0607.1008 1: SQLDriverConnect = [iODBC][Driver Manager]/usr/lib/oracle/10.2.0.4/client/lib/libsqora.so.10.1: undefined symbol: _tcsnccmp (0) SQLSTATE=00000 2: SQLDriverConnect = [iODBC][Driver Manager]Specified driver could not be loaded (0) SQLSTATE=IM003 What is _tcsnccmp and where can I get it from? I hope it is nothing Windows specific. Google suggests that its prototype is: int _tcsnccmp(const _TXCHAR* string1, const _TXCHAR* string2, size_t count); From wagner.andrew at gmail.com Thu Jun 26 11:11:21 2008 From: wagner.andrew at gmail.com (Andrew Wagner) Date: Thu Jun 26 11:02:47 2008 Subject: [Haskell-cafe] Haskell, Microsoft, and interview questions In-Reply-To: References: Message-ID: > Did they score you on coding or on geometry? > It was definitely more on coding and my ability to think about the problem. > For what it's worth, a 3-dimensional kd tree really flew on this problem. > I did some reading up on this, and it seems interesting. It would be need to implement something like this in Haskell, but I can't seem to find any detailed specs on the data-structure. Got any recommendations? From cmb21 at kent.ac.uk Thu Jun 26 11:17:07 2008 From: cmb21 at kent.ac.uk (C.M.Brown) Date: Thu Jun 26 11:08:34 2008 Subject: [Haskell-cafe] Call Graph Tool? Message-ID: Hi, I have approx. 100+ source files and I was wondering if anyone has a tool that would let me see a visual call graph for the source files; i.e. a visual hierarchy of which module is imported by what, and so forth. Kind regards, Chris. From jgoerzen at complete.org Thu Jun 26 11:30:08 2008 From: jgoerzen at complete.org (John Goerzen) Date: Thu Jun 26 11:21:35 2008 Subject: [Haskell-cafe] Access to Oracle database from Haskell In-Reply-To: References: <79d7c4980806192210j11796038sc5008d669df926b5@mail.gmail.com> <79d7c4980806200251o6e74e409mbd993a09c835014@mail.gmail.com> <79d7c4980806240755p724777e3i9240067c3c050ccb@mail.gmail.com> <4862474E.8070801@complete.org> <486289DF.70107@complete.org> Message-ID: <4863B600.6040705@complete.org> Henning Thielemann wrote: > On Wed, 25 Jun 2008, John Goerzen wrote: > > $ iodbctest NMR2 > iODBC Demonstration program > This program shows an interactive SQL processor > Driver Manager: 03.52.0607.1008 > 1: SQLDriverConnect = [iODBC][Driver Manager]/usr/lib/oracle/10.2.0.4/client/lib/libsqora.so.10.1: undefined > symbol: _tcsnccmp (0) SQLSTATE=00000 > 2: SQLDriverConnect = [iODBC][Driver Manager]Specified driver could not be loaded (0) SQLSTATE=IM003 > > > What is _tcsnccmp and where can I get it from? I hope it is nothing > Windows specific. I don't know, but it could be that you are missing some Oracle libraries, or that your Oracle library location isn't on your LD_LIBRARY_PATH or /etc/ld.so.conf path. Since this isn't a Haskell-specific problem, I'd suggest you check it out on the Oracle, unixODBC, or iODBC groups. -- John From igloo at earth.li Thu Jun 26 11:43:01 2008 From: igloo at earth.li (Ian Lynagh) Date: Thu Jun 26 11:34:27 2008 Subject: [Haskell-cafe] ghc-HEAD: build succeeds, but install fails with linker errors? In-Reply-To: <20080626070027.GD8867@rwbarton.mit.edu> References: <20080626070027.GD8867@rwbarton.mit.edu> Message-ID: <20080626154301.GA4762@matrix.chaos.earth.li> On Thu, Jun 26, 2008 at 03:00:27AM -0400, Reid Barton wrote: > > but during the "make install" step I get the error "make install" is probably broken at the moment. You should be able to use it in-place, though (run compiler/stage2/ghc-inplace). Thanks Ian From claus.reinke at talk21.com Thu Jun 26 12:02:02 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Thu Jun 26 11:53:36 2008 Subject: [Haskell-cafe] Call Graph Tool? References: Message-ID: <00d401c8d7a5$fb7ce0a0$351b8351@cr3lt> > I have approx. 100+ source files and I was wondering if anyone has a tool > that would let me see a visual call graph for the source files; i.e. a > visual hierarchy of which module is imported by what, and so forth. Hi Chris, Programatica used to have such a thing for the module graph (tools/base/Pfe0Cmds.hs; "graph"), via dot. But for that many modules, the graph is highly likely to be neither pretty nor useful, I'm afraid.. Claus http://en.wikipedia.org/wiki/DOT_language From eeoam at ukfsn.org Thu Jun 26 12:13:50 2008 From: eeoam at ukfsn.org (Eric) Date: Thu Jun 26 12:05:38 2008 Subject: [Haskell-cafe] Parsing problem In-Reply-To: <200806261554.50830.daniel.is.fischer@web.de> References: <48637229.7000904@ukfsn.org> <200806261554.50830.daniel.is.fischer@web.de> Message-ID: <4863C03E.4050109@ukfsn.org> Daniel Fischer wrote: > Am Donnerstag, 26. Juni 2008 12:40 schrieb Eric: > > What does the tokeniser return? > I would have to see more of the code to diagnose it. > Here is the code for the tokenizer: type Scanner a = GenParser Char () a data Token = INum Integer | FNum Double | Varid String | Reserved String deriving (Show,Eq) scan :: Scanner a -> Scanner(a, SourcePos) scan p = do pos <- getPosition x <- p return(x,pos) scan_integer, scan_varid, hreserved, htoken :: Scanner (Token,SourcePos) scan_integer = do (i,pos) <- scan(integer (makeTokenParser haskellDef)) return (INum i, pos) scan_varid = do (c,pos) <- scan(hlower) cs <- identifier(makeTokenParser haskellDef) return (Varid (c:cs), pos) hlower :: Scanner Char hlower = lower <|> char '_' hreserved = do (cs, pos) <- scan(string "(" <|> string ")") return (Reserved cs,pos) htoken = scan_integer <|> scan_varid <|> hreserved scanall :: String -> [(Token,SourcePos)] scanall cs = let result = parse (many htoken) "" cs in case result of Right tkns -> tkns Left err -> error (show err) E. From eeoam at ukfsn.org Thu Jun 26 12:18:42 2008 From: eeoam at ukfsn.org (Eric) Date: Thu Jun 26 12:10:50 2008 Subject: [Haskell-cafe] Parsing problem In-Reply-To: <4863C03E.4050109@ukfsn.org> References: <48637229.7000904@ukfsn.org> <200806261554.50830.daniel.is.fischer@web.de> <4863C03E.4050109@ukfsn.org> Message-ID: <4863C162.6030404@ukfsn.org> Eric wrote: > Daniel Fischer wrote: >> Am Donnerstag, 26. Juni 2008 12:40 schrieb Eric: >> What does the tokeniser return? >> I would have to see more of the code to diagnose it. Thunderbird mangled my code. I've attached it as a pdf file. E. -------------- next part -------------- A non-text attachment was scrubbed... Name: H0help.pdf Type: application/pdf Size: 36663 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080626/be10c21a/H0help.pdf From mmitar at gmail.com Thu Jun 26 12:34:08 2008 From: mmitar at gmail.com (Mitar) Date: Thu Jun 26 12:25:33 2008 Subject: [Haskell-cafe] Internet Communications Engine and Haskell Message-ID: Hi! Has been any work on implementing Internet Communications Engine in Haskell already done? Any other suggestions how could I use ICE in Haskell? Through FFI calls to its C++ version? http://www.zeroc.com/ice.html Mitar From martindemello at gmail.com Thu Jun 26 13:00:53 2008 From: martindemello at gmail.com (Martin DeMello) Date: Thu Jun 26 12:52:20 2008 Subject: [Haskell-cafe] haskell and dockapps Message-ID: Anyone written a windowmaker dockapp in Haskell? I thought it'd be a fun project, but I don't quite know where to start. martin From mailing_list at istitutocolli.org Thu Jun 26 13:03:23 2008 From: mailing_list at istitutocolli.org (Andrea Rossato) Date: Thu Jun 26 12:55:03 2008 Subject: [Haskell-cafe] hxt and pickler combinations In-Reply-To: <20080626141157.GM27924@laptop.nowhere.net> References: <20080626141157.GM27924@laptop.nowhere.net> Message-ID: <20080626170323.GA10224@laptop.nowhere.net> On Thu, Jun 26, 2008 at 04:11:58PM +0200, Andrea Rossato wrote: > Hello, > > I'm using HXT for writing a Citation Style Language > (http://xbiblio.sourceforge.net) implementation in Haskell and I'm > trying to use the hxt pickler library to parse XML data contained in > elements that can be interleaved, that is to say, elements that can > appear in any order within other elements. > > For instance: > > ciao > 2 > > or > > 2 > ciao > > > are both permitted. > > I'm not able to write picklers able to parse such kind of data. I > indeed noticed that this is not possible with interleaved elements, > but it is possible with attributes. Thanks to a suggestion from Uwe (I contacted the HXT authors too, since I thought it could be a non intended behaviour: instead it is, in order to conform to the standard DTD validation), I came up with this solution. I'm leaving it here too, for the archives. This is a pickler that search the element in the contents and match it without regard to the elements' order: xpElem' :: String -> PU a -> PU a xpElem' name pa = PU { appPickle = ( \ (a, st) -> let st' = appPickle pa (a, emptySt) in addCont (XN.mkElement (mkName name) (attributes st') (contents st')) st ) , appUnPickle = \ st -> fromMaybe (Nothing, st) (unpickleElement st) , theSchema = scElem name (theSchema pa) } where unpickleElement st = do let t = contents st n <- mapM XN.getElemName t case elemIndex name (map qualifiedName n) of Nothing -> fail "element name does not match" Just i -> do let cs = XN.getChildren (t !! i) al <- XN.getAttrl (t !! i) res <- fst . appUnPickle pa $ St {attributes = al, contents = cs} return (Just res, st {contents = take i t ++ drop (i + 1) t}) Andrea From dons at galois.com Thu Jun 26 13:31:09 2008 From: dons at galois.com (Don Stewart) Date: Thu Jun 26 13:22:37 2008 Subject: [Haskell-cafe] haskell and dockapps In-Reply-To: References: Message-ID: <20080626173109.GA24704@scytale.galois.com> martindemello: > Anyone written a windowmaker dockapp in Haskell? I thought it'd be a > fun project, but I don't quite know where to start. > Might be fun to take hsclock, the gtk/cairo based clock, http://haskell.org/gtk2hs/archives/2006/01/26/cairo-eye-candy/ and turn it into a beautiful dock app. -- Don From dons at galois.com Thu Jun 26 13:31:41 2008 From: dons at galois.com (Don Stewart) Date: Thu Jun 26 13:23:09 2008 Subject: [Haskell-cafe] Internet Communications Engine and Haskell In-Reply-To: References: Message-ID: <20080626173141.GB24704@scytale.galois.com> mmitar: > Hi! > > Has been any work on implementing Internet Communications Engine in > Haskell already done? Any other suggestions how could I use ICE in > Haskell? Through FFI calls to its C++ version? > > http://www.zeroc.com/ice.html I think FFI would be the cheapest solution. There's likely a C api somewhere on the internets. From martindemello at gmail.com Thu Jun 26 13:37:26 2008 From: martindemello at gmail.com (Martin DeMello) Date: Thu Jun 26 13:28:52 2008 Subject: [Haskell-cafe] haskell and dockapps In-Reply-To: <20080626173109.GA24704@scytale.galois.com> References: <20080626173109.GA24704@scytale.galois.com> Message-ID: On Thu, Jun 26, 2008 at 10:31 AM, Don Stewart wrote: > martindemello: >> Anyone written a windowmaker dockapp in Haskell? I thought it'd be a >> fun project, but I don't quite know where to start. >> > > Might be fun to take hsclock, the gtk/cairo based clock, > > http://haskell.org/gtk2hs/archives/2006/01/26/cairo-eye-candy/ > > and turn it into a beautiful dock app. Thanks - the code looks very clean and easy to grasp. Would be nicely appropriate too, given my last foray into dockapp writing :) http://www.cs.rice.edu/~ssiyer/code/pclock-bezier/ martin From sebastian.sylvan at gmail.com Thu Jun 26 13:39:07 2008 From: sebastian.sylvan at gmail.com (Sebastian Sylvan) Date: Thu Jun 26 13:30:32 2008 Subject: [Haskell-cafe] Haskell, Microsoft, and interview questions In-Reply-To: References: Message-ID: <3d96ac180806261039y3a1b2bc0jf7d411fe4f380f11@mail.gmail.com> On 6/26/08, Andrew Wagner wrote: > > > Did they score you on coding or on geometry? > > > > > It was definitely more on coding and my ability to think about the problem. > > > > For what it's worth, a 3-dimensional kd tree really flew on this problem. > > > > > I did some reading up on this, and it seems interesting. It would be > need to implement something like this in Haskell, but I can't seem to > find any detailed specs on the data-structure. Got any > recommendations? http://en.wikipedia.org/wiki/Kd_tree -- Sebastian Sylvan +44(0)7857-300802 UIN: 44640862 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080626/84444009/attachment.htm From jeremy at n-heptane.com Thu Jun 26 15:39:44 2008 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Thu Jun 26 15:28:53 2008 Subject: [Haskell-cafe] Re: Haskell on ARM (was Re: ANN: Topkata) In-Reply-To: References: <87zlpoguqh.fsf@elefant.olsbruecken.local> <4B3E7353-F7F2-4D2D-A335-30D2D3883A4A@gmail.com> <200806170851.22718.valgarv@gmx.net> <87ej6ww9dy.fsf_-_@columbia.edu> <20080617201233.GD19304@scytale.galois.com> <871w2mit8o.wl%jeremy@n-heptane.com> Message-ID: <87vdzwgf3z.wl%jeremy@n-heptane.com> At Tue, 24 Jun 2008 20:43:45 -0400, Braden Shepherdson wrote: > I recently acquired the ARM-based Nokia N810 (and <3 it), powered by > Maemo. Running a uname -a on it: > I might be one to attempt this, as I know C and ARM-ish asm decently > well and have a powerful desktop to compile on. I have no familiarity > with GHC internals, though. I think that is a fine set of qualifications. The porting process requires low-level knowledge of C, asm, and the ARM more than GHC internals. It's mostly stuff like #defining what the names of the ARM registers are, and which ones are preserved across C function calls. Also, if you are not starting until at least Sept, waiting for 6.10 might be a good choice, since it sounds like the backend will be changing quite a bit. No point in doing it twice if there is no rush. j. ps. Perhaps we should have some sort of GHC on the ARM hackathon when 6.10 comes out. I think there are quite a few people who have tried or who are interested in trying a port. Having more heads look at it would probably make things go faster. From daniel.is.fischer at web.de Thu Jun 26 16:55:16 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Jun 26 16:44:41 2008 Subject: [Haskell-cafe] Parsing problem In-Reply-To: <48637229.7000904@ukfsn.org> References: <48637229.7000904@ukfsn.org> Message-ID: <200806262255.16404.daniel.is.fischer@web.de> Am Donnerstag, 26. Juni 2008 12:40 schrieb Eric: > Hi all, > > I'm using the Parsec library to parse the following grammar > > expr = atom+ > atom = integer | var | (expr) > > The input to the parser is a list of (Token, SourcePos). I have the > following code for atom: > > atom > = try variable <|> try integerr <|> > do{sat(== Reserved "("); (e,pos) <- expression; sat(==Reserved > ")"); return (e,pos)} > > sat p = do (t,pos) <- item > if p t then return(t,pos) else pzero > > When I run the code on the input "(_ineg_ 0)" the parser fails, but > removing > > sat(==Reserved ")") > > and it succeeds. Can any one see why? > > E. > I can't be absolutely sure without seeing your code for item and expression, possibly also variable and integerr, but I'm rather sure it's a case of a missing 'try'. I'd expect 'expression' using something like many1 atom , then when parsing the tokens of "(_ineg_ 0)", which, ignoring the SourcePos are [Reserved "(", Varid "_ineg_", INum 0, Reserved ")"], as it should be, variable and integerr fail, so the third branch is entered, sat (== Reserved "(") succeeds, the Varid and INum are parsed and finally only [Reserved ")"] is left over, on which atom is tried again. variable and integerr again fail gracefully, so sat (== Reserved "(") is tried on it, which fails, but unfortunately not gracefully, because item returns (Consumed _) and thus the overall failure consumes. Because of that, many1 atom fails and the overall parse fails. Can't be exactly that, though because then removing sat (== Reserved ")") shouldn't help. Anyway, I need at least the failure message, better the complete code, to diagnose. Cheers, Daniel From eeoam at ukfsn.org Thu Jun 26 17:22:13 2008 From: eeoam at ukfsn.org (Eric) Date: Thu Jun 26 17:14:27 2008 Subject: [Haskell-cafe] Parsing problem In-Reply-To: <200806262255.16404.daniel.is.fischer@web.de> References: <48637229.7000904@ukfsn.org> <200806262255.16404.daniel.is.fischer@web.de> Message-ID: <48640885.7060408@ukfsn.org> Daniel Fischer wrote: > > Can't be exactly that, though because then removing sat (== Reserved ")") > shouldn't help. > Anyway, I need at least the failure message, better the complete code, to > diagnose. > I've attached the complete code. E. -------------- next part -------------- A non-text attachment was scrubbed... Name: h0a.pdf Type: application/pdf Size: 99442 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080626/57717f52/h0a-0001.pdf From daniel.is.fischer at web.de Thu Jun 26 18:16:23 2008 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Jun 26 18:05:47 2008 Subject: [Haskell-cafe] Parsing problem In-Reply-To: <48640885.7060408@ukfsn.org> References: <48637229.7000904@ukfsn.org> <200806262255.16404.daniel.is.fischer@web.de> <48640885.7060408@ukfsn.org> Message-ID: <200806270016.23429.daniel.is.fischer@web.de> Am Donnerstag, 26. Juni 2008 23:22 schrieb Eric: > Daniel Fischer wrote: > > Can't be exactly that, though because then removing sat (== Reserved ")") > > shouldn't help. > > Anyway, I need at least the failure message, better the complete code, to > > diagnose. > > I've attached the complete code. > > E. Thanks, though a plaintext file would've been better. It's pretty much what I came up with myself, the odd thing is that I can't reproduce your behaviour, whether sat (== Reserved ")") is present or not doesn't make a difference. Which version of GHC and parsec are you using? (I tried with 6.8.3 & parsec-2.1.0.1, 6.8.2 & parsec-2.1.0.0 and 6.6.1 & parsec-2.0, all give the same results, *Eric2> parseall . scanall $ "(_ineg_ 0)" *** Exception: (line 1, column 1):unknown parse error with or without the second sat). However, the problem is indeed that upon failure (sat p) returns a Consumed value (and removes the token from the input), make it sat p = try $ do (t,pos) <- item if p t then return (t,pos) else pzero and you're all set (you don't need the try's in atom, then). Cheers, Daniel From ok at cs.otago.ac.nz Thu Jun 26 18:34:03 2008 From: ok at cs.otago.ac.nz (Richard A. O'Keefe) Date: Thu Jun 26 18:25:32 2008 Subject: [Haskell-cafe] Haskell, Microsoft, and interview questions In-Reply-To: References: Message-ID: <4E37FB1A-7721-45D2-B5F8-692777F76263@cs.otago.ac.nz> On 27 Jun 2008, at 3:11 am, Andrew Wagner wrote: For what it's worth, a 3-dimensional kd tree really flew on this problem. >> > I did some reading up on this, and it seems interesting. It would be > need to implement something like this in Haskell, but I can't seem to > find any detailed specs on the data-structure. Got any > recommendations? http://en.wikipedia.org/wiki/K-d_tree is perhaps the obvious place to start. There's a link there to Jon L. Bentley's original (1975) paper, which is really very clear. The key to getting an efficient version in C was to specialise the code to the particular k that I wanted (k=3). Of course there are much newer data structures that can do all sorts of things, but for simply finding the closest point in 1, 2, 3, or 4-dimensional space k-d trees are darned good. There isn't much that works well for high dimensions. Last year I marked a 4th year project that studied/evaluated a comparatively recent data structure that was said to be good for high dimensions. I had difficulty understanding it, because I couldn't see where the recursive step was. The answer was that there wasn't one: the algorithm worked better for high dimensions than other trees because it turned into a simple linear search after one partitioning step. In effect, it was too dumb to keep tripping over its own feet. So _really_ don't expect k-d trees to work well for large k. > From agl at imperialviolet.org Thu Jun 26 19:36:53 2008 From: agl at imperialviolet.org (Adam Langley) Date: Thu Jun 26 19:28:23 2008 Subject: [Haskell-cafe] Haskell, Microsoft, and interview questions In-Reply-To: References: Message-ID: <396556a20806261636o1bda9d39g9c6e767a3287159c@mail.gmail.com> On Thu, Jun 26, 2008 at 8:11 AM, Andrew Wagner wrote: > I did some reading up on this, and it seems interesting. It would be > need to implement something like this in Haskell, but I can't seem to > find any detailed specs on the data-structure. Got any > recommendations? Specialised for 2d only, but: http://www.imperialviolet.org/binary/NearestNeighbour2D.hs AGL -- Adam Langley agl@imperialviolet.org http://www.imperialviolet.org From nornagon at gmail.com Thu Jun 26 19:57:29 2008 From: nornagon at gmail.com (Jeremy Apthorp) Date: Thu Jun 26 19:48:54 2008 Subject: [Haskell-cafe] Re: Haskell on ARM (was Re: ANN: Topkata) In-Reply-To: <14d615330806241903s30734fe4q5c7af4569e9b421@mail.gmail.com> References: <87zlpoguqh.fsf@elefant.olsbruecken.local> <4B3E7353-F7F2-4D2D-A335-30D2D3883A4A@gmail.com> <200806170851.22718.valgarv@gmx.net> <87ej6ww9dy.fsf_-_@columbia.edu> <20080617201233.GD19304@scytale.galois.com> <871w2mit8o.wl%jeremy@n-heptane.com> <14d615330806241903s30734fe4q5c7af4569e9b421@mail.gmail.com> Message-ID: <14d615330806261657h3ce55bebx74f8e89205a9854@mail.gmail.com> 2008/6/25 Braden Shepherdson : > Jeremy Shaw wrote: >> >> If any does attempt to build for the ARM, please, please, please, >> document what you do in the wiki. And, if you do, edit the wiki as you >> go, you definitely won't be able to remember what you did after the >> fact. (Or, at the very least, use some program to capture everything >> you do so that you can refer to it later). >> >> And, finally, I heard vague rumors a while ago that made me think that >> GHC 6.10 might have a pure ANSI-C backend? Is there any truth to this? >> That would make porting much easier if it meant you did not have to do >> steps 1-4. >> >> j. >> ps. I would be happy to try to answer any questions if someone tries a >> port. I would still like to run GHC on my 770, and I hope to own an >> iPhone if they fix a few ommisions (bluetooth keyboard support, and >> similar stuff). >> > > > I recently acquired the ARM-based Nokia N810 (and <3 it), powered by Maemo. > Running a uname -a on it: > > Linux Nokia-N810-42-19 2.6.21-omap1 #2 Fri Nov 16 16:24:58 EET 2007 armv6l > unknown > > I would love a working GHC implementation on it, if for nothing else than > how awesome it would be. Whether that means using a C back-end or native > compilation doesn't matter to me so much. > > I might be one to attempt this, as I know C and ARM-ish asm decently well > and have a powerful desktop to compile on. I have no familiarity > with GHC internals, though. Lastly, I won't have anything like the time to > attempt this seriously until mid-September or so. Oops, forgot to Cc the list. Next year I'll be working on a project for my undergraduate computing course at UNSW that will involve getting GHC to target the Nintendo DS. It'll require cross-compilation, because the DS isn't powerful enough to actually run GHC (4M main ram and a 66MHz processor). It'll also require that I significantly strip down the runtime system, as the current RTS won't fit in 4M and leave any left over for the main application. I'll be documenting the whole process, but I won't be starting until next year... Jeremy From Ivan.Miljenovic at gmail.com Thu Jun 26 23:13:18 2008 From: Ivan.Miljenovic at gmail.com (Ivan Miljenovic) Date: Thu Jun 26 23:11:28 2008 Subject: [Haskell-cafe] Re: Call Graph Tool? References: Message-ID: C.M.Brown kent.ac.uk> writes: > I have approx. 100+ source files and I was wondering if anyone has a tool > that would let me see a visual call graph for the source files; i.e. a > visual hierarchy of which module is imported by what, and so forth. For my maths honours thesis, I'll be writing a tool to help people understand the relationships in their Haskell code. I'm hoping to have a visualisation component in there, but that's a relatively low priority. Assuming I get it included, is there any features in particular you'd want to see in there? Note that if I do have it produce visualisations, they'll be static images as part of an analysis report rather than being interactive. From ok at cs.otago.ac.nz Fri Jun 27 00:33:35 2008 From: ok at cs.otago.ac.nz (Richard A. O'Keefe) Date: Fri Jun 27 00:25:07 2008 Subject: [Haskell-cafe] Haskell, Microsoft, and interview questions In-Reply-To: <396556a20806261636o1bda9d39g9c6e767a3287159c@mail.gmail.com> References: <396556a20806261636o1bda9d39g9c6e767a3287159c@mail.gmail.com> Message-ID: On 27 Jun 2008, at 11:36 am, Adam Langley wrote: > Specialised for 2d only, but: > > http://www.imperialviolet.org/binary/NearestNeighbour2D.hs In my C code for this, specialised to 3D, - dimension numbers were never stored - no arrays were used - the "search in x" function called the "search in y" function, which called the "search in z" function, which called the "search in x" function Here's the relevant part of my kd3.h: typedef struct KD3_Node *kd3ptr; struct KD3_Node { double x, y, z; kd3ptr left, right; bool present; << payload data goes here >> }; From nornagon at gmail.com Fri Jun 27 01:18:45 2008 From: nornagon at gmail.com (Jeremy Apthorp) Date: Fri Jun 27 01:10:09 2008 Subject: [Haskell-cafe] Re: Call Graph Tool? In-Reply-To: References: Message-ID: <14d615330806262218o501df15k61845b6c705d5114@mail.gmail.com> 2008/6/27 Ivan Miljenovic : > C.M.Brown kent.ac.uk> writes: >> I have approx. 100+ source files and I was wondering if anyone has a tool >> that would let me see a visual call graph for the source files; i.e. a >> visual hierarchy of which module is imported by what, and so forth. > > For my maths honours thesis, I'll be writing a tool to help people understand > the relationships in their Haskell code. I'm hoping to have a visualisation > component in there, but that's a relatively low priority. > > Assuming I get it included, is there any features in particular you'd want to > see in there? Note that if I do have it produce visualisations, they'll be > static images as part of an analysis report rather than being interactive. Just today I wished for something similar for this MATLAB code I'm maintaining... would be good to have a pluggable syntax definition so that it could be easily adapted for use with other languages. Jeremy From ivan.miljenovic at gmail.com Fri Jun 27 01:57:46 2008 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Fri Jun 27 01:49:17 2008 Subject: [Haskell-cafe] Re: Call Graph Tool? In-Reply-To: <14d615330806262218o501df15k61845b6c705d5114@mail.gmail.com> References: <14d615330806262218o501df15k61845b6c705d5114@mail.gmail.com> Message-ID: <20080627155746.4065a8c8@gmail.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Fri, 27 Jun 2008 15:18:45 +1000 "Jeremy Apthorp" wrote: > 2008/6/27 Ivan Miljenovic : > > C.M.Brown kent.ac.uk> writes: > >> I have approx. 100+ source files and I was wondering if anyone has a tool > >> that would let me see a visual call graph for the source files; i.e. a > >> visual hierarchy of which module is imported by what, and so forth. > > > > For my maths honours thesis, I'll be writing a tool to help people > > understand the relationships in their Haskell code. I'm hoping to have a > > visualisation component in there, but that's a relatively low priority. > > > > Assuming I get it included, is there any features in particular you'd want > > to see in there? Note that if I do have it produce visualisations, they'll > > be static images as part of an analysis report rather than being > > interactive. > > Just today I wished for something similar for this MATLAB code I'm > maintaining... would be good to have a pluggable syntax definition so > that it could be easily adapted for use with other languages. Technically, what I'm doing is a graph-theoretic analysis framework, with a sample application in which Haskell code is parsed and analysed. Once I get it done, it should be pretty simple to port over to other languages but you'd need to write a parser first (I plan on using Haskell-src and Haskell-src-exts). > > Jeremy - -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAkhkgVwACgkQfEfFJ9JhvyiKwwCfaz8WjluQ2rUwD57pmqP15bOn KsUAn3uqbOyGMrEq6nFr71yTyy/mdB7y =+xX9 -----END PGP SIGNATURE----- From qdunkan at gmail.com Fri Jun 27 03:18:18 2008 From: qdunkan at gmail.com (Evan Laforge) Date: Fri Jun 27 03:09:45 2008 Subject: [Haskell-cafe] Re: Call Graph Tool? In-Reply-To: References: Message-ID: <2518b95d0806270018u3aecb381h6f44a196720376e7@mail.gmail.com> > Assuming I get it included, is there any features in particular you'd want to > see in there? Note that if I do have it produce visualisations, they'll be > static images as part of an analysis report rather than being interactive. I was just recently wondering about something like this. I'd like the ability to show individual module dependencies, and then to collapse modules in one package to just the package, so I could "zoom out" and see how the packages relate to each other. By "package" here I mean the "A" in "A.B, A.C, etc." It seems like it would be fairly simple to use Language.Haskell.Parse to turn a set of modules into a graph, and then something to massage that and give it to dot. It actually brings up a question about module discipline in general: At one point I wanted to have each package re-export its public modules and then sibling packages can only export the "package" module as some libraries do, but it got to be too much re-exporting bookkeeppiing and I didn't so much like symbols having multiple "homes", and most of all it was increasingly awkward to split packages into strictly higher level and strictly lower level relationships since this discipline means coarser granularity which means more trouble avoiding circular imports. So now I just import modules directly from their packages. I still have a general structure of higher, lower, and sibling packages though, so some kind of visualization would be handy to keep deps under control, look for packages and modules that could be split up for a clearer hierarchy, find good places to cut circular imports, etc. I've also thought I could move private modules in A to A.Private, so you can see that if you're importing X.Private.Y from a module that doesn't start with X. then something fishy is going on. How do other people approach this issue? From silva.samuel at gmail.com Fri Jun 27 04:55:38 2008 From: silva.samuel at gmail.com (Samuel Silva) Date: Fri Jun 27 04:47:01 2008 Subject: [Haskell-cafe] Fwd: Stack Overflow with HaXml In-Reply-To: <382ead9b0806270153p3870e9dej83acd89f006e8dde@mail.gmail.com> References: <382ead9b0806270153p3870e9dej83acd89f006e8dde@mail.gmail.com> Message-ID: <382ead9b0806270155pf83c847qb3cad481252e841d@mail.gmail.com> Hello I presents a small case studie, when I was using HaXml with DtdToHaskell. I write small DTD: > > I run DtdToHaskell small.DTD > Extsubext.hs and test it with small XML > Result it is presented below: >$ ghci Extsubset.hs >GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help >Loading package base ... linking ... done. >[1 of 1] Compiling Extsubset ( Extsubset.hs, interpreted ) >Ok, modules loaded: Extsubset. >*Extsubset> fReadXml "sample.xml" :: IO Top >Loading package array-0.1.0.0 ... linking ... done. >Loading package bytestring-0.9.0.1 ... linking ... done. >Loading package pretty-1.0.0.0 ... linking ... done. >Loading package old-locale-1.0.0.0 ... linking ... done. >Loading package old-time-1.0.0.0 ... linking ... done. >Loading package filepath-1.1.0.0 ... linking ... done. >Loading package directory-1.0.0.0 ... linking ... done. >Loading package random-1.0.0.0 ... linking ... done. >Loading package process-1.0.0.0 ... linking ... done. >Loading package haskell98 ... linking ... done. >Loading package polyparse-1.1 ... linking ... done. >Loading package containers-0.1.0.1 ... linking ... done. >Loading package HaXml-1.19.4 ... linking ... done. >*** Exception: stack overflow >*Extsubset> HaXml is able handle XML mixed elements? -- Don't hug that, Hugs ME! Samuel Silva From d.kahlenberg at googlemail.com Fri Jun 27 06:34:16 2008 From: d.kahlenberg at googlemail.com (Daniel Kahlenberg) Date: Fri Jun 27 06:25:39 2008 Subject: [Haskell-cafe] System.Console.Readline stifleHistory Question In-Reply-To: <5d4de89e0806260531j5286947au8b1f839603897444@mail.gmail.com> References: <5d4de89e0806260531j5286947au8b1f839603897444@mail.gmail.com> Message-ID: <5d4de89e0806270334m6cbbcc5u13e55dda6fd693f2@mail.gmail.com> Hello all, I'm learning Haskell and so very likely will have advantages from the history persistence feature added to the ghci haskell interpreter. It drives very well in my setup (the history file is growing and used), but I wanted to increase the number of saved history entries and now my question concerning ghci: In the ticket (http://hackage.haskell.org/trac/ghc/ticket/2050) associated with the feature, there's written that one can call stifleHistory in its dotghci file. Have done it like: :m +System.Console.Readline stifleHistory 300 :m -System.Console.Readline but now my ghci.exe says: Could not find module `System.Console.Readline': Use -v to see a list of the files searched for. :1:0: Not in scope: `stifleHistory' `uname -r`: MINGW32_NT-5.1 CLE10 1.0.11(0.46/3/2) 2007-01-12 12:05 i686 Msys Do you have an idea, where I'm wrong? I'm starting my ghci session from zsh shell, provided by cygwin, wrapped in a tty emulator: $Drive\puttycyg\putty.exe -cygterm $Drive\zsh\bin\zsh.exe -p -c 'PATH=/cygdrive/h/zsh/bin:$PATH HOME=/cygdrive/h/.homedir rlwrap $(which ghcii.sh) -package-conf $Drive/.homedir/ghc/i386-mingw32-6.8.3/package.conf -read-dot-ghci' So I did not expect Readline not to work, but maybe the ghc system only sees the result from `uname -r` above?? Bye, Daniel. From claus.reinke at talk21.com Fri Jun 27 06:39:45 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Fri Jun 27 06:31:29 2008 Subject: [Haskell-cafe] Re: Call Graph Tool? References: <2518b95d0806270018u3aecb381h6f44a196720376e7@mail.gmail.com> Message-ID: <006e01c8d842$271b97a0$4d268351@cr3lt> >> Assuming I get it included, is there any features in particular you'd want to >> see in there? Note that if I do have it produce visualisations, they'll be >> static images as part of an analysis report rather than being interactive. > > I'd like the ability to show individual module dependencies, and then > to collapse modules in one package to just the package, so I could > "zoom out" and see how the packages relate to each other. By > "package" here I mean the "A" in "A.B, A.C, etc." > > It seems like it would be fairly simple to use Language.Haskell.Parse > to turn a set of modules into a graph, and then something to massage > that and give it to dot. If you wanted to go down that route, try using 'ghc --make -v2' and translate that dependency graph to dot. It isn't difficult to produce visualizations (though gathering the data might be - proper dependency analysis in Haskell projects has rated a GSoC project this year, for Cabal). It is difficult to produce *useful* visualizations that *scale* to realistic projects. To begin with, it helps to see the visualization as *input* for software development decisions, not as pretty output for some data traversal. However, the problem is far from new, and it is perhaps not unreasonable to assume that most papers in the area are going to reference this one (so you could start with a reverse reference search, then try to separate the gimmicks from the potentially useful approaches..): Thomas A. Ball and Stephen G. Eick. Software visualization in the large. IEEE Computer, 29(4):33--43, April 1996. http://citeseer.ist.psu.edu/78256.html As far as I can tell, a variety of visualizations is needed in practice, integrated in a single tool suite, with good interactivity/navigation/view switching, so that one can choose the most suitable view and focus/slice for each question one might have about a software project (and change track as new questions arise interactively). It would be great to have such a visualization suite for Haskell projects.. There was Chris Ryder's Medina project (unreleased, web site seems to have disappeared?), which focussed on a metrics library, with some example metrics and visualizations: http://web.archive.org/web/20041229065821/www.cs.kent.ac.uk/people/rpg/cr24/medina/examples.shtml http://www.cs.kent.ac.uk/pubs/2004/2236/index.html http://www.haskell.org/communities/11-2002/html/report.html#sect4.5.1 Hth, Claus From d.kahlenberg at googlemail.com Fri Jun 27 06:53:21 2008 From: d.kahlenberg at googlemail.com (Daniel Kahlenberg) Date: Fri Jun 27 06:44:46 2008 Subject: [Haskell-cafe] Re: System.Console.Readline stifleHistory Question In-Reply-To: <5d4de89e0806270334m6cbbcc5u13e55dda6fd693f2@mail.gmail.com> References: <5d4de89e0806260531j5286947au8b1f839603897444@mail.gmail.com> <5d4de89e0806270334m6cbbcc5u13e55dda6fd693f2@mail.gmail.com> Message-ID: <5d4de89e0806270353p8aa663fj4c2a806207609c18@mail.gmail.com> OK, I detected it was my own fail: I was misleaded by the creation of the persistence file, which doesn't result from Readline.hs but simply from the rlwrap utility I earlier piped in before the ghci call. For those interested, the answer to the original question as usual from the man page: option --histsize N for rlwrap does the job. Maybe for a later discussion of using readline or some compatibility library instead of the rlwrap tool on ms windows systems I will post an extra message with a link. Bye. ---------- Forwarded message ---------- From: Daniel Kahlenberg Date: 2008/6/27 Subject: System.Console.Readline stifleHistory Question To: haskell-cafe@haskell.org Hello all, I'm learning Haskell and so very likely will have advantages from the history persistence feature added to the ghci haskell interpreter. It drives very well in my setup (the history file is growing and used), but I wanted to increase the number of saved history entries and now my question concerning ghci: In the ticket (http://hackage.haskell.org/trac/ghc/ticket/2050) associated with the feature, there's written that one can call stifleHistory in its dotghci file. Have done it like: :m +System.Console.Readline stifleHistory 300 :m -System.Console.Readline but now my ghci.exe says: Could not find module `System.Console.Readline': Use -v to see a list of the files searched for. :1:0: Not in scope: `stifleHistory' `uname -r`: MINGW32_NT-5.1 CLE10 1.0.11(0.46/3/2) 2007-01-12 12:05 i686 Msys Do you have an idea, where I'm wrong? I'm starting my ghci session from zsh shell, provided by cygwin, wrapped in a tty emulator: $Drive\puttycyg\putty.exe -cygterm $Drive\zsh\bin\zsh.exe -p -c 'PATH=/cygdrive/h/zsh/bin:$PATH HOME=/cygdrive/h/.homedir rlwrap $(which ghcii.sh) -package-conf $Drive/.homedir/ghc/i386-mingw32-6.8.3/package.conf -read-dot-ghci' So I did not expect Readline not to work, but maybe the ghc system only sees the result from `uname -r` above?? Bye, Daniel. From jno at di.uminho.pt Fri Jun 27 07:04:52 2008 From: jno at di.uminho.pt (J.N. Oliveira) Date: Fri Jun 27 06:56:20 2008 Subject: [Haskell-cafe] Call Graph Tool? In-Reply-To: References: Message-ID: On Jun 26, 2008, at 4:17 PM, C.M.Brown wrote: > Hi, > > I have approx. 100+ source files and I was wondering if anyone has > a tool > that would let me see a visual call graph for the source files; i.e. a > visual hierarchy of which module is imported by what, and so forth. > > Kind regards, > Chris. I suggest that you have a look at HaSlicer, a (visual) Haskell slicing tool available online from http://labdotnet.di.uminho.pt/ HaSlicer/HaSlicer.aspx , developed by Nuno Rodrigues (nfr@di.uminho.pt). Best regards jno -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3109 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080627/e7b16ecf/smime.bin From dougal at dougalstanton.net Fri Jun 27 07:49:35 2008 From: dougal at dougalstanton.net (Dougal Stanton) Date: Fri Jun 27 07:41:00 2008 Subject: [Haskell-cafe] Re: Call Graph Tool? In-Reply-To: <006e01c8d842$271b97a0$4d268351@cr3lt> References: <2518b95d0806270018u3aecb381h6f44a196720376e7@mail.gmail.com> <006e01c8d842$271b97a0$4d268351@cr3lt> Message-ID: <2d3641330806270449y7c6de172r27ae70e2b74980fc@mail.gmail.com> On Fri, Jun 27, 2008 at 11:39 AM, Claus Reinke wrote: > If you wanted to go down that route, try using 'ghc --make -v2' > and translate that dependency graph to dot. Also, if you want to get a quick 'n dirty list of which of your own files depend on which others, "ghc -M $main.hs" works quite well. I've had some success in the past shoving this stuff almost directly into the graph libraries and out to graphviz. Be warned that it fiddles with any file called Makefile in your working directory... Cheers, D -- Dougal Stanton dougal@dougalstanton.net // http://www.dougalstanton.net From Malcolm.Wallace at cs.york.ac.uk Fri Jun 27 08:32:49 2008 From: Malcolm.Wallace at cs.york.ac.uk (Malcolm Wallace) Date: Fri Jun 27 08:26:53 2008 Subject: [Haskell-cafe] Re: Call Graph Tool? In-Reply-To: <2d3641330806270449y7c6de172r27ae70e2b74980fc@mail.gmail.com> References: <2518b95d0806270018u3aecb381h6f44a196720376e7@mail.gmail.com> <006e01c8d842$271b97a0$4d268351@cr3lt> <2d3641330806270449y7c6de172r27ae70e2b74980fc@mail.gmail.com> Message-ID: <20080627133249.764a62c3.Malcolm.Wallace@cs.york.ac.uk> > > try using 'ghc --make -v2' and translate that dependency graph to dot. > > "ghc -M $main.hs" works quite well hmake -M Main.hs gives much the same output as ghc -M, but without side-effecting your Makefile. Even better, hmake -g Main.hs gives the pure module graph dependencies without the .hs/.o clutter. Caveat: You may need some extra commandline flags like -package base, since hmake does not add those automatically. Regards, Malcolm From josef.svenningsson at gmail.com Fri Jun 27 08:37:08 2008 From: josef.svenningsson at gmail.com (Josef Svenningsson) Date: Fri Jun 27 08:28:31 2008 Subject: [Haskell-cafe] Re: Call Graph Tool? In-Reply-To: <006e01c8d842$271b97a0$4d268351@cr3lt> References: <2518b95d0806270018u3aecb381h6f44a196720376e7@mail.gmail.com> <006e01c8d842$271b97a0$4d268351@cr3lt> Message-ID: <8dde104f0806270537q19188e96p49975d24b7075410@mail.gmail.com> On Fri, Jun 27, 2008 at 12:39 PM, Claus Reinke wrote: >>> Assuming I get it included, is there any features in particular you'd >>> want to >>> see in there? Note that if I do have it produce visualisations, they'll >>> be >>> static images as part of an analysis report rather than being >>> interactive. >> >> I'd like the ability to show individual module dependencies, and then >> to collapse modules in one package to just the package, so I could >> "zoom out" and see how the packages relate to each other. By >> "package" here I mean the "A" in "A.B, A.C, etc." >> >> It seems like it would be fairly simple to use Language.Haskell.Parse >> to turn a set of modules into a graph, and then something to massage >> that and give it to dot. > > If you wanted to go down that route, try using 'ghc --make -v2' > and translate that dependency graph to dot. > Yep, this is a pretty easy route and there is already a tool for doing the translation: ocamldot. Don't be fooled by the name, it works on Makefile's dependency information and in particular works well with the output from ghc. Back in the days (like six years ago) I used it on ghc itself. I also extended it so that different directories were grouped together inside a box to get a better feel for the intended structure of the program. ocamldot can be found here: http://www.research.att.com/~trevor/ocamldot/ I should add that I didn't find the information the least bit helpful so my general recommendation is to try to find some other method to help understanding code. All the best, Josef From claus.reinke at talk21.com Fri Jun 27 08:53:44 2008 From: claus.reinke at talk21.com (Claus Reinke) Date: Fri Jun 27 08:45:22 2008 Subject: [Haskell-cafe] Re: Call Graph Tool? References: <2518b95d0806270018u3aecb381h6f44a196720376e7@mail.gmail.com><006e01c8d842$271b97a0$4d268351@cr3lt> <2d3641330806270449y7c6de172r27ae70e2b74980fc@mail.gmail.com> Message-ID: <00be01c8d854$db36bff0$4d268351@cr3lt> >> If you wanted to go down that route, try using 'ghc --make -v2' >> and translate that dependency graph to dot. > > Also, if you want to get a quick 'n dirty list of which of your own > files depend on which others, "ghc -M $main.hs" works quite well. I've > had some success in the past shoving this stuff almost directly into > the graph libraries and out to graphviz. Be warned that it fiddles > with any file called Makefile in your working directory... You can redirect the output of -M, but since it appears that you cannot combine --make with -fno-code, the incantation you want is probably something like: ghc -M -v2 -optdep-f -optdep depend Main.hs which gives you dependency output in two forms, a module-based one to stdout (-v2), a file-based one to file depend (-M -f depend): $ ghc -M -v2 -optdep-f -optdep depend TestGMap.lhs Glasgow Haskell Compiler, Version 6.9.20080514, for Haskell 98, stage 2 booted by GHC version 6.6.1 Using package config file: C:\ghc\ghc-6.9.20080514\package.conf wired-in package ghc-prim mapped to ghc-prim-0.1 wired-in package integer mapped to integer-0.1 wired-in package base mapped to base-3.0 wired-in package rts mapped to rts-1.0 wired-in package haskell98 mapped to haskell98-1.0.1 wired-in package template-haskell mapped to template-haskell-2.2 wired-in package ndp not found. Created temporary directory: C:\DOCUME~1\cr3\LOCALS~1\Temp\/ghc1564_0 *** Chasing dependencies: Chasing modules from: TestGMap.lhs *** Literate pre-processor: Module dependencies [NONREC ModSummary { ms_hs_date = Tue Jun 24 19:25:08 GMT Daylight Time 2008 ms_mod = main:BinTreeDatatype, ms_imps = [Data.Generics] ms_srcimps = [] }, NONREC ModSummary { ms_hs_date = Tue Jun 24 19:35:32 GMT Daylight Time 2008 ms_mod = main:GMap, ms_imps = [Unsafe.Coerce, Data.Generics, BinTreeDatatype] ms_srcimps = [] }, NONREC ModSummary { ms_hs_date = Tue Jun 24 19:24:46 GMT Daylight Time 2008 ms_mod = main:Main, ms_imps = [GMap, BinTreeDatatype] ms_srcimps = [] }] *** Installing new makefile: *** Deleting temp files: *** Deleting temp dirs: $ cat depend # DO NOT DELETE: Beginning of Haskell dependencies BinTreeDatatype.o : BinTreeDatatype.hs GMap.o : GMap.hs GMap.o : BinTreeDatatype.hi TestGMap.o : TestGMap.lhs TestGMap.o : GMap.hi TestGMap.o : BinTreeDatatype.hi # DO NOT DELETE: End of Haskell dependencies Claus http://www.haskell.org/ghc/docs/latest/html/users_guide/separate-compilation.html#makefile-dependencies From alistair at abayley.org Fri Jun 27 09:58:24 2008 From: alistair at abayley.org (Alistair Bayley) Date: Fri Jun 27 09:49:48 2008 Subject: [Haskell-cafe] Access to Oracle database from Haskell In-Reply-To: References: <79d7c4980806241435y2d0f2054n714b1c8701c2eea@mail.gmail.com> <125EACD0CAE4D24ABDB4D148C4593DA9049E943F@GBLONXMB02.corp.amvescap.net> <79d7c4980806250307h64bfba7dh95b518967c171384@mail.gmail.com> <79d7c4980806260142m41baeab4m2a13dde21b83cefc@mail.gmail.com> <79d7c4980806260554w3698f3d3p624dde7f16b6b06d@mail.gmail.com> Message-ID: <79d7c4980806270658u78530f51qc2d32f372976f1a0@mail.gmail.com> 2008/6/26 Henning Thielemann : > >> Do you need to say -lclntsh when you use ghc to compile? > > Ah, I see, I must run both GHCi and GHC with -package Takusen and everything > is fine. This still doesn't seem right. Both ghci and ghc --make should automatically link the package. The only time you should need to use -package is in ghc "batch" mode i.e. ghc sans --make. > configOracle verbose buildtools = do > if not (sqlplusProgram `isElem` buildtools) > then return Nothing > else do > path <- getEnv "ORACLE_HOME" > info verbose ("Using Oracle: " ++ path) > let (libDir, includeDir) = > if isWindows > then ("bin", "oci/include") > else ("lib", "/usr/include/oracle/10.2.0.4/client") > makeConfig path libDir includeDir > > This is obviously a hack. We should get the Oracle include path from the > user, maybe via another environment variable or a custom Cabal option. Yes... I've had a quick look at the instant client packages. The SDK zip just puts the headers under instantclient_10_2/sdk/include (which is still not $ORACLE_HOME/rdbms/public, but c'est la vie). So it looks like the .rpm puts them somewhere completely different: /usr/include/oracle/10.2.0.4/client. Do you also have $ORACLE_HOME/sdk/include, with headers in? Alistair From jefferson.r.heard at gmail.com Fri Jun 27 10:15:23 2008 From: jefferson.r.heard at gmail.com (Jefferson Heard) Date: Fri Jun 27 10:06:46 2008 Subject: [Haskell-cafe] Error in configure script for GHC Message-ID: <4165d3a70806270715pab9937egc40f0c631680b817@mail.gmail.com> I've tried all the 6.6 and 6.8 versions, trying to compile them on a RHEL-based supercomputer, and I always see this error when I run ./configure: -bash-3.00$ ./configure checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64-unknown-linux-gnu Which we'll further canonicalise into: x86_64-unknown-linux checking for path to top of build tree... pwd: timer_create: Invalid argument configure: error: cannot determine current directory Is this a known bug with GHC, or is it my supercomputer? We have several supercomputers here running in production, so I can't really ask them to change the configuration just for me, but nonetheless I'd like to run on them. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080627/82110ae7/attachment.htm From eeoam at ukfsn.org Fri Jun 27 12:02:27 2008 From: eeoam at ukfsn.org (Eric) Date: Fri Jun 27 11:54:00 2008 Subject: [Haskell-cafe] Parsing problem In-Reply-To: <200806270016.23429.daniel.is.fischer@web.de> References: <48637229.7000904@ukfsn.org> <200806262255.16404.daniel.is.fischer@web.de> <48640885.7060408@ukfsn.org> <200806270016.23429.daniel.is.fischer@web.de> Message-ID: <48650F13.3000007@ukfsn.org> Daniel Fischer wrote: > sat p = try $ do > (t,pos) <- item > if p t then return (t,pos) else pzero > > and you're all set (you don't need the try's in atom, then). > Thanks, that works! E. From martindemello at gmail.com Fri Jun 27 12:23:39 2008 From: martindemello at gmail.com (Martin DeMello) Date: Fri Jun 27 12:15:08 2008 Subject: [Haskell-cafe] what's up with hackage.haskell.org? Message-ID: haven't been able to get to it in a couple of days (at least) martin From simonpj at microsoft.com Fri Jun 27 12:25:20 2008 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Fri Jun 27 12:16:44 2008 Subject: [Haskell-cafe] what's up with hackage.haskell.org? In-Reply-To: References: Message-ID: <638ABD0A29C8884A91BC5FB5C349B1C32AE71E1A94@EA-EXMSG-C334.europe.corp.microsoft.com> | Subject: [Haskell-cafe] what's up with hackage.haskell.org? | | haven't been able to get to it in a couple of days (at least) It's offline for 24 hrs while Galois move office. Simon From martindemello at gmail.com Fri Jun 27 12:33:20 2008 From: martindemello at gmail.com (Martin DeMello) Date: Fri Jun 27 12:24:42 2008 Subject: [Haskell-cafe] what's up with hackage.haskell.org? In-Reply-To: <638ABD0A29C8884A91BC5FB5C349B1C32AE71E1A94@EA-EXMSG-C334.europe.corp.microsoft.com> References: <638ABD0A29C8884A91BC5FB5C349B1C32AE71E1A94@EA-EXMSG-C334.europe.corp.microsoft.com> Message-ID: On Fri, Jun 27, 2008 at 9:25 AM, Simon Peyton-Jones wrote: > | Subject: [Haskell-cafe] what's up with hackage.haskell.org? > | > | haven't been able to get to it in a couple of days (at least) > > It's offline for 24 hrs while Galois move office. Ah, okay :) Just noticed it when I tried to click on a google result that pointed there. martin From cmb21 at kent.ac.uk Fri Jun 27 13:08:19 2008 From: cmb21 at kent.ac.uk (C.M.Brown) Date: Fri Jun 27 12:59:41 2008 Subject: [Haskell-cafe] Re: Call Graph Tool? In-Reply-To: References: Message-ID: Hi Ivan, > Assuming I get it included, is there any features in particular you'd want to > see in there? Note that if I do have it produce visualisations, they'll be > static images as part of an analysis report rather than being interactive. I'd basically like to see a graph of the overall struture of a Haskell project: what modules import what, and so forth. This would be useful to show which modules are forming the core of a system say, and which modules are acting on the top layer. Hope that gives some insight... Chris. From cmb21 at kent.ac.uk Fri Jun 27 13:10:13 2008 From: cmb21 at kent.ac.uk (C.M.Brown) Date: Fri Jun 27 13:01:36 2008 Subject: [Haskell-cafe] Call Graph Tool? In-Reply-To: References: Message-ID: Hi Jno, > I suggest that you have a look at HaSlicer, a (visual) Haskell > slicing tool available online from http://labdotnet.di.uminho.pt/ > HaSlicer/HaSlicer.aspx , developed by Nuno Rodrigues (nfr@di.uminho.pt). Oh excellent, yes I'd forgotten about this, thanks. Chris. From allbery at ece.cmu.edu Fri Jun 27 14:00:08 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Fri Jun 27 13:51:31 2008 Subject: [Haskell-cafe] Error in configure script for GHC In-Reply-To: <4165d3a70806270715pab9937egc40f0c631680b817@mail.gmail.com> References: <4165d3a70806270715pab9937egc40f0c631680b817@mail.gmail.com> Message-ID: On Jun 27, 2008, at 10:15 , Jefferson Heard wrote: > checking for path to top of build tree... pwd: timer_create: > Invalid argument Translated into plain English, this means "your glibc is too old for this binary distribution". You will probably have to build from source with an older gcc as the bootstrap compiler. -- 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 lemming at henning-thielemann.de Fri Jun 27 14:35:57 2008 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri Jun 27 14:27:34 2008 Subject: [Haskell-cafe] Access to Oracle database from Haskell In-Reply-To: <79d7c4980806270658u78530f51qc2d32f372976f1a0@mail.gmail.com> References: <79d7c4980806241435y2d0f2054n714b1c8701c2eea@mail.gmail.com> <125EACD0CAE4D24ABDB4D148C4593DA9049E943F@GBLONXMB02.corp.amvescap.net> <79d7c4980806250307h64bfba7dh95b518967c171384@mail.gmail.com> <79d7c4980806260142m41baeab4m2a13dde21b83cefc@mail.gmail.com> <79d7c4980806260554w3698f3d3p624dde7f16b6b06d@mail.gmail.com> <79d7c4980806270658u78530f51qc2d32f372976f1a0@mail.gmail.com> Message-ID: On Fri, 27 Jun 2008, Alistair Bayley wrote: > 2008/6/26 Henning Thielemann : >> >>> Do you need to say -lclntsh when you use ghc to compile? >> >> Ah, I see, I must run both GHCi and GHC with -package Takusen and everything >> is fine. > > This still doesn't seem right. Both ghci and ghc --make should > automatically link the package. The only time you should need to use > -package is in ghc "batch" mode i.e. ghc sans --make. I actually called GHC without --make because the example program consists of only one (the main) module. > Yes... I've had a quick look at the instant client packages. The SDK > zip just puts the headers under instantclient_10_2/sdk/include (which > is still not $ORACLE_HOME/rdbms/public, but c'est la vie). So it looks > like the .rpm puts them somewhere completely different: > /usr/include/oracle/10.2.0.4/client. Do you also have > $ORACLE_HOME/sdk/include, with headers in? No, in ORACLE_HOME there is only 'bin' and 'lib'. From jeremy at n-heptane.com Fri Jun 27 14:58:53 2008 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Fri Jun 27 14:48:00 2008 Subject: [Haskell-cafe] Re: Haskell on ARM (was Re: ANN: Topkata) In-Reply-To: <14d615330806261657h3ce55bebx74f8e89205a9854@mail.gmail.com> References: <87zlpoguqh.fsf@elefant.olsbruecken.local> <4B3E7353-F7F2-4D2D-A335-30D2D3883A4A@gmail.com> <200806170851.22718.valgarv@gmx.net> <87ej6ww9dy.fsf_-_@columbia.edu> <20080617201233.GD19304@scytale.galois.com> <871w2mit8o.wl%jeremy@n-heptane.com> <14d615330806241903s30734fe4q5c7af4569e9b421@mail.gmail.com> <14d615330806261657h3ce55bebx74f8e89205a9854@mail.gmail.com> Message-ID: <87tzfehfgy.wl%jeremy@n-heptane.com> At Fri, 27 Jun 2008 09:57:29 +1000, Jeremy Apthorp wrote: > Next year I'll be working on a project for my undergraduate computing > course at UNSW that will involve getting GHC to target the Nintendo > DS. It'll require cross-compilation, because the DS isn't powerful > enough to actually run GHC (4M main ram and a 66MHz processor). Cool! By cross-compilation, I assume you mean, a version of GHC which runs on x86, but generates ARM assembly? Another option might be to use a nintendo DS emulator which has been configured to support more RAM and CPU power ? A true cross-compiler would be nice though, because it will run much faster. GHC does have some support for cross-compilation, but in the current implementation, it is mostly (entirely?) there for bootstrapping. I have no idea how the ghc backend rewrite for 6.10 will affect this. Hope this helps, j. From rwbarton at math.harvard.edu Fri Jun 27 14:59:20 2008 From: rwbarton at math.harvard.edu (Reid Barton) Date: Fri Jun 27 14:49:22 2008 Subject: [Haskell-cafe] Error in configure script for GHC In-Reply-To: <4165d3a70806270715pab9937egc40f0c631680b817@mail.gmail.com> References: <4165d3a70806270715pab9937egc40f0c631680b817@mail.gmail.com> Message-ID: <20080627185920.GH8867@rwbarton.mit.edu> On Fri, Jun 27, 2008 at 10:15:23AM -0400, Jefferson Heard wrote: > I've tried all the 6.6 and 6.8 versions, trying to compile them on a > RHEL-based supercomputer, and I always see this error when I run > ./configure: > > -bash-3.00$ ./configure > checking build system type... x86_64-unknown-linux-gnu > checking host system type... x86_64-unknown-linux-gnu > checking target system type... x86_64-unknown-linux-gnu > Which we'll further canonicalise into: x86_64-unknown-linux > checking for path to top of build tree... pwd: timer_create: Invalid > argument > configure: error: cannot determine current directory I don't know whether this is related, but I've noticed that the most recent source distribution of the HEAD branch (ghc-6.9.20080615) includes a binary executable utils/pwd/pwd compiled for x86-64. This causes ./configure to break with a similar message, since I have a 32-bit system. If I delete utils/pwd/pwd, the configure script automatically rebuilds it and then completes successfully. Regards, Reid Barton From adam.smyczek at gmail.com Fri Jun 27 15:04:22 2008 From: adam.smyczek at gmail.com (Adam Smyczek) Date: Fri Jun 27 14:55:50 2008 Subject: [Haskell-cafe] ghci vi mode? Message-ID: <00D43556-2F67-4BF4-8524-2F8BF2E9A159@gmail.com> If I remember correctly, ghci uses readline framework on Linux/OS X. Is it possible to change ghci editing mode to vi? Thanks, Adam From jefferson.r.heard at gmail.com Fri Jun 27 15:04:51 2008 From: jefferson.r.heard at gmail.com (Jefferson Heard) Date: Fri Jun 27 14:56:13 2008 Subject: [Haskell-cafe] Error in configure script for GHC In-Reply-To: References: <4165d3a70806270715pab9937egc40f0c631680b817@mail.gmail.com> Message-ID: <4165d3a70806271204x74e2f680o61b420b3af746d79@mail.gmail.com> Linux version 2.6.9-34.0.2.ELsmp (buildcentos@x8664-build.centos.org) (gcc version 3.4.5 20051201 (Red Hat 3.4.5-2)) #1 SMP Fri Jul 7 18:22:55 CDT 2006 This is my version string if that helps... I'd do the bootstrap build right now, but hackage is down (I understand it's moving), and I can't get to the instructions for bootstrapping. On Fri, Jun 27, 2008 at 2:00 PM, Brandon S. Allbery KF8NH < allbery@ece.cmu.edu> wrote: > > On Jun 27, 2008, at 10:15 , Jefferson Heard wrote: > > checking for path to top of build tree... pwd: timer_create: Invalid >> argument >> > > Translated into plain English, this means "your glibc is too old for this > binary distribution". > You will probably have to build from source with an older gcc as the > bootstrap compiler. > > -- > 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 > > > -- I try to take things like a crow; war and chaos don't always ruin a picnic, they just mean you have to be careful what you swallow. -- Jessica Edwards -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080627/791df4ce/attachment.htm From allbery at ece.cmu.edu Fri Jun 27 16:04:59 2008 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Fri Jun 27 15:56:22 2008 Subject: [Haskell-cafe] Error in configure script for GHC In-Reply-To: <4165d3a70806271204x74e2f680o61b420b3af746d79@mail.gmail.com> References: <4165d3a70806270715pab9937egc40f0c631680b817@mail.gmail.com> <4165d3a70806271204x74e2f680o61b420b3af746d79@mail.gmail.com> Message-ID: <1D9DFB6A-8AD4-4711-A340-82B191EAB73C@ece.cmu.edu> On Jun 27, 2008, at 15:04 , Jefferson Heard wrote: > Linux version 2.6.9-34.0.2.ELsmp (buildcentos@x8664- > build.centos.org) (gcc version 3.4.5 20051201 (Red Hat 3.4.5-2)) #1 > SMP Fri Jul 7 18:22:55 CDT 2006 I can't help with much of anything Linux aside form having run into that error on SuSE 9.3. But in any case, that's the kernel version. for glibc version, run /lib/libc.so.6. -- 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 qdunkan at gmail.com Fri Jun 27 16:53:24 2008 From: qdunkan at gmail.com (Evan Laforge) Date: Fri Jun 27 16:44:45 2008 Subject: [Haskell-cafe] ghci vi mode? In-Reply-To: <00D43556-2F67-4BF4-8524-2F8BF2E9A159@gmail.com> References: <00D43556-2F67-4BF4-8524-2F8BF2E9A159@gmail.com> Message-ID: <2518b95d0806271353k31c7e339h71c5e6f8de188458@mail.gmail.com> On Fri, Jun 27, 2008 at 12:04 PM, Adam Smyczek wrote: > If I remember correctly, ghci uses readline framework on Linux/OS X. > Is it possible to change ghci editing mode to vi? Here's what I have: % cat ~/.inputrc set editing-mode vi set keymap vi set bell-style none From john at repetae.net Fri Jun 27 20:08:04 2008 From: john at repetae.net (John Meacham) Date: Fri Jun 27 19:59:25 2008 Subject: Haskell on ARM (was Re: [Haskell-cafe] ANN: Topkata) In-Reply-To: <20080626142619.GA4743@matrix.chaos.earth.li> References: <87zlpoguqh.fsf@elefant.olsbruecken.local> <4B3E7353-F7F2-4D2D-A335-30D2D3883A4A@gmail.com> <200806170851.22718.valgarv@gmx.net> <87ej6ww9dy.fsf_-_@columbia.edu> <20080617201233.GD19304@scytale.galois.com> <871w2mit8o.wl%jeremy@n-heptane.com> <20080626142619.GA4743@matrix.chaos.earth.li> Message-ID: <20080628000804.GI12977@sliver.repetae.net> Just a random note. jhc works fine on ARM, I have successfully run Haskell programs on on iPhone and a nokia n800 tablet compiled with it. jhc is, of course, still pretty unstable. but new developers are always welcome. John -- John Meacham - ?repetae.net?john? From aeyakovenko at gmail.com Fri Jun 27 21:20:51 2008 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Fri Jun 27 21:12:13 2008 Subject: [Haskell-cafe] blas bindings, why are they so much slower the C? In-Reply-To: <20080618170543.GK32397@darcs.net> References: <20080618170543.GK32397@darcs.net> Message-ID: > I suspect that it is your initialization that is the difference. For > one thing, you've initialized the arrays to different values, and in > your C code you've fused what are two separate loops in your Haskell > code. So you've not only given the C compiler an easier loop to run > (since you're initializing the array to a constant rather than to a > sequence of numbers), but you've also manually optimized that > initialization. In fact, this fusion could be precisely the factor of > two. Why not see what happens in Haskell if you create just one > vector and dot it with itself? (of course, that'll also make the blas > call faster, so you'll need to be careful in your interpretation of > your results.) The difference cant be in the initialization. I am calling the dot product a million times, the malloc and init in both cases are insignificant. Also, "fusing" the two loops in C probably wont help, if anything having each loop run separate is likely to be faster and result in less cache misses. In this case, i am using vectors of size 10 only, and calling the loop 10 million times, haskell is far far slower, or 35 times. That's pretty crappy. $ cat htestdot.hs {-# OPTIONS_GHC -O2 -fexcess-precision -funbox-strict-fields -fglasgow-exts -fbang-patterns -lcblas#-} module Main where import Data.Vector.Dense.IO import Control.Monad main = do let size = 10 let times = 10*1000*1000 v1::IOVector Int Double <- newListVector size $ replicate size 0.1 v2::IOVector Int Double <- newListVector size $ replicate size 0.1 sum <- foldM (\ ii zz -> do rv <- v1 `getDot` v2 return $ zz + rv ) 0.0 [0..times] print $ sum $ ghc --make htestdot.hs $ time ./htestdot 1.00000001e7 real 0m17.328s user 0m17.320s sys 0m0.010 $ cat testdot.c #include #include #include #include int main() { int size = 10; int times = 10*1000*1000; int ii = 0; double dd = 0.0; double* v1 = malloc(sizeof(double) * (size)); double* v2 = malloc(sizeof(double) * (size)); for(ii = 0; ii < size; ++ii) { v1[ii] = 0.1; } for(ii = 0; ii < size; ++ii) { v2[ii] = 0.1; } for(ii = 0; ii < times; ++ii) { dd += cblas_ddot(size, v1, 1, v2, 1); } free(v1); free(v2); printf("%f\n", dd); return 0; } $ gcc -O2 testdot.c -lcblas -o testdot $ time ./testdot 999999.999839 real 0m0.491s user 0m0.480s sys 0m0.020s Just to make sure that fold isnt causing the slowdown, i reverted the haskell program to use the mapM_, i still got almost the same performance: $ cat htestdot.hs {-# OPTIONS_GHC -O2 -fexcess-precision -funbox-strict-fields -fglasgow-exts -fbang-patterns -lcblas#-} module Main where import Data.Vector.Dense.IO import Control.Monad main = do let size = 10 let times = 10*1000*1000 v1::IOVector Int Double <- newListVector size $ replicate size 0.1 v2::IOVector Int Double <- newListVector size $ replicate size 0.1 mapM_ (\ ii -> do v1 `getDot` v2) [0..times] $ ghc --make htestdot $ time ./htestdot real 0m15.660s user 0m15.630s sys 0m0.030s This is what the profiler has to say: $ cat htestdot.prof Fri Jun 27 18:06 2008 Time and Allocation Profiling Report (Final) htestdot +RTS -p -RTS total time = 22.00 secs (1100 ticks @ 20 ms) total alloc = 3,320,010,716 bytes (excludes profiling overheads) COST CENTRE MODULE %time %alloc main Main 100.0 100.0 individual inherited COST CENTRE MODULE no. entries %time %alloc %time %alloc MAIN MAIN 1 0 0.0 0.0 100.0 100.0 main Main 222 1 93.6 88.0 93.6 88.0 CAF Main 216 5 0.0 0.0 6.4 12.0 main Main 223 0 6.4 12.0 6.4 12.0 CAF GHC.Handle 168 3 0.0 0.0 0.0 0.0 From dan.doel at gmail.com Fri Jun 27 22:41:51 2008 From: dan.doel at gmail.com (Dan Doel) Date: Fri Jun 27 22:33:18 2008 Subject: [Haskell-cafe] blas bindings, why are they so much slower the C? In-Reply-To: References: <20080618170543.GK32397@darcs.net> Message-ID: <200806272241.51624.dan.doel@gmail.com> On Friday 27 June 2008, Anatoly Yakovenko wrote: > $ cat htestdot.hs > {-# OPTIONS_GHC -O2 -fexcess-precision -funbox-strict-fields > -fglasgow-exts -fbang-patterns -lcblas#-} > module Main where > > import Data.Vector.Dense.IO > import Control.Monad > > main = do > let size = 10 > let times = 10*1000*1000 > v1::IOVector Int Double <- newListVector size $ replicate size 0.1 > v2::IOVector Int Double <- newListVector size $ replicate size 0.1 > sum <- foldM (\ ii zz -> do > rv <- v1 `getDot` v2 > return $ zz + rv > ) 0.0 [0..times] > print $ sum Hackage is down for the time being, so I can't install blas and look at the core for your program. However, there are still some reasons why this code would be slow. For instance, a brief experiment seems to indicate that foldM is not a good consumer in the foldr/build sense, so no deforestation occurs. Your program is iterating over a 10-million element lazy list. That's going to add overhead. I wrote a simple test program which just adds 0.1 in each iteration: ---- snip ---- {-# LANGUAGE BangPatterns #-} module Main (main) where import Control.Monad main = do let times = 10*1000*1000 sum <- foldM (\_ zz -> return $ zz + 0.1) 0.0 [0..times] -- sum <- foo 0 times 0.0 print $ sum foo :: Int -> Int -> Double -> IO Double foo k m !zz | k <= m = foo (k+1) m (zz + 0.1) | otherwise = return zz ---- snip ---- With foldM, it takes 2.5 seconds on my machine. If you comment that line, and use foo instead, it takes around .1 seconds. So that's a factor of what, 250? That loop allows for a lot more unboxing, which allows much better code to be generated. When Hackage comes back online, I'll take a look at your code, and see if I can make it run faster, but you might want to try it yourself in the time being. Strictifying the addition of the accumulator is probably a good idea, for instance. Cheers, -- Dan From pgavin at gmail.com Fri Jun 27 23:19:01 2008 From: pgavin at gmail.com (Peter Gavin) Date: Fri Jun 27 23:10:25 2008 Subject: [Haskell-cafe] ANN: Gtk2Hs 0.9.13 released Message-ID: <4865ADA5.3070103@gmail.com> Hello everyone, Gtk2Hs version 0.9.13 is now available. [1] New features: * bindings for Gnome VFS and GStreamer * a new Gtk+ tutorial has been adapted by Hans van Thiel * cairo image stride support * many new demos * compiles with GHC 6.8.3 * lots of bug fixes This release has been tested on a variety of platforms with different versions of Gtk+ and GHC, so you should have no trouble compiling it if you're using an older version of Gtk+. Note that the binaries for Win32 for this release are only provided for GHC 6.8.3 and Gtk+ 2.12. As with older releases, all the C libraries needed are included in the installer, so you don't need to download anything else to get up an running. I've also created zip files containing only the C libraries that can be used for redistribution. The sources for these binaries are available at [2] Links: [1] http://sourceforge.net/project/showfiles.php?group_id=49207&package_id=42440 [2] http://ftp.gnome.org/pub/GNOME/sources/ -- Pete From aeyakovenko at gmail.com Sat Jun 28 01:29:22 2008 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Sat Jun 28 01:20:43 2008 Subject: [Haskell-cafe] blas bindings, why are they so much slower the C? In-Reply-To: <200806272241.51624.dan.doel@gmail.com> References: <20080618170543.GK32397@darcs.net> <200806272241.51624.dan.doel@gmail.com> Message-ID: i get the same crappy performance with: $ cat htestdot.hs {-# OPTIONS_GHC -O2 -fexcess-precision -funbox-strict-fields -fglasgow-exts -fbang-patterns -lcblas#-} module Main where import Data.Vector.Dense.IO import Control.Monad main = do let size = 10 let times = 10*1000*1000 v1::IOVector Int Double <- newListVector size $ replicate size 0.1 v2::IOVector Int Double <- newListVector size $ replicate size 0.1 replicateM_ times $ v1 `getDot` v2 On Fri, Jun 27, 2008 at 7:41 PM, Dan Doel wrote: > On Friday 27 June 2008, Anatoly Yakovenko wrote: >> $ cat htestdot.hs >> {-# OPTIONS_GHC -O2 -fexcess-precision -funbox-strict-fields >> -fglasgow-exts -fbang-patterns -lcblas#-} >> module Main where >> >> import Data.Vector.Dense.IO >> import Control.Monad >> >> main = do >> let size = 10 >> let times = 10*1000*1000 >> v1::IOVector Int Double <- newListVector size $ replicate size 0.1 >> v2::IOVector Int Double <- newListVector size $ replicate size 0.1 >> sum <- foldM (\ ii zz -> do >> rv <- v1 `getDot` v2 >> return $ zz + rv >> ) 0.0 [0..times] >> print $ sum > > Hackage is down for the time being, so I can't install blas and look at the > core for your program. However, there are still some reasons why this code > would be slow. > > For instance, a brief experiment seems to indicate that foldM is not a good > consumer in the foldr/build sense, so no deforestation occurs. Your program > is iterating over a 10-million element lazy list. That's going to add > overhead. I wrote a simple test program which just adds 0.1 in each > iteration: > > ---- snip ---- > > {-# LANGUAGE BangPatterns #-} > > module Main (main) where > > import Control.Monad > > main = do > let times = 10*1000*1000 > sum <- foldM (\_ zz -> return $ zz + 0.1) 0.0 [0..times] > -- sum <- foo 0 times 0.0 > print $ sum > > foo :: Int -> Int -> Double -> IO Double > foo k m !zz > | k <= m = foo (k+1) m (zz + 0.1) > | otherwise = return zz > > ---- snip ---- > > With foldM, it takes 2.5 seconds on my machine. If you comment that line, and > use foo instead, it takes around .1 seconds. So that's a factor of what, 250? > That loop allows for a lot more unboxing, which allows much better code to be > generated. > > When Hackage comes back online, I'll take a look at your code, and see if I > can make it run faster, but you might want to try it yourself in the time > being. Strictifying the addition of the accumulator is probably a good idea, > for instance. > > Cheers, > -- Dan > From dons at galois.com Sat Jun 28 01:51:09 2008 From: dons at galois.com (Don Stewart) Date: Sat Jun 28 01:42:35 2008 Subject: [Haskell-cafe] blas bindings, why are they so much slower the C? In-Reply-To: References: <20080618170543.GK32397@darcs.net> <200806272241.51624.dan.doel@gmail.com> Message-ID: <20080628055109.GA28148@liouville.galois.com> aeyakovenko: > i get the same crappy performance with: > > $ cat htestdot.hs > {-# OPTIONS_GHC -O2 -fexcess-precision -funbox-strict-fields > -fglasgow-exts -fbang-patterns -lcblas#-} > module Main where > > import Data.Vector.Dense.IO > import Control.Monad > > main = do > let size = 10 > let times = 10*1000*1000 > v1::IOVector Int Double <- newListVector size $ replicate size 0.1 > v2::IOVector Int Double <- newListVector size $ replicate size 0.1 > replicateM_ times $ v1 `getDot` v2 replicateM_ is using a list underneath for control as well, replicateM n x = sequence (replicate n x) Try writing a simple recursive loop, as Dan suggested. No list node forcing overhead, so in a very tight loop you'll just want the index in a register. See here for more examples of tight register loops, http://cgi.cse.unsw.edu.au/~dons/blog/2008/05/16#fast In general, if you're chasing C performance for a loop, your best bet is to write a loop first. Then later see if you can get the same kind of code from higher order, lazy, monadic functions. -- Don From dons at galois.com Sat Jun 28 03:44:51 2008 From: dons at galois.com (Don Stewart) Date: Sat Jun 28 03:36:16 2008 Subject: [Haskell-cafe] blas bindings, why are they so much slower the C? In-Reply-To: References: <20080618170543.GK32397@darcs.net> <200806272241.51624.dan.doel@gmail.com> Message-ID: <20080628074451.GA29980@liouville.galois.com> so I had a look at the code. The loops are all fine. replicateM_ isn't a problem, but getDot is decidedly non trivial. Lots of pattern matching on different vector forms, and to top it off ffi calls. With some inlining in the blas library I was able to cut a few seconds off the running time, but getDot looks to be fundamentally a bit complicated in the current implementation. I wonder if you'll get different results with hmatrix? Anyway, this is a library issue. Better take it up with Patrick. Pass on to the library author the C code, the Haskell you think should be compiled identically. -- Don aeyakovenko: > i get the same crappy performance with: > > $ cat htestdot.hs > {-# OPTIONS_GHC -O2 -fexcess-precision -funbox-strict-fields > -fglasgow-exts -fbang-patterns -lcblas#-} > module Main where > > import Data.Vector.Dense.IO > import Control.Monad > > main = do > let size = 10 > let times = 10*1000*1000 > v1::IOVector Int Double <- newListVector size $ replicate size 0.1 > v2::IOVector Int Double <- newListVector size $ replicate size 0.1 > replicateM_ times $ v1 `getDot` v2 > > > > On Fri, Jun 27, 2008 at 7:41 PM, Dan Doel wrote: > > On Friday 27 June 2008, Anatoly Yakovenko wrote: > >> $ cat htestdot.hs > >> {-# OPTIONS_GHC -O2 -fexcess-precision -funbox-strict-fields > >> -fglasgow-exts -fbang-patterns -lcblas#-} > >> module Main where > >> > >> import Data.Vector.Dense.IO > >> import Control.Monad > >> > >> main = do > >> let size = 10 > >> let times = 10*1000*1000 > >> v1::IOVector Int Double <- newListVector size $ replicate size 0.1 > >> v2::IOVector Int Double <- newListVector size $ replicate size 0.1 > >> sum <- foldM (\ ii zz -> do > >> rv <- v1 `getDot` v2 > >> return $ zz + rv > >> ) 0.0 [0..times] > >> print $ sum > > > > Hackage is down for the time being, so I can't install blas and look at the > > core for your program. However, there are still some reasons why this code > > would be slow. > > > > For instance, a brief experiment seems to indicate that foldM is not a good > > consumer in the foldr/build sense, so no deforestation occurs. Your program > > is iterating over a 10-million element lazy list. That's going to add > > overhead. I wrote a simple test program which just adds 0.1 in each > > iteration: > > > > ---- snip ---- > > > > {-# LANGUAGE BangPatterns #-} > > > > module Main (main) where > > > > import Control.Monad > > > > main = do > > let times = 10*1000*1000 > > sum <- foldM (\_ zz -> return $ zz + 0.1) 0.0 [0..times] > > -- sum <- foo 0 times 0.0 > > print $ sum > > > > foo :: Int -> Int -> Double -> IO Double > > foo k m !zz > > | k <= m = foo (k+1) m (zz + 0.1) > > | otherwise = return zz > > > > ---- snip ---- > > > > With foldM, it takes 2.5 seconds on my machine. If you comment that line, and > > use foo instead, it takes around .1 seconds. So that's a factor of what, 250? > > That loop allows for a lot more unboxing, which allows much better code to be > > generated. > > > > When Hackage comes back online, I'll take a look at your code, and see if I > > can make it run faster, but you might want to try it yourself in the time > > being. Strictifying the addition of the accumulator is probably a good idea, > > for instance. > > > > Cheers, > > -- Dan > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- Sat Jun 28 00:33:17 PDT 200